import useSWR from "swr"; import { DateTime } from "luxon"; import { BrowserRouter, Route, Switch } from "react-router-dom"; import MainPage from "./MainPage"; import History from "./History"; import "./App.css"; const url = "https://rcpoller.galenguyer.com/api/v0/history"; function App() { const { data: data, error: error } = useSWR(url); if (error) return (

RIT Covid Dashboard

An error occurred

); if (!data) return (

RIT Covid Dashboard

Loading latest data...

); const latest = data[data.length - 1]; const prior = data[data.length - 2]; const local = DateTime.local().zoneName; const lastUpdate = DateTime.fromSQL(latest.last_updated, { zone: "UTC" }).setZone(local); return (

RIT Covid Dashboard

Last Updated:{" "} {lastUpdate.toLocaleString({ weekday: "long", month: "long", day: "2-digit", hour: "2-digit", minute: "2-digit", })}



{" "} { return { value: d.total_students, date: d.last_updated }; })} />
); } export default App;