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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | 3x 33x 66x | import { LoaderCircle } from 'lucide-react'
import { Fragment, type ReactElement } from 'react'
import { Button } from '@/components/Button'
import { Logo } from '@/features/shell'
import googleMark from '../../assets/google-mark.svg'
import { ALLOWED_DOMAINS } from '../../constants'
import { formatDomain, getSignInMessage } from '../../lib/messages'
interface SignInScreenProps {
/** Waiting for Google, or opening the session after Google sent the browser back. */
isBusy: boolean
/** Why the last sign-in failed (an API error code or a SIGN_IN_ERROR_CODE). */
errorCode: string | null
/** The request id of the failed call, so support can find it in the logs. */
requestId: string | null
onSignInClick: () => void
/** Replaces the default subtitle (the broker names the preview it signs in for). */
description?: string
}
// The one screen someone who is not signed in can see (design 2.4, 4.1): one Google button, no
// password and no sign-up, since every account on an allowed domain gets in without an invite.
export const SignInScreen = ({
isBusy,
errorCode,
requestId,
onSignInClick,
description = 'Asoft’s team chat. Use your company Google account.',
}: SignInScreenProps): ReactElement => (
<main className="grid min-h-dvh place-items-center p-4">
<section
aria-labelledby="sign-in-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"
>
<Logo className="size-12" />
<div className="flex flex-col gap-1.5">
<h1 id="sign-in-title" className="text-xl font-bold text-foreground">
Sign in to Chattra
</h1>
<p className="text-sm text-muted-foreground">{description}</p>
</div>
{errorCode ? (
<div role="alert" className="w-full rounded-xl bg-bad-bg p-3 text-left text-sm">
<p className="text-foreground">{getSignInMessage(errorCode)}</p>
{requestId ? (
<p className="mt-1 text-xs text-foreground">{`Request id: ${requestId}`}</p>
) : null}
</div>
) : null}
<Button
variant="outline"
size="lg"
className="w-full"
disabled={isBusy}
onClick={onSignInClick}
>
{isBusy ? (
<LoaderCircle aria-hidden="true" className="animate-spin" />
) : (
<img src={googleMark} alt="" className="size-4" />
)}
{isBusy ? 'Signing in…' : 'Continue with Google'}
</Button>
<p className="w-full rounded-xl border bg-secondary p-3 text-left text-sm text-muted-foreground">
Accounts on an allowed company domain get in straight away, no invite needed. Right now that
is{' '}
{ALLOWED_DOMAINS.map((domain, index) => (
<Fragment key={domain}>
{index > 0 ? ', ' : null}
<strong className="font-semibold text-foreground">{formatDomain(domain)}</strong>
</Fragment>
))}
.
</p>
</section>
</main>
)
|