// 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[] { return attributeKeys.map(key => ({ id: `attr_${key}`, accessorFn: (row: Tag) => { if (row.attributes && typeof row.attributes === 'object') { return (row.attributes as Record)[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, })) }