import { Outlet } from "react-router-dom"; import { LogOut, AlertTriangle, RefreshCw } from "lucide-react"; import { useAuth } from "../context/AuthContext"; import Sidebar from "./Sidebar"; import NotificationBell from "./NotificationBell"; import React from "react"; /* ── Error Boundary ────────────────────────────────────────────────── Catches any unhandled rendering error and shows a recoverable error screen instead of a blank white page. ─────────────────────────────────────────────────────────────────── */ interface EBState { hasError: boolean; error: Error | null } class PageErrorBoundary extends React.Component<{ children: React.ReactNode }, EBState> { constructor(props: { children: React.ReactNode }) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error: Error): EBState { return { hasError: true, error }; } componentDidCatch(error: Error, info: React.ErrorInfo) { console.error("[PageErrorBoundary]", error, info.componentStack); } render() { if (this.state.hasError) { return (

Something went wrong

{this.state.error?.message ?? "An unexpected error occurred while rendering this page."}

{this.state.error?.stack && (
                {this.state.error.stack}
              
)}
); } return this.props.children; } } /* ── Layout ─────────────────────────────────────────────────────────── */ export default function Layout() { const { user, logout } = useAuth(); return (
{/* Header */}
{user?.username}
{/* Main content wrapped in error boundary */}
); }