From 071632e2bee59d64b4d196ed3512af7f24c6b994 Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Mon, 16 Nov 2020 20:17:14 -0500 Subject: add positiveTests table --- src/App.js | 17 ++++++++++++++++- src/HistoryTable.js | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/HistoryTable.js diff --git a/src/App.js b/src/App.js index fbee2c1..77d9a41 100644 --- a/src/App.js +++ b/src/App.js @@ -4,6 +4,7 @@ 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"; @@ -33,7 +34,18 @@ function App() { const local = DateTime.local().zoneName; const lastUpdate = DateTime.fromSQL(latest.last_updated, { zone: "UTC" }).setZone(local); const priorUpdate = DateTime.fromSQL(prior.last_updated, { zone: "UTC" }).setZone(local); - + let positiveCases = []; + for (let i = 1; i < data.length; i++) { + positiveCases.push({ + date: data[i].last_updated, + value: ( + ((data[i].total_students - data[i - 1].total_students) * 100) / + (data[i].tests_administered - data[i - 1].tests_administered) + ).toFixed(1), + }); + } + positiveCases = positiveCases.filter((o) => o.value > 0 && o.value <= 100); + console.log(positiveCases); return (
@@ -145,6 +157,9 @@ function App() { })} /> + + + { + const data = props.data; + console.log(data); + let table = ( + + + + + + + {data.map((element) => { + return ( + + + + + ); + })} + +
DatePositive Case Rate
+ {DateTime.fromSQL(element.date, { zone: "UTC" }) + .setZone(DateTime.local().zoneName) + .toLocaleString({ weekday: "long", month: "long", day: "2-digit" })} + {element.value}%
+ ); + + return ( + <> +

{props.name}

+ {table} + + + ); +}; + +export default HistoryTable; -- cgit v1.2.3