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

---
 .../template/basic-contract-template.tsx           | 104 +++++++++++++++++++++
 1 file changed, 104 insertions(+)
 create mode 100644 lib/basic-contract/template/basic-contract-template.tsx

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

diff --git a/lib/basic-contract/template/basic-contract-template.tsx b/lib/basic-contract/template/basic-contract-template.tsx
new file mode 100644
index 00000000..0cca3a41
--- /dev/null
+++ b/lib/basic-contract/template/basic-contract-template.tsx
@@ -0,0 +1,104 @@
+"use client";
+
+import * as React from "react";
+import { DataTable } from "@/components/data-table/data-table";
+import { useDataTable } from "@/hooks/use-data-table";
+import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-advanced-toolbar";
+import type {
+  DataTableAdvancedFilterField,
+  DataTableRowAction,
+} from "@/types/table"
+import { getBasicContractTemplates} from "../service";
+import { getColumns } from "./basic-contract-template-columns";
+import { DeleteTemplatesDialog } from "./delete-basicContract-dialog";
+import { UpdateTemplateSheet } from "./update-basicContract-sheet";
+import { TemplateTableToolbarActions } from "./basicContract-table-toolbar-actions";
+import { BasicContractTemplate } from "@/db/schema";
+
+
+interface BasicTemplateTableProps {
+  promises: Promise<
+    [
+      Awaited<ReturnType<typeof getBasicContractTemplates>>,
+    ]
+  >
+}
+
+
+export function BasicContractTemplateTable({ promises }: BasicTemplateTableProps) {
+
+
+  const [rowAction, setRowAction] =
+    React.useState<DataTableRowAction<BasicContractTemplate> | null>(null)
+
+
+  const [{ data, pageCount }] =
+    React.use(promises)
+
+  // 컬럼 설정 - 외부 파일에서 가져옴
+  const columns = React.useMemo(
+    () => getColumns({ setRowAction }),
+    [setRowAction]
+  )
+
+  // config 기반으로 필터 필드 설정
+  const advancedFilterFields: DataTableAdvancedFilterField<BasicContractTemplate>[] = [
+    { id: "templateName", label: "템플릿명", type: "text" },
+    {
+      id: "status", label: "상태", type: "select", options: [
+        { label: "활성", value: "ACTIVE" },
+        { label: "비활성", value: "INACTIVE" },
+      ]
+    },
+    { id: "fileName", 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}
+        >
+          <TemplateTableToolbarActions table={table} />
+
+        </DataTableAdvancedToolbar>
+      </DataTable>
+
+      <DeleteTemplatesDialog
+        open={rowAction?.type === "delete"}
+        onOpenChange={() => setRowAction(null)}
+        templates={rowAction?.row.original ? [rowAction?.row.original] : []}
+        showTrigger={false}
+        onSuccess={() => rowAction?.row.toggleSelected(false)}
+      />
+
+      <UpdateTemplateSheet
+        open={rowAction?.type === "update"}
+        onOpenChange={() => setRowAction(null)}
+        template={rowAction?.row.original ?? null}
+      />
+
+    </>
+
+  );
+} 
\ No newline at end of file
-- 
cgit v1.2.3

