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

54 lines
1.8 KiB
JavaScript
Raw Normal View History

2021-04-20 22:23:35 +00:00
import classNames from "classnames"
import Style from "./App.module.css"
2021-04-21 13:08:54 +00:00
import Layout from "./components/Layout"
2021-04-21 13:37:12 +00:00
import ContextTheme from "./contexts/ContextTheme"
import { BrowserRouter } from "react-router-dom"
2021-04-21 16:21:30 +00:00
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"
2021-04-20 22:09:13 +00:00
2021-04-20 22:07:39 +00:00
/**
* 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
*/
2021-04-20 22:23:35 +00:00
export default function App() {
const [theme, setAndSaveTheme] = useSavedTheme();
2021-04-20 22:23:35 +00:00
2021-04-20 22:09:13 +00:00
return (
<ContextTheme.Provider value={[theme, setAndSaveTheme]}>
<BrowserRouter>
2021-04-21 13:37:12 +00:00
<div className={classNames(Style.App, theme)}>
<Layout>
2021-04-21 16:21:30 +00:00
<Switch>
<Route path={"/repositories"} exact={true}>
2021-04-21 16:21:30 +00:00
<PageRepositories/>
</Route>
<Route path={"/alerts"} exact={true}>
2021-04-21 16:21:30 +00:00
<PageAlerts/>
</Route>
<Route path={"/settings"} exact={true}>
2021-04-21 16:21:30 +00:00
<PageSettings/>
</Route>
<Route path={"/sandbox"} exact={true}>
<PageSandbox/>
</Route>
<Route path={"/"} exact={true}>
2021-04-21 16:32:05 +00:00
<PageHome/>
</Route>
2021-04-21 16:21:30 +00:00
</Switch>
2021-04-21 13:37:12 +00:00
</Layout>
</div>
</BrowserRouter>
2021-04-21 13:37:12 +00:00
</ContextTheme.Provider>
2021-04-20 22:09:13 +00:00
)
2021-04-20 22:07:39 +00:00
}