FIx clients routes
Seto Elkahfi committed
Aug 7, 2023 at 16:06 UTC
4af5275719f04aba39cba7019de6de662734d710
2 files changed
+14
-6
src/components/Main.tsx
+1
-2
@@ -1,6 +1,5 @@
1
import React from 'react';
2
import { Switch, Route } from 'react-router-dom';
3
-import { FirebaseContext } from './Firebase';
3
import routes from '../shared/routes';
4
5
const mainStyle = {
@@ -25,7 +24,7 @@ const Main = () => (
24
<Switch>
25
{
26
routes.map((route, index) => (
28
- <Route key={index} path={route.path}>
27
+ <Route key={index} exact={route.exact} path={route.path} >
28
<route.component />
29
</Route>
30
))
src/shared/routes.tsx
+13
-4
@@ -2,10 +2,13 @@ import Home from '../components/Home';
2
import About from '../components/About';
3
import React from 'react';
4
import { getCaraousel } from './api';
5
+import Contact from '../components/Contact';
6
+import Cv from '../components/Cv';
7
8
export interface Route {
9
path: string;
10
component: React.ComponentType<any>;
11
+ exact?: boolean;
12
fetchInitialData?: (path?: string) => Promise<any>;
13
}
14
@@ -14,17 +17,23 @@ const routes: Route[] = [
17
{
18
path: '/',
19
component: Home,
17
- fetchInitialData: (path = '') => getCaraousel()
20
+ exact: true,
21
+ fetchInitialData: () => getCaraousel()
22
},
23
{
24
path: '/about',
25
component: About,
22
- fetchInitialData: (path = '') => Promise.resolve()
26
+ fetchInitialData: () => Promise.resolve()
27
},
28
{
29
path: '/cv',
26
- component: About,
27
- fetchInitialData: (path = '') => Promise.resolve()
30
+ component: Cv,
31
+ fetchInitialData: () => Promise.resolve()
32
+ },
33
+ {
34
+ path: '/contact',
35
+ component: Contact,
36
+ fetchInitialData: () => Promise.resolve()
37
}
38
];
39