From c72d0897f7b37843109c86f61d97eba05ba3ca0d Mon Sep 17 00:00:00 2001 From: dujinkim Date: Fri, 13 Jun 2025 07:08:01 +0000 Subject: (대표님) 20250613 16시 08분 b-rfq, document 등 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user-vendor-document-table-container.tsx | 129 +++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 components/ship-vendor-document/user-vendor-document-table-container.tsx (limited to 'components/ship-vendor-document/user-vendor-document-table-container.tsx') diff --git a/components/ship-vendor-document/user-vendor-document-table-container.tsx b/components/ship-vendor-document/user-vendor-document-table-container.tsx new file mode 100644 index 00000000..0ede3e19 --- /dev/null +++ b/components/ship-vendor-document/user-vendor-document-table-container.tsx @@ -0,0 +1,129 @@ +"use client" + +import React from "react" +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" +import { Badge } from "@/components/ui/badge" +import { Building, FileText, AlertCircle } from "lucide-react" +import { SimplifiedDocumentsTable } from "@/lib/vendor-document-list/ship/enhanced-documents-table" +import { getUserVendorDocuments, getUserVendorDocumentStats } from "@/lib/vendor-document-list/enhanced-document-service" + +interface UserVendorDocumentDisplayProps { + allPromises: Promise<[ + Awaited>, + Awaited> + ]> +} + +// DrawingKind별 설명 매핑 +const DRAWING_KIND_INFO = { + B3: { + title: "B3 승인 도면", + description: "Approval → Work 단계로 진행되는 승인 중심 도면", + color: "bg-blue-50 text-blue-700 border-blue-200" + }, + B4: { + title: "B4 작업 도면", + description: "Pre → Work 단계로 진행되는 DOLCE 연동 도면", + color: "bg-green-50 text-green-700 border-green-200" + }, + B5: { + title: "B5 단계 도면", + description: "First → Second 단계로 진행되는 순차적 도면", + color: "bg-purple-50 text-purple-700 border-purple-200" + } +} as const + +export function UserVendorDocumentDisplay({ + allPromises +}: UserVendorDocumentDisplayProps) { + // allPromises가 제대로 전달되었는지 확인 + if (!allPromises) { + return ( + + +
+ +

데이터를 불러올 수 없습니다.

+
+
+
+ ) + } + + // Promise.all로 감싸진 Promise를 사용해서 데이터 가져오기 + const [documentResult, statsResult] = React.use(allPromises) + + const { data, pageCount, total, drawingKind, vendorInfo } = documentResult + const { stats, totalDocuments, primaryDrawingKind } = statsResult + + // 문서가 없는 경우 + if (total === 0) { + return ( + + +
+ +

등록된 문서가 없습니다.

+
+
+
+ ) + } + + // 실제 데이터의 drawingKind 또는 주요 drawingKind 사용 + const activeDrawingKind = drawingKind || primaryDrawingKind + + if (!activeDrawingKind) { + return ( + + +
+ +

문서 유형을 확인할 수 없습니다.

+
+
+
+ ) + } + + // SimplifiedDocumentsTable에 전달할 promise (단일 객체로 변경) + const tablePromise = Promise.resolve({ data, pageCount, total }) + + const kindInfo = DRAWING_KIND_INFO[activeDrawingKind] + + return ( +
+ {/* 벤더 정보 헤더 */} + + + + + {vendorInfo?.vendorName || "내 회사"} 문서 관리 + + + {vendorInfo?.vendorCode && `코드: ${vendorInfo.vendorCode} • `} + 총 {totalDocuments}개 문서 + + + +
+ {Object.entries(stats).map(([kind, count]) => ( + + + {kind}: {count}개 + + ))} +
+
+
+ + + + +
+ ) +} \ No newline at end of file -- cgit v1.2.3