"use client"; import { Loader2Icon } from "lucide-react"; import { usePathname, useRouter } from "next/navigation"; import { useEffect, type ReactNode } from "react"; import { StepUpProvider } from "@/components/inbox/stepup"; import { AppShell } from "@/components/shell/app-shell"; import { useAuth } from "@/lib/auth"; import { useI18n } from "@/lib/i18n"; /** Everything behind sign-in. Tokens live in memory, so the gate waits for the silent * refresh (httpOnly cookie) before deciding. */ export function AppGate({ children }: { children: ReactNode }) { const { status } = useAuth(); const { t } = useI18n(); const router = useRouter(); const pathname = usePathname(); useEffect(() => { if (status === "anonymous") router.replace(`/login?next=${encodeURIComponent(pathname)}`); }, [status, router, pathname]); if (status !== "authenticated") return ; return ( {children} ); } export function FullPageLoading({ label }: { label?: string }) { const { t } = useI18n(); return (
{label ?? t("common.loading")}
); }