Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit d738057

Browse files
committed
Added Routing
1 parent 158c982 commit d738057

File tree

4 files changed

+143
-12
lines changed

4 files changed

+143
-12
lines changed

webapp_frontend/package-lock.json

Lines changed: 114 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webapp_frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
"@types/react": "^16.9.51",
1313
"@types/react-bootstrap": "^0.32.24",
1414
"@types/react-dom": "^16.9.8",
15+
"@types/react-router-dom": "^5.1.6",
1516
"axios": "^0.20.0",
1617
"bootstrap": "^4.5.3",
1718
"node-sass": "^4.14.1",
1819
"react": "^16.13.1",
1920
"react-bootstrap": "^1.4.0",
2021
"react-dom": "^16.13.1",
22+
"react-router-dom": "^5.2.0",
2123
"react-scripts": "3.4.3",
2224
"react-toastify": "^6.1.0",
2325
"typescript": "^3.8.3"

webapp_frontend/src/components/App.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import React, {ReactElement} from 'react';
22
import './App.css';
3-
4-
53
import {Container} from 'react-bootstrap';
64
import Header from "./basicElements/Header";
7-
import {Health} from "./health/Health";
5+
import {BrowserRouter} from "react-router-dom";
6+
import {Router} from "./Router/Router";
87

98
function App(): ReactElement {
109

1110

1211
return (
1312
<div className="App">
14-
<Header/>
15-
<Container>
16-
<Health/>
17-
</Container>
13+
<BrowserRouter>
14+
<Header/>
15+
<Container>
16+
<Router/>
17+
</Container>
18+
</BrowserRouter>
1819
</div>
1920
);
2021
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React, {ReactElement} from "react";
2+
import {useLocation, Redirect, Route, BrowserRouter, Switch} from "react-router-dom";
3+
import {Health} from "../health/Health";
4+
import {Error404} from "../pages/Error404";
5+
6+
export function Router(props: Object): ReactElement {
7+
const {} = props;
8+
9+
10+
return (
11+
<Switch>
12+
<Route path={"/health"} component={Health}/>
13+
<Route exact path={"/"}>
14+
<Redirect to={"/health"}/>
15+
</Route>
16+
<Route path={"*"} component={Error404}/>
17+
</Switch>
18+
)
19+
}

0 commit comments

Comments
 (0)