diff options
Diffstat (limited to 'lib/form-list/table')
| -rw-r--r-- | lib/form-list/table/formLists-table-columns.tsx | 14 | ||||
| -rw-r--r-- | lib/form-list/table/formLists-table-toolbar-actions.tsx | 4 | ||||
| -rw-r--r-- | lib/form-list/table/formLists-table.tsx | 8 | ||||
| -rw-r--r-- | lib/form-list/table/meta-sheet.tsx | 5 |
4 files changed, 16 insertions, 15 deletions
diff --git a/lib/form-list/table/formLists-table-columns.tsx b/lib/form-list/table/formLists-table-columns.tsx index 647a8af1..5b120796 100644 --- a/lib/form-list/table/formLists-table-columns.tsx +++ b/lib/form-list/table/formLists-table-columns.tsx @@ -17,16 +17,16 @@ import { import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header" import { formListsColumnsConfig } from "@/config/formListsColumnsConfig" -import { ExtendedFormMappings } from "../validation" +import { FormListsView } from "@/db/schema" interface GetColumnsProps { - setRowAction: React.Dispatch<React.SetStateAction<DataTableRowAction<ExtendedFormMappings> | null>> + setRowAction: React.Dispatch<React.SetStateAction<DataTableRowAction<FormListsView> | null>> } /** * tanstack table 컬럼 정의 (중첩 헤더 버전) */ -export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<ExtendedFormMappings>[] { +export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<FormListsView>[] { // ---------------------------------------------------------------- // 1) select 컬럼 (체크박스) // ---------------------------------------------------------------- @@ -35,7 +35,7 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<Extende // ---------------------------------------------------------------- // 2) actions 컬럼 (단일 버튼 - Meta Info 바로 보기) // ---------------------------------------------------------------- - const actionsColumn: ColumnDef<ExtendedFormMappings> = { + const actionsColumn: ColumnDef<FormListsView> = { id: "actions", enableHiding: false, cell: function Cell({ row }) { @@ -65,7 +65,7 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<Extende // 3) 일반 컬럼들을 "그룹"별로 묶어 중첩 columns 생성 // ---------------------------------------------------------------- // 3-1) groupMap: { [groupName]: ColumnDef<TagTypeClassFormMappings>[] } - const groupMap: Record<string, ColumnDef<ExtendedFormMappings>[]> = {} + const groupMap: Record<string, ColumnDef<FormListsView>[]> = {} formListsColumnsConfig.forEach((cfg) => { // 만약 group가 없으면 "_noGroup" 처리 @@ -76,7 +76,7 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<Extende } // child column 정의 - const childCol: ColumnDef<ExtendedFormMappings> = { + const childCol: ColumnDef<FormListsView> = { accessorKey: cfg.id, enableResizing: true, header: ({ column }) => ( @@ -104,7 +104,7 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<Extende // ---------------------------------------------------------------- // 3-2) groupMap에서 실제 상위 컬럼(그룹)을 만들기 // ---------------------------------------------------------------- - const nestedColumns: ColumnDef<ExtendedFormMappings>[] = [] + const nestedColumns: ColumnDef<FormListsView>[] = [] // 순서를 고정하고 싶다면 group 순서를 미리 정의하거나 sort해야 함 // 여기서는 그냥 Object.entries 순서 diff --git a/lib/form-list/table/formLists-table-toolbar-actions.tsx b/lib/form-list/table/formLists-table-toolbar-actions.tsx index 97db9a91..fc1e9c80 100644 --- a/lib/form-list/table/formLists-table-toolbar-actions.tsx +++ b/lib/form-list/table/formLists-table-toolbar-actions.tsx @@ -7,10 +7,10 @@ import { toast } from "sonner" import { exportTableToExcel } from "@/lib/export" import { Button } from "@/components/ui/button" -import { ExtendedFormMappings } from "../validation" +import { FormListsView } from "@/db/schema" interface ItemsTableToolbarActionsProps { - table: Table<ExtendedFormMappings> + table: Table<FormListsView> } export function FormListsTableToolbarActions({ table }: ItemsTableToolbarActionsProps) { diff --git a/lib/form-list/table/formLists-table.tsx b/lib/form-list/table/formLists-table.tsx index 9f35db03..a9a56338 100644 --- a/lib/form-list/table/formLists-table.tsx +++ b/lib/form-list/table/formLists-table.tsx @@ -16,7 +16,7 @@ import { getFormLists } from "../service" import { getColumns } from "./formLists-table-columns" import { FormListsTableToolbarActions } from "./formLists-table-toolbar-actions" import { ViewMetas } from "./meta-sheet" -import { ExtendedFormMappings } from "../validation" +import { FormListsView } from "@/db/schema" interface ItemsTableProps { promises: Promise< @@ -33,7 +33,7 @@ export function FormListsTable({ promises }: ItemsTableProps) { React.use(promises) const [rowAction, setRowAction] = - React.useState<DataTableRowAction<ExtendedFormMappings> | null>(null) + React.useState<DataTableRowAction<FormListsView> | null>(null) const columns = React.useMemo( () => getColumns({ setRowAction }), @@ -51,7 +51,7 @@ export function FormListsTable({ promises }: ItemsTableProps) { * @prop {React.ReactNode} [icon] - An optional icon to display next to the label. * @prop {boolean} [withCount] - An optional boolean to display the count of the filter option. */ - const filterFields: DataTableFilterField<ExtendedFormMappings>[] = [ + const filterFields: DataTableFilterField<FormListsView>[] = [ ] @@ -66,7 +66,7 @@ export function FormListsTable({ promises }: ItemsTableProps) { * 3. Used with DataTableAdvancedToolbar: Enables a more sophisticated filtering UI. * 4. Date and boolean types: Adds support for filtering by date ranges and boolean values. */ - const advancedFilterFields: DataTableAdvancedFilterField<ExtendedFormMappings>[] = [ + const advancedFilterFields: DataTableAdvancedFilterField<FormListsView>[] = [ { id: "projectCode", label: "Project Code", diff --git a/lib/form-list/table/meta-sheet.tsx b/lib/form-list/table/meta-sheet.tsx index 03e7d257..24140a95 100644 --- a/lib/form-list/table/meta-sheet.tsx +++ b/lib/form-list/table/meta-sheet.tsx @@ -32,8 +32,8 @@ import { CardHeader, CardTitle } from "@/components/ui/card" -import type { TagTypeClassFormMappings } from "@/db/schema/vendorData" // or your actual type import { fetchFormMetadata, FormColumn } from "@/lib/forms/services" +import { FormListsView } from "@/db/schema" // 옵션을 표시하기 위한 새로운 컴포넌트 const CollapsibleOptions = ({ options }: { options?: string[] }) => { @@ -89,7 +89,7 @@ const CollapsibleOptions = ({ options }: { options?: string[] }) => { interface ViewMetasProps { open: boolean onOpenChange: (open: boolean) => void - form: TagTypeClassFormMappings | null + form: FormListsView | null } export function ViewMetas({ open, onOpenChange, form }: ViewMetasProps) { @@ -124,6 +124,7 @@ export function ViewMetas({ open, onOpenChange, form }: ViewMetasProps) { React.useEffect(() => { async function fetchMeta() { if (!form || !open) return + if (form.formCode === null || form.projectId === null) return setLoading(true) try { |
