1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 14:34:19 +00:00
pds-2021-g2-nest/code/frontend/src/App.js
2021-04-24 01:02:48 +02:00

53 lines
1.8 KiB
JavaScript

import classNames from "classnames"
import Style from "./App.module.css"
import Layout from "./components/Layout"
import ContextTheme from "./contexts/ContextTheme"
import { BrowserRouter } from "react-router-dom"
import { Route, Switch } from "react-router"
import PageHome from "./routes/PageHome"
import PageRepositories from "./routes/PageRepositories"
import PageAlerts from "./routes/PageAlerts"
import PageSettings from "./routes/PageSettings"
import PageSandbox from "./routes/PageSandbox"
import useSavedTheme from "./hooks/useSavedTheme"
/**
* The main component of the webapp, the root of the render tree, what is displayed when the web page is visited.
*
* @returns {JSX.Element}
* @constructor
*/
export default function App() {
const [theme, setAndSaveTheme] = useSavedTheme();
return (
<ContextTheme.Provider value={[theme, setAndSaveTheme]}>
<BrowserRouter>
<div className={classNames(Style.App, theme)}>
<Layout>
<Switch>
<Route path={"/repositories"} exact={true}>
<PageRepositories/>
</Route>
<Route path={"/alerts"} exact={true}>
<PageAlerts/>
</Route>
<Route path={"/settings"} exact={true}>
<PageSettings/>
</Route>
<Route path={"/sandbox"} exact={true}>
<PageSandbox/>
</Route>
<Route path={"/"} exact={true}>
<PageHome/>
</Route>
</Switch>
</Layout>
</div>
</BrowserRouter>
</ContextTheme.Provider>
)
}