summaryrefslogtreecommitdiff
path: root/lib/vendor-document-list/ship/enhanced-documents-table.tsx
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-06-13 07:11:18 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-06-13 07:11:18 +0000
commit0fddf148402fd6b99a1b3800d73679899bcb2ed3 (patch)
treeeb51c02e6fa6037ddcc38a3b57d10d8c739125cf /lib/vendor-document-list/ship/enhanced-documents-table.tsx
parentc72d0897f7b37843109c86f61d97eba05ba3ca0d (diff)
(대표님) 20250613 16시 10분 global css, b-rfq, document 등
Diffstat (limited to 'lib/vendor-document-list/ship/enhanced-documents-table.tsx')
-rw-r--r--lib/vendor-document-list/ship/enhanced-documents-table.tsx135
1 files changed, 90 insertions, 45 deletions
diff --git a/lib/vendor-document-list/ship/enhanced-documents-table.tsx b/lib/vendor-document-list/ship/enhanced-documents-table.tsx
index 47bce275..2354a9be 100644
--- a/lib/vendor-document-list/ship/enhanced-documents-table.tsx
+++ b/lib/vendor-document-list/ship/enhanced-documents-table.tsx
@@ -9,36 +9,69 @@ import type {
} from "@/types/table"
import { useDataTable } from "@/hooks/use-data-table"
-import { getEnhancedDocumentsShip } from "../enhanced-document-service"
+import { getUserVendorDocuments, getUserVendorDocumentStats } from "@/lib/vendor-document-list/enhanced-document-service"
import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-advanced-toolbar"
import { toast } from "sonner"
+import { Badge } from "@/components/ui/badge"
+import { FileText } from "lucide-react"
import { Label } from "@/components/ui/label"
import { DataTable } from "@/components/data-table/data-table"
import { SimplifiedDocumentsView } from "@/db/schema"
import { getSimplifiedDocumentColumns } from "./enhanced-doc-table-columns"
+import { EnhancedDocTableToolbarActions } from "./enhanced-doc-table-toolbar-actions"
+
+// DrawingKind별 설명 매핑
+const DRAWING_KIND_INFO = {
+ B3: {
+ title: "B3 Vendor",
+ description: "Approval → Work 단계로 진행되는 승인 중심 도면",
+ color: "bg-blue-50 text-blue-700 border-blue-200"
+ },
+ B4: {
+ title: "B4 GTT",
+ description: "Pre → Work 단계로 진행되는 DOLCE 연동 도면",
+ color: "bg-green-50 text-green-700 border-green-200"
+ },
+ B5: {
+ title: "B5 FMEA",
+ description: "First → Second 단계로 진행되는 순차적 도면",
+ color: "bg-purple-50 text-purple-700 border-purple-200"
+ }
+} as const
interface SimplifiedDocumentsTableProps {
- promises: Promise<{
- data: SimplifiedDocumentsView[],
- pageCount: number,
- total: number
- }>
+ allPromises: Promise<[
+ Awaited<ReturnType<typeof getUserVendorDocuments>>,
+ Awaited<ReturnType<typeof getUserVendorDocumentStats>>
+ ]>
+ onDataLoaded?: (data: SimplifiedDocumentsView[]) => void
}
export function SimplifiedDocumentsTable({
- promises,
+ allPromises,
+ onDataLoaded,
}: SimplifiedDocumentsTableProps) {
// React.use()로 Promise 결과를 받고, 그 다음에 destructuring
- const result = React.use(promises)
- const { data, pageCount, total } = result
+ const [documentResult, statsResult] = React.use(allPromises)
+ const { data, pageCount, total, drawingKind, vendorInfo } = documentResult
+ const { stats, totalDocuments, primaryDrawingKind } = statsResult
+
+ // 데이터가 로드되면 콜백 호출
+ React.useEffect(() => {
+ if (onDataLoaded && data) {
+ onDataLoaded(data)
+ }
+ }, [data, onDataLoaded])
// 기존 상태들
- const [rowAction, setRowAction] = React.useState<DataTableRowAction<SimplifiedDocumentsView> | null>(null) // ✅ 타입 변경
+ const [rowAction, setRowAction] = React.useState<DataTableRowAction<SimplifiedDocumentsView> | null>(null)
const [expandedRows,] = React.useState<Set<string>>(new Set())
const columns = React.useMemo(
- () => getSimplifiedDocumentColumns({ setRowAction }),
+ () => getSimplifiedDocumentColumns({
+ setRowAction,
+ }),
[setRowAction]
)
@@ -51,7 +84,7 @@ export function SimplifiedDocumentsTable({
},
{
id: "vendorDocNumber",
- label: "벤더 문서번호",
+ label: "벤더 문서번호",
type: "text",
},
{
@@ -107,7 +140,7 @@ export function SimplifiedDocumentsTable({
},
{
id: "secondStageName",
- label: "2차 스테이지",
+ label: "2차 스테이지",
type: "text",
},
{
@@ -155,14 +188,14 @@ export function SimplifiedDocumentsTable({
type: "text",
},
{
- id: "dGbn",
+ id: "dGbn",
label: "D 구분",
type: "text",
},
{
id: "degreeGbn",
label: "Degree 구분",
- type: "text",
+ type: "text",
},
{
id: "deptGbn",
@@ -171,7 +204,7 @@ export function SimplifiedDocumentsTable({
},
{
id: "jGbn",
- label: "J 구분",
+ label: "J 구분",
type: "text",
},
{
@@ -183,7 +216,7 @@ export function SimplifiedDocumentsTable({
// B4 문서가 있는지 확인하여 B4 전용 필드 추가
const hasB4Documents = data.some(doc => doc.drawingKind === 'B4')
- const finalFilterFields = hasB4Documents
+ const finalFilterFields = hasB4Documents
? [...advancedFilterFields, ...b4FilterFields]
: advancedFilterFields
@@ -203,36 +236,48 @@ export function SimplifiedDocumentsTable({
columnResizeMode: "onEnd",
})
- // ✅ 행 액션 처리 (필요에 따라 구현)
- React.useEffect(() => {
- if (rowAction?.type === "view") {
- toast.info(`문서 조회: ${rowAction.row.docNumber}`)
- setRowAction(null)
- } else if (rowAction?.type === "edit") {
- toast.info(`문서 편집: ${rowAction.row.docNumber}`)
- setRowAction(null)
- } else if (rowAction?.type === "delete") {
- toast.error(`문서 삭제: ${rowAction.row.docNumber}`)
- setRowAction(null)
- }
- }, [rowAction])
+ // 실제 데이터의 drawingKind 또는 주요 drawingKind 사용
+ const activeDrawingKind = drawingKind || primaryDrawingKind
+ const kindInfo = activeDrawingKind ? DRAWING_KIND_INFO[activeDrawingKind] : null
return (
- <div className="w-full" style={{maxWidth:'100%'}}>
- <DataTable table={table}>
- <DataTableAdvancedToolbar
- table={table}
- filterFields={finalFilterFields}
- shallow={false}
- >
- {/* ✅ 추가 툴바 컨텐츠 (필요시) */}
- <div className="flex items-center gap-2">
- <Label className="text-sm font-medium">
- 총 {total}개 문서
- </Label>
+ <div className="w-full space-y-4">
+ {/* DrawingKind 정보 간단 표시 */}
+ {kindInfo && (
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-4">
+ <Badge variant="default" className="flex items-center gap-1 text-sm">
+ <FileText className="w-4 h-4" />
+ {kindInfo.title}
+ </Badge>
+ <span className="text-sm text-muted-foreground">
+ {kindInfo.description}
+ </span>
+ </div>
+ <div className="flex items-center gap-2">
+ <Badge variant="outline">
+ {total}개 문서
+ </Badge>
+ </div>
</div>
- </DataTableAdvancedToolbar>
- </DataTable>
+ )}
+
+ {/* 테이블 */}
+ <div className="overflow-x-auto">
+ <DataTable table={table} compact>
+ <DataTableAdvancedToolbar
+ table={table}
+ filterFields={finalFilterFields}
+ shallow={false}
+ >
+ <EnhancedDocTableToolbarActions
+ table={table}
+ projectType="ship"
+ />
+
+ </DataTableAdvancedToolbar>
+ </DataTable>
+ </div>
</div>
)
-}
+} \ No newline at end of file