diff --git a/apps/consent/app/components/varification-components/verification-code-form.tsx b/apps/consent/app/components/varification-components/verification-code-form.tsx index ea904e7449..52515601fd 100644 --- a/apps/consent/app/components/varification-components/verification-code-form.tsx +++ b/apps/consent/app/components/varification-components/verification-code-form.tsx @@ -1,4 +1,5 @@ -import React from "react" +"use client" +import React, { useState, useEffect } from "react" import InputComponent from "@/app/components/input-component" import PrimaryButtonComponent from "@/app/components/button/primary-button-component" @@ -21,35 +22,53 @@ const VerificationCodeForm: React.FC = ({ remember, loginType, value, -}) => ( - <> -

- Enter Verification Code -

-
- - - - - -
-

- The code was sent to your {loginType}{" "} -

- {value} -
- - - Submit - - - -) +}) => { + const [code, setCode] = useState("") + + const handleChange = (e: React.ChangeEvent) => { + if (e.target.value.length <= 6) { + setCode(e.target.value) + } + } + + useEffect(() => { + if (code.length === 6 && !isNaN(Number(code))) { + document.forms[0].requestSubmit() + } + }, [code]) + + return ( + <> +

+ Enter Verification Code +

+
+ + + + + +
+

+ The code was sent to your {loginType}{" "} +

+ {value} +
+ + + Submit + + + + ) +} export default VerificationCodeForm diff --git a/apps/consent/cypress/e2e/email-sign-in/login-email.cy.ts b/apps/consent/cypress/e2e/email-sign-in/login-email.cy.ts index 01c2979569..607ef47c7d 100644 --- a/apps/consent/cypress/e2e/email-sign-in/login-email.cy.ts +++ b/apps/consent/cypress/e2e/email-sign-in/login-email.cy.ts @@ -21,7 +21,6 @@ describe("Account ID Test", () => { cy.getOTP(email).then((otp) => { const code = otp cy.get("[data-testid=verification_code_input]").type(code) - cy.get("[data-testid=verification_code_submit_btn]").click() cy.get("[data-testid=submit_consent_btn]").click() }) }) diff --git a/apps/consent/cypress/e2e/phone-sign-in/login-phone.cy.ts b/apps/consent/cypress/e2e/phone-sign-in/login-phone.cy.ts index fe58b03aab..cecf1d10ed 100644 --- a/apps/consent/cypress/e2e/phone-sign-in/login-phone.cy.ts +++ b/apps/consent/cypress/e2e/phone-sign-in/login-phone.cy.ts @@ -37,7 +37,6 @@ describe("Account ID Test", () => { cy.setCookie(login_challenge, cookieValue, { secure: true }) cy.visit(`/login/verification?login_challenge=${login_challenge}`) cy.get("[data-testid=verification_code_input]").type(testData.VERIFICATION_CODE) - cy.get("[data-testid=verification_code_submit_btn]").click() cy.get("[data-testid=submit_consent_btn]").click() }) })