From c79bc058e1ea5659427933dcd710cec660e5a9f9 Mon Sep 17 00:00:00 2001 From: Eric Luce <37158449+eluce2@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:14:11 -0600 Subject: [PATCH] auto submit pin --- .../reset-password/verify-email/verify-email-form.tsx | 5 +++-- .../app/auth/verify-email/email-verification-form.tsx | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cli/template/extras/proofkit-auth/app/auth/reset-password/verify-email/verify-email-form.tsx b/cli/template/extras/proofkit-auth/app/auth/reset-password/verify-email/verify-email-form.tsx index 2886126..6c2e521 100644 --- a/cli/template/extras/proofkit-auth/app/auth/reset-password/verify-email/verify-email-form.tsx +++ b/cli/template/extras/proofkit-auth/app/auth/reset-password/verify-email/verify-email-form.tsx @@ -23,6 +23,9 @@ export default function VerifyEmailForm() { {...form.register("code")} onChange={(value) => { form.setValue("code", value); + if (value.length === 8) { + handleSubmitWithAction(); + } }} error={!!form.formState.errors.code?.message} autoFocus @@ -30,13 +33,11 @@ export default function VerifyEmailForm() { {form.formState.errors.code?.message && ( {form.formState.errors.code.message} )} - {action.result.data?.error ? ( {action.result.data.error} ) : action.hasErrored ? ( An error occured ) : null} - diff --git a/cli/template/extras/proofkit-auth/app/auth/verify-email/email-verification-form.tsx b/cli/template/extras/proofkit-auth/app/auth/verify-email/email-verification-form.tsx index b8affea..ea8fe2b 100644 --- a/cli/template/extras/proofkit-auth/app/auth/verify-email/email-verification-form.tsx +++ b/cli/template/extras/proofkit-auth/app/auth/verify-email/email-verification-form.tsx @@ -3,7 +3,7 @@ import { useHookFormAction } from "@next-safe-action/adapter-react-hook-form/hoo import { emailVerificationSchema } from "./schema"; import { verifyEmailAction } from "./actions"; import { zodResolver } from "@hookform/resolvers/zod"; -import { Anchor, Button, Group, Paper, PinInput, Text } from "@mantine/core"; +import { Button, Paper, PinInput, Text } from "@mantine/core"; import { Stack } from "@mantine/core"; export default function LoginForm() { @@ -22,7 +22,12 @@ export default function LoginForm() { autoFocus oneTimeCode {...form.register("code")} - onChange={(value) => form.setValue("code", value)} + onChange={(value) => { + form.setValue("code", value); + if (value.length === 8) { + handleSubmitWithAction(); + } + }} /> {action.result.data?.error ? (