diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-28 09:19:42 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-28 09:19:42 +0000 |
| commit | 50ae0b8f02c034e60d4cbb504620dfa1575a836f (patch) | |
| tree | 24c661a0c7354e15ad56e2bded4d300bd7fd2b41 /lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx | |
| parent | 738f956aa61264ffa761e30398eca23393929f8c (diff) | |
(박서영) 설계 document Numbering Rule 개발-최겸 업로드
Diffstat (limited to 'lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx')
| -rw-r--r-- | lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx | 105 |
1 files changed, 105 insertions, 0 deletions
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 |
