diff options
author | Galen Guyer <galen@galenguyer.com> | 2022-08-31 12:31:25 -0400 |
---|---|---|
committer | Galen Guyer <galen@galenguyer.com> | 2022-08-31 12:31:25 -0400 |
commit | e9b9cd2cd88e453a3a35cf3f672ba965660b9ff2 (patch) | |
tree | df34e0aa8ffbc51fc14cbb1065437ba87e7b490f /src/App.jsx | |
parent | 3ce7ae5c53705c213b293bb7bca833b066c14d6a (diff) |
Update the dashboard with a message about the lack of any dashboards
Diffstat (limited to 'src/App.jsx')
-rw-r--r-- | src/App.jsx | 140 |
1 files changed, 3 insertions, 137 deletions
diff --git a/src/App.jsx b/src/App.jsx index 5afcb03..ff72a91 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,112 +1,16 @@ -import { useLocation, Routes, Route, Link } from "react-router-dom"; -import { useState, lazy, Suspense } from "react"; -import useFetch from "./useFetch"; -import { DateTime } from "luxon"; +import { Link } from "react-router-dom"; import "./App.css"; -const Index = lazy(() => import("./pages/Index")); -const Graph = lazy(() => import("./pages/Graph")); -import { useEffect } from "react"; +import Index from "./pages/Index"; const App = () => { - const url = localStorage.getItem("url") ?? "https://ritcoviddashboard.com/api/v0/history"; - - let routerLocation = useLocation(); - useEffect(() => { - !window.goatcounter ?? - window.goatcounter.count({ - path: location.pathname + location.search + location.hash, - }); - }, [routerLocation]); - - const response = useFetch(url); - - const [timeDifference, setTimeDifference] = useState(1); - const local = DateTime.local().zoneName; - - let data = response.data ?? []; - - const latest = response.loading ? null : data[data.length - 1]; - const prior = response.loading ? null : data[data.length - (1 + timeDifference)]; - - const lastUpdate = response.loading ? null : DateTime.fromSQL(latest.last_updated).setZone(local); - const priorUpdate = response.loading ? null : DateTime.fromSQL(prior.last_updated).setZone(local); - return ( <div className="App"> <header> <Link to="/"> <h1>RIT COVID Dashboard</h1> </Link> - <Updated - loading={response.loading} - lastUpdate={lastUpdate} - priorUpdate={priorUpdate} - timeDifference={timeDifference} - /> </header> - <Routes> - <Route - path="/totalstudents" - element={ - <Suspense fallback={null}> - <Graph - name={"Total Student Cases"} - response={response} - dataKey={"total_students"} - timeDifference={timeDifference} - /> - </Suspense> - } - ></Route> - <Route - path="/totalstaff" - element={ - <Suspense fallback={null}> - <Graph - name={"Total Staff Cases"} - response={response} - dataKey={"total_staff"} - timeDifference={timeDifference} - /> - </Suspense> - } - ></Route> - <Route - path="/newstudents" - element={ - <Suspense fallback={null}> - <Graph - name={"New Student Cases"} - response={response} - dataKey={"new_students"} - timeDifference={timeDifference} - /> - </Suspense> - } - ></Route> - <Route - path="/newstaff" - element={ - <Suspense fallback={null}> - <Graph - name={"New Staff Cases"} - response={response} - dataKey={"new_staff"} - timeDifference={timeDifference} - /> - </Suspense> - } - ></Route> - <Route - exact - path="/" - element={ - <Suspense fallback={null}> - <Index response={response} timeDifference={timeDifference} /> - </Suspense> - } - /> - </Routes> + <Index /> <footer> <p> By Galen Guyer. Source available on{" "} @@ -119,48 +23,10 @@ const App = () => { </a> ) </p> - <p> - <a className="BlueLink" href="https://galenguyer.com/projects/ritcoviddashboard"> - API Documentation - </a> - </p> </footer> <script data-goatcounter="https://rcd.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script> </div> ); }; -const Updated = (props) => { - const { loading, lastUpdate, priorUpdate, timeDifference } = props; - if (loading) { - return <div></div>; - } - - return ( - <div className="Updated"> - <div className="Latest"> - Last Updated:{" "} - {lastUpdate.toLocaleString({ - weekday: "long", - month: "long", - day: "2-digit", - hour: "2-digit", - minute: "2-digit", - })} - </div> - <div className="Prior"> - Prior Update:{" "} - {priorUpdate.toLocaleString({ - weekday: "long", - month: "long", - day: "2-digit", - hour: "2-digit", - minute: "2-digit", - })}{" "} - ({timeDifference == 1 ? "one weekday ago" : timeDifference == 5 ? "one week ago" : "two weeks ago"}) - </div> - </div> - ); -}; - export default App; |