"use client";
import { Product, Image, Color, Category, Size } from "@prisma/client";
// Remaining imports not included for brevity
const formSchema = z.object({
name: z.string().min(1),
image: z.object({ url: z.string() }).array(),
price: z.coerce.number().min(1),
categoryId: z.string().min(1),
colorId: z.string().min(1),
sizeId: z.string().min(1),
isFeatured: z.boolean().default(false).optional(),
isArchived: z.boolean().default(false).optional(),
});
// Remaining content of the component not included for brevity
export default ProductForm;
When attempting to create a new product in the database by submitting the form, the onSubmit function does not seem to be triggered. Despite adding console logs to verify if the function runs upon form submission, no output is observed. There are no indications of errors or issues in the console.
UPDATE: Upon further investigation, I implemented an onInvalid function in the submit process and encountered the following error message:
{image: {…}}The error appears to be Zod-related, specifically indicating an "invalid_type". What could potentially be causing this issue within my code?
image
: {message: 'Required', type: 'invalid_type', ref: undefined}
[[Prototype]]
: Object