Skip to content

Commit 46837ba

Browse files
committed
feat(dashboard): add different functionality for cancel button on login.
Signed-off-by: amitamrutiya2210 <amitamrutiya2210@gmail.com>
1 parent 0006351 commit 46837ba

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

apps/consent/app/login/email-login-form.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React from "react"
33

44
import { useFormState } from "react-dom"
5+
import { useRouter } from "next/navigation"
56
import { toast } from "react-toastify"
67

78
import InputComponent from "../../components/input-component"
@@ -23,6 +24,8 @@ interface LoginProps {
2324
}
2425

2526
const EmailLoginForm = ({ login_challenge }: LoginProps) => {
27+
const router = useRouter()
28+
2629
const [state, formAction] = useFormState<LoginEmailResponse, FormData>(submitForm, {
2730
error: false,
2831
message: null,
@@ -73,11 +76,12 @@ const EmailLoginForm = ({ login_challenge }: LoginProps) => {
7376
Next
7477
</PrimaryButton>
7578
<SecondaryButton
76-
type="submit"
79+
type="button"
7780
id="reject"
78-
name="submit"
81+
name="cancel"
7982
value={SubmitValue.denyAccess}
8083
formNoValidate
84+
onClick={() => router.back()}
8185
>
8286
Cancel
8387
</SecondaryButton>

apps/consent/components/phone-auth/phone-auth-form.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import SelectComponent from "@/components/select"
3434
import RegisterLink from "@/components/register-link"
3535

3636
import { GetCaptchaChallengeResponse } from "@/app/types/phone-auth.types"
37+
import { useRouter } from "next/navigation"
3738

3839
interface AuthFormProps {
3940
authAction: "Register" | "Login"
@@ -46,6 +47,7 @@ const PhoneAuthForm: React.FC<AuthFormProps> = ({
4647
countryCodes,
4748
authAction,
4849
}) => {
50+
const router = useRouter()
4951
const [phoneNumber, setPhoneNumber] = useState<string>("")
5052
const [state, formAction] = useFormState<GetCaptchaChallengeResponse, FormData>(
5153
getCaptchaChallenge,
@@ -156,11 +158,12 @@ const PhoneAuthForm: React.FC<AuthFormProps> = ({
156158
Next
157159
</PrimaryButton>
158160
<SecondaryButton
159-
type="submit"
161+
type="button"
160162
id="reject"
161-
name="submit"
163+
name="cancel"
162164
value={SubmitValue.denyAccess}
163165
formNoValidate
166+
onClick={() => router.back()}
164167
>
165168
Cancel
166169
</SecondaryButton>

0 commit comments

Comments
 (0)