blob: e7137a220abb1f301e057932210ddf2c1ff9f64a (
plain) (
blame)
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
|
import useSWR from "swr";
import Card from "./Card";
import "./App.css";
const url = "https://rcpoller.galenguyer.com/api/v0/history";
function App() {
const { data: data, error: error } = useSWR(url);
if (error)
return (
<div className="App">
<h1>RIT Covid Dashboard</h1>
<h2>An error occurred</h2>
</div>
);
if (!data)
return (
<div className="App">
<h1>RIT Covid Dashboard</h1>
<h2>Loading latest data...</h2>
</div>
);
const latest = data[data.length - 1];
const prior = data[data.length - 2];
return (
<div className="App">
<h1>RIT Covid Dashboard</h1>
<div className="Section">
<Card name="Total Student Cases" latest={latest.total_students} prior={prior.total_students} />
<Card name="Total Staff Cases" latest={latest.total_staff} prior={prior.total_staff} />
</div>
</div>
);
}
export default App;
|