Skip to content

Commit

Permalink
fix: fix table ui column def
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed Dec 4, 2022
1 parent e0ac1c4 commit 93d5b3e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/table-ui/src/table.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { QueryRecords, Table as CoreTable } from '@egodb/core'
import type { IFieldValue, QueryRecords, Table as CoreTable } from '@egodb/core'
import { Table, Text, UnstyledButton } from '@egodb/ui'
import { createColumnHelper, flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table'

Expand All @@ -9,12 +9,16 @@ interface IProps {

export const EGOTable: React.FC<IProps> = ({ table, records }) => {
// TODO: helper types should infered by type
const fieldHelper = createColumnHelper<Record<string, string | number>>()
const fields = table.schema.fields.map((c) => fieldHelper.accessor(c.name.value, { id: c.id.value }))
const fieldHelper = createColumnHelper<Record<string, IFieldValue>>()
const columns = table.schema.fields.map((c) =>
fieldHelper.accessor(c.name.value, {
id: c.name.value,
}),
)

const rt = useReactTable({
data: records.map((r) => r.values),
columns: fields,
columns,
getCoreRowModel: getCoreRowModel(),
})

Expand Down

0 comments on commit 93d5b3e

Please sign in to comment.