const form = useForm({
defaultValues: {
email: user!.email,
first_name: profile?.first_name || "",
last_name: profile?.last_name || "",
job_title: profile?.job_title || "",
target_market: "",
note: getInitialNote(leadType, contextInfo),
type: leadType,
},
validators: {
onChange: SubmitLeadSchema,
},
// this doesn't execute unless onChange is removed
onSubmit: async ({ value }) => {
try {
console.log("inside try")
const res = SubmitLeadSchema.parse({ ...value, brand_id: brandId });
console.log(res)
await trpc.leads.submit.mutate({ ...value, brand_id: brandId });
onClose();
toast.success("Your request has been sent to the brand!");
} catch (error) {
if (error instanceof TRPCError) {
console.error(error);
return;
}
if (error instanceof Error) {
console.error(error);
return;
}
console.error(error);
return;
}
},
});
const form = useForm({
defaultValues: {
email: user!.email,
first_name: profile?.first_name || "",
last_name: profile?.last_name || "",
job_title: profile?.job_title || "",
target_market: "",
note: getInitialNote(leadType, contextInfo),
type: leadType,
},
validators: {
onChange: SubmitLeadSchema,
},
// this doesn't execute unless onChange is removed
onSubmit: async ({ value }) => {
try {
console.log("inside try")
const res = SubmitLeadSchema.parse({ ...value, brand_id: brandId });
console.log(res)
await trpc.leads.submit.mutate({ ...value, brand_id: brandId });
onClose();
toast.success("Your request has been sent to the brand!");
} catch (error) {
if (error instanceof TRPCError) {
console.error(error);
return;
}
if (error instanceof Error) {
console.error(error);
return;
}
console.error(error);
return;
}
},
});