1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
"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 { getColumns } from "./possible-items-table-columns";
import { PossibleItemsTableToolbarActions } from "./possible-items-table-toolbar-actions";
// 새로운 스키마에 맞는 타입 import
import type { TechVendorPossibleItemsData } from "../service";
import type { DataTableAdvancedFilterField } from "@/types/table";
interface PossibleItemsDataTableProps {
promises: Promise<[{
data: TechVendorPossibleItemsData[];
pageCount: number;
totalCount: number;
}, string[]]>;
}
export function PossibleItemsDataTable({ promises }: PossibleItemsDataTableProps) {
const [{ data, pageCount }, vendorTypes] = React.use(promises);
const columns = React.useMemo(() => getColumns(), []);
const filterFields: DataTableAdvancedFilterField<TechVendorPossibleItemsData>[] = [
{
id: "vendorCode",
label: "벤더코드",
type: "text",
},
{
id: "vendorName",
label: "벤더명",
type: "text",
},
{
id: "vendorEmail",
label: "벤더이메일",
type: "text",
},
{
id: "vendorStatus",
label: "벤더상태",
type: "multi-select",
options: [
{ label: "ACTIVE", value: "ACTIVE", count: 0 },
{ label: "PENDING_INVITE", value: "PENDING_INVITE", count: 0 },
{ label: "PENDING_REVIEW", value: "PENDING_REVIEW", count: 0 },
{ label: "INACTIVE", value: "INACTIVE", count: 0 },
],
},
{
id: "itemCode",
label: "아이템코드",
type: "text",
},
{
id: "itemList",
label: "아이템리스트",
type: "text",
},
{
id: "workType",
label: "공종",
type: "text",
},
{
id: "shipTypes",
label: "선종",
type: "text",
},
{
id: "subItemList",
label: "서브아이템리스트",
type: "text",
},
{
id: "techVendorType",
label: "벤더타입",
type: "multi-select",
options: Array.isArray(vendorTypes) ? vendorTypes.map((type: string) => ({
label: type,
value: type,
count: 0,
})) : [],
},
];
const { table } = useDataTable({
data,
columns,
pageCount,
filterFields,
enableAdvancedFilter: true,
initialState: {
sorting: [{ id: "createdAt", desc: true }],
pagination: { pageIndex: 0, pageSize: 10 },
},
getRowId: (originalRow) => `${originalRow.vendorId}-${originalRow.itemCode}-${originalRow.id}`,
shallow: false,
clearOnDefault: true,
});
return (
<>
<DataTable table={table}>
<DataTableAdvancedToolbar table={table} filterFields={filterFields}>
<PossibleItemsTableToolbarActions table={table} />
</DataTableAdvancedToolbar>
</DataTable>
</>
);
}
|