From 264e571b0ca34d24f4997c5864a43d4f475e14dc Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Wed, 13 Apr 2022 19:10:44 -0400 Subject: full version 2 re-write --- src/App.js | 229 ------------------------------------------------------------- 1 file changed, 229 deletions(-) delete mode 100644 src/App.js (limited to 'src/App.js') diff --git a/src/App.js b/src/App.js deleted file mode 100644 index 3edd599..0000000 --- a/src/App.js +++ /dev/null @@ -1,229 +0,0 @@ -import React from "react"; -import useSWR from "swr"; -import { DateTime } from "luxon"; -import { BrowserRouter, Route, Switch, Link } from "react-router-dom"; -import MainPage from "./MainPage"; -import History from "./History"; -import HistoryTable from "./HistoryTable"; -import "./App.css"; - -const url = "https://ritcoviddashboard.com/api/v0/history"; - -function App() { - let { data: rawData, error: error } = useSWR(url); - - const [timeDifference, setTimeDifference] = React.useState(1); - const [showAllTime, setShowAllTime] = React.useState(false); - - if (error) - return ( -
-

RIT Covid Dashboard

-

An error occurred

-
- ); - if (!rawData) - return ( -
-

RIT Covid Dashboard

-

Loading latest data...

-
- ); - - // rawData = rawData.slice(0, 177); - let data = rawData; - console.log(data.length); - const local = DateTime.local().zoneName; - const semesterStart = DateTime.fromISO("2021-01-01"); - // if (!showAllTime) { - // data = rawData.filter((d) => { - // let date = DateTime.fromSQL(d.last_updated, { zone: "UTC" }).setZone(local); - // return date > semesterStart; - // }); - // const last = rawData[rawData.length - data.length - 1]; - // data = data.map((d) => { - // return { - // alert_level: d.alert_level, - // beds_available: d.beds_available, - // isolation_off_campus: d.isolation_off_campus, - // isolation_on_campus: d.isolation_on_campus, - // last_updated: d.last_updated, - // new_staff: d.new_staff, - // new_students: d.new_students, - // quarantine_off_campus: d.quarantine_off_campus, - // quarantine_on_campus: d.quarantine_on_campus, - // tests_administered: d.tests_administered - last.tests_administered, - // total_staff: d.total_staff - last.total_staff, - // total_students: d.total_students - last.total_students, - // }; - // }); - // } - - const latest = data[data.length - 1]; - const prior = data[data.length - (1 + timeDifference)]; - const lastUpdate = DateTime.fromSQL(latest.last_updated).setZone(local); - const priorUpdate = DateTime.fromSQL(prior.last_updated).setZone(local); - // let positiveCases = []; - // for (let i = 5; i < data.length; i++) { - // positiveCases.push({ - // date: data[i].last_updated, - // value: ( - // ((data[i].total_students - data[i - 5].total_students) * 100) / - // (data[i].tests_administered - data[i - 5].tests_administered) - // ).toFixed(1), - // }); - // } - // positiveCases = positiveCases.filter((o) => o.value > 0 && o.value <= 100); - return ( - -
-

- RIT Covid Dashboard -

-

- 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 day ago" : timeDifference == 5 ? "one week ago" : "two weeks ago"}) -

- {/* -   - */} -
- - - - - - { - return { value: d.total_students, date: d.last_updated }; - })} - /> - - - { - return { value: d.total_staff, date: d.last_updated }; - })} - /> - - - { - return { value: d.new_students, date: d.last_updated }; - })} - /> - - - { - return { value: d.new_staff, date: d.last_updated }; - })} - /> - - {/* - { - return { value: d.quarantine_on_campus, date: d.last_updated }; - })} - /> - - - { - return { value: d.quarantine_off_campus, date: d.last_updated }; - })} - /> - - - - { - return { value: d.isolation_on_campus, date: d.last_updated }; - })} - /> - - - { - return { value: d.isolation_off_campus, date: d.last_updated }; - })} - /> - - - { - return { value: d.tests_administered, date: d.last_updated }; - })} - /> - - - - - - { - return { value: d.beds_available, date: d.last_updated }; - })} - /> - */} - -
-

- By Galen Guyer. Source available on{" "} - - GitHub - {" "} - ( - - Report Issue - - ) -

-

- - API Documentation - -

-
-
- ); -} - -export default App; -- cgit v1.2.3