|
| 1 | +/* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | + * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | + |
| 5 | +import Image from 'next/image'; |
| 6 | +import errorIcon from '@fxa/shared/assets/images/error.svg'; |
| 7 | +import mozillaIcon from '@fxa/shared/assets/images/moz-logo-bw-rgb.svg'; |
| 8 | +import Link from 'next/link'; |
| 9 | +import { cookies } from 'next/headers'; |
| 10 | +import { BaseButton, ButtonVariant } from '@fxa/payments/ui'; |
| 11 | +import { config } from '../../../../config'; |
| 12 | +import { getApp } from '@fxa/payments/ui/server'; |
| 13 | + |
| 14 | +export default function AuthErrorPage({ |
| 15 | + searchParams, |
| 16 | +}: { |
| 17 | + searchParams: Record<string, string>; |
| 18 | +}) { |
| 19 | + const cookieStore = cookies(); |
| 20 | + const redirectUrl = |
| 21 | + cookieStore.get('__Secure-authjs.callback-url')?.value || |
| 22 | + cookieStore.get('authjs.callback-url')?.value; |
| 23 | + const supportUrl = config.supportUrl |
| 24 | + const l10n = getApp().getL10n(); |
| 25 | + getApp().getEmitterService().emit('auth', { type: 'error', errorMessage: searchParams?.error }); |
| 26 | + |
| 27 | + return ( |
| 28 | + <> |
| 29 | + <header |
| 30 | + className="bg-white fixed flex justify-between items-center shadow h-16 left-0 top-0 mx-auto my-0 px-4 py-0 w-full z-40 tablet:h-20" |
| 31 | + role="banner" |
| 32 | + > |
| 33 | + <div className="flex items-center"> |
| 34 | + <Image |
| 35 | + src={mozillaIcon} |
| 36 | + alt="Mozilla logo" |
| 37 | + className="object-contain" |
| 38 | + width={140} |
| 39 | + /> |
| 40 | + </div> |
| 41 | + </header> |
| 42 | + <section |
| 43 | + className="flex flex-col items-center text-center max-w-lg mx-auto mt-6 p-16 tablet:my-10 gap-16 bg-white shadow tablet:rounded-xl border border-transparent" |
| 44 | + aria-labelledby='unable-to-signin-heading' |
| 45 | + > |
| 46 | + <h1 id="unable-to-signin-heading" className="text-xl font-bold"> |
| 47 | + {l10n.getString('auth-error-page-title', 'We Couldn’t Sign You In')} |
| 48 | + </h1> |
| 49 | + <Image src={errorIcon} alt="" /> |
| 50 | + <p className="flex flex-col gap-6 items-center text-grey-400 max-w-md text-sm"> |
| 51 | + <span> |
| 52 | + {l10n.getFragmentWithSource('checkout-error-boundary-basic-error-message', |
| 53 | + { |
| 54 | + elems: { |
| 55 | + contactSupportLink: ( |
| 56 | + <Link href={supportUrl} className="underline hover:text-grey-400"> |
| 57 | + contact support. |
| 58 | + </Link> |
| 59 | + ) |
| 60 | + } |
| 61 | + } |
| 62 | + , |
| 63 | + <> |
| 64 | + Something went wrong. Please try again or{' '} |
| 65 | + <Link href={supportUrl} className="underline hover:text-grey-400"> |
| 66 | + contact support. |
| 67 | + </Link> |
| 68 | + </> |
| 69 | + )} |
| 70 | + </span> |
| 71 | + {redirectUrl && |
| 72 | + <Link href={redirectUrl}> |
| 73 | + <BaseButton |
| 74 | + variant={ButtonVariant.Primary} |
| 75 | + className="text-base" |
| 76 | + > |
| 77 | + Try again |
| 78 | + </BaseButton> |
| 79 | + </Link> |
| 80 | + } |
| 81 | + </p> |
| 82 | + </section> |
| 83 | + </> |
| 84 | + ); |
| 85 | +} |
| 86 | + |
0 commit comments