From 935ef7d2f76cca7bc1f9840dc357de85f93a1ec2 Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Mon, 11 Jul 2022 17:10:23 -0400 Subject: Update for new dashboard frontend --- src/App.jsx | 205 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 src/App.jsx (limited to 'src/App.jsx') diff --git a/src/App.jsx b/src/App.jsx new file mode 100644 index 0000000..7f1f9c3 --- /dev/null +++ b/src/App.jsx @@ -0,0 +1,205 @@ +import { useLocation, Routes, Route, Link } from "react-router-dom"; +import { useState, lazy, Suspense } from "react"; +import useFetch from "./useFetch"; +import { DateTime } from "luxon"; +import "./App.css"; +const Index = lazy(() => import("./pages/Index")); +const Graph = lazy(() => import("./pages/Graph")); +import { useEffect } from "react"; + +const App = () => { + const url = localStorage.getItem("url") ?? "/data.json"; + + 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); + + return ( +
+
+ +

2020-2021 RIT COVID Dashboard

+ +
+ + + + + } + > + + + + } + > + + + + } + > + + + + } + > + + + + } + > + + + + } + > + + + + + } + > + + + + } + > + + + + } + > + + + + } + > + + + + + } + /> + + + +
+ ); +}; + +const Updated = (props) => { + const { loading, lastUpdate, priorUpdate, timeDifference } = props; + if (loading) { + return
; + } + + return ( +
+
+ Last Updated:{" "} + {lastUpdate.toLocaleString({ + weekday: "long", + month: "long", + day: "2-digit", + hour: "2-digit", + minute: "2-digit", + })} +
+
+ 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"}) +
+
+ ); +}; + +export default App; -- cgit v1.2.3