Skip to content

Commit

Permalink
fix(aih): add navigation on slug change in edit list form
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtaholik committed Jan 14, 2025
1 parent 9ca5fcc commit 506572e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client'

import * as React from 'react'
import { useRouter } from 'next/navigation'
import { PostMetadataFormFields } from '@/app/(content)/posts/_components/edit-post-form-metadata'
import { ImageResourceUploader } from '@/components/image-uploader/image-resource-uploader'
import { env } from '@/env.mjs'
Expand Down Expand Up @@ -65,10 +66,15 @@ export function EditListForm({ list }: Omit<EditListFormProps, 'form'>) {
},
})
const isMobile = useIsMobile()

const router = useRouter()
return (
<EditResourcesFormDesktop
resource={list}
onSave={async () => {
if (form.getValues().fields.slug !== list?.fields?.slug) {
router.push(`/lists/${form.getValues().fields.slug}/edit`)
}
}}
resourceSchema={ListSchema}
getResourcePath={(slug) => `/lists`}
updateResource={updateList}
Expand Down

0 comments on commit 506572e

Please sign in to comment.