diff options
Diffstat (limited to 'lib/b-rfq/initial/initial-rfq-detail-table.tsx')
| -rw-r--r-- | lib/b-rfq/initial/initial-rfq-detail-table.tsx | 267 |
1 files changed, 0 insertions, 267 deletions
diff --git a/lib/b-rfq/initial/initial-rfq-detail-table.tsx b/lib/b-rfq/initial/initial-rfq-detail-table.tsx deleted file mode 100644 index 5ea6b0bf..00000000 --- a/lib/b-rfq/initial/initial-rfq-detail-table.tsx +++ /dev/null @@ -1,267 +0,0 @@ -"use client" - -import * as React from "react" -import { type DataTableAdvancedFilterField, type DataTableFilterField } from "@/types/table" -import { useDataTable } from "@/hooks/use-data-table" -import { DataTable } from "@/components/data-table/data-table" -import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-advanced-toolbar" -import { getInitialRfqDetail } from "../service" // 앞서 만든 서버 액션 -import { - getInitialRfqDetailColumns, - type DataTableRowAction -} from "./initial-rfq-detail-columns" -import { InitialRfqDetailTableToolbarActions } from "./initial-rfq-detail-toolbar-actions" -import { DeleteInitialRfqDialog } from "./delete-initial-rfq-dialog" -import { UpdateInitialRfqSheet } from "./update-initial-rfq-sheet" -import { InitialRfqDetailView } from "@/db/schema" - -interface InitialRfqDetailTableProps { - promises: Promise<Awaited<ReturnType<typeof getInitialRfqDetail>>> - rfqId?: number -} - -export function InitialRfqDetailTable({ promises, rfqId }: InitialRfqDetailTableProps) { - const { data, pageCount } = React.use(promises) - - // 선택된 상세 정보 - const [selectedDetail, setSelectedDetail] = React.useState<any>(null) - - // Row action 상태 (update/delete) - const [rowAction, setRowAction] = React.useState<DataTableRowAction<InitialRfqDetailView> | null>(null) - - const columns = React.useMemo( - () => getInitialRfqDetailColumns({ - onSelectDetail: setSelectedDetail, - setRowAction: setRowAction - }), - [] - ) - - /** - * 필터 필드 정의 - */ - const filterFields: DataTableFilterField<any>[] = [ - { - id: "rfqCode", - label: "RFQ 코드", - placeholder: "RFQ 코드로 검색...", - }, - { - id: "vendorName", - label: "벤더명", - placeholder: "벤더명으로 검색...", - }, - { - id: "rfqStatus", - label: "RFQ 상태", - options: [ - { label: "Draft", value: "DRAFT", count: 0 }, - { label: "문서 접수", value: "Doc. Received", count: 0 }, - { label: "담당자 배정", value: "PIC Assigned", count: 0 }, - { label: "문서 확정", value: "Doc. Confirmed", count: 0 }, - { label: "초기 RFQ 발송", value: "Init. RFQ Sent", count: 0 }, - { label: "초기 RFQ 응답", value: "Init. RFQ Answered", count: 0 }, - { label: "TBE 시작", value: "TBE started", count: 0 }, - { label: "TBE 완료", value: "TBE finished", count: 0 }, - { label: "최종 RFQ 발송", value: "Final RFQ Sent", count: 0 }, - { label: "견적 접수", value: "Quotation Received", count: 0 }, - { label: "벤더 선정", value: "Vendor Selected", count: 0 }, - ], - }, - { - id: "initialRfqStatus", - label: "초기 RFQ 상태", - options: [ - { label: "초안", value: "DRAFT", count: 0 }, - { label: "발송", value: "Init. RFQ Sent", count: 0 }, - { label: "응답", value: "Init. RFQ Answered", count: 0 }, - { label: "거절", value: "S/L Decline", count: 0 }, - ], - }, - { - id: "vendorCountry", - label: "벤더 국가", - options: [ - { label: "한국", value: "KR", count: 0 }, - { label: "중국", value: "CN", count: 0 }, - { label: "일본", value: "JP", count: 0 }, - { label: "미국", value: "US", count: 0 }, - { label: "독일", value: "DE", count: 0 }, - ], - }, - ] - - /** - * 고급 필터 필드 - */ - const advancedFilterFields: DataTableAdvancedFilterField<any>[] = [ - { - id: "rfqCode", - label: "RFQ 코드", - type: "text", - }, - { - id: "vendorName", - label: "벤더명", - type: "text", - }, - { - id: "vendorCode", - label: "벤더 코드", - type: "text", - }, - { - id: "vendorCountry", - label: "벤더 국가", - type: "multi-select", - options: [ - { label: "한국", value: "KR" }, - { label: "중국", value: "CN" }, - { label: "일본", value: "JP" }, - { label: "미국", value: "US" }, - { label: "독일", value: "DE" }, - ], - }, - { - id: "rfqStatus", - label: "RFQ 상태", - type: "multi-select", - options: [ - { label: "Draft", value: "DRAFT" }, - { label: "문서 접수", value: "Doc. Received" }, - { label: "담당자 배정", value: "PIC Assigned" }, - { label: "문서 확정", value: "Doc. Confirmed" }, - { label: "초기 RFQ 발송", value: "Init. RFQ Sent" }, - { label: "초기 RFQ 응답", value: "Init. RFQ Answered" }, - { label: "TBE 시작", value: "TBE started" }, - { label: "TBE 완료", value: "TBE finished" }, - { label: "최종 RFQ 발송", value: "Final RFQ Sent" }, - { label: "견적 접수", value: "Quotation Received" }, - { label: "벤더 선정", value: "Vendor Selected" }, - ], - }, - { - id: "initialRfqStatus", - label: "초기 RFQ 상태", - type: "multi-select", - options: [ - { label: "초안", value: "DRAFT" }, - { label: "발송", value: "Init. RFQ Sent" }, - { label: "응답", value: "Init. RFQ Answered" }, - { label: "거절", value: "S/L Decline" }, - ], - }, - { - id: "vendorBusinessSize", - label: "벤더 규모", - type: "multi-select", - options: [ - { label: "대기업", value: "LARGE" }, - { label: "중기업", value: "MEDIUM" }, - { label: "소기업", value: "SMALL" }, - { label: "스타트업", value: "STARTUP" }, - ], - }, - { - id: "incotermsCode", - label: "Incoterms", - type: "text", - }, - { - id: "dueDate", - label: "마감일", - type: "date", - }, - { - id: "validDate", - label: "유효일", - type: "date", - }, - { - id: "shortList", - label: "Short List", - type: "boolean", - }, - { - id: "returnYn", - label: "Return 여부", - type: "boolean", - }, - { - id: "cpRequestYn", - label: "CP Request 여부", - type: "boolean", - }, - { - id: "prjectGtcYn", - label: "Project GTC 여부", - type: "boolean", - }, - { - id: "classification", - label: "분류", - type: "text", - }, - { - id: "sparepart", - label: "예비부품", - type: "text", - }, - { - id: "createdAt", - label: "등록일", - type: "date", - }, - ] - - const { table } = useDataTable({ - data, - columns, - pageCount, - filterFields, - enableAdvancedFilter: true, - initialState: { - sorting: [{ id: "createdAt", desc: true }], - columnPinning: { right: ["actions"] }, - }, - getRowId: (originalRow) => originalRow.initialRfqId ? originalRow.initialRfqId.toString():"1", - shallow: false, - clearOnDefault: true, - }) - - return ( - <div className="space-y-6"> - {/* 메인 테이블 */} - <div className="h-full w-full"> - <DataTable table={table} className="h-full"> - <DataTableAdvancedToolbar - table={table} - filterFields={advancedFilterFields} - shallow={false} - > - <InitialRfqDetailTableToolbarActions table={table} rfqId={rfqId} /> - </DataTableAdvancedToolbar> - </DataTable> - </div> - - {/* Update Sheet */} - <UpdateInitialRfqSheet - open={rowAction?.type === "update"} - onOpenChange={() => setRowAction(null)} - initialRfq={rowAction?.type === "update" ? rowAction.row.original : null} - /> - - {/* Delete Dialog */} - <DeleteInitialRfqDialog - open={rowAction?.type === "delete"} - onOpenChange={() => setRowAction(null)} - initialRfqs={rowAction?.type === "delete" ? [rowAction.row.original] : []} - showTrigger={false} - onSuccess={() => { - setRowAction(null) - // 테이블 리프레시는 revalidatePath로 자동 처리됨 - }} - /> - </div> - ) -}
\ No newline at end of file |
