1- import { useRouter } from 'next/router '
2-
1+ import { type Usable , use } from 'react '
2+ import { useRouter } from 'next/navigation'
33import { Button } from '@keystar/ui/button'
44import { VStack } from '@keystar/ui/layout'
55
6- import { useList } from '../../../../admin-ui'
6+ import { useKeystone , useList } from '../../../../admin-ui'
77import { GraphQLErrorNotice } from '../../../../admin-ui/components'
88import { PageContainer } from '../../../../admin-ui/components/PageContainer'
99import { Fields } from '../../../../admin-ui/utils'
1010import { useCreateItem } from '../../../../admin-ui/utils/useCreateItem'
1111import { BaseToolbar , ColumnLayout , ItemPageHeader } from '../ItemPage/common'
1212
13- export const getCreateItemPage = ( props : Parameters < typeof CreateItemPage > [ 0 ] ) => ( ) => (
14- < CreateItemPage { ...props } />
15- )
13+ export function CreateItemPage ( { params } : { params : Usable < { listKey : string } > } ) {
14+ const _params = use < { listKey : string } > ( params )
15+ return < CreateItemPageInternal listKey = { _params . listKey } />
16+ }
1617
17- function CreateItemPage ( { listKey } : { listKey : string } ) {
18- const list = useList ( listKey )
18+ export function CreateItemPageInternal ( { listKey } : { listKey : string } ) {
19+ const { adminPath, listsKeyByPath } = useKeystone ( )
20+ const list = useList ( listsKeyByPath [ listKey ] )
1921 const createItem = useCreateItem ( list )
2022 const router = useRouter ( )
2123
@@ -42,7 +44,7 @@ function CreateItemPage({ listKey }: { listKey: string }) {
4244 const item = await createItem . create ( )
4345 if ( ! item ) return
4446
45- router . push ( `/${ list . path } /${ item . id } ` )
47+ router . push ( `${ adminPath } /${ list . path } /${ item . id } ` )
4648 } }
4749 style = { { display : 'contents' } }
4850 >
0 commit comments