diff --git a/frontend/src/components/auth/totp-form.tsx b/frontend/src/components/auth/totp-form.tsx index 60e5dbd..2be9216 100644 --- a/frontend/src/components/auth/totp-form.tsx +++ b/frontend/src/components/auth/totp-form.tsx @@ -14,11 +14,10 @@ import z from "zod"; interface Props { formId: string; onSubmit: (code: TotpSchema) => void; - loading?: boolean; } export const TotpForm = (props: Props) => { - const { formId, onSubmit, loading } = props; + const { formId, onSubmit } = props; const { t } = useTranslation(); z.config({ @@ -30,6 +29,14 @@ export const TotpForm = (props: Props) => { resolver: zodResolver(totpSchema), }); + const handleChange = (value: string) => { + form.setValue("code", value, { shouldDirty: true, shouldValidate: true }); + + if (value.length === 6) { + onSubmit({ code: value }); + } + }; + return (
@@ -41,10 +48,10 @@ export const TotpForm = (props: Props) => { diff --git a/frontend/src/pages/totp-page.tsx b/frontend/src/pages/totp-page.tsx index ef05565..ebc21b0 100644 --- a/frontend/src/pages/totp-page.tsx +++ b/frontend/src/pages/totp-page.tsx @@ -70,7 +70,6 @@ export const TotpPage = () => { totpMutation.mutate(values)} - loading={totpMutation.isPending} />