import { getFormProps, useForm } from "@conform-to/react"; import { getZodConstraint, parseWithZod } from "@conform-to/zod"; import { useGo, useIsAuthenticated, useParsed } from "@refinedev/core"; import { Link } from "@remix-run/react"; import { useEffect } from "react"; import { z } from "zod"; import { Field } from "~/components/forms"; import { Button } from "~/components/ui/button"; import type { LoginParams } from "./login"; const OtpSchema = z.object({ otp: z.string().length(6, { message: "OTP must be 6 characters" }), }); export default function OtpForm() { const { isLoading: isAuthLoading, data: authData } = useIsAuthenticated(); const go = useGo(); const parsed = useParsed(); // TODO: Add support for resending the OTP const [form, fields] = useForm({ id: "otp", constraint: getZodConstraint(OtpSchema), onValidate({ formData }) { return parseWithZod(formData, { schema: OtpSchema }); }, shouldValidate: "onSubmit", }); const valid = true; const to = parsed.params?.to ?? "/dashboard"; useEffect(() => { if (!isAuthLoading) { if (authData?.authenticated && valid) { go({ to, type: "push" }); } } }, [isAuthLoading, authData, to, go]); return (

Check your inbox

We will need the six digit confirmation code you received in your email in order to verify your account and get started. Didn’t receive a code?{" "}

← Back to Login

); }