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") ?? "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 (