From ef4c533ebacc2cdc97e518f30e9a9350004fcdfb Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 28 Apr 2025 02:13:30 +0000
Subject: ~20250428 작업사항
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../vendor-table/basic-contract-table.tsx          | 94 ++++++++++++++++++++++
 1 file changed, 94 insertions(+)
 create mode 100644 lib/basic-contract/vendor-table/basic-contract-table.tsx

(limited to 'lib/basic-contract/vendor-table/basic-contract-table.tsx')

diff --git a/lib/basic-contract/vendor-table/basic-contract-table.tsx b/lib/basic-contract/vendor-table/basic-contract-table.tsx
new file mode 100644
index 00000000..34e15ae3
--- /dev/null
+++ b/lib/basic-contract/vendor-table/basic-contract-table.tsx
@@ -0,0 +1,94 @@
+"use client";
+
+import * as React from "react";
+import { DataTable } from "@/components/data-table/data-table";
+import { Button } from "@/components/ui/button";
+import { Plus, Loader2 } from "lucide-react";
+import { useDataTable } from "@/hooks/use-data-table";
+import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-advanced-toolbar";
+import type {
+  DataTableAdvancedFilterField,
+  DataTableFilterField,
+  DataTableRowAction,
+} from "@/types/table"
+import { toast } from "sonner";
+import { getColumns } from "./basic-contract-columns";
+import { getBasicContracts, getBasicContractsByVendorId } from "../service";
+import { BasicContractView } from "@/db/schema";
+import { BasicContractTableToolbarActions } from "./basicContract-table-toolbar-actions";
+
+
+interface BasicTemplateTableProps {
+  promises: Promise<
+    [
+      Awaited<ReturnType<typeof getBasicContractsByVendorId>>,
+    ]
+  >
+}
+
+
+export function BasicContractsVendorTable({ promises }: BasicTemplateTableProps) {
+
+
+  const [rowAction, setRowAction] =
+    React.useState<DataTableRowAction<BasicContractView> | null>(null)
+
+
+  const [{ data, pageCount }] =
+    React.use(promises)
+
+    // console.log(data)
+
+  // 컬럼 설정 - 외부 파일에서 가져옴
+  const columns = React.useMemo(
+    () => getColumns({ setRowAction }),
+    [setRowAction]
+  )
+
+  // config 기반으로 필터 필드 설정
+  const advancedFilterFields: DataTableAdvancedFilterField<BasicContractView>[] = [
+    { id: "templateName", label: "템플릿명", type: "text" },
+    {
+      id: "status", label: "상태", type: "select", options: [
+        { label: "서명대기", value: "PENDING" },
+        { label: "서명완료", value: "COMPLETED" },
+      ]
+    },
+    { id: "userName", label: "요청자", type: "text" },
+    { id: "createdAt", label: "생성일", type: "date" },
+    { id: "updatedAt", label: "수정일", type: "date" },
+  ];
+
+  const { table } = useDataTable({
+    data,
+    columns,
+    pageCount,
+    // filterFields,
+    enablePinning: true,
+    enableAdvancedFilter: true,
+    initialState: {
+      sorting: [{ id: "createdAt", desc: true }],
+      columnPinning: { right: ["actions"] },
+    },
+    getRowId: (originalRow) => String(originalRow.id),
+    shallow: false,
+    clearOnDefault: true,
+  })
+
+  return (
+    <>
+
+      <DataTable table={table}>
+        <DataTableAdvancedToolbar
+          table={table}
+          filterFields={advancedFilterFields}
+        >
+          <BasicContractTableToolbarActions table={table} />
+
+        </DataTableAdvancedToolbar>
+      </DataTable>
+
+    </>
+
+  );
+} 
\ No newline at end of file
-- 
cgit v1.2.3

