All files / apps / web/src / features / auth / components / SignInRefused index.tsx

100% Statements 3/3
100% Branches 4/4
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53                          2x       5x                                       10x                              
import { ChevronLeft, ShieldAlert } from 'lucide-react'
import { Fragment, type ReactElement } from 'react'
import { Button } from '@/components/Button'
import { ALLOWED_DOMAINS } from '../../constants'
import { formatDomain } from '../../lib/messages'
 
interface SignInRefusedProps {
  /** The Google account that was refused, when Google told us which one. */
  email: string | null
  onUseAnotherAccountClick: () => void
}
 
// A Google account outside the allowed domains (AUTH-1): say which account and which to use instead.
export const SignInRefused = ({
  email,
  onUseAnotherAccountClick,
}: SignInRefusedProps): ReactElement => (
  <main className="grid min-h-dvh place-items-center p-4">
    <section
      aria-labelledby="sign-in-refused-title"
      className="flex w-full max-w-sm flex-col items-center gap-4 rounded-2xl border bg-card p-6 text-center shadow-soft backdrop-blur-xl"
    >
      <div className="grid size-12 place-items-center rounded-xl bg-bad-bg text-destructive">
        <ShieldAlert aria-hidden="true" className="size-5" />
      </div>
      <div role="alert" className="flex flex-col gap-1.5">
        <h1 id="sign-in-refused-title" className="text-xl font-bold text-foreground">
          This account can’t sign in
        </h1>
        <p className="text-sm text-muted-foreground">
          {email ? (
            <strong className="font-semibold break-all text-foreground">{email}</strong>
          ) : (
            'This Google account'
          )}{' '}
          isn’t on an allowed company domain. Sign in with your{' '}
          {ALLOWED_DOMAINS.map((domain, index) => (
            <Fragment key={domain}>
              {index > 0 ? ' or ' : null}
              <strong className="font-semibold text-foreground">{formatDomain(domain)}</strong>
            </Fragment>
          ))}{' '}
          account instead.
        </p>
      </div>
      <Button variant="outline" onClick={onUseAnotherAccountClick}>
        <ChevronLeft aria-hidden="true" />
        Use a different account
      </Button>
    </section>
  </main>
)