From 156bc7c658ab56f6607189e3f5cba66d00a90802 Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Mon, 16 Nov 2020 19:15:54 -0500 Subject: move all calculation logic into MainPage --- src/Card.js | 13 ++++++------- src/MainPage.js | 37 ++++++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/Card.js b/src/Card.js index a296681..cac335c 100644 --- a/src/Card.js +++ b/src/Card.js @@ -3,21 +3,20 @@ import { Link } from "react-router-dom"; import "./Card.css"; const Card = (props) => { - let diff = props.latest - props.prior; - if (diff >= 0) { - diff = "+" + diff.toString(); + let diff = props.diff.toString(); + if (diff.charAt(0) != "-") { + diff = "+" + diff; } + return (

- {props.latest} - {props.suffix}{" "} + {props.latest}{" "} - ({diff} - {props.suffix}) + ({diff})

{props.name}

diff --git a/src/MainPage.js b/src/MainPage.js index 7dd0cc9..f00db6a 100644 --- a/src/MainPage.js +++ b/src/MainPage.js @@ -22,18 +22,33 @@ const MainPage = (props) => { - +

New Positive Cases From Past 14 Days

- - + +

@@ -47,13 +62,13 @@ const MainPage = (props) => { @@ -68,13 +83,13 @@ const MainPage = (props) => { @@ -86,7 +101,7 @@ const MainPage = (props) => { @@ -97,8 +112,8 @@ const MainPage = (props) => {
-- cgit v1.2.3