From 969c25b56f6d29d7ffa4bc2ce04c5fb4e5846b34 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Thu, 14 Aug 2025 11:54:47 +0000 Subject: (대표님) 정규벤더등록, 벤더문서관리, 벤더데이터입력, 첨부파일관리 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vendor-registration-status-view.tsx | 260 ++++----------------- 1 file changed, 45 insertions(+), 215 deletions(-) (limited to 'lib/vendor-registration-status/vendor-registration-status-view.tsx') diff --git a/lib/vendor-registration-status/vendor-registration-status-view.tsx b/lib/vendor-registration-status/vendor-registration-status-view.tsx index b3000f73..850dd777 100644 --- a/lib/vendor-registration-status/vendor-registration-status-view.tsx +++ b/lib/vendor-registration-status/vendor-registration-status-view.tsx @@ -4,13 +4,11 @@ import { useState, useEffect } from "react" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" -import { Separator } from "@/components/ui/separator" + import { CheckCircle, XCircle, FileText, - Users, - Building2, AlertCircle, Eye, Upload @@ -21,6 +19,9 @@ import { format } from "date-fns" import { toast } from "sonner" import { fetchVendorRegistrationStatus } from "@/lib/vendor-regular-registrations/service" +// 세션에서 벤더아이디 가져오기 위한 훅 +import { useSession } from "next-auth/react" + // 상태별 정의 const statusConfig = { audit_pass: { @@ -81,11 +82,15 @@ export function VendorRegistrationStatusView() { const [data, setData] = useState(null) const [loading, setLoading] = useState(true) - // 임시로 vendorId = 1 사용 (실제로는 세션에서 가져와야 함) - const vendorId = 1 + // 세션에서 vendorId 가져오기 + const { data: session, status: sessionStatus } = useSession() + const vendorId = session?.user?.companyId + console.log(vendorId) // 데이터 로드 useEffect(() => { + if (!vendorId) return + const initialLoad = async () => { try { const result = await fetchVendorRegistrationStatus(vendorId) @@ -104,10 +109,14 @@ export function VendorRegistrationStatusView() { initialLoad() }, [vendorId]) - if (loading) { + if (sessionStatus === "loading" || loading) { return
로딩 중...
} + if (!vendorId) { + return
벤더 정보가 없습니다. 다시 로그인 해주세요.
+ } + if (!data) { return
데이터를 불러올 수 없습니다.
} @@ -123,9 +132,10 @@ export function VendorRegistrationStatusView() { const registrationForDialog: any = { id: data.registration?.id || 0, vendorId: data.vendor.id, - companyName: data.vendor.companyName, - businessNumber: data.vendor.businessNumber, - representative: data.vendor.representative || "", + companyName: data.vendor.vendorName, + businessNumber: data.vendor.taxId, + representative: data.vendor.representativeName || "", + country: data.vendor.country || "KR", // 기본값 KR potentialCode: data.registration?.potentialCode || "", status: data.registration?.status || "audit_pass", majorItems: "[]", // 빈 JSON 문자열 @@ -136,9 +146,12 @@ export function VendorRegistrationStatusView() { assignedUser: data.registration?.assignedUser, assignedUserCode: data.registration?.assignedUserCode, remarks: data.registration?.remarks, + safetyQualificationContent: data.registration?.safetyQualificationContent || null, + gtcSkipped: data.registration?.gtcSkipped || false, additionalInfo: data.additionalInfo, documentSubmissions: data.documentStatus, // documentSubmissions를 documentStatus로 설정 contractAgreements: [], + basicContracts: data.basicContracts || [], // 실제 데이터 사용 documentSubmissionsStatus: data.documentStatus, contractAgreementsStatus: { cpDocument: data.documentStatus.cpDocument, @@ -164,10 +177,12 @@ export function VendorRegistrationStatusView() { } const loadData = async () => { + if (!vendorId) return try { const result = await fetchVendorRegistrationStatus(vendorId) if (result.success) { setData(result.data) + toast.success("데이터가 새로고침되었습니다.") } else { toast.error(result.error) } @@ -226,214 +241,28 @@ export function VendorRegistrationStatusView() { - {/* 기본 정보 */} -
- - - - - 업체 정보 - - - -
-
- 업체명: -

{data.vendor.companyName}

-
-
- 사업자번호: -

{data.vendor.businessNumber}

-
-
-
-
- 업체구분: -

{data.registration ? "정규업체" : "잠재업체"}

-
-
- eVCP 가입: -

{data.vendor.createdAt ? format(new Date(data.vendor.createdAt), "yyyy.MM.dd") : "-"}

-
-
-
-
- - - - - - 담당자 정보 - - - -
-
- SHI 담당자: -

{data.registration?.assignedDepartment || "-"} {data.registration?.assignedUser || "-"}

-
-
- 진행상태: - - {currentStatusConfig.label} - -
-
-
-
- 상태변경일: -

{data.registration?.updatedAt ? format(new Date(data.registration.updatedAt), "yyyy.MM.dd") : "-"}

-
-
-
-
+ {/* 간소화된 액션 버튼들 */} +
+ +
- {/* 미완항목 */} - {missingDocuments.length > 0 && ( - - - - - 미완항목 - - - -
- {data.incompleteItemsCount.documents > 0 && ( -
- 미제출문서 - {data.incompleteItemsCount.documents} 건 -
- )} - {!data.documentStatus.auditResult && ( -
- 실사결과 - 미실시 -
- )} - {data.incompleteItemsCount.additionalInfo > 0 && ( -
- 추가정보 - 미입력 -
- )} -
-
-
- )} - - {/* 상세 진행현황 */} - - - 상세 진행현황 - - -
- {/* 기본 진행상황 */} -
-
-
PQ 제출
-
- {data.pqSubmission ? ( -
- - {format(new Date(data.pqSubmission.createdAt), "yyyy.MM.dd")} -
- ) : ( -
- - 미제출 -
- )} -
-
-
-
실사 통과
-
- {data.auditPassed ? ( -
- - 통과 -
- ) : ( -
- - 미통과 -
- )} -
-
-
-
문서 현황
- -
-
-
추가정보
- -
-
- - - - {/* 필수문서 상태 */} -
-

필수문서 제출 현황

-
- {requiredDocuments.map((doc) => { - const isSubmitted = data.documentStatus[doc.key as keyof typeof data.documentStatus] - return ( -
-
- {isSubmitted ? ( - - ) : ( - - )} -
-
{doc.label}
- {isSubmitted && ( - - )} -
- ) - })} -
-
-
-
-
- {/* 상태 설명 */} @@ -456,6 +285,7 @@ export function VendorRegistrationStatusView() { open={documentDialogOpen} onOpenChange={setDocumentDialogOpen} registration={registrationForDialog} + onRefresh={loadData} /> {/* 추가정보 입력 Dialog */} -- cgit v1.2.3