From 4c15b99d9586aa48693213c78c02fba4639ebb85 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Tue, 1 Jul 2025 11:47:47 +0000 Subject: (최겸) 인포메이션 기능 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/information/table/information-table.tsx | 148 ---------------------------- 1 file changed, 148 deletions(-) delete mode 100644 lib/information/table/information-table.tsx (limited to 'lib/information/table/information-table.tsx') diff --git a/lib/information/table/information-table.tsx b/lib/information/table/information-table.tsx deleted file mode 100644 index 9fc4ec29..00000000 --- a/lib/information/table/information-table.tsx +++ /dev/null @@ -1,148 +0,0 @@ -"use client" - -import * as React from "react" -import type { - DataTableAdvancedFilterField, - DataTableFilterField, - DataTableRowAction, -} 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 type { PageInformation } from "@/db/schema/information" -import { getInformationColumns } from "./information-table-columns" -import { InformationTableToolbarActions } from "./information-table-toolbar-actions" -import { AddInformationDialog } from "./add-information-dialog" -import { UpdateInformationDialog } from "./update-information-dialog" -import { DeleteInformationDialog } from "./delete-information-dialog" - -interface InformationTableProps { - promises: Promise<{ - data: PageInformation[] - pageCount: number - total: number - }> -} - -export function InformationTable({ promises }: InformationTableProps) { - const [rowAction, setRowAction] = React.useState | null>(null) - const [showAddDialog, setShowAddDialog] = React.useState(false) - const [showUpdateDialog, setShowUpdateDialog] = React.useState(false) - const [showDeleteDialog, setShowDeleteDialog] = React.useState(false) - - const { data, pageCount } = React.use(promises) - - // 컬럼 설정 - const columns = React.useMemo( - () => getInformationColumns({ setRowAction }), - [setRowAction] - ) - - const filterFields: DataTableFilterField[] = [] - - // 고급 필터 필드 설정 - const advancedFilterFields: DataTableAdvancedFilterField[] = [ - { - id: "pageCode", - label: "페이지 코드", - type: "text", - }, - { - id: "pageName", - label: "페이지명", - type: "text", - }, - { - id: "title", - label: "제목", - type: "text", - }, - { - id: "isActive", - label: "상태", - type: "select", - options: [ - { label: "활성", value: "true" }, - { label: "비활성", value: "false" }, - ], - }, - { - 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, - }) - - // 행 액션 처리 - React.useEffect(() => { - if (rowAction?.type === "update") { - setShowUpdateDialog(true) - } else if (rowAction?.type === "delete") { - setShowDeleteDialog(true) - } - }, [rowAction]) - - return ( - <> - - - setShowAddDialog(true)} - /> - - - - - - { - setShowUpdateDialog(false) - setRowAction(null) - }} - /> - - { - setShowDeleteDialog(false) - setRowAction(null) - }} - /> - - ) -} \ No newline at end of file -- cgit v1.2.3