Skip to content

Commit 48aed91

Browse files
committed
more organizing
1 parent 967a5c7 commit 48aed91

File tree

7 files changed

+41
-29
lines changed

7 files changed

+41
-29
lines changed

exercises/99.final/01.solution.final/src/app.tsx

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { createRoot } from 'react-dom/client'
2-
import { BrowserRouter } from 'react-router'
2+
import { RouterProvider } from 'react-router'
33
import './styles/index.css'
4-
import { AppRoutes } from './routes.tsx'
4+
import { router } from './routes.tsx'
55

66
createRoot(document.getElementById('🧭')!).render(
7-
<BrowserRouter>
8-
<AppRoutes />
9-
</BrowserRouter>,
7+
<RouterProvider router={router} />,
108
)
Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
1-
import { Routes, Route } from 'react-router'
1+
import { createBrowserRouter } from 'react-router'
22
import { AppLayout } from './routes/app/layout.tsx'
3+
import { AboutRoute } from './routes/app/marketing/about.tsx'
4+
import { HomepageRoute } from './routes/app/marketing/homepage.tsx'
5+
import { MarketingLayout } from './routes/app/marketing/layout.tsx'
36
import { RecipientRoute } from './routes/app/recipient.tsx'
47
import { RecipientsRoute } from './routes/app/recipients.tsx'
5-
import { AboutRoute } from './routes/marketing/about.tsx'
6-
import { HomepageRoute } from './routes/marketing/homepage.tsx'
7-
import { MarketingLayout } from './routes/marketing/layout.tsx'
88
import { SignupRoute } from './routes/signup.tsx'
99

10-
export function AppRoutes() {
11-
return (
12-
<Routes>
13-
<Route element={<AppLayout />}>
14-
<Route path="/" element={<MarketingLayout />}>
15-
<Route index element={<HomepageRoute />} />
16-
<Route path="about" element={<AboutRoute />} />
17-
</Route>
18-
<Route path="recipients" element={<RecipientsRoute />} />
19-
<Route path="recipients/:id" element={<RecipientRoute />} />
20-
</Route>
21-
<Route path="/signup" element={<SignupRoute />} />
22-
</Routes>
23-
)
24-
}
10+
export const router = createBrowserRouter([
11+
{
12+
element: <AppLayout />,
13+
children: [
14+
{
15+
element: <MarketingLayout />,
16+
children: [
17+
{
18+
index: true,
19+
element: <HomepageRoute />,
20+
},
21+
{
22+
path: 'about',
23+
element: <AboutRoute />,
24+
},
25+
],
26+
},
27+
{
28+
path: 'recipients',
29+
element: <RecipientsRoute />,
30+
},
31+
{
32+
path: 'recipients/:id',
33+
element: <RecipientRoute />,
34+
},
35+
],
36+
},
37+
{
38+
path: '/signup',
39+
element: <SignupRoute />,
40+
},
41+
])

exercises/99.final/01.solution.final/src/routes/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { LinkButton } from '#src/components/button.tsx'
33

44
export function AppLayout() {
55
return (
6-
<div className="bg-background flex h-screen flex-col overflow-hidden">
6+
<div className="bg-background flex h-screen flex-col">
77
<header className="bg-background-alt px-4 py-3">
88
<div className="container mx-auto flex max-w-6xl items-center justify-between">
99
<Link

exercises/99.final/01.solution.final/src/routes/marketing/homepage.tsx renamed to exercises/99.final/01.solution.final/src/routes/app/marketing/homepage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LinkButton } from '../../components/button.tsx'
1+
import { LinkButton } from '#src/components/button.tsx'
22

33
export function HomepageRoute() {
44
return (

0 commit comments

Comments
 (0)