From e9b9cd2cd88e453a3a35cf3f672ba965660b9ff2 Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Wed, 31 Aug 2022 12:31:25 -0400 Subject: Update the dashboard with a message about the lack of any dashboards --- src/App.jsx | 140 ++---------------------------------------------------------- 1 file changed, 3 insertions(+), 137 deletions(-) (limited to 'src/App.jsx') 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 (

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