-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathApp.tsx
53 lines (47 loc) · 1 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { createBrowserRouter, Outlet, RouterProvider } from 'react-router-dom'
import { Box, Center, VStack } from '@chakra-ui/react'
import { Login } from './features/auth/Login'
import { PrivateOutlet } from './utils/PrivateOutlet'
import { ProtectedComponent } from './features/auth/ProtectedComponent'
function AppLayout() {
return (
<Box>
<Outlet />
</Box>
)
}
function Hooray() {
return (
<Center h="500px">
<VStack>
<Box>Hooray you logged in!</Box>
<Box>
<ProtectedComponent />
</Box>
</VStack>
</Center>
)
}
const router = createBrowserRouter([
{
path: '/',
element: <AppLayout />,
children: [
{ path: 'login', element: <Login /> },
{
path: '*',
element: <PrivateOutlet />,
children: [
{
index: true,
element: <Hooray />,
},
],
},
],
},
])
function App() {
return <RouterProvider router={router} />
}
export default App