summaryrefslogtreecommitdiff
path: root/lib/vendor-investigation/table/investigation-result-sheet.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vendor-investigation/table/investigation-result-sheet.tsx')
-rw-r--r--lib/vendor-investigation/table/investigation-result-sheet.tsx49
1 files changed, 37 insertions, 12 deletions
diff --git a/lib/vendor-investigation/table/investigation-result-sheet.tsx b/lib/vendor-investigation/table/investigation-result-sheet.tsx
index 36000333..740b837e 100644
--- a/lib/vendor-investigation/table/investigation-result-sheet.tsx
+++ b/lib/vendor-investigation/table/investigation-result-sheet.tsx
@@ -129,10 +129,11 @@ export function InvestigationResultSheet({
defaultValues: {
investigationId: investigation?.investigationId ?? 0,
completedAt: investigation?.completedAt ?? undefined,
+ requestedAt: investigation?.requestedAt ?? undefined, // 날짜 검증을 위해 추가
evaluationScore: investigation?.evaluationScore ?? undefined,
evaluationResult: investigation?.evaluationResult ?? undefined,
investigationNotes: investigation?.investigationNotes ?? "",
- attachments: undefined,
+ attachments: [],
},
})
@@ -175,10 +176,11 @@ export function InvestigationResultSheet({
form.reset({
investigationId: investigation.investigationId,
completedAt: investigation.completedAt ?? undefined,
+ requestedAt: investigation.requestedAt ?? undefined, // 날짜 검증을 위해 추가
evaluationScore: investigation.evaluationScore ?? undefined,
evaluationResult: investigation.evaluationResult ?? undefined,
investigationNotes: investigation.investigationNotes ?? "",
- attachments: undefined,
+ attachments: [],
})
// 기존 첨부파일 로드
@@ -240,9 +242,9 @@ export function InvestigationResultSheet({
// 선택된 파일에서 특정 파일 제거
const handleRemoveSelectedFile = (indexToRemove: number) => {
- const currentFiles = form.getValues("attachments") || []
+ const currentFiles = (form.getValues("attachments") as File[]) || []
const updatedFiles = currentFiles.filter((_: File, index: number) => index !== indexToRemove)
- form.setValue("attachments", updatedFiles.length > 0 ? updatedFiles : undefined)
+ form.setValue("attachments", updatedFiles as any)
if (updatedFiles.length === 0) {
toast.success("모든 선택된 파일이 제거되었습니다.")
@@ -326,7 +328,6 @@ export function InvestigationResultSheet({
name="attachments"
render={({ field: { onChange, ...field } }) => (
<FormItem>
- <FormLabel>{config.label}</FormLabel>
<FormControl>
<Dropzone
onDrop={(acceptedFiles, rejectedFiles) => {
@@ -346,7 +347,7 @@ export function InvestigationResultSheet({
if (acceptedFiles.length > 0) {
// 기존 파일들과 새로 선택된 파일들을 합치기
- const currentFiles = form.getValues("attachments") || []
+ const currentFiles = (form.getValues("attachments") as File[]) || []
const newFiles = [...currentFiles, ...acceptedFiles]
onChange(newFiles)
toast.success(`${acceptedFiles.length}개 파일이 추가되었습니다.`)
@@ -513,13 +514,23 @@ export function InvestigationResultSheet({
}
}
- // 2) 파일이 있으면 업로드
- if (values.attachments && values.attachments.length > 0) {
+ // 2) 첨부파일 검증 (필수: 기존 첨부파일 + 새 파일 합계 최소 1개)
+ const newFilesCount = values.attachments?.length || 0
+ const existingFilesCount = existingAttachments.length
+ const totalFilesCount = newFilesCount + existingFilesCount
+
+ if (totalFilesCount === 0) {
+ toast.error("최소 1개의 첨부파일이 필요합니다.")
+ return
+ }
+
+ // 새 파일이 있는 경우에만 업로드 진행
+ if (newFilesCount > 0) {
setUploadingFiles(true)
try {
await uploadFiles(values.attachments, values.investigationId)
- toast.success(`실사 결과와 ${values.attachments.length}개 파일이 업데이트되었습니다!`)
+ toast.success(`실사 결과와 ${newFilesCount}개 파일이 업데이트되었습니다!`)
// 첨부파일 목록 새로고침
loadExistingAttachments(values.investigationId)
@@ -530,6 +541,7 @@ export function InvestigationResultSheet({
setUploadingFiles(false)
}
} else {
+ // 기존 첨부파일만 있는 경우
toast.success("실사 결과가 업데이트되었습니다!")
}
@@ -668,7 +680,14 @@ export function InvestigationResultSheet({
if (result === "APPROVED") return <span className="text-green-600">합격 (승인)</span>
if (result === "SUPPLEMENT") return <span className="text-yellow-600">보완 필요 (방법 선택)</span>
if (result === "SUPPLEMENT_REINSPECT") return <span className="text-yellow-600">보완 필요 - 재실사</span>
- if (result === "SUPPLEMENT_DOCUMENT") return <span className="text-yellow-600">보완 필요 - 자료제출</span>
+ if (result === "SUPPLEMENT_DOCUMENT") return (
+ <div className="flex flex-col gap-1">
+ <span className="text-yellow-600">보완 필요 - 자료제출</span>
+ <span className="text-xs text-muted-foreground font-normal">
+ 💡 저장 시 협력업체에 자동으로 보완 요청 메일이 발송됩니다.
+ </span>
+ </div>
+ )
if (result === "REJECTED") return <span className="text-destructive">불합격</span>
return <span className="text-muted-foreground">-</span>
})()}
@@ -711,8 +730,14 @@ export function InvestigationResultSheet({
)}
/>
- {/* 파일 첨부 섹션 */}
- {renderFileUploadSection()}
+ {/* 파일 첨부 섹션 */}
+ <div className="space-y-2">
+ <FormLabel>실사 관련 첨부파일<span className="text-red-500 ml-1">*</span></FormLabel>
+ <div className="text-sm text-muted-foreground">
+ 실사 결과 입력 시 최소 1개의 첨부파일이 필요합니다.
+ </div>
+ {renderFileUploadSection()}
+ </div>
</form>
</Form>
</div>