diff --git a/.server-changes/conform-v1.md b/.server-changes/conform-v1.md new file mode 100644 index 0000000000..5e18782946 --- /dev/null +++ b/.server-changes/conform-v1.md @@ -0,0 +1,6 @@ +--- +area: webapp +type: improvement +--- + +Upgrade the dashboard form layer from `@conform-to` 0.9 to 1.x. conform 1.x supports both zod 3 and zod 4, which unblocks the upcoming zod 4 upgrade. diff --git a/apps/webapp/app/components/Feedback.tsx b/apps/webapp/app/components/Feedback.tsx index 0848359e21..f8b4e8b398 100644 --- a/apps/webapp/app/components/Feedback.tsx +++ b/apps/webapp/app/components/Feedback.tsx @@ -1,5 +1,5 @@ -import { conform, useForm } from "@conform-to/react"; -import { parse } from "@conform-to/zod"; +import { getFormProps, getSelectProps, getInputProps, getTextareaProps, useForm } from "@conform-to/react"; +import { parseWithZod } from "@conform-to/zod"; import { InformationCircleIcon, ArrowUpCircleIcon } from "@heroicons/react/20/solid"; import { EnvelopeIcon, ShieldCheckIcon } from "@heroicons/react/24/solid"; import { Form, useActionData, useLocation, useNavigation, useSearchParams } from "@remix-run/react"; @@ -34,11 +34,11 @@ export function Feedback({ button, defaultValue = "bug", onOpenChange }: Feedbac const navigation = useNavigation(); const [type, setType] = useState(defaultValue); - const [form, { path, feedbackType, message }] = useForm({ + const [form, fields] = useForm({ id: "accept-invite", - lastSubmission: lastSubmission as any, + lastResult: lastSubmission as any, onValidate({ formData }) { - return parse(formData, { schema }); + return parseWithZod(formData, { schema }); }, shouldRevalidate: "onInput", }); @@ -47,8 +47,7 @@ export function Feedback({ button, defaultValue = "bug", onOpenChange }: Feedbac if ( navigation.formAction === "/resources/feedback" && navigation.state === "loading" && - form.error === undefined && - form.errors.length === 0 + (form.errors === undefined || form.errors.length === 0) ) { setOpen(false); } @@ -90,9 +89,9 @@ export function Feedback({ button, defaultValue = "bug", onOpenChange }: Feedbac type === "concurrency" || type === "hipaa" ) &&
} -
+
- + {type === "feature" && ( )} - {feedbackType.error} + {fields.feedbackType.errors} -