251210_01_ENH : 프로젝트 수정, 에디터 구현중
This commit is contained in:
269
src/components/dialog/ProjectCreateDialog.tsx
Normal file
269
src/components/dialog/ProjectCreateDialog.tsx
Normal file
@@ -0,0 +1,269 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useEffect } from 'react'
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {Label} from "@/components/ui/label";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {KriSingleSelect} from "@/components/common/KriAutoComplete";
|
||||
import {useDialog} from "@/hooks/useDialog";
|
||||
import type {DialogId} from "@/store/jotai/dialog";
|
||||
import {NONE_HTTP_ERROR, UNKNOWN_HTTP_ERROR} from "@/const/commonConst";
|
||||
import {apiError} from "@/lib/http-util";
|
||||
import {IntranetProjectSearchResponse, ProjectCreateRequest} from "@/types/project";
|
||||
import {useDebouncedValue} from "@/hooks/useDebouncedValue";
|
||||
import {nextApi} from "@/lib/http-client";
|
||||
import {PROJECT_NAME_REGEX} from "@/const/projectConst";
|
||||
import {FW_TEAM, USER_NAME_REGEX} from "@/const/userConst";
|
||||
import {MultiSelectOption} from "@/components/ui/multi-select";
|
||||
import {ItrntUserInfo} from "@/types/user";
|
||||
|
||||
export type ProjectCreateDialogProps = {
|
||||
/** Jotai로 관리할 다이얼로그 ID (기본값: 'userUpsertDialog') */
|
||||
dialogId?: DialogId
|
||||
|
||||
/** 필요하면 여전히 외부에서 open 제어도 가능하게 */
|
||||
open?: boolean
|
||||
onOpenChange?: (open: boolean) => void
|
||||
users:ItrntUserInfo[]
|
||||
ownerFw: string;
|
||||
onSubmit: (data: ProjectCreateRequest) => void | Promise<void>
|
||||
}
|
||||
|
||||
|
||||
|
||||
const ProjectCreateDialog = ({
|
||||
dialogId = 'projectCreateDialog',
|
||||
open,
|
||||
onOpenChange,
|
||||
users,
|
||||
ownerFw,
|
||||
onSubmit,
|
||||
}:ProjectCreateDialogProps) => {
|
||||
const defaultProjectInfo:ProjectCreateRequest = {
|
||||
prjctName: "",
|
||||
itrntPrjctCd: "",
|
||||
ownerDept: "",
|
||||
ownerFw: ownerFw,
|
||||
}
|
||||
const { isDialogOpen, showDialog, hideDialog } = useDialog();
|
||||
const [deptArray, setDeptArray] = useState<string[]>([]);
|
||||
const [fwArray, setFwArray] = useState<MultiSelectOption[]>([]);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [formData, setFormData] = useState<ProjectCreateRequest>(defaultProjectInfo);
|
||||
|
||||
const [itrntKeyword, setItrntKeyword] = useState('');
|
||||
const debouncedKeyword = useDebouncedValue(itrntKeyword, 500);
|
||||
const [itrntPrjctArray, setItrntPrjctArray] = useState<IntranetProjectSearchResponse[]>([]);
|
||||
|
||||
// 🔹 실제로 Dialog에 넘길 open 값 (외부 open 있으면 우선)
|
||||
const resolvedOpen = open ?? isDialogOpen(dialogId);
|
||||
|
||||
// 🔹 실제 onOpenChange 핸들러 (외부 콜백 + jotai 둘 다 처리)
|
||||
const handleOpenChange = (nextOpen: boolean) => {
|
||||
// 1) 외부에서 넘겨준 onOpenChange 먼저 호출
|
||||
onOpenChange?.(nextOpen);
|
||||
|
||||
// 2) jotai 전역 상태도 함께 업데이트
|
||||
if (nextOpen) {
|
||||
showDialog(dialogId);
|
||||
setItrntKeyword("");
|
||||
} else {
|
||||
hideDialog(dialogId);
|
||||
}
|
||||
}
|
||||
|
||||
const handleInputChange = (field: keyof ProjectCreateRequest, value: any) => {
|
||||
setFormData((prev) => {
|
||||
const next = { ...prev, [field]: value } as ProjectCreateRequest;
|
||||
|
||||
if (field === "itrntPrjctCd") {
|
||||
const selected = itrntPrjctArray.find((p) => p.childSn === value);
|
||||
if (selected){
|
||||
next.ownerDept = selected.researchTeam;
|
||||
next.prjctName = selected.title;
|
||||
}
|
||||
}
|
||||
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if(!formData.itrntPrjctCd.trim()){
|
||||
alert("인트라넷 프로젝트를 선택해 주세요");
|
||||
return;
|
||||
}
|
||||
if (!formData.prjctName.trim()) {
|
||||
alert('프로젝트 명을 입력해 주세요');
|
||||
return;
|
||||
}
|
||||
if (!PROJECT_NAME_REGEX.test(formData.prjctName)) {
|
||||
alert("프로젝트명에 허용되지 않는 문자가 포함되어 있습니다");
|
||||
return;
|
||||
}
|
||||
if(!formData.ownerDept.trim()){
|
||||
alert('담당 그룹을 입력해 주세요');
|
||||
return;
|
||||
}
|
||||
if(!USER_NAME_REGEX.test(formData.ownerDept)){
|
||||
alert('담당 그룹이 올바르지 않습니다.');
|
||||
return;
|
||||
}
|
||||
if(!formData.ownerFw.trim()){
|
||||
alert('담당 SV를 입력해 주세요');
|
||||
return;
|
||||
}
|
||||
if(!USER_NAME_REGEX.test(formData.ownerDept)){
|
||||
alert('담당 SV가 올바르지 않습니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
setIsSubmitting(true);
|
||||
try {
|
||||
await onSubmit(formData as ProjectCreateRequest);
|
||||
handleOpenChange(false);
|
||||
} catch (e) {
|
||||
const err = apiError(e);
|
||||
if(err.code !== NONE_HTTP_ERROR && err.code !== UNKNOWN_HTTP_ERROR){
|
||||
alert(err.message);
|
||||
}
|
||||
else{
|
||||
alert('저장에 실패했습니다.');
|
||||
}
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
}
|
||||
|
||||
const searchItrntPrjct = async (keyword:string): Promise<void> => {
|
||||
const res = await nextApi.get<IntranetProjectSearchResponse[]>(
|
||||
"/intranet/project",
|
||||
{ query: keyword ? { keyword } : {} }
|
||||
);
|
||||
|
||||
setItrntPrjctArray(res);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const keyword = debouncedKeyword.trim();
|
||||
searchItrntPrjct(keyword).then();
|
||||
}, [debouncedKeyword]);
|
||||
|
||||
useEffect(() => {
|
||||
setFormData(defaultProjectInfo);
|
||||
}, [resolvedOpen])
|
||||
|
||||
useEffect(() => {
|
||||
let userTeams = Array.from(new Set(users.map(u => u.userTeam)));
|
||||
if(!userTeams.includes("T900")){ //TFT
|
||||
userTeams.push("T900");
|
||||
}
|
||||
userTeams = userTeams.sort((a, b) => a.localeCompare(b, "ko"));
|
||||
setDeptArray(userTeams);
|
||||
|
||||
const userOptions: MultiSelectOption[] = users
|
||||
.filter(u => u.userId == ownerFw || u.userTeam == FW_TEAM)
|
||||
.map(u => ({
|
||||
value: u.userId,
|
||||
label: u.userNm,
|
||||
}));
|
||||
setFwArray(userOptions);
|
||||
}, [users]);
|
||||
|
||||
return (
|
||||
<Dialog open={resolvedOpen} onOpenChange={handleOpenChange}>
|
||||
<DialogContent className="sm:max-w-[500px] content-text-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="content-text-sxl">
|
||||
프로젝트 생성
|
||||
</DialogTitle>
|
||||
<DialogDescription>프로젝트 생성에 필요한 기본정보를 입력해주세요.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="grid gap-6 py-4">
|
||||
<div className="grid gap-2">
|
||||
<Label>
|
||||
인트라넷 프로젝트<span className="text-red-500 ml-1">*</span>
|
||||
</Label>
|
||||
<KriSingleSelect
|
||||
items={itrntPrjctArray}
|
||||
value={String(formData.itrntPrjctCd)}
|
||||
onChange={(e) => handleInputChange('itrntPrjctCd', e)}
|
||||
getLabel={(item) => `[${item.childSn}] ${item.title}`}
|
||||
getValue={(item) => item.childSn}
|
||||
searchMode={"inputOnly"}
|
||||
onSearchValueChange={setItrntKeyword}
|
||||
placeholder="인트라넷 프로젝트"
|
||||
widthClassName="w-full"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="prjctName">
|
||||
프로젝트 명<span className="text-red-500 ml-1">*</span>
|
||||
</Label>
|
||||
<Input
|
||||
id="prjctName"
|
||||
placeholder="프로젝트명을 입력하세요"
|
||||
value={formData.prjctName}
|
||||
onChange={(e) => handleInputChange('prjctName', e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="ownerDept">
|
||||
담당 그룹<span className="text-red-500 ml-1">*</span>
|
||||
</Label>
|
||||
<KriSingleSelect
|
||||
items={deptArray}
|
||||
value={formData.ownerDept || ''}
|
||||
onChange={(value) => handleInputChange('ownerDept', value)}
|
||||
placeholder="담당 그룹을 선택하세요"
|
||||
heightClassName="h-9"
|
||||
widthClassName="w-full"
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="ownerFw">
|
||||
담당 실사<span className="text-red-500 ml-1">*</span>
|
||||
</Label>
|
||||
<KriSingleSelect
|
||||
items={fwArray}
|
||||
value={formData.ownerFw || ''}
|
||||
onChange={(value) => handleInputChange('ownerFw', value)}
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
placeholder="담당 실사를 선택하세요"
|
||||
heightClassName="h-9"
|
||||
widthClassName="w-full"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => handleOpenChange(false)}
|
||||
>
|
||||
취소
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
onClick={handleSubmit}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
생성
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export default ProjectCreateDialog
|
||||
325
src/components/dialog/ResultCodeDialog.tsx
Normal file
325
src/components/dialog/ResultCodeDialog.tsx
Normal file
@@ -0,0 +1,325 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo, useState } from 'react'
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import {Trash2, Plus, Download, Search, XIcon} from 'lucide-react'
|
||||
|
||||
export type ResultCode = {
|
||||
code: string
|
||||
label: string
|
||||
}
|
||||
|
||||
type Project = {
|
||||
prjctCd: string
|
||||
prjctName: string
|
||||
resultCodes: ResultCode[]
|
||||
}
|
||||
|
||||
type ResultCodeDialogProps = {
|
||||
open?: boolean
|
||||
onOpenChange?: (open: boolean) => void
|
||||
onSave?: (codes: ResultCode[]) => void
|
||||
}
|
||||
|
||||
const ResultCodeDialog = ({ open, onOpenChange, onSave }: ResultCodeDialogProps) => {
|
||||
const [importMode, setImportMode] = useState(false)
|
||||
const [selectedProject, setSelectedProject] = useState<string>('')
|
||||
|
||||
const [resultCodes, setResultCodes] = useState<ResultCode[]>([
|
||||
{ code: '0', label: '컨택 성공' },
|
||||
{ code: '1', label: '통화 예약' },
|
||||
{ code: '2', label: '비수신' },
|
||||
{ code: '3', label: '부재' },
|
||||
{ code: '4', label: '휴가' },
|
||||
{ code: '5', label: '출장' },
|
||||
{ code: '6', label: '단순 거절' },
|
||||
{ code: '7', label: '강력 거절' },
|
||||
{ code: '8', label: '그런 사람 아님' },
|
||||
{ code: '9', label: '메일 발송' },
|
||||
{ code: '10', label: '독려' },
|
||||
{ code: '11', label: '퇴사' },
|
||||
{ code: '12', label: '기타' },
|
||||
{ code: '13', label: '조사 대상 아님' },
|
||||
{ code: '14', label: '수신 거부' },
|
||||
])
|
||||
|
||||
// 샘플 프로젝트 목록 (실제로는 API에서 가져옴)
|
||||
const projects: Project[] = [
|
||||
{
|
||||
prjctCd: '250701yd',
|
||||
prjctName: '250701yd',
|
||||
resultCodes: [
|
||||
{ code: '0', label: '완료' },
|
||||
{ code: '1', label: '거절' },
|
||||
{ code: '2', label: '진행중' },
|
||||
],
|
||||
},
|
||||
{
|
||||
prjctCd: '1509013',
|
||||
prjctName: '1509013_J2307KJC_KFB_저기 1차 카카오톡 AUTOAGI_#01250Group',
|
||||
resultCodes: [
|
||||
{ code: '0', label: '성공' },
|
||||
{ code: '1', label: '실패' },
|
||||
{ code: '2', label: '보류' },
|
||||
],
|
||||
},
|
||||
{
|
||||
prjctCd: '1503013',
|
||||
prjctName: '1503013_J2307KJC_KFB_저기 1차 카카오톡 AUTOAGI_그룹01테스트0',
|
||||
resultCodes: [
|
||||
{ code: '0', label: '승인' },
|
||||
{ code: '1', label: '반려' },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const [projectSearch, setProjectSearch] = useState('')
|
||||
const filteredProjects = useMemo(() => {
|
||||
const q = projectSearch.trim().toLowerCase()
|
||||
if (!q) return projects
|
||||
return projects.filter(p =>
|
||||
`${p.prjctCd} ${p.prjctName}`.toLowerCase().includes(q)
|
||||
)
|
||||
}, [projectSearch])
|
||||
|
||||
const selectedProjectData = useMemo(
|
||||
() => projects.find(p => p.prjctCd === selectedProject),
|
||||
[selectedProject]
|
||||
)
|
||||
|
||||
const handleAddCode = () => {
|
||||
setResultCodes(prev => [...prev, { code: String(prev.length), label: '' }])
|
||||
}
|
||||
|
||||
const handleDeleteCode = (index: number) => {
|
||||
setResultCodes(prev => prev.filter((_, i) => i !== index))
|
||||
}
|
||||
|
||||
const handleCodeChange = (index: number, field: keyof ResultCode, value: string) => {
|
||||
setResultCodes(prev => {
|
||||
const next = [...prev]
|
||||
next[index] = { ...next[index], [field]: value }
|
||||
return next
|
||||
})
|
||||
}
|
||||
|
||||
const handleImportClick = () => {
|
||||
setImportMode(true)
|
||||
}
|
||||
|
||||
const handleImportApply = () => {
|
||||
if (selectedProjectData) {
|
||||
setResultCodes(selectedProjectData.resultCodes)
|
||||
setImportMode(false)
|
||||
setSelectedProject('')
|
||||
setProjectSearch('')
|
||||
}
|
||||
}
|
||||
|
||||
const handleImportCancel = () => {
|
||||
setImportMode(false)
|
||||
setSelectedProject('')
|
||||
setProjectSearch('')
|
||||
}
|
||||
|
||||
const handleSave = () => {
|
||||
onSave?.(resultCodes)
|
||||
onOpenChange?.(false)
|
||||
setImportMode(false)
|
||||
setSelectedProject('')
|
||||
setProjectSearch('')
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
onOpenChange?.(false)
|
||||
setImportMode(false)
|
||||
setSelectedProject('')
|
||||
setProjectSearch('')
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={handleClose}>
|
||||
{/* ✅ importMode일 때 더 넓게(그리고 애니메이션으로 부드럽게) */}
|
||||
<DialogContent
|
||||
className={[
|
||||
'p-0 overflow-hidden',
|
||||
'transition-all duration-200',
|
||||
importMode ? 'sm:max-w-6xl' : 'sm:max-w-3xl',
|
||||
'w-[calc(100vw-2rem)]',
|
||||
'max-h-[85vh]',
|
||||
'gap-2',
|
||||
].join(' ')}
|
||||
>
|
||||
<DialogHeader className="px-6 pt-6 pb-4 border-b">
|
||||
<DialogTitle className="flex items-center justify-between gap-3">
|
||||
<span>결과 코드 설정</span>
|
||||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
{/* 상단 버튼 영역 */}
|
||||
<div className="px-6 pt-1 pb-3 border-b bg-white flex justify-end">
|
||||
{!importMode ? (
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={handleImportClick}
|
||||
className="h-9 px-3 gap-2"
|
||||
>
|
||||
<Download className="w-4 h-4" />
|
||||
가져오기
|
||||
</Button>
|
||||
) : (
|
||||
<div className="flex items-center gap-2 w-130">
|
||||
<div className="relative flex-1">
|
||||
<Search className="w-4 h-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2" />
|
||||
<Input
|
||||
value={projectSearch}
|
||||
onChange={(e) => setProjectSearch(e.target.value)}
|
||||
placeholder="프로젝트 코드/이름 검색..."
|
||||
className="h-9 pl-9"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 본문 */}
|
||||
<div className={importMode ? 'grid grid-cols-1 lg:grid-cols-2' : 'block'}>
|
||||
{/* 왼쪽: 결과 코드 */}
|
||||
<div className="p-6">
|
||||
<div className="rounded-lg border bg-white overflow-hidden">
|
||||
<div className="px-4 py-3 border-b bg-gray-50 flex items-center justify-between">
|
||||
<div className="font-semibold text-sm text-gray-900">결과 코드 목록</div>
|
||||
{!importMode && (
|
||||
<Button onClick={handleAddCode} variant="outline" size="sm" className="gap-2">
|
||||
<Plus className="w-4 h-4" />
|
||||
추가
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="max-h-[420px] overflow-y-auto">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="sticky top-0 bg-white border-b">
|
||||
<tr className="text-gray-600">
|
||||
<th className="px-4 py-2 text-left w-36">코드</th>
|
||||
<th className="px-4 py-2 text-left">레이블</th>
|
||||
<th className="px-2 py-2 w-12" />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y">
|
||||
{resultCodes.map((code, index) => (
|
||||
<tr key={index} className="hover:bg-gray-50">
|
||||
<td className="px-4 py-2 align-middle">
|
||||
<Input
|
||||
value={code.code}
|
||||
onChange={(e) => handleCodeChange(index, 'code', e.target.value)}
|
||||
className="h-9"
|
||||
disabled={importMode}
|
||||
/>
|
||||
</td>
|
||||
<td className="px-4 py-2 align-middle">
|
||||
<Input
|
||||
value={code.label}
|
||||
onChange={(e) => handleCodeChange(index, 'label', e.target.value)}
|
||||
className="h-9"
|
||||
disabled={importMode}
|
||||
/>
|
||||
</td>
|
||||
<td className="px-2 py-2 align-middle">
|
||||
{!importMode && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => handleDeleteCode(index)}
|
||||
aria-label="delete"
|
||||
>
|
||||
<Trash2 className="w-4 h-4 text-red-600" />
|
||||
</Button>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{!importMode && (
|
||||
<div className="px-4 py-3 border-t bg-gray-50 text-xs text-gray-500">
|
||||
Tip: 코드 값은 중복되지 않게 유지해주세요.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 오른쪽: importMode일 때만 */}
|
||||
{importMode && (
|
||||
<div className="p-6 border-t lg:border-t-0 lg:border-l bg-white">
|
||||
{/* 미리보기 */}
|
||||
<div className="rounded-lg border bg-white overflow-hidden">
|
||||
<div className="px-4 py-3 border-b bg-gray-50 flex items-center justify-between">
|
||||
<div className="font-semibold text-sm text-gray-900">미리보기</div>
|
||||
</div>
|
||||
|
||||
<div className="max-h-[180px] overflow-y-auto">
|
||||
{selectedProjectData ? (
|
||||
<table className="w-full text-sm">
|
||||
<thead className="sticky top-0 bg-white border-b">
|
||||
<tr className="text-gray-600">
|
||||
<th className="px-4 py-2 text-left w-32">코드</th>
|
||||
<th className="px-4 py-2 text-left">레이블</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y">
|
||||
{selectedProjectData.resultCodes.map((code, idx) => (
|
||||
<tr key={idx}>
|
||||
<td className="px-4 py-2">{code.code}</td>
|
||||
<td className="px-4 py-2">{code.label}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
) : (
|
||||
<div className="p-4 text-sm text-gray-500">프로젝트를 선택하세요.</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<DialogFooter className="px-6 py-4 border-t bg-white">
|
||||
{importMode ? (
|
||||
<>
|
||||
<Button variant="outline" onClick={handleImportCancel}>
|
||||
취소
|
||||
</Button>
|
||||
<Button onClick={handleImportApply} disabled={!selectedProject} className="gap-2">
|
||||
<Download className="w-4 h-4" />
|
||||
가져오기 적용
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Button variant="outline" onClick={handleClose}>
|
||||
취소
|
||||
</Button>
|
||||
<Button onClick={handleSave}>
|
||||
저장
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
|
||||
export default ResultCodeDialog
|
||||
@@ -18,9 +18,10 @@ import { UserInfoSaveRequest } from '@/types/user'
|
||||
import KriPassword from "@/components/common/KriPassword";
|
||||
import {KriSelect, KriSelectItem} from "@/components/common/KriSelect";
|
||||
import {DataVerification} from "@/types/common";
|
||||
import commonConst from "@/config/commonConst";
|
||||
import {apiError} from "@/lib/http-util";
|
||||
import {KriSingleSelect} from "@/components/common/KriAutoComplete";
|
||||
import {USER_NAME_REGEX} from "@/const/userConst";
|
||||
import {NONE_HTTP_ERROR, UNKNOWN_HTTP_ERROR} from "@/const/commonConst";
|
||||
|
||||
export type UserUpsertDialogProps = {
|
||||
/** Jotai로 관리할 다이얼로그 ID (기본값: 'userUpsertDialog') */
|
||||
@@ -151,19 +152,20 @@ const UserUpsertDialog = ({
|
||||
alert('이름을 입력해주세요.');
|
||||
return;
|
||||
}
|
||||
if(!commonConst.nameRegex.test(formData.userName)){
|
||||
if(!USER_NAME_REGEX.test(formData.userName)){
|
||||
alert('올바르지 않은 이름입니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
setIsSubmitting(true)
|
||||
setIsSubmitting(true);
|
||||
|
||||
try {
|
||||
await onSubmit(formData as UserInfoSaveRequest);
|
||||
handleOpenChange(false);
|
||||
} catch (e) {
|
||||
const err = apiError(e);
|
||||
console.error(err.status, err.code, err.message);
|
||||
if(err.code !== commonConst.noneHttpError && err.code !== commonConst.unknownHttpError){
|
||||
if(err.code !== NONE_HTTP_ERROR && err.code !== UNKNOWN_HTTP_ERROR){
|
||||
alert(err.message);
|
||||
}
|
||||
else{
|
||||
|
||||
Reference in New Issue
Block a user