260722_01_ENH: 버그 수정 및 개선 사항 수정
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { KriDialog } from '@/components/common/KriDialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
@@ -9,7 +9,9 @@ import { useDialog } from '@/hooks/useDialog'
|
||||
import type { DialogId } from '@/store/jotai/dialog'
|
||||
import type { CmpnInfoSaveRequest } from '@/types/cmpn'
|
||||
import type { DataVerification } from "@kri/common";
|
||||
import { apiError, NONE_HTTP_ERROR, UNKNOWN_HTTP_ERROR } from "@kri/common/http";
|
||||
import { COMMON_TEXT_REGEX } from "@/const/validationConst";
|
||||
import { validateValue } from "@/utils/validation";
|
||||
import { formatKoreanPhoneNumber } from "@/utils/phone";
|
||||
|
||||
export type CmpnUpsertDialogProps = {
|
||||
dialogId?: DialogId
|
||||
@@ -43,6 +45,12 @@ const CmpnUpsertDialog = ({
|
||||
const [formData, setFormData] = useState<CmpnInfoSaveRequest>(createDefaultCmpnInfo);
|
||||
const [isCheckedDuplicate, setIsCheckedDuplicate] = useState(false);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [invalidField, setInvalidField] = useState<'cmpnId' | 'cmpnAlias' | 'cmpnTel' | 'memo' | null>(null);
|
||||
|
||||
const cmpnIdRef = useRef<HTMLInputElement>(null);
|
||||
const cmpnAliasRef = useRef<HTMLInputElement>(null);
|
||||
const cmpnTelRef = useRef<HTMLInputElement>(null);
|
||||
const memoRef = useRef<HTMLTextAreaElement>(null);
|
||||
|
||||
const resolvedOpen = open ?? isDialogOpen(dialogId);
|
||||
|
||||
@@ -57,6 +65,7 @@ const CmpnUpsertDialog = ({
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setInvalidField(null);
|
||||
if (initialData) {
|
||||
setFormData({
|
||||
...createDefaultCmpnInfo(),
|
||||
@@ -87,6 +96,8 @@ const CmpnUpsertDialog = ({
|
||||
const cmpnId = formData.cmpnId.trim();
|
||||
if (!cmpnId) {
|
||||
alert("회사 ID를 입력해주세요.");
|
||||
setInvalidField('cmpnId');
|
||||
cmpnIdRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -105,18 +116,53 @@ const CmpnUpsertDialog = ({
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
setInvalidField(null);
|
||||
|
||||
if (!formData.cmpnId.trim()) {
|
||||
alert("회사 ID를 입력해주세요.");
|
||||
setInvalidField('cmpnId');
|
||||
cmpnIdRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode === 'create' && !isCheckedDuplicate) {
|
||||
alert("회사 ID 중복체크를 해주세요.");
|
||||
setInvalidField('cmpnId');
|
||||
cmpnIdRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!formData.cmpnAlias.trim()) {
|
||||
alert("별칭을 입력해주세요.");
|
||||
const cmpnAliasCheck = validateValue(formData.cmpnAlias, {
|
||||
required: true,
|
||||
requiredMessage: "별칭을 입력해주세요.",
|
||||
maxLength: 32,
|
||||
pattern: COMMON_TEXT_REGEX,
|
||||
patternMessage: "별칭에 허용되지 않는 문자가 포함되어 있습니다.",
|
||||
});
|
||||
if (!cmpnAliasCheck.valid) {
|
||||
alert(cmpnAliasCheck.message);
|
||||
setInvalidField('cmpnAlias');
|
||||
cmpnAliasRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
const cmpnTelCheck = validateValue(formData.cmpnTel ?? '', {
|
||||
maxLength: 16,
|
||||
pattern: COMMON_TEXT_REGEX,
|
||||
patternMessage: "전화번호에 허용되지 않는 문자가 포함되어 있습니다.",
|
||||
});
|
||||
if (!cmpnTelCheck.valid) {
|
||||
alert(cmpnTelCheck.message);
|
||||
setInvalidField('cmpnTel');
|
||||
cmpnTelRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
const memoCheck = validateValue(formData.memo ?? '', { maxLength: 2048 });
|
||||
if (!memoCheck.valid) {
|
||||
alert(memoCheck.message);
|
||||
setInvalidField('memo');
|
||||
memoRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -133,15 +179,7 @@ const CmpnUpsertDialog = ({
|
||||
});
|
||||
handleOpenChange(false);
|
||||
} catch (e) {
|
||||
const err = apiError(e, {
|
||||
fallbackMessage: "Save failed.",
|
||||
});
|
||||
console.error(err.status, err.code, err.message);
|
||||
if (err.code !== NONE_HTTP_ERROR && err.code !== UNKNOWN_HTTP_ERROR) {
|
||||
alert(err.message);
|
||||
} else {
|
||||
alert("저장에 실패했습니다.");
|
||||
}
|
||||
console.error(e);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
@@ -180,11 +218,13 @@ const CmpnUpsertDialog = ({
|
||||
</Label>
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
ref={cmpnIdRef}
|
||||
id="cmpnId"
|
||||
placeholder="Enter company ID"
|
||||
placeholder="회사 ID를 입력하세요"
|
||||
value={formData.cmpnId}
|
||||
onChange={(e) => handleInputChange('cmpnId', e.target.value)}
|
||||
disabled={mode === 'edit'}
|
||||
aria-invalid={invalidField === 'cmpnId'}
|
||||
/>
|
||||
{mode === 'create' && (
|
||||
<Button
|
||||
@@ -200,30 +240,36 @@ const CmpnUpsertDialog = ({
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="cmpnAlias">별칭</Label>
|
||||
<Input
|
||||
ref={cmpnAliasRef}
|
||||
id="cmpnAlias"
|
||||
placeholder="Enter alias"
|
||||
placeholder="별칭을 입력하세요"
|
||||
value={formData.cmpnAlias ?? ''}
|
||||
onChange={(e) => handleInputChange('cmpnAlias', e.target.value)}
|
||||
aria-invalid={invalidField === 'cmpnAlias'}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="cmpnTel">전화번호</Label>
|
||||
<Input
|
||||
ref={cmpnTelRef}
|
||||
id="cmpnTel"
|
||||
placeholder="Enter tel"
|
||||
value={formData.cmpnTel ?? ''}
|
||||
onChange={(e) => handleInputChange('cmpnTel', e.target.value)}
|
||||
placeholder="전화번호를 입력하세요"
|
||||
value={formatKoreanPhoneNumber(formData.cmpnTel ?? '')}
|
||||
onChange={(e) => handleInputChange('cmpnTel', e.target.value.replace(/\D/g, ''))}
|
||||
aria-invalid={invalidField === 'cmpnTel'}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="memo">메모</Label>
|
||||
<textarea
|
||||
ref={memoRef}
|
||||
id="memo"
|
||||
className="flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
className="flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20"
|
||||
rows={3}
|
||||
placeholder="Enter memo"
|
||||
placeholder="메모를 입력하세요"
|
||||
value={formData.memo ?? ''}
|
||||
onChange={(e) => handleInputChange('memo', e.target.value)}
|
||||
aria-invalid={invalidField === 'memo'}
|
||||
/>
|
||||
</div>
|
||||
</KriDialog>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { Plus, X } from 'lucide-react'
|
||||
import { KriDialog } from '@/components/common/KriDialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
@@ -13,12 +13,15 @@ import {
|
||||
SelectValue,
|
||||
} from '@/components/ui/select'
|
||||
import { KriSingleSelect } from '@/components/common/KriAutoComplete'
|
||||
import ApplyFilterOption from './ListDialogOption/ApplyFilterOption'
|
||||
import ApplyFilterOption, { validateApplyFilterTarget } from './ListDialogOption/ApplyFilterOption'
|
||||
import { useDialog } from '@/hooks/useDialog'
|
||||
import type { DialogId } from '@/store/jotai/dialog'
|
||||
import type { FilterValueOption, ListFilterTarget } from '@/types/list'
|
||||
import { type ResultCode, ResultCodeType } from '@/types/project'
|
||||
import { type ProjectSurvey, type ResultCode, ResultCodeType } from '@/types/project'
|
||||
import { ListHeaderConst, LIST_BATCH_EDIT_FILE_DELETE_VALUE } from '@/const/listConst'
|
||||
import { COMMON_TEXT_REGEX } from '@/const/validationConst'
|
||||
import { validateValue } from '@/utils/validation'
|
||||
import { formatKoreanPhoneNumber } from '@/utils/phone'
|
||||
|
||||
export type BatchEditOption = {
|
||||
id: number
|
||||
@@ -33,11 +36,13 @@ export type BatchEditRow = {
|
||||
value: string
|
||||
}
|
||||
|
||||
export type BatchEditResultCodes = Partial<Record<ResultCodeType, number>>
|
||||
export type BatchEditResultCodes = Partial<Record<Exclude<ResultCodeType, ResultCodeType.SURVEY>, number>>
|
||||
export type BatchEditSurveyResultCodes = Record<number, number>
|
||||
|
||||
export type BatchEditPayload = {
|
||||
rows: BatchEditRow[]
|
||||
resultCodes: BatchEditResultCodes
|
||||
surveyResultCodes: { prjctSurveyIdx: number; resultCd: number }[]
|
||||
target: ListFilterTarget
|
||||
}
|
||||
|
||||
@@ -47,9 +52,11 @@ export type ListBatchEditDialogProps = {
|
||||
onOpenChange?: (open: boolean) => void
|
||||
headerOptions: BatchEditOption[]
|
||||
resultCodes: ResultCode[]
|
||||
surveys: ProjectSurvey[]
|
||||
filterSummary?: string[]
|
||||
initialRows?: BatchEditRow[]
|
||||
initialResultCodes?: BatchEditResultCodes
|
||||
initialSurveyResultCodes?: BatchEditSurveyResultCodes
|
||||
onConfirm: (payload: BatchEditPayload) => void | Promise<void>
|
||||
}
|
||||
|
||||
@@ -61,10 +68,9 @@ const createRow = (headerId: number, value = ''): BatchEditRow => ({
|
||||
|
||||
const NO_CHANGE = '__no_change__'
|
||||
|
||||
const resultCodeGroups: { type: ResultCodeType; label: string }[] = [
|
||||
const resultCodeGroups: { type: Exclude<ResultCodeType, ResultCodeType.SURVEY>; label: string }[] = [
|
||||
{ type: ResultCodeType.CONTACT, label: '컨택 결과' },
|
||||
{ type: ResultCodeType.INTERVIEW, label: '면접 결과' },
|
||||
{ type: ResultCodeType.SURVEY, label: '설문 결과' },
|
||||
]
|
||||
|
||||
const ListBatchEditDialog = ({
|
||||
@@ -73,21 +79,27 @@ const ListBatchEditDialog = ({
|
||||
onOpenChange,
|
||||
headerOptions,
|
||||
resultCodes,
|
||||
surveys,
|
||||
filterSummary,
|
||||
initialRows = [],
|
||||
initialResultCodes = {},
|
||||
initialSurveyResultCodes = {},
|
||||
onConfirm,
|
||||
}: ListBatchEditDialogProps) => {
|
||||
const { isDialogOpen, showDialog, hideDialog } = useDialog()
|
||||
const [rows, setRows] = useState<BatchEditRow[]>([])
|
||||
const [resultCodeSelections, setResultCodeSelections] = useState<BatchEditResultCodes>({})
|
||||
const [surveyResultSelections, setSurveyResultSelections] = useState<BatchEditSurveyResultCodes>({})
|
||||
const [target, setTarget] = useState<ListFilterTarget>('filtered')
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
const [invalidRowId, setInvalidRowId] = useState<string | null>(null)
|
||||
const rowInputRefs = useRef<Map<string, HTMLInputElement>>(new Map())
|
||||
|
||||
const resolvedOpen = open ?? isDialogOpen(dialogId)
|
||||
const defaultHeaderId = headerOptions[0]?.id ?? 0
|
||||
|
||||
const isFileHeader = (headerId: number) => headerOptions.find((option) => option.id === headerId)?.listHderTy === ListHeaderConst.FILE
|
||||
const isTelHeader = (headerId: number) => headerOptions.find((option) => option.id === headerId)?.listHderTy === ListHeaderConst.TEL_NUM
|
||||
|
||||
useEffect(() => {
|
||||
if (!resolvedOpen) return
|
||||
@@ -99,8 +111,10 @@ const ListBatchEditDialog = ({
|
||||
setRows([])
|
||||
}
|
||||
setResultCodeSelections({ ...initialResultCodes })
|
||||
setSurveyResultSelections({ ...initialSurveyResultCodes })
|
||||
setTarget('filtered')
|
||||
}, [resolvedOpen, initialRows, initialResultCodes, defaultHeaderId])
|
||||
setInvalidRowId(null)
|
||||
}, [resolvedOpen, initialRows, initialResultCodes, initialSurveyResultCodes, defaultHeaderId])
|
||||
|
||||
const handleOpenChange = (nextOpen: boolean) => {
|
||||
onOpenChange?.(nextOpen)
|
||||
@@ -131,7 +145,7 @@ const ListBatchEditDialog = ({
|
||||
setRows((prev) => prev.map((row) => (row.id === id ? { ...row, value } : row)))
|
||||
}
|
||||
|
||||
const handleChangeResultCode = (type: ResultCodeType, value: string) => {
|
||||
const handleChangeResultCode = (type: Exclude<ResultCodeType, ResultCodeType.SURVEY>, value: string) => {
|
||||
setResultCodeSelections((prev) => {
|
||||
if (value === NO_CHANGE) {
|
||||
const next = { ...prev }
|
||||
@@ -142,17 +156,53 @@ const ListBatchEditDialog = ({
|
||||
})
|
||||
}
|
||||
|
||||
const handleChangeSurveyResultCode = (prjctSurveyIdx: number, value: string) => {
|
||||
setSurveyResultSelections((prev) => {
|
||||
if (value === NO_CHANGE) {
|
||||
const next = { ...prev }
|
||||
delete next[prjctSurveyIdx]
|
||||
return next
|
||||
}
|
||||
return { ...prev, [prjctSurveyIdx]: Number(value) }
|
||||
})
|
||||
}
|
||||
|
||||
const handleConfirm = async () => {
|
||||
setInvalidRowId(null)
|
||||
if (!validateApplyFilterTarget(target, filterSummary)) return
|
||||
|
||||
const normalized = rows.filter((row) => row.headerId > 0 && row.value.trim().length > 0)
|
||||
const hasResultCodeChange = Object.keys(resultCodeSelections).length > 0
|
||||
const surveyResultCodes = Object.entries(surveyResultSelections).map(([prjctSurveyIdx, resultCd]) => ({
|
||||
prjctSurveyIdx: Number(prjctSurveyIdx),
|
||||
resultCd,
|
||||
}))
|
||||
const hasResultCodeChange = Object.keys(resultCodeSelections).length > 0 || surveyResultCodes.length > 0
|
||||
if (normalized.length === 0 && !hasResultCodeChange) {
|
||||
alert('일괄 수정할 항목을 입력해주세요.')
|
||||
return
|
||||
}
|
||||
|
||||
// 직접 값을 타이핑하는 행(선택형/파일 삭제가 아닌 행)만 형식을 검증한다.
|
||||
for (const row of normalized) {
|
||||
const isFreeTextRow = !isFileHeader(row.headerId) && getValueOptions(row.headerId) === undefined
|
||||
if (!isFreeTextRow) continue
|
||||
|
||||
const valueCheck = validateValue(row.value, {
|
||||
maxLength: 2048,
|
||||
pattern: COMMON_TEXT_REGEX,
|
||||
patternMessage: '수정 값에 허용되지 않는 문자가 포함되어 있습니다.',
|
||||
})
|
||||
if (!valueCheck.valid) {
|
||||
alert(valueCheck.message)
|
||||
setInvalidRowId(row.id)
|
||||
rowInputRefs.current.get(row.id)?.focus()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
setSubmitting(true)
|
||||
try {
|
||||
await onConfirm({ rows: normalized, resultCodes: resultCodeSelections, target })
|
||||
await onConfirm({ rows: normalized, resultCodes: resultCodeSelections, surveyResultCodes, target })
|
||||
handleOpenChange(false)
|
||||
} finally {
|
||||
setSubmitting(false)
|
||||
@@ -215,6 +265,41 @@ const ListBatchEditDialog = ({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{surveys.length > 0 ? (
|
||||
<div className="rounded-md border p-4 space-y-3">
|
||||
<p className="font-semibold text-sm">설문별 결과 수정</p>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-3 gap-2">
|
||||
{surveys.map((survey) => (
|
||||
<div key={survey.prjctSurveyIdx} className="space-y-1">
|
||||
<p className="text-sm text-muted-foreground">{survey.surveyName}</p>
|
||||
<Select
|
||||
value={
|
||||
survey.prjctSurveyIdx != null && surveyResultSelections[survey.prjctSurveyIdx] !== undefined
|
||||
? String(surveyResultSelections[survey.prjctSurveyIdx])
|
||||
: NO_CHANGE
|
||||
}
|
||||
onValueChange={(v) => survey.prjctSurveyIdx != null && handleChangeSurveyResultCode(survey.prjctSurveyIdx, v)}
|
||||
>
|
||||
<SelectTrigger className="w-full">
|
||||
<SelectValue placeholder="변경 안함" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value={NO_CHANGE}>변경 안함</SelectItem>
|
||||
{resultCodes
|
||||
.filter((code) => code.resultCdTy === ResultCodeType.SURVEY && code.resultCd !== 0)
|
||||
.map((code) => (
|
||||
<SelectItem key={code.resultCdUUID} value={String(code.resultCd)}>
|
||||
{code.resultCdLbl}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<p className="font-semibold text-sm">항목값 수정</p>
|
||||
<div className="rounded-md border overflow-hidden">
|
||||
<div className="h-11 px-4 border-b bg-muted grid grid-cols-[1fr_2fr_64px] items-center text-sm font-semibold">
|
||||
@@ -263,11 +348,27 @@ const ListBatchEditDialog = ({
|
||||
widthClassName="w-full"
|
||||
className="w-full"
|
||||
/>
|
||||
) : isTelHeader(row.headerId) ? (
|
||||
<Input
|
||||
ref={(el) => {
|
||||
if (el) rowInputRefs.current.set(row.id, el)
|
||||
else rowInputRefs.current.delete(row.id)
|
||||
}}
|
||||
value={formatKoreanPhoneNumber(row.value)}
|
||||
onChange={(e) => handleChangeValue(row.id, e.target.value.replace(/\D/g, ''))}
|
||||
placeholder="수정할 값을 입력해주세요"
|
||||
aria-invalid={invalidRowId === row.id}
|
||||
/>
|
||||
) : (
|
||||
<Input
|
||||
ref={(el) => {
|
||||
if (el) rowInputRefs.current.set(row.id, el)
|
||||
else rowInputRefs.current.delete(row.id)
|
||||
}}
|
||||
value={row.value}
|
||||
onChange={(e) => handleChangeValue(row.id, e.target.value)}
|
||||
placeholder="수정할 값을 입력해주세요"
|
||||
aria-invalid={invalidRowId === row.id}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
@@ -7,6 +7,18 @@ import type { ListFilterTarget } from "@/types/list";
|
||||
|
||||
export type ApplyFilterOptionValue = ListFilterTarget
|
||||
|
||||
/**
|
||||
* "필터 적용 대상만"을 선택했는데 실제로 적용된 필터가 없는 경우를 검사한다.
|
||||
* alert 후 진행을 막아야 하는 호출부에서 공통으로 사용한다.
|
||||
*/
|
||||
export const validateApplyFilterTarget = (value: ApplyFilterOptionValue, filterSummary?: string[]): boolean => {
|
||||
if (value === 'filtered' && (filterSummary?.length ?? 0) === 0) {
|
||||
alert('적용된 필터가 없습니다. 필터를 적용해 주세요.')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type ApplyFilterGroupProps = {
|
||||
value: ApplyFilterOptionValue
|
||||
onValueChange: (value: ApplyFilterOptionValue) => void
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Label } from '@/components/ui/label'
|
||||
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
|
||||
import { useDialog } from '@/hooks/useDialog'
|
||||
import type { DialogId } from '@/store/jotai/dialog'
|
||||
import ApplyFilterOption from './ListDialogOption/ApplyFilterOption'
|
||||
import ApplyFilterOption, { validateApplyFilterTarget } from './ListDialogOption/ApplyFilterOption'
|
||||
import KriDateRangePicker from '@/components/common/KriDateRangePicker'
|
||||
import type { ContactHistoryDownloadType, ListDownloadMode, ListDownloadPayload, ListFilterTarget } from '@/types/list'
|
||||
|
||||
@@ -55,6 +55,8 @@ const ListDownloadDialog = ({
|
||||
}
|
||||
|
||||
const handleDownload = async () => {
|
||||
if (!validateApplyFilterTarget(target, filterSummary)) return
|
||||
|
||||
if (mode === 'contact-history') {
|
||||
const hasFrom = contactHistoryDateFrom.length > 0
|
||||
const hasTo = contactHistoryDateTo.length > 0
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Label } from '@/components/ui/label'
|
||||
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
|
||||
import { useDialog } from '@/hooks/useDialog'
|
||||
import type { DialogId } from '@/store/jotai/dialog'
|
||||
import ApplyFilterOption from './ListDialogOption/ApplyFilterOption'
|
||||
import ApplyFilterOption, { validateApplyFilterTarget } from './ListDialogOption/ApplyFilterOption'
|
||||
import type { ListFilterTarget, ListResetScope } from '@/types/list'
|
||||
|
||||
export type ListResetDialogProps = {
|
||||
@@ -42,6 +42,9 @@ const ListResetDialog = ({
|
||||
}
|
||||
|
||||
const handleConfirm = async () => {
|
||||
if (!validateApplyFilterTarget(target, filterSummary)) return
|
||||
if (target === 'all' && !confirm('전체 리스트가 초기화 됩니다. 진행하시겠습니까?')) return
|
||||
|
||||
setSubmitting(true)
|
||||
try {
|
||||
await onConfirm({ target, scope })
|
||||
|
||||
@@ -189,8 +189,8 @@ const ListUploadDialog = ({
|
||||
})
|
||||
resetState()
|
||||
handleOpenChange(false)
|
||||
} catch {
|
||||
alert('리스트 업로드 중 오류가 발생했습니다.')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
setSubmitting(false)
|
||||
}
|
||||
@@ -314,6 +314,9 @@ const ListUploadDialog = ({
|
||||
</Button>
|
||||
<input ref={fileInputRef} type="file" accept={ACCEPT_EXTENSIONS.join(',')} className="hidden" onChange={handleSelectFile} />
|
||||
</div>
|
||||
<p className="text-sm text-red-600 font-medium">
|
||||
⚠️ 해당 파일의 내용대로 배정도 수정됩니다.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{selectedFile && excelHeaders.length > 0 && compareRows.length > 0 && (
|
||||
|
||||
@@ -16,6 +16,7 @@ import type { DialogId } from '@/store/jotai/dialog'
|
||||
import type { BulkSendInfo } from '@kri/common/noti-hub'
|
||||
import type { SendResultInfo } from '@/types/message'
|
||||
import {clientEnv} from "@/lib/env.client";
|
||||
import { formatKoreanPhoneNumber } from "@/utils/phone";
|
||||
|
||||
export type MessageHistoryType = 'sms' | 'email'
|
||||
|
||||
@@ -43,9 +44,9 @@ const historyColumns: DataTableColumn<BulkSendInfo>[] = [
|
||||
]
|
||||
|
||||
const detailColumns: DataTableColumn<SendResultInfo>[] = [
|
||||
{ id: 'destTo', header: '수신처', accessorFn: (row) => row.destEml || row.destTel || '-' },
|
||||
{ id: 'destTo', header: '수신처', accessorFn: (row) => row.destEml || (row.destTel ? formatKoreanPhoneNumber(row.destTel) : '') || '-' },
|
||||
{ id: 'destNm', header: '수신자명', accessorFn: (row) => row.destNm ?? '-' },
|
||||
{ id: 'sendFrom', header: '발신지', accessorFn: (row) => row.sendEml || row.sendTel || '-' },
|
||||
{ id: 'sendFrom', header: '발신지', accessorFn: (row) => row.sendEml || (row.sendTel ? formatKoreanPhoneNumber(row.sendTel) : '') || '-' },
|
||||
{ id: 'resultViewLabel', header: '결과', accessorFn: (row) => row.resultViewLabel || row.resultLabel || String(row.resultCode) },
|
||||
{ id: 'sendDt', header: '발송 일시', accessorFn: (row) => (row.sendDt ? formatKst(row.sendDt, 'dateTime') : '-') },
|
||||
{ id: 'regDt', header: '등록 일시', accessorFn: (row) => (row.regDt ? formatKst(row.regDt, 'dateTime') : '-') },
|
||||
|
||||
@@ -23,7 +23,7 @@ import type { DialogId } from '@/store/jotai/dialog'
|
||||
import { createEmptyListFilter, type ListFilter, type ListFilterTarget, type listHeader } from '@/types/list'
|
||||
import { ListHeaderConst } from '@/const/listConst'
|
||||
import type { ListTableRow } from '@/components/table-column/ListTableColumn'
|
||||
import ApplyFilterOption from './ListDialogOption/ApplyFilterOption'
|
||||
import ApplyFilterOption, { validateApplyFilterTarget } from './ListDialogOption/ApplyFilterOption'
|
||||
import { KriEditor } from '@/components/kri-editor'
|
||||
|
||||
export type MessageSendMode = 'email' | 'sms'
|
||||
@@ -151,6 +151,7 @@ const MessageSendDialog = ({
|
||||
}
|
||||
|
||||
const handleConfirm = async () => {
|
||||
if (!validateApplyFilterTarget(target, filterSummary)) return
|
||||
if (!selectedTemplate || !templateIdx) {
|
||||
alert('템플릿을 선택해 주세요.')
|
||||
return
|
||||
@@ -196,7 +197,6 @@ const MessageSendDialog = ({
|
||||
handleOpenChange(false)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
alert('발송 중 오류가 발생했습니다.')
|
||||
} finally {
|
||||
setSubmitting(false)
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
'use client'
|
||||
|
||||
import {useState, useEffect, useMemo} from 'react'
|
||||
import {useState, useEffect, useMemo, useRef} from 'react'
|
||||
import { KriDialog } from "@/components/common/KriDialog";
|
||||
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 type {MultiSelectRef} from "@/components/common/KriAutoComplete";
|
||||
import {useDialog} from "@/hooks/useDialog";
|
||||
import type {DialogId} from "@/store/jotai/dialog";
|
||||
import {NONE_HTTP_ERROR, UNKNOWN_HTTP_ERROR} from "@kri/common/http";
|
||||
import {apiError} from "@kri/common/http";
|
||||
import {ProjectCreateRequest} from "@/types/project";
|
||||
import { useDebouncedValue } from "@kri/common/hooks";
|
||||
import {PROJECT_NAME_REGEX} from "@/const/projectConst";
|
||||
import {FW_TEAM, USER_NAME_REGEX} from "@/const/userConst";
|
||||
import {FW_TEAM} from "@/const/userConst";
|
||||
import {COMMON_TEXT_REGEX, USER_NAME_REGEX} from "@/const/validationConst";
|
||||
import { validateValue } from "@/utils/validation";
|
||||
import type { MultiSelectOption } from "@/components/common/KriAutoComplete";
|
||||
import {ItrntUserInfo} from "@/types/user";
|
||||
import {useIntranetProjectListQuery} from "@/query/intranet";
|
||||
import {useGroupCodeListQuery, useIntranetProjectListQuery} from "@/query/intranet";
|
||||
|
||||
export type ProjectCreateDialogProps = {
|
||||
/** Jotai로 관리할 다이얼로그 ID */
|
||||
@@ -45,10 +45,11 @@ const ProjectCreateDialog = ({
|
||||
ownerFw: ownerFw,
|
||||
}
|
||||
const { isDialogOpen, showDialog, hideDialog } = useDialog();
|
||||
const [deptArray, setDeptArray] = useState<string[]>([]);
|
||||
const [deptArray, setDeptArray] = useState<MultiSelectOption[]>([]);
|
||||
const [fwArray, setFwArray] = useState<MultiSelectOption[]>([]);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [formData, setFormData] = useState<ProjectCreateRequest>(defaultProjectInfo);
|
||||
const [invalidField, setInvalidField] = useState<'itrntPrjctCd' | 'prjctName' | 'ownerDept' | 'ownerFw' | null>(null);
|
||||
|
||||
// 실제 Dialog에 전달할 open 값
|
||||
const resolvedOpen = open ?? isDialogOpen(dialogId);
|
||||
@@ -56,9 +57,20 @@ const ProjectCreateDialog = ({
|
||||
const [itrntKeyword, setItrntKeyword] = useState('');
|
||||
const debouncedKeyword = useDebouncedValue(itrntKeyword, 500);
|
||||
|
||||
const itrntPrjctRef = useRef<MultiSelectRef>(null);
|
||||
const prjctNameRef = useRef<HTMLInputElement>(null);
|
||||
const ownerDeptRef = useRef<MultiSelectRef>(null);
|
||||
const ownerFwRef = useRef<MultiSelectRef>(null);
|
||||
|
||||
const itrntPrjctListQuery = useIntranetProjectListQuery(debouncedKeyword, resolvedOpen);
|
||||
const itrntPrjctArray = useMemo(() => itrntPrjctListQuery.data ?? [] ,[itrntPrjctListQuery.data]);
|
||||
|
||||
const groupCodeListQuery = useGroupCodeListQuery(resolvedOpen);
|
||||
const groupCodeLabelMap = useMemo(
|
||||
() => new Map((groupCodeListQuery.data ?? []).map((g) => [g.groupCode, g.groupCodeLabel])),
|
||||
[groupCodeListQuery.data]
|
||||
);
|
||||
|
||||
// 부모 콜백과 jotai 상태를 함께 처리
|
||||
const handleOpenChange = (nextOpen: boolean) => {
|
||||
onOpenChange?.(nextOpen);
|
||||
@@ -88,32 +100,51 @@ const ProjectCreateDialog = ({
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if(!formData.itrntPrjctCd.trim()){
|
||||
alert("Please select an intranet project.");
|
||||
setInvalidField(null);
|
||||
|
||||
const itrntPrjctCheck = validateValue(formData.itrntPrjctCd, {
|
||||
required: true,
|
||||
requiredMessage: "인트라넷 프로젝트를 선택해주세요.",
|
||||
});
|
||||
if (!itrntPrjctCheck.valid) {
|
||||
alert(itrntPrjctCheck.message);
|
||||
setInvalidField('itrntPrjctCd');
|
||||
itrntPrjctRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
if (!formData.prjctName.trim()) {
|
||||
alert("Please enter project name.");
|
||||
const prjctNameCheck = validateValue(formData.prjctName, {
|
||||
required: true,
|
||||
requiredMessage: "프로젝트명을 입력해주세요.",
|
||||
maxLength: 128,
|
||||
pattern: COMMON_TEXT_REGEX,
|
||||
patternMessage: "프로젝트명에 허용되지 않는 문자가 포함되어 있습니다.",
|
||||
});
|
||||
if (!prjctNameCheck.valid) {
|
||||
alert(prjctNameCheck.message);
|
||||
setInvalidField('prjctName');
|
||||
prjctNameRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
if (!PROJECT_NAME_REGEX.test(formData.prjctName)) {
|
||||
alert("프로젝트명에 허용되지 않는 문자가 포함되어 있습니다.");
|
||||
const ownerDeptCheck = validateValue(formData.ownerDept, {
|
||||
required: true,
|
||||
requiredMessage: "담당 그룹을 입력해주세요.",
|
||||
pattern: USER_NAME_REGEX,
|
||||
patternMessage: "해당 그룹이 올바르지 않습니다.",
|
||||
});
|
||||
if (!ownerDeptCheck.valid) {
|
||||
alert(ownerDeptCheck.message);
|
||||
setInvalidField('ownerDept');
|
||||
ownerDeptRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
if(!formData.ownerDept.trim()){
|
||||
alert("Please enter owner department.");
|
||||
return;
|
||||
}
|
||||
if(!USER_NAME_REGEX.test(formData.ownerDept)){
|
||||
alert("해당 그룹이 올바르지 않습니다.");
|
||||
return;
|
||||
}
|
||||
if(!formData.ownerFw.trim()){
|
||||
alert("Please enter owner department.");
|
||||
return;
|
||||
}
|
||||
if(!USER_NAME_REGEX.test(formData.ownerDept)){
|
||||
alert("해당 SV가 올바르지 않습니다.");
|
||||
const ownerFwCheck = validateValue(formData.ownerFw, {
|
||||
required: true,
|
||||
requiredMessage: "담당 실사(SV)를 입력해주세요.",
|
||||
});
|
||||
if (!ownerFwCheck.valid) {
|
||||
alert(ownerFwCheck.message);
|
||||
setInvalidField('ownerFw');
|
||||
ownerFwRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,15 +153,7 @@ const ProjectCreateDialog = ({
|
||||
await onSubmit(formData as ProjectCreateRequest);
|
||||
handleOpenChange(false);
|
||||
} catch (e) {
|
||||
const err = apiError(e, {
|
||||
fallbackMessage: "Save failed.",
|
||||
});
|
||||
if(err.code !== NONE_HTTP_ERROR && err.code !== UNKNOWN_HTTP_ERROR){
|
||||
alert(err.message);
|
||||
}
|
||||
else{
|
||||
alert("저장에 실패했습니다.");
|
||||
}
|
||||
console.error(e);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
@@ -138,6 +161,7 @@ const ProjectCreateDialog = ({
|
||||
|
||||
useEffect(() => {
|
||||
setFormData(defaultProjectInfo);
|
||||
setInvalidField(null);
|
||||
}, [resolvedOpen])
|
||||
|
||||
useEffect(() => {
|
||||
@@ -146,7 +170,10 @@ const ProjectCreateDialog = ({
|
||||
userTeams.push("T900");
|
||||
}
|
||||
userTeams = userTeams.sort((a, b) => a.localeCompare(b, "ko"));
|
||||
setDeptArray(userTeams);
|
||||
setDeptArray(userTeams.map((code) => ({
|
||||
value: code,
|
||||
label: groupCodeLabelMap.get(code) ?? code,
|
||||
})));
|
||||
|
||||
const userOptions: MultiSelectOption[] = users
|
||||
.filter(u => u.userId == ownerFw || u.userTeam == FW_TEAM)
|
||||
@@ -155,7 +182,7 @@ const ProjectCreateDialog = ({
|
||||
label: u.userNm,
|
||||
}));
|
||||
setFwArray(userOptions);
|
||||
}, [users]);
|
||||
}, [users, groupCodeLabelMap]);
|
||||
|
||||
return (
|
||||
<KriDialog
|
||||
@@ -189,6 +216,7 @@ const ProjectCreateDialog = ({
|
||||
인트라넷 프로젝트<span className="text-red-500 ml-1">*</span>
|
||||
</Label>
|
||||
<KriSingleSelect
|
||||
ref={itrntPrjctRef}
|
||||
items={itrntPrjctArray}
|
||||
value={String(formData.itrntPrjctCd)}
|
||||
onChange={(e) => handleInputChange('itrntPrjctCd', e)}
|
||||
@@ -199,17 +227,20 @@ const ProjectCreateDialog = ({
|
||||
placeholder="인트라넷 프로젝트"
|
||||
widthClassName="w-full"
|
||||
heightClassName="h-9"
|
||||
aria-invalid={invalidField === 'itrntPrjctCd'}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="prjctName">
|
||||
Project name<span className="text-red-500 ml-1">*</span>
|
||||
프로젝트명<span className="text-red-500 ml-1">*</span>
|
||||
</Label>
|
||||
<Input
|
||||
ref={prjctNameRef}
|
||||
id="prjctName"
|
||||
placeholder="Enter project name"
|
||||
placeholder="프로젝트명을 입력하세요"
|
||||
value={formData.prjctName}
|
||||
onChange={(e) => handleInputChange('prjctName', e.target.value)}
|
||||
aria-invalid={invalidField === 'prjctName'}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
@@ -217,12 +248,16 @@ const ProjectCreateDialog = ({
|
||||
담당 그룹<span className="text-red-500 ml-1">*</span>
|
||||
</Label>
|
||||
<KriSingleSelect
|
||||
ref={ownerDeptRef}
|
||||
items={deptArray}
|
||||
value={formData.ownerDept || ''}
|
||||
onChange={(value) => handleInputChange('ownerDept', value)}
|
||||
placeholder="Select owner department"
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
placeholder="담당 그룹을 선택하세요"
|
||||
heightClassName="h-9"
|
||||
widthClassName="w-full"
|
||||
aria-invalid={invalidField === 'ownerDept'}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
@@ -230,14 +265,16 @@ const ProjectCreateDialog = ({
|
||||
담당 실사<span className="text-red-500 ml-1">*</span>
|
||||
</Label>
|
||||
<KriSingleSelect
|
||||
ref={ownerFwRef}
|
||||
items={fwArray}
|
||||
value={formData.ownerFw || ''}
|
||||
onChange={(value) => handleInputChange('ownerFw', value)}
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
placeholder="Select owner department"
|
||||
placeholder="담당 실사를 선택하세요"
|
||||
heightClassName="h-9"
|
||||
widthClassName="w-full"
|
||||
aria-invalid={invalidField === 'ownerFw'}
|
||||
/>
|
||||
</div>
|
||||
</KriDialog>
|
||||
|
||||
@@ -132,7 +132,6 @@ const SingleMessageSendDialog = ({
|
||||
handleOpenChange(false)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
alert('발송 중 오류가 발생했습니다.')
|
||||
} finally {
|
||||
setSubmitting(false)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import { useState, useRef } from 'react'
|
||||
import {Download, Upload, X} from 'lucide-react'
|
||||
import { useDialog } from '@/hooks/useDialog'
|
||||
import type { DialogId } from '@/store/jotai/dialog'
|
||||
import {apiError} from "@kri/common/http";
|
||||
|
||||
export type UserUploadDialogProps = {
|
||||
/** jotai로 관리할 dialog id */
|
||||
@@ -92,11 +91,7 @@ const UserUploadDialog = ({
|
||||
handleRemoveFile();
|
||||
handleOpenChange(false);
|
||||
} catch (e) {
|
||||
const err = apiError(e, {
|
||||
fallbackMessage: "File upload failed.",
|
||||
});
|
||||
console.error(err.status, err.code, err.message);
|
||||
alert("업로드에 실패했습니다.");
|
||||
console.error(e);
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { KriDialog } from '@/components/common/KriDialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
@@ -8,14 +8,14 @@ import { Label } from '@/components/ui/label'
|
||||
import { useDialog } from '@/hooks/useDialog'
|
||||
import type { DialogId } from '@/store/jotai/dialog'
|
||||
import { UserInfoSaveRequest } from '@/types/user'
|
||||
import KriPassword, { KRI_PW_REGEX } from "@/components/common/KriPassword";
|
||||
import {KriSelect, KriSelectItem} from "@/components/common/KriSelect";
|
||||
import KriPassword, { type KriPasswordRef } from "@/components/common/KriPassword";
|
||||
import {KriSelect, KriSelectItem, type KriSelectRef} from "@/components/common/KriSelect";
|
||||
import type { DataVerification } from "@kri/common";
|
||||
import {apiError} from "@kri/common/http";
|
||||
import {CONTACT_INTERVIEWER_ROLE, FW_TEAM, USER_NAME_REGEX} from "@/const/userConst";
|
||||
import {NONE_HTTP_ERROR, UNKNOWN_HTTP_ERROR} from "@kri/common/http";
|
||||
import {CONTACT_INTERVIEWER_ROLE, FW_TEAM} from "@/const/userConst";
|
||||
import {KRI_PW_REGEX, USER_NAME_REGEX} from "@/const/validationConst";
|
||||
import type { CmpnInfo } from "@/types/cmpn";
|
||||
import { isExternalManager, isFieldWorkUser } from "@/utils/userRole";
|
||||
import { validateValue } from "@/utils/validation";
|
||||
|
||||
// 외주사(EXTERNAL_USER_ROLE_GROUP)와 콜센터/컨택원/면접원(FW_USER_ROLE_GROUP)은 배정 체계가 완전히 달라
|
||||
// 서로 넘나드는 권한 수정을 지원하지 않는다. 하나 새로 만들어서 넘기는 게 맞다.
|
||||
@@ -69,6 +69,13 @@ const UserUpsertDialog = ({
|
||||
|
||||
const [isCheckedDuplicate, setIsCheckedDuplicate] = useState(false);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [invalidField, setInvalidField] = useState<'userId' | 'userPw' | 'userName' | 'userCmpn' | 'memo' | null>(null);
|
||||
|
||||
const userIdRef = useRef<HTMLInputElement>(null);
|
||||
const userPwRef = useRef<KriPasswordRef>(null);
|
||||
const userNameRef = useRef<HTMLInputElement>(null);
|
||||
const userCmpnRef = useRef<KriSelectRef>(null);
|
||||
const memoRef = useRef<HTMLTextAreaElement>(null);
|
||||
|
||||
// 실제 Dialog에 전달할 open 값
|
||||
const resolvedOpen = open ?? isDialogOpen(dialogId);
|
||||
@@ -86,6 +93,7 @@ const UserUpsertDialog = ({
|
||||
|
||||
// initialData / mode / open 변경 시 폼 세팅
|
||||
useEffect(() => {
|
||||
setInvalidField(null);
|
||||
if (initialData) {
|
||||
setFormData(prev => ({
|
||||
...prev,
|
||||
@@ -108,6 +116,12 @@ const UserUpsertDialog = ({
|
||||
return userRoleArray.filter((item) => !isCrossExternalFwRoleChange(initialRole, Number(item.value)))
|
||||
}, [mode, initialData?.userRole, userRoleArray])
|
||||
|
||||
// 외주 실사(외주사) 권한은 자사 소속을 가질 수 없으므로 회사 선택지에서 제외한다.
|
||||
const availableCmpnArray = useMemo(() => {
|
||||
if (!isExternalManager(formData.userRole)) return userCmpnArray
|
||||
return userCmpnArray.filter((c) => !c.ownCmpn)
|
||||
}, [userCmpnArray, formData.userRole])
|
||||
|
||||
const handleInputChange = <K extends keyof UserInfoSaveRequest>(field: K, value: UserInfoSaveRequest[K]) => {
|
||||
setFormData(prev => ({
|
||||
...prev,
|
||||
@@ -120,8 +134,11 @@ const UserUpsertDialog = ({
|
||||
}
|
||||
|
||||
const handleCheckDuplicate = async () => {
|
||||
if (!formData.userId.trim()) {
|
||||
alert("아이디를 입력해주세요.");
|
||||
const userIdCheck = validateValue(formData.userId, { required: true, requiredMessage: "아이디를 입력해주세요." });
|
||||
if (!userIdCheck.valid) {
|
||||
alert(userIdCheck.message);
|
||||
setInvalidField('userId');
|
||||
userIdRef.current?.focus();
|
||||
return
|
||||
}
|
||||
|
||||
@@ -140,28 +157,73 @@ const UserUpsertDialog = ({
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!formData.userId.trim()) {
|
||||
alert("아이디를 입력해주세요.");
|
||||
setInvalidField(null);
|
||||
|
||||
const userIdCheck = validateValue(formData.userId, { required: true, requiredMessage: "아이디를 입력해주세요." });
|
||||
if (!userIdCheck.valid) {
|
||||
alert(userIdCheck.message);
|
||||
setInvalidField('userId');
|
||||
userIdRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
if (mode === 'create' && !isCheckedDuplicate) {
|
||||
alert("아이디 중복체크를 해주세요.");
|
||||
setInvalidField('userId');
|
||||
userIdRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
if (!formData.userPw.trim()) {
|
||||
alert("비밀번호를 입력해주세요.");
|
||||
const userPwCheck = validateValue(formData.userPw, {
|
||||
required: true,
|
||||
requiredMessage: "비밀번호를 입력해주세요.",
|
||||
pattern: KRI_PW_REGEX,
|
||||
patternMessage: "비밀번호는 영문과 숫자를 포함한 8~20자로 입력해주세요.",
|
||||
});
|
||||
if (!userPwCheck.valid) {
|
||||
alert(userPwCheck.message);
|
||||
setInvalidField('userPw');
|
||||
userPwRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
if (!KRI_PW_REGEX.test(formData.userPw)) {
|
||||
alert("비밀번호는 영문과 숫자를 포함한 8~20자로 입력해주세요.");
|
||||
const userNameCheck = validateValue(formData.userName, {
|
||||
required: true,
|
||||
requiredMessage: "이름을 입력해주세요.",
|
||||
maxLength: 32,
|
||||
pattern: USER_NAME_REGEX,
|
||||
patternMessage: "이름에 허용되지 않는 문자가 포함되어 있습니다.",
|
||||
});
|
||||
if (!userNameCheck.valid) {
|
||||
alert(userNameCheck.message);
|
||||
setInvalidField('userName');
|
||||
userNameRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
if (!formData.userName.trim()) {
|
||||
alert("이름을 입력해주세요.");
|
||||
|
||||
const userCmpnCheck = validateValue(formData.userCmpn, {
|
||||
required: true,
|
||||
requiredMessage: "회사를 선택해주세요.",
|
||||
});
|
||||
if (!userCmpnCheck.valid) {
|
||||
alert(userCmpnCheck.message);
|
||||
setInvalidField('userCmpn');
|
||||
userCmpnRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
if(!USER_NAME_REGEX.test(formData.userName)){
|
||||
alert("올바르지 않은 이름입니다.");
|
||||
|
||||
if (isExternalManager(formData.userRole)) {
|
||||
const selectedCmpn = userCmpnArray.find((c) => c.cmpnId === formData.userCmpn);
|
||||
if (selectedCmpn?.ownCmpn) {
|
||||
alert("외주 실사 권한은 자사를 소속 회사로 선택할 수 없습니다.");
|
||||
setInvalidField('userCmpn');
|
||||
userCmpnRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const memoCheck = validateValue(formData.memo ?? '', { maxLength: 2048 });
|
||||
if (!memoCheck.valid) {
|
||||
alert(memoCheck.message);
|
||||
setInvalidField('memo');
|
||||
memoRef.current?.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -173,16 +235,7 @@ const UserUpsertDialog = ({
|
||||
await onSubmit(formData as UserInfoSaveRequest);
|
||||
handleOpenChange(false);
|
||||
} catch (e) {
|
||||
const err = apiError(e, {
|
||||
fallbackMessage: "Save failed.",
|
||||
});
|
||||
console.error(err.status, err.code, err.message);
|
||||
if(err.code !== NONE_HTTP_ERROR && err.code !== UNKNOWN_HTTP_ERROR){
|
||||
alert(err.message);
|
||||
}
|
||||
else{
|
||||
alert("저장에 실패했습니다.");
|
||||
}
|
||||
console.error(e);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
@@ -221,11 +274,13 @@ const UserUpsertDialog = ({
|
||||
</Label>
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
ref={userIdRef}
|
||||
id="userId"
|
||||
placeholder="Enter ID"
|
||||
placeholder="아이디를 입력하세요"
|
||||
value={formData.userId}
|
||||
onChange={(e) => handleInputChange('userId', e.target.value)}
|
||||
disabled={mode === 'edit'}
|
||||
aria-invalid={invalidField === 'userId'}
|
||||
/>
|
||||
{mode === 'create' && (
|
||||
<Button
|
||||
@@ -240,14 +295,16 @@ const UserUpsertDialog = ({
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="password">
|
||||
PW<span className="text-red-500 ml-1">*</span>
|
||||
Password<span className="text-red-500 ml-1">*</span>
|
||||
</Label>
|
||||
<KriPassword
|
||||
ref={userPwRef}
|
||||
id="password"
|
||||
label=""
|
||||
value={formData.userPw}
|
||||
onChange={(v) => handleInputChange('userPw', v)}
|
||||
placeholder="Enter password"
|
||||
placeholder="비밀번호를 입력하세요"
|
||||
aria-invalid={invalidField === 'userPw'}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
@@ -255,14 +312,18 @@ const UserUpsertDialog = ({
|
||||
이름<span className="text-red-500 ml-1">*</span>
|
||||
</Label>
|
||||
<Input
|
||||
ref={userNameRef}
|
||||
id="userName"
|
||||
placeholder="Enter name"
|
||||
placeholder="이름을 입력하세요"
|
||||
value={formData.userName}
|
||||
onChange={(e) => handleInputChange('userName', e.target.value)}
|
||||
aria-invalid={invalidField === 'userName'}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>계정 권한</Label>
|
||||
<Label>
|
||||
계정 권한 <span className="text-red-500 ml-1">*</span>
|
||||
</Label>
|
||||
<KriSelect
|
||||
items={availableRoleArray}
|
||||
value={String(formData.userRole)}
|
||||
@@ -272,7 +333,15 @@ const UserUpsertDialog = ({
|
||||
if(mode !== 'create'){
|
||||
alert("권한이 변경되면 해당 계정에 배정된 리스트 정보가 초기화됩니다.");
|
||||
}
|
||||
handleInputChange('userRole', Number(e));
|
||||
const nextRole = Number(e);
|
||||
handleInputChange('userRole', nextRole);
|
||||
|
||||
if (isExternalManager(nextRole)) {
|
||||
const currentCmpn = userCmpnArray.find((c) => c.cmpnId === formData.userCmpn);
|
||||
if (currentCmpn?.ownCmpn) {
|
||||
handleInputChange('userCmpn', '');
|
||||
}
|
||||
}
|
||||
}}
|
||||
useAll={false}
|
||||
className="w-full min-w-0 overflow-hidden [&>span]:truncate"
|
||||
@@ -280,9 +349,12 @@ const UserUpsertDialog = ({
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>소속 회사</Label>
|
||||
<Label>
|
||||
소속 회사 <span className="text-red-500 ml-1">*</span>
|
||||
</Label>
|
||||
<KriSelect
|
||||
items={userCmpnArray}
|
||||
ref={userCmpnRef}
|
||||
items={availableCmpnArray}
|
||||
value={formData.userCmpn}
|
||||
getValue={(item) => item.cmpnId}
|
||||
getLabel={(item) => item.cmpnAlias || item.cmpnId}
|
||||
@@ -291,15 +363,17 @@ const UserUpsertDialog = ({
|
||||
disabled={mode !== 'create'}
|
||||
className="w-full min-w-0 overflow-hidden [&>span]:truncate"
|
||||
heightClassName="h-9"
|
||||
aria-invalid={invalidField === 'userCmpn'}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="memo">메모</Label>
|
||||
<textarea id="memo" className="flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
<textarea ref={memoRef} id="memo" className="flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20"
|
||||
rows={3}
|
||||
placeholder="Enter memo"
|
||||
placeholder="메모를 입력하세요"
|
||||
value={formData.memo}
|
||||
onChange={(e) => handleInputChange('memo', e.target.value)}
|
||||
aria-invalid={invalidField === 'memo'}
|
||||
/>
|
||||
</div>
|
||||
</KriDialog>
|
||||
|
||||
Reference in New Issue
Block a user