import { Outlet, Link, useLocation } from "react-router-dom"; import { Sidebar } from "./Sidebar"; import { useEffect } from "react"; interface Props { sidebarOpen: boolean; setSidebarOpen: (open: boolean) => void; } export function Layout({ sidebarOpen, setSidebarOpen }: Props) { const location = useLocation(); // Auto-close the mobile sidebar whenever the route changes — the user // tapped a link in it; getting the content underneath back into view is // expected. useEffect(() => { setSidebarOpen(false); }, [location.pathname, setSidebarOpen]); // Lock body scroll while the off-canvas sidebar is open on small screens. useEffect(() => { const orig = document.body.style.overflow; if (sidebarOpen) document.body.style.overflow = "hidden"; return () => { document.body.style.overflow = orig; }; }, [sidebarOpen]); return (