From 46837ba38b8d87d04e1fc23d988979cffd4f8463 Mon Sep 17 00:00:00 2001 From: amitamrutiya2210 Date: Sun, 5 May 2024 11:31:09 +0530 Subject: [PATCH] feat(dashboard): add different functionality for cancel button on login. Signed-off-by: amitamrutiya2210 --- apps/consent/app/login/email-login-form.tsx | 8 ++++++-- apps/consent/components/phone-auth/phone-auth-form.tsx | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/consent/app/login/email-login-form.tsx b/apps/consent/app/login/email-login-form.tsx index 3b822df352c..65df80b6313 100644 --- a/apps/consent/app/login/email-login-form.tsx +++ b/apps/consent/app/login/email-login-form.tsx @@ -2,6 +2,7 @@ import React from "react" import { useFormState } from "react-dom" +import { useRouter } from "next/navigation" import { toast } from "react-toastify" import InputComponent from "../../components/input-component" @@ -23,6 +24,8 @@ interface LoginProps { } const EmailLoginForm = ({ login_challenge }: LoginProps) => { + const router = useRouter() + const [state, formAction] = useFormState(submitForm, { error: false, message: null, @@ -73,11 +76,12 @@ const EmailLoginForm = ({ login_challenge }: LoginProps) => { Next router.back()} > Cancel diff --git a/apps/consent/components/phone-auth/phone-auth-form.tsx b/apps/consent/components/phone-auth/phone-auth-form.tsx index 835f80a2456..f973f2b4bc0 100644 --- a/apps/consent/components/phone-auth/phone-auth-form.tsx +++ b/apps/consent/components/phone-auth/phone-auth-form.tsx @@ -34,6 +34,7 @@ import SelectComponent from "@/components/select" import RegisterLink from "@/components/register-link" import { GetCaptchaChallengeResponse } from "@/app/types/phone-auth.types" +import { useRouter } from "next/navigation" interface AuthFormProps { authAction: "Register" | "Login" @@ -46,6 +47,7 @@ const PhoneAuthForm: React.FC = ({ countryCodes, authAction, }) => { + const router = useRouter() const [phoneNumber, setPhoneNumber] = useState("") const [state, formAction] = useFormState( getCaptchaChallenge, @@ -156,11 +158,12 @@ const PhoneAuthForm: React.FC = ({ Next router.back()} > Cancel