admin_ruspet/src/components/Layout/MainLayout.tsx

43 lines
1.3 KiB
TypeScript

import { AppShell } from '@mantine/core'
import { useDisclosure } from '@mantine/hooks'
import { Outlet, useLocation } from 'react-router-dom'
import Sidebar from './Sidebar'
import Header from './Header'
import ErrorBoundary from '../DiagnosticErrorBoundary'
export default function MainLayout() {
const [mobileOpened, { toggle: toggleMobile }] = useDisclosure()
const [desktopOpened, { toggle: toggleDesktop }] = useDisclosure(true)
const location = useLocation()
return (
<AppShell
header={{ height: 60 }}
navbar={{
width: 280,
breakpoint: 'sm',
collapsed: { mobile: !mobileOpened, desktop: !desktopOpened },
}}
padding="md"
>
<AppShell.Header>
<Header
toggleMobile={toggleMobile}
toggleDesktop={toggleDesktop}
mobileOpened={mobileOpened}
desktopOpened={desktopOpened}
/>
</AppShell.Header>
<AppShell.Navbar p={0}>
<Sidebar />
</AppShell.Navbar>
<AppShell.Main bg="gray.0" miw={0}>
<ErrorBoundary key={location.pathname}>
<Outlet />
</ErrorBoundary>
</AppShell.Main>
</AppShell>
)
}