blob: 9a552d6ee80083a98edf7b34088f9fd7cfbfa1e5 (
plain)
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
|
// lib/vendor-data-plant/column-builder.service.ts
import { ColumnDef } from "@tanstack/react-table"
import { Tag } from "@/db/schema/vendorData"
/**
* 동적 속성 컬럼 생성 (ATT_ID만 사용, 라벨 없음)
*/
export function createDynamicAttributeColumns(
attributeKeys: string[]
): ColumnDef<Tag>[] {
return attributeKeys.map(key => ({
id: `attr_${key}`,
accessorFn: (row: Tag) => {
if (row.attributes && typeof row.attributes === 'object') {
return (row.attributes as Record<string, string>)[key] || ''
}
return ''
},
header: key, // 단순 문자열로 반환
cell: ({ getValue }) => {
const value = getValue()
return value as string || "-"
},
meta: {
excelHeader: key
},
enableSorting: true,
enableColumnFilter: true,
filterFn: "includesString",
enableResizing: true,
minSize: 100,
size: 150,
}))
}
|