1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
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 (
<div className="App">
<header>
<Link to="/">
<h1>2020-2021 RIT COVID Dashboard</h1>
</Link>
</header>
<Routes>
<Route
path="/totalstudents"
element={
<Suspense fallback={null}>
<Graph
name={"Total Student Cases"}
response={response}
dataKey={"total_students"}
timeDifference={timeDifference}
/>
</Suspense>
}
></Route>
<Route
path="/totalstaff"
element={
<Suspense fallback={null}>
<Graph
name={"Total Staff Cases"}
response={response}
dataKey={"total_staff"}
timeDifference={timeDifference}
/>
</Suspense>
}
></Route>
<Route
path="/newstudents"
element={
<Suspense fallback={null}>
<Graph
name={"New Student Cases"}
response={response}
dataKey={"new_students"}
timeDifference={timeDifference}
/>
</Suspense>
}
></Route>
<Route
path="/newstaff"
element={
<Suspense fallback={null}>
<Graph
name={"New Staff Cases"}
response={response}
dataKey={"new_staff"}
timeDifference={timeDifference}
/>
</Suspense>
}
></Route>
<Route
path="/quarantineoncampus"
element={
<Suspense fallback={null}>
<Graph name={"Quarantine On Campus"} response={response} dataKey={"quarantine_on_campus"} />
</Suspense>
}
></Route>
<Route
path="/quarantineoffcampus"
element={
<Suspense fallback={null}>
<Graph
name={"Quarantine Off Campus"}
response={response}
dataKey={"quarantine_off_campus"}
/>
</Suspense>
}
></Route>
<Route
path="/isolationoncampus"
element={
<Suspense fallback={null}>
<Graph name={"Isolation On Campus"} response={response} dataKey={"isolation_on_campus"} />
</Suspense>
}
></Route>
<Route
path="/isolationoffcampus"
element={
<Suspense fallback={null}>
<Graph name={"Isolation Off Campus"} response={response} dataKey={"isolation_off_campus"} />
</Suspense>
}
></Route>
<Route
path="/tests"
element={
<Suspense fallback={null}>
<Graph name={"Tests Administered"} response={response} dataKey={"tests_administered"} />
</Suspense>
}
></Route>
<Route
path="/beds"
element={
<Suspense fallback={null}>
<Graph name={"Quarantine/Isolation Bed Availability On-campus"} response={response} dataKey={"beds_available"} />
</Suspense>
}
></Route>
<Route
exact
path="/"
element={
<Suspense fallback={null}>
<Index response={response} timeDifference={timeDifference} />
</Suspense>
}
/>
</Routes>
<footer>
<p>
By Galen Guyer. Source available on{" "}
<a className="BlueLink" href="https://github.com/galenguyer/rit-covid-dashboard">
GitHub
</a>{" "}
(
<a className="BlueLink" href="https://github.com/galenguyer/rit-covid-dashboard/issues">
Report Issue
</a>
)
</p>
<p>
<a className="BlueLink" href="https://galenguyer.com/projects/ritcoviddashboard">
API Documentation
</a>
</p>
</footer>
<script data-goatcounter="https://rcd.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script>
</div>
);
};
const Updated = (props) => {
const { loading, lastUpdate, priorUpdate, timeDifference } = props;
if (loading) {
return <div></div>;
}
return (
<div className="Updated">
<div className="Latest">
Last Updated:{" "}
{lastUpdate.toLocaleString({
weekday: "long",
month: "long",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
})}
</div>
<div className="Prior">
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"})
</div>
</div>
);
};
export default App;
|