diff --git a/apps/api/src/components/modules/common/session-menu.tsx b/apps/api/src/components/modules/common/session-menu.tsx index 24b0595..50928d7 100644 --- a/apps/api/src/components/modules/common/session-menu.tsx +++ b/apps/api/src/components/modules/common/session-menu.tsx @@ -4,6 +4,7 @@ import type { Profile } from "@gov-portal/api-client"; import { GithubLogoIcon, ShieldCheckIcon, SignOutIcon, UserIcon } from "@phosphor-icons/react"; import Link from "next/link"; import { useState } from "react"; +import { toast } from "sonner"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Badge } from "@/components/ui/badge"; @@ -40,6 +41,7 @@ export function SessionMenu({ greetingLabel, profileLabel, adminLabel, + retryLabel, }: { locale: Locale; signInLabel: string; @@ -48,17 +50,36 @@ export function SessionMenu({ greetingLabel: string; profileLabel: string; adminLabel: string; + retryLabel: string; }) { - const { actor, isLoading } = useActor(); + const { actor, isLoading, isSignedOut, error, refresh } = useActor(); const [busy, setBusy] = useState(false); if (isLoading) { return null; } + if (error !== undefined || (actor === null && !isSignedOut)) { + return ( + + ); + } + if (actor === null) { return ( - diff --git a/apps/api/src/components/modules/common/sign-in-panel.tsx b/apps/api/src/components/modules/common/sign-in-panel.tsx index 7ccd5de..e14667d 100644 --- a/apps/api/src/components/modules/common/sign-in-panel.tsx +++ b/apps/api/src/components/modules/common/sign-in-panel.tsx @@ -1,6 +1,7 @@ "use client"; import { useState } from "react"; +import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { signInWithGitHub } from "@/lib/auth-client"; @@ -17,7 +18,13 @@ export function SignInPanel({ label, locale }: { label: string; locale: Locale } disabled={busy} onClick={() => { setBusy(true); - signInWithGitHub(`/${locale}/welcome`).catch(() => setBusy(false)); + signInWithGitHub(`/${locale}/welcome`).catch((error: unknown) => { + console.error("Failed to start GitHub sign-in", error); + toast.error( + error instanceof Error ? error.message : "Could not start GitHub sign-in", + ); + setBusy(false); + }); }} > {label} diff --git a/apps/api/src/components/modules/common/site-header.tsx b/apps/api/src/components/modules/common/site-header.tsx index b2f2de1..005b9c6 100644 --- a/apps/api/src/components/modules/common/site-header.tsx +++ b/apps/api/src/components/modules/common/site-header.tsx @@ -81,6 +81,7 @@ export function SiteHeader({ locale }: { locale: Locale }) { greetingLabel={dict.session.greeting} profileLabel={dict.nav.myProfile} adminLabel={dict.nav.admin} + retryLabel={dict.session.retryAccount} /> diff --git a/apps/api/src/components/modules/landing/hero-section.tsx b/apps/api/src/components/modules/landing/hero-section.tsx index 3e08e31..434e520 100644 --- a/apps/api/src/components/modules/landing/hero-section.tsx +++ b/apps/api/src/components/modules/landing/hero-section.tsx @@ -21,7 +21,12 @@ export function HeroSection({ dict, locale }: { dict: Dictionary; locale: Locale

{dict.home.lead}

- + + ); + } + + if (actor !== null) { + return ( + + ); + } + return (