-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTabContent.tsx
More file actions
42 lines (33 loc) · 927 Bytes
/
TabContent.tsx
File metadata and controls
42 lines (33 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { useMemo } from 'react'
import type { Tab } from '../../types/explorer.types'
import { useTableDataStore } from '@/app/store/table-data.store'
import { DataGrid } from '@/widgets/data-grid/DataGrid'
import { QueryEditor } from '@/widgets/query-editor/components/QueryEditor'
interface Props {
tab: Tab
}
export function TabContent({ tab }: Props) {
const tableMap = useTableDataStore(s => s.tables)
if (tab.type === 'query') {
return <QueryEditor />
}
const key = `public.${tab.name}`
const data = tableMap[key]
if (!data) {
return (
<div className="text-muted-foreground flex h-full items-center justify-center">
Loading table…
</div>
)
}
const gridData = useMemo(() => {
return {
rows: data.rows,
columns: data.columns.map(col => ({
name: col.name,
type: col.type
}))
}
}, [data])
return <DataGrid data={gridData} rowHeight={32} renderer="dom" editable />
}