fix: resolve customer creation fk violation and implement instant updates in admin dialogs
All checks were successful
Staging Build / build (push) Successful in 2m26s
All checks were successful
Staging Build / build (push) Successful in 2m26s
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useForm, useFieldArray } from 'react-hook-form'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import * as z from 'zod'
|
||||
@@ -60,6 +61,7 @@ type ProductFormValues = z.infer<typeof productSchema>
|
||||
|
||||
export function CreateProductDialog({ children, categories, product }: { children?: React.ReactNode, categories: Category[], product?: Product }) {
|
||||
const [open, setOpen] = useState(false)
|
||||
const router = useRouter()
|
||||
|
||||
const form = useForm<ProductFormValues>({
|
||||
resolver: zodResolver(productSchema) as any,
|
||||
@@ -102,6 +104,7 @@ export function CreateProductDialog({ children, categories, product }: { childre
|
||||
|
||||
setOpen(false)
|
||||
if (!product) form.reset()
|
||||
router.refresh()
|
||||
} catch (error) {
|
||||
console.error('Error saving product:', error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user