init code

This commit is contained in:
Tham Luu
2024-09-23 15:07:25 +08:00
commit 2842b3fc19
63 changed files with 7901 additions and 0 deletions

41
src/pages/Layout.jsx Normal file
View File

@ -0,0 +1,41 @@
import Header from '@components/Header'
import Navbar from '@components/Navbar'
import { useAuth } from '@hooks/useAuth'
import { AppShell, ScrollArea } from '@mantine/core'
import { useDisclosure } from '@mantine/hooks'
import { PathConstants } from '@routes/routes'
import { useEffect } from 'react'
import { Outlet, useNavigate } from 'react-router-dom'
export default function Layout() {
const [opened, { toggle }] = useDisclosure()
const { auth } = useAuth()
const navigate = useNavigate()
useEffect(() => {
if (!auth.isLogged) {
navigate(PathConstants.LOGIN)
}
}, [])
return (
<AppShell
header={{ height: 60 }}
navbar={{ width: 300, breakpoint: 'md', collapsed: { mobile: !opened } }}
padding="md"
bg="#f2fcff"
>
<AppShell.Header>
<Header opened={opened} onClick={toggle} />
</AppShell.Header>
<AppShell.Navbar>
<AppShell.Section component={ScrollArea}>
<Navbar />
</AppShell.Section>
</AppShell.Navbar>
<AppShell.Main>
<Outlet />
</AppShell.Main>
</AppShell>
)
}