"use client"; import React from "react"; import { Loader2, RefreshCw } from "lucide-react"; import { useAuth } from "@/components/auth/authContext"; import { Button } from "@/components/ui/button"; import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"; import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, } from "@/components/ui/card"; /** * AuthGate * * Renders auth-related states *inside* the AppShell main area to avoid "blank spinner" screens. * * Why this exists: * - AuthProvider owns the session check and provides AuthContext. * - We want the AppShell frame (TopNav/sidebar) to remain stable while auth checks run. * - This component decides what the user sees inside the main content area. * * UX rule: * - All user-facing strings are German. * * @param {{ children: React.ReactNode }} props */ export default function AuthGate({ children }) { const { status, error, retry } = useAuth(); const canRetry = typeof retry === "function"; if (status === "authenticated") { return children; } if (status === "error") { return ( Sitzungsprüfung fehlgeschlagen Die Sitzung konnte nicht geprüft werden. Fehler {error || "Bitte prüfen Sie Ihre Verbindung und versuchen Sie es erneut."} ); } // "unauthenticated" -> redirect happens in AuthProvider. if (status === "unauthenticated") { return ( Weiterleitung Sie werden zum Login weitergeleitet.
Weiterleitung zum Login…
); } // Default: loading (or unknown) return ( Sitzung wird geprüft Bitte warten…
Sitzung wird geprüft…
); }