Skip to content

Commit

Permalink
feat(consent): add different functionality for cancel button on login.
Browse files Browse the repository at this point in the history
Signed-off-by: amitamrutiya2210 <[email protected]>
  • Loading branch information
amitamrutiya committed May 5, 2024
1 parent 0006351 commit d10a888
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions apps/consent/app/login/email-login-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -23,6 +24,8 @@ interface LoginProps {
}

const EmailLoginForm = ({ login_challenge }: LoginProps) => {
const router = useRouter()

const [state, formAction] = useFormState<LoginEmailResponse, FormData>(submitForm, {
error: false,
message: null,
Expand Down Expand Up @@ -73,11 +76,12 @@ const EmailLoginForm = ({ login_challenge }: LoginProps) => {
Next
</PrimaryButton>
<SecondaryButton
type="submit"
type="button"
id="reject"
name="submit"
name="cancel"
value={SubmitValue.denyAccess}
formNoValidate
onClick={() => router.back()}
>
Cancel
</SecondaryButton>
Expand Down
7 changes: 5 additions & 2 deletions apps/consent/components/phone-auth/phone-auth-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -46,6 +47,7 @@ const PhoneAuthForm: React.FC<AuthFormProps> = ({
countryCodes,
authAction,
}) => {
const router = useRouter()
const [phoneNumber, setPhoneNumber] = useState<string>("")
const [state, formAction] = useFormState<GetCaptchaChallengeResponse, FormData>(
getCaptchaChallenge,
Expand Down Expand Up @@ -156,11 +158,12 @@ const PhoneAuthForm: React.FC<AuthFormProps> = ({
Next
</PrimaryButton>
<SecondaryButton
type="submit"
type="button"
id="reject"
name="submit"
name="cancel"
value={SubmitValue.denyAccess}
formNoValidate
onClick={() => router.back()}
>
Cancel
</SecondaryButton>
Expand Down

0 comments on commit d10a888

Please sign in to comment.