add persistence to cart

This commit is contained in:
2025-12-25 23:01:24 -03:00
parent 7dc2d2ef10
commit dbfa82ce72
5 changed files with 258 additions and 47 deletions

View File

@@ -38,6 +38,7 @@ const emptyRow = {
type BulkProps = {
onSubmit: (value: any) => void | Promise<void>
courses: Promise<{ hits: Course[] }>
defaultValues?: { items: object[] }
}
const item = z.object({
@@ -68,11 +69,11 @@ const formSchema = z.object({
type Schema = z.infer<typeof formSchema>
export function Bulk({ courses, onSubmit }: BulkProps) {
export function Bulk({ courses, onSubmit, defaultValues }: BulkProps) {
const wizard = useWizard()
const form = useForm({
resolver: zodResolver(formSchema),
defaultValues: { items: [emptyRow] }
defaultValues: { items: defaultValues?.items || [emptyRow] }
})
const {
formState,