2022-09-29 14:58:16 -06:00
|
|
|
import React, {useContext} from 'react';
|
2021-11-01 16:42:52 -06:00
|
|
|
import './App.css';
|
|
|
|
|
import {NavBar} from "./components/Nav";
|
2023-01-04 19:45:42 -07:00
|
|
|
import {createBrowserRouter, createRoutesFromElements, Link, Outlet, Route, RouterProvider} from "react-router-dom";
|
2022-08-06 05:22:07 +00:00
|
|
|
import {VideosRoute, VideoWrapper} from "./components/Videos";
|
2022-09-29 12:02:09 -06:00
|
|
|
import Admin from "./components/admin/Admin";
|
2022-09-29 14:58:16 -06:00
|
|
|
import {Container} from "semantic-ui-react";
|
2021-11-01 16:42:52 -06:00
|
|
|
import 'semantic-ui-offline/semantic.min.css';
|
|
|
|
|
import {SemanticToastContainer} from 'react-semantic-toasts';
|
|
|
|
|
import 'react-semantic-toasts/styles/react-semantic-alert.css';
|
|
|
|
|
import {AppsRoute} from "./components/Apps";
|
|
|
|
|
import {InventoryRoute} from "./components/Inventory";
|
2022-08-06 05:22:07 +00:00
|
|
|
import {ArchiveRoute} from "./components/Archive";
|
2022-09-29 14:58:16 -06:00
|
|
|
import {FilesRoute} from "./components/Files";
|
2022-10-16 11:53:44 -06:00
|
|
|
import {useStatusInterval} from "./hooks/customHooks";
|
2022-03-08 13:26:03 -07:00
|
|
|
import {MapRoute} from "./components/Map";
|
2023-01-07 18:31:39 -07:00
|
|
|
import {MediaContextProvider, mediaStyles, StatusContext, ThemeContext} from "./contexts/contexts";
|
2023-01-04 19:45:42 -07:00
|
|
|
import {Header, ThemeWrapper} from "./components/Theme";
|
2022-09-29 14:58:16 -06:00
|
|
|
import {Dashboard} from "./Dashboard";
|
2022-11-08 22:42:00 -07:00
|
|
|
import {Donate} from "./components/Donate";
|
2022-12-23 16:04:09 -07:00
|
|
|
import {useEventsInterval} from "./Events";
|
2022-08-06 05:22:07 +00:00
|
|
|
|
2021-11-01 16:42:52 -06:00
|
|
|
function PageNotFound() {
|
2023-01-04 19:45:42 -07:00
|
|
|
const {t} = useContext(ThemeContext);
|
2022-12-19 10:40:01 -07:00
|
|
|
return <Container fluid>
|
2023-01-04 19:45:42 -07:00
|
|
|
<Header as='h1'>Page Not Found!</Header>
|
|
|
|
|
<p {...t}>The page you requested cannot be found</p>
|
2022-12-19 10:40:01 -07:00
|
|
|
</Container>
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
2022-11-12 13:43:31 -07:00
|
|
|
function Dot() {
|
|
|
|
|
return <> • </>
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-30 16:59:26 -07:00
|
|
|
function Footer() {
|
2022-08-06 05:22:07 +00:00
|
|
|
const {t} = useContext(ThemeContext);
|
2022-10-16 11:53:44 -06:00
|
|
|
const {status} = useContext(StatusContext);
|
2022-11-08 22:42:00 -07:00
|
|
|
let {version} = status;
|
|
|
|
|
version = version ? `v${version}` : null;
|
|
|
|
|
return <Container textAlign='center' style={{marginTop: '1.5em', marginBottom: '1em', ...t}}>
|
|
|
|
|
<span {...t}>
|
2022-11-12 13:43:31 -07:00
|
|
|
WROLPi {version} <Dot/>
|
2023-01-23 09:52:05 -07:00
|
|
|
<a href='https://wrolpi.org' target='_blank' rel='nofollow noreferrer'>WROLPi.org</a> <Dot/>
|
2022-11-12 13:43:31 -07:00
|
|
|
<Link to='/donate'>Donate</Link>
|
2022-11-08 22:42:00 -07:00
|
|
|
</span>
|
2022-01-30 16:59:26 -07:00
|
|
|
</Container>
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-04 19:45:42 -07:00
|
|
|
function Root() {
|
|
|
|
|
return <>
|
|
|
|
|
<header>
|
|
|
|
|
<NavBar/>
|
|
|
|
|
</header>
|
|
|
|
|
<Outlet/>
|
|
|
|
|
<Footer/>
|
|
|
|
|
<SemanticToastContainer position="top-right"/>
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const router = createBrowserRouter(createRoutesFromElements(
|
|
|
|
|
<Route
|
|
|
|
|
path='/'
|
|
|
|
|
element={<Root/>}
|
|
|
|
|
errorElement={<PageNotFound/>}
|
|
|
|
|
>
|
|
|
|
|
<Route index element={<Dashboard/>}/>
|
|
|
|
|
<Route path='donate' element={<Donate/>}/>
|
|
|
|
|
<Route path='videos/video/:videoId' exact element={<VideoWrapper/>}/>
|
|
|
|
|
<Route path='videos/channel/:channelId/video/:videoId' exact element={<VideoWrapper/>}/>
|
|
|
|
|
<Route path="videos/*" element={<VideosRoute/>}/>
|
|
|
|
|
<Route path="admin/*" element={<Admin/>}/>
|
|
|
|
|
<Route path="apps/*" element={<AppsRoute/>}/>
|
|
|
|
|
<Route path="inventory/*" element={<InventoryRoute/>}/>
|
|
|
|
|
<Route path='archive/*' element={<ArchiveRoute/>}/>
|
|
|
|
|
<Route path='map/*' element={<MapRoute/>}/>
|
|
|
|
|
<Route path='files/*' element={<FilesRoute/>}/>
|
|
|
|
|
</Route>
|
|
|
|
|
));
|
|
|
|
|
|
2021-11-01 16:42:52 -06:00
|
|
|
export default function App() {
|
2022-10-16 11:53:44 -06:00
|
|
|
const status = useStatusInterval();
|
2022-12-23 16:04:09 -07:00
|
|
|
useEventsInterval();
|
2022-08-06 05:22:07 +00:00
|
|
|
|
2023-01-04 19:45:42 -07:00
|
|
|
return <ThemeWrapper>
|
2023-01-07 18:31:39 -07:00
|
|
|
{/* Context and style to handle switching between mobile/computer. */}
|
|
|
|
|
<style>{mediaStyles}</style>
|
|
|
|
|
<MediaContextProvider>
|
|
|
|
|
<StatusContext.Provider value={status}>
|
|
|
|
|
<RouterProvider router={router}/>
|
|
|
|
|
</StatusContext.Provider>
|
|
|
|
|
</MediaContextProvider>
|
|
|
|
|
</ThemeWrapper>
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|