Start UI Change
This commit is contained in:
28
frontend/composables/useTableColumns.ts
Normal file
28
frontend/composables/useTableColumns.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
type LegacyTableColumn = {
|
||||
id?: string
|
||||
key?: string
|
||||
label?: unknown
|
||||
header?: unknown
|
||||
accessorKey?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export const normalizeTableColumns = (columns: LegacyTableColumn[] = []) => {
|
||||
return columns.map((column, index) => {
|
||||
const accessorKey = typeof column.accessorKey === 'string'
|
||||
? column.accessorKey
|
||||
: typeof column.key === 'string'
|
||||
? column.key
|
||||
: undefined
|
||||
|
||||
const header = column.header ?? column.label ?? accessorKey ?? `column_${index}`
|
||||
const id = column.id ?? accessorKey ?? (typeof header === 'string' ? header : `column_${index}`)
|
||||
|
||||
return {
|
||||
...column,
|
||||
id,
|
||||
accessorKey,
|
||||
header
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user