Skip to content

Commit

Permalink
feat: code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
WanShufen committed Dec 13, 2022
1 parent b6f0f51 commit d8f75ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions apps/web/app/table/[id]/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Table as CoreTable, QueryRecords } from '@egodb/core'
import { EGOTable } from '@egodb/table-ui'
import { Box, Space } from '@egodb/ui'
import { useUpdateAtom } from 'jotai/utils'
import { useCallback, useState } from 'react'
import { useCallback } from 'react'
import { CreateRecordFormDrawer } from '../../../components/create-record-form/create-record-form-drawer'
import { editRecordFormDrawerOpened } from '../../../components/edit-record-form/drawer-opened.atom'
import { EditRecordFormDrawer } from '../../../components/edit-record-form/edit-record-form-drawer'
Expand All @@ -19,9 +19,9 @@ interface IProps {
export default function Table({ table, records }: IProps) {
const setOpened = useUpdateAtom(editRecordFormDrawerOpened)

const onRowClick = useCallback(
const onRecordClick = useCallback(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(id: string) => {
console.log(id)
setOpened(true)
},
[setOpened],
Expand All @@ -34,7 +34,7 @@ export default function Table({ table, records }: IProps) {
<TableToolbar table={table} />
</Box>
<Space h="md" />
<EGOTable onRowClick={onRowClick} records={records} table={table} />
<EGOTable onRecordClick={onRecordClick} records={records} table={table} />
<CreateRecordFormDrawer table={table} />
<EditRecordFormDrawer table={table} />
</Box>
Expand Down
6 changes: 3 additions & 3 deletions packages/table-ui/src/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ interface IProps {
table: CoreTable
records: QueryRecords
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onRowClick: (row: any) => void
onRecordClick: (row: any) => void
}

export const EGOTable: React.FC<IProps> = ({ table, records, onRowClick }) => {
export const EGOTable: React.FC<IProps> = ({ table, records, onRecordClick }) => {
// TODO: helper types should infered by type
const fieldHelper = createColumnHelper<Record<string, IFieldValue>>()
const columns = table.schema.fields.map((c) =>
Expand Down Expand Up @@ -54,7 +54,7 @@ export const EGOTable: React.FC<IProps> = ({ table, records, onRowClick }) => {
<tr
key={row.id}
onClick={() => {
onRowClick(row.id)
onRecordClick(row.id)
}}
>
{row.getVisibleCells().map((cell) => (
Expand Down

0 comments on commit d8f75ca

Please sign in to comment.