summaryrefslogtreecommitdiff
path: root/components/vendor-regular-registrations/document-status-dialog.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'components/vendor-regular-registrations/document-status-dialog.tsx')
-rw-r--r--components/vendor-regular-registrations/document-status-dialog.tsx213
1 files changed, 136 insertions, 77 deletions
diff --git a/components/vendor-regular-registrations/document-status-dialog.tsx b/components/vendor-regular-registrations/document-status-dialog.tsx
index f8e2e1cd..db3defe6 100644
--- a/components/vendor-regular-registrations/document-status-dialog.tsx
+++ b/components/vendor-regular-registrations/document-status-dialog.tsx
@@ -8,13 +8,12 @@ import {
} from "@/components/ui/dialog";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
-import { FileText, Download, CheckCircle, XCircle, Clock } from "lucide-react";
+import { FileText, Download, CheckCircle, XCircle, Clock, RefreshCw } from "lucide-react";
import { toast } from "sonner";
import type { VendorRegularRegistration } from "@/config/vendorRegularRegistrationsColumnsConfig";
import {
documentStatusColumns,
- contractAgreementColumns,
} from "@/config/vendorRegularRegistrationsColumnsConfig";
import { downloadFile } from "@/lib/file-download";
@@ -22,6 +21,7 @@ interface DocumentStatusDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
registration: VendorRegularRegistration | null;
+ onRefresh?: () => void;
}
const StatusIcon = ({ status }: { status: string | boolean }) => {
@@ -68,63 +68,87 @@ export function DocumentStatusDialog({
open,
onOpenChange,
registration,
+ onRefresh,
}: DocumentStatusDialogProps) {
if (!registration) return null;
+ // 디버깅: registration 데이터 확인
+ console.log(`📋 DocumentStatusDialog - Partners 등록 데이터:`, {
+ companyName: registration.companyName,
+ businessNumber: registration.businessNumber,
+ representative: registration.representative,
+ safetyQualificationContent: registration.safetyQualificationContent,
+ basicContractsLength: registration.basicContracts?.length || 0,
+ additionalInfo: registration.additionalInfo
+ });
+
// 파일 다운로드 핸들러
- const handleFileDownload = async (docKey: string, fileIndex: number = 0) => {
- try {
- const files = registration.documentFiles[docKey as keyof typeof registration.documentFiles];
- if (!files || files.length === 0) {
- toast.error("다운로드할 파일이 없습니다.");
- return;
- }
+ // const handleFileDownload = async (docKey: string, fileIndex: number = 0) => {
+ // try {
+ // const files = registration.documentFiles[docKey as keyof typeof registration.documentFiles];
+ // if (!files || files.length === 0) {
+ // toast.error("다운로드할 파일이 없습니다.");
+ // return;
+ // }
- const file = files[fileIndex];
- if (!file) {
- toast.error("파일을 찾을 수 없습니다.");
- return;
- }
+ // const file = files[fileIndex];
+ // if (!file) {
+ // toast.error("파일을 찾을 수 없습니다.");
+ // return;
+ // }
- // filePath와 fileName 추출
- const filePath = file.filePath || file.path;
- const fileName = file.originalFileName || file.fileName || file.name;
+ // // filePath와 fileName 추출
+ // const filePath = file.filePath || file.path;
+ // const fileName = file.originalFileName || file.fileName || file.name;
- if (!filePath || !fileName) {
- toast.error("파일 정보가 올바르지 않습니다.");
- return;
- }
+ // if (!filePath || !fileName) {
+ // toast.error("파일 정보가 올바르지 않습니다.");
+ // return;
+ // }
- console.log(`📥 파일 다운로드 시작:`, { filePath, fileName, docKey });
+ // console.log(`📥 파일 다운로드 시작:`, { filePath, fileName, docKey });
- // downloadFile 함수를 사용하여 파일 다운로드
- const result = await downloadFile(filePath, fileName, {
- showToast: true,
- onError: (error) => {
- console.error("파일 다운로드 오류:", error);
- toast.error(`파일 다운로드 실패: ${error}`);
- },
- onSuccess: (fileName, fileSize) => {
- console.log(`✅ 파일 다운로드 성공:`, { fileName, fileSize });
- }
- });
+ // // downloadFile 함수를 사용하여 파일 다운로드
+ // const result = await downloadFile(filePath, fileName, {
+ // showToast: true,
+ // onError: (error) => {
+ // console.error("파일 다운로드 오류:", error);
+ // toast.error(`파일 다운로드 실패: ${error}`);
+ // },
+ // onSuccess: (fileName, fileSize) => {
+ // console.log(`✅ 파일 다운로드 성공:`, { fileName, fileSize });
+ // }
+ // });
- if (!result.success) {
- console.error("파일 다운로드 실패:", result.error);
- }
- } catch (error) {
- console.error("파일 다운로드 중 오류 발생:", error);
- toast.error("파일 다운로드 중 오류가 발생했습니다.");
- }
- };
+ // if (!result.success) {
+ // console.error("파일 다운로드 실패:", result.error);
+ // }
+ // } catch (error) {
+ // console.error("파일 다운로드 중 오류 발생:", error);
+ // toast.error("파일 다운로드 중 오류가 발생했습니다.");
+ // }
+ // };
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-4xl max-h-[80vh] overflow-y-auto">
<DialogHeader>
- <DialogTitle className="flex items-center gap-2">
- <FileText className="w-5 h-5" />
- 문서/자료 접수 현황 - {registration.companyName}
+ <DialogTitle className="flex items-center justify-between">
+ <div className="flex items-center gap-2">
+ <FileText className="w-5 h-5" />
+ 문서/자료 접수 현황 - {registration.companyName}
+ </div>
+ {onRefresh && (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={onRefresh}
+ className="flex items-center gap-2"
+ >
+ <RefreshCw className="w-4 h-4" />
+ 새로고침
+ </Button>
+ )}
</DialogTitle>
</DialogHeader>
@@ -160,12 +184,18 @@ export function DocumentStatusDialog({
<div>상태</div>
<div>제출일자</div>
<div>액션</div>
- </div>
+ </div>
{documentStatusColumns.map((doc) => {
const isSubmitted = registration.documentSubmissions[
doc.key as keyof typeof registration.documentSubmissions
] as boolean;
+ // 내자인 경우 통장사본은 표시하지 않음
+ const isForeign = registration.country !== 'KR';
+ if (doc.key === 'bankCopy' && !isForeign) {
+ return null;
+ }
+
return (
<div
key={doc.key}
@@ -174,6 +204,9 @@ export function DocumentStatusDialog({
<div className="flex items-center gap-2">
<StatusIcon status={isSubmitted} />
{doc.label}
+ {doc.key === 'bankCopy' && isForeign && (
+ <span className="text-xs text-blue-600">(외자 필수)</span>
+ )}
</div>
<div>
<StatusBadge status={isSubmitted} />
@@ -182,7 +215,7 @@ export function DocumentStatusDialog({
{isSubmitted ? "2024.01.01" : "-"}
</div>
<div>
- {isSubmitted && (
+ {/* {isSubmitted && (
<Button
size="sm"
variant="outline"
@@ -191,7 +224,7 @@ export function DocumentStatusDialog({
<Download className="w-4 h-4 mr-1" />
다운로드
</Button>
- )}
+ )} */}
</div>
</div>
);
@@ -211,37 +244,63 @@ export function DocumentStatusDialog({
<div>서약일자</div>
<div>액션</div>
</div>
- {contractAgreementColumns.map((agreement) => {
- const status = registration.contractAgreements[
- agreement.key as keyof typeof registration.contractAgreements
- ] as string;
-
- return (
- <div
- key={agreement.key}
- className="grid grid-cols-4 gap-4 p-4 border-t items-center"
- >
- <div className="flex items-center gap-2">
- <StatusIcon status={status} />
- {agreement.label}
- </div>
- <div>
- <StatusBadge status={status} />
- </div>
- <div className="text-sm text-gray-600">
- {status === "completed" ? "2024.01.01" : "-"}
- </div>
- <div>
- {status === "completed" && (
- <Button size="sm" variant="outline">
- <Download className="w-4 h-4 mr-1" />
- 다운로드
- </Button>
- )}
+ {!registration.basicContracts || registration.basicContracts.length === 0 ? (
+ <div className="p-4 border-t text-center text-gray-500">
+ 요청된 기본계약이 없습니다.
+ </div>
+ ) : (
+ registration.basicContracts.map((contract, index) => {
+ const isCompleted = contract.status === "COMPLETED";
+
+ return (
+ <div
+ key={`${contract.templateId}-${index}`}
+ className="grid grid-cols-4 gap-4 p-4 border-t items-center"
+ >
+ <div className="flex items-center gap-2">
+ <StatusIcon status={isCompleted} />
+ {contract.templateName || "템플릿명 없음"}
+ </div>
+ <div>
+ <StatusBadge status={isCompleted} />
+ </div>
+ <div className="text-sm text-gray-600">
+ {isCompleted && contract.createdAt
+ ? new Intl.DateTimeFormat('ko-KR').format(new Date(contract.createdAt))
+ : "-"
+ }
+ </div>
+ <div>
+ {isCompleted && (
+ <Button size="sm" variant="outline">
+ <Download className="w-4 h-4 mr-1" />
+ 다운로드
+ </Button>
+ )}
+ </div>
</div>
- </div>
- );
- })}
+ );
+ })
+ )}
+ </div>
+ </div>
+
+ {/* 안전적격성 평가 */}
+ <div>
+ <h3 className="text-lg font-semibold mb-4">안전적격성 평가</h3>
+ <div className="p-4 border rounded-lg">
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-2">
+ <StatusIcon status={!!registration.safetyQualificationContent} />
+ <span>안전적격성 평가</span>
+ </div>
+ <StatusBadge status={!!registration.safetyQualificationContent} />
+ </div>
+ {registration.safetyQualificationContent && (
+ <div className="mt-3 p-3 bg-gray-50 rounded">
+ <p className="text-sm">{registration.safetyQualificationContent}</p>
+ </div>
+ )}
</div>
</div>