new.tsx40 lines · main
1import { useParams } from 'common'
2import { useRouter } from 'next/router'
3
4import { SidePanelEditor } from '@/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor'
5import { DefaultLayout } from '@/components/layouts/DefaultLayout'
6import { EditorBaseLayout } from '@/components/layouts/editors/EditorBaseLayout'
7import { TableEditorLayout } from '@/components/layouts/TableEditorLayout/TableEditorLayout'
8import { TableEditorMenu } from '@/components/layouts/TableEditorLayout/TableEditorMenu'
9import { NewTab } from '@/components/layouts/Tabs/NewTab'
10import type { NextPageWithLayout } from '@/types'
11
12const EditorNewPage: NextPageWithLayout = () => {
13 const router = useRouter()
14 const { ref: projectRef } = useParams()
15
16 const onTableCreated = (table: { id: number }) => {
17 router.push(`/project/${projectRef}/editor/${table.id}`)
18 }
19
20 return (
21 <>
22 <NewTab />
23 <SidePanelEditor onTableCreated={onTableCreated} />
24 </>
25 )
26}
27
28EditorNewPage.getLayout = (page) => (
29 <DefaultLayout>
30 <EditorBaseLayout
31 productMenu={<TableEditorMenu />}
32 product="Table Editor"
33 productMenuClassName="overflow-y-hidden"
34 >
35 <TableEditorLayout>{page}</TableEditorLayout>
36 </EditorBaseLayout>
37 </DefaultLayout>
38)
39
40export default EditorNewPage