From 50ae0b8f02c034e60d4cbb504620dfa1575a836f Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 28 Jul 2025 09:19:42 +0000
Subject: (박서영) 설계 document Numbering Rule 개발-최겸 업로드
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../table/combo-box-settings-table.tsx             | 105 +++++++++++++++++++++
 1 file changed, 105 insertions(+)
 create mode 100644 lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx

(limited to 'lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx')

diff --git a/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx b/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx
new file mode 100644
index 00000000..356b2706
--- /dev/null
+++ b/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx
@@ -0,0 +1,105 @@
+"use client"
+
+import * as React from "react"
+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 type { DataTableAdvancedFilterField } from "@/types/table"
+import { getComboBoxCodeGroups } from "../service"
+import { getColumns } from "./combo-box-settings-table-columns"
+import { ComboBoxOptionsDetailSheet } from "./combo-box-options-detail-sheet"
+import { ComboBoxSettingsTableToolbarActions } from "./combo-box-settings-table-toolbar"
+import { codeGroups } from "@/db/schema/docu-list-rule"
+
+interface ComboBoxSettingsTableProps {
+  promises?: Promise<[{ data: typeof codeGroups.$inferSelect[]; pageCount: number }]>
+}
+
+export function ComboBoxSettingsTable({ promises }: ComboBoxSettingsTableProps) {
+  const rawData = React.use(promises!)
+  const [isDetailSheetOpen, setIsDetailSheetOpen] = React.useState(false)
+  const [selectedCodeGroup, setSelectedCodeGroup] = React.useState<typeof codeGroups.$inferSelect | null>(null)
+
+  const refreshData = React.useCallback(() => {
+    window.location.reload()
+  }, [])
+
+  // Detail 버튼 클릭 핸들러
+  const handleDetail = (codeGroup: typeof codeGroups.$inferSelect) => {
+    setSelectedCodeGroup(codeGroup)
+    setIsDetailSheetOpen(true)
+  }
+
+  const columns = React.useMemo(() => getColumns({ onDetail: handleDetail }), [handleDetail])
+
+  // 고급 필터 필드 설정
+  const advancedFilterFields: DataTableAdvancedFilterField<typeof codeGroups.$inferSelect>[] = [
+    { id: "groupId", label: "Group ID", type: "text" },
+    { id: "description", label: "Description", type: "text" },
+    { id: "codeFormat", label: "Code Format", type: "text" },
+    {
+      id: "controlType", label: "Control Type", type: "select", options: [
+        { label: "Textbox", value: "textbox" },
+        { label: "Combobox", value: "combobox" },
+        { label: "Date", value: "date" },
+        { label: "Number", value: "number" },
+      ]
+    },
+    {
+      id: "isActive", label: "Status", type: "select", options: [
+        { label: "Active", value: "true" },
+        { label: "Inactive", value: "false" },
+      ]
+    },
+    { id: "createdAt", label: "Created At", type: "date" },
+  ]
+
+  const { table } = useDataTable({
+    data: rawData[0].data as any,
+    columns,
+    pageCount: rawData[0].pageCount,
+    enablePinning: true,
+    enableAdvancedFilter: true,
+    manualSorting: false,
+    initialState: {
+      sorting: [{ id: "createdAt", desc: true }],
+      columnPinning: { right: ["actions"] },
+      columnFilters: [
+        {
+          id: "controlType",
+          value: "combobox",
+        },
+      ],
+    },
+    getRowId: (originalRow) => String(originalRow.groupId),
+    shallow: false,
+    clearOnDefault: true,
+  })
+
+  return (
+    <>
+      <DataTable table={table}>
+        <DataTableAdvancedToolbar
+          table={table}
+          filterFields={advancedFilterFields}
+        >
+          <ComboBoxSettingsTableToolbarActions table={table} onSuccess={refreshData} />
+        </DataTableAdvancedToolbar>
+      </DataTable>
+
+      {/* Detail 시트 */}
+      <ComboBoxOptionsDetailSheet
+        open={isDetailSheetOpen}
+        onOpenChange={setIsDetailSheetOpen}
+        codeGroup={selectedCodeGroup}
+        onSuccess={() => {
+          setIsDetailSheetOpen(false)
+          setSelectedCodeGroup(null)
+        }}
+
+      />
+
+
+    </>
+  )
+} 
\ No newline at end of file
-- 
cgit v1.2.3

