| 1 | import Link from "next/link"; |
| 2 | import { ACCOUNT_ENTRY_COPY } from "@/lib/content/account-entry"; |
| 3 | import { pickText } from "@/lib/i18n/dictionaries"; |
| 4 | import { publicAuthAppDestination, type PublicAuthKind } from "@/lib/public-auth-routes"; |
| 5 | import { WhalePose } from "./whale-pose"; |
| 6 | |
| 7 | /** |
| 8 | * The public sign-in and create-account doors. codewhale.net is not the |
| 9 | * signed-in app: one primary action sends the reader to it, one secondary |
| 10 | * action installs locally (no account needed), and one line switches |
| 11 | * between signing in and creating an account. The whale listens. |
| 12 | */ |
| 13 | export function PublicAccountEntry({ |
| 14 | locale, |
| 15 | kind, |
| 16 | }: { |
| 17 | locale: string; |
| 18 | kind: Exclude<PublicAuthKind, "callback">; |
| 19 | }) { |
| 20 | const creating = kind === "sign-up"; |
| 21 | const copy = creating ? ACCOUNT_ENTRY_COPY.signUp : ACCOUNT_ENTRY_COPY.signIn; |
| 22 | const appHref = publicAuthAppDestination(kind, locale); |
| 23 | const otherHref = `/${locale}/${creating ? "signin" : "signup"}`; |
| 24 | |
| 25 | return ( |
| 26 | <div className="account-entry"> |
| 27 | <WhalePose pose="listen" className="account-entry-pose" priority /> |
| 28 | <h1 className="page-title">{pickText(copy.title, locale)}</h1> |
| 29 | <p className="page-lede">{pickText(ACCOUNT_ENTRY_COPY.lede, locale)}</p> |
| 30 | <div className="actions"> |
| 31 | <a className="btn btn-primary btn-lg" href={appHref} data-usage={creating ? "signup" : "login"}> |
| 32 | {pickText(copy.action, locale)} |
| 33 | </a> |
| 34 | <Link className="btn btn-secondary btn-lg" href={`/${locale}/install`}> |
| 35 | {pickText(ACCOUNT_ENTRY_COPY.installLocally, locale)} |
| 36 | </Link> |
| 37 | </div> |
| 38 | <p className="page-meta"> |
| 39 | {pickText(copy.switchPrompt, locale)}{" "} |
| 40 | <Link href={otherHref} className="link"> |
| 41 | {pickText(copy.switchLabel, locale)} |
| 42 | </Link> |
| 43 | </p> |
| 44 | </div> |
| 45 | ); |
| 46 | } |
| 47 |