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'
@@ -14,10 +14,13 @@ export const getCreateItemPage = (props: Parameters<typeof CreateItemPage>[0]) =
1414 < CreateItemPage { ...props } />
1515)
1616
17- function CreateItemPage ( { listKey } : { listKey : string } ) {
18- const list = useList ( listKey )
17+ export function CreateItemPage ( { params } : { params : Usable < { listKey : string } > } ) {
18+ const { listsKeyByPath } = useKeystone ( )
19+ const _params = use < { listKey : string } > ( params )
20+ const list = useList ( listsKeyByPath [ _params . listKey ] )
1921 const createItem = useCreateItem ( list )
2022 const router = useRouter ( )
23+ const { adminPath } = useKeystone ( )
2124
2225 return (
2326 < PageContainer
@@ -42,7 +45,7 @@ function CreateItemPage({ listKey }: { listKey: string }) {
4245 const item = await createItem . create ( )
4346 if ( ! item ) return
4447
45- router . push ( `/${ list . path } /${ item . id } ` )
48+ router . push ( `${ adminPath } /${ list . path } /${ item . id } ` )
4649 } }
4750 style = { { display : 'contents' } }
4851 >
0 commit comments