Files
frontend/apps/st/src/components/util/grid/gridFunction.ts
T

16 lines
543 B
TypeScript

/**
* 객체 배열을 그리드 row 형식으로 변환 (null/undefined → "").
* 어떤 엔티티 타입이든 공통 사용 가능.
*/
export function toGridRows<T extends object>(
items: T[]
): Record<string, string | number>[] {
return items.map((item) => {
const row: Record<string, string | number> = {};
for (const [key, value] of Object.entries(item)) {
row[key] =
value === null || value === undefined ? "" : (value as string | number);
}
return row;
});
};