@@ -12,97 +12,109 @@ class Overview extends Component {
1212 dataChanges : { } ,
1313 isLoading : false ,
1414 } ;
15- this . calculateChange = this . calculateChange . bind ( this ) ;
16- this . getData = this . getData . bind ( this ) ;
17- this . setData = this . setData . bind ( this ) ;
15+ // this.calculateChange = this.calculateChange.bind(this);
16+ // this.getData = this.getData.bind(this);
17+ // this.setData = this.setData.bind(this);
1818 }
1919
20- componentDidMount ( ) {
21- this . getData ( this . props . data ) ;
22- }
20+ // componentDidMount() {
21+ // this.getData(this.props.data);
22+ // }
2323
24- setData ( ) {
25- this . getData ( ) ;
26- }
24+ // setData() {
25+ // this.getData();
26+ // }
2727
28- getData ( propsData ) {
29- const data = propsData . slice ( - 2 ) ;
30- try {
31- const previousDay = data [ 0 ] . summary ;
32- const currentDay = data [ 1 ] . summary ;
33- this . setState (
34- {
35- previousDay : {
36- confirmed : previousDay . total ,
37- recovered : previousDay . discharged ,
38- deaths : previousDay . deaths ,
39- activeCases :
40- previousDay . total - ( previousDay . discharged + previousDay . deaths ) ,
41- } ,
42- currentDay : {
43- confirmed : currentDay . total ,
44- recovered : currentDay . discharged ,
45- deaths : currentDay . deaths ,
46- activeCases :
47- currentDay . total - ( currentDay . discharged + currentDay . deaths ) ,
48- } ,
49- } ,
50- this . calculateChange
51- ) ;
52- } catch { }
53- }
28+ // getData(propsData) {
29+ // const data = propsData.slice(-2);
30+ // try {
31+ // const previousDay = data[0].summary;
32+ // const currentDay = data[1].summary;
33+ // this.setState(
34+ // {
35+ // previousDay: {
36+ // confirmed: previousDay.total,
37+ // recovered: previousDay.discharged,
38+ // deaths: previousDay.deaths,
39+ // activeCases:
40+ // previousDay.total - (previousDay.discharged + previousDay.deaths),
41+ // },
42+ // currentDay: {
43+ // confirmed: currentDay.total,
44+ // recovered: currentDay.discharged,
45+ // deaths: currentDay.deaths,
46+ // activeCases:
47+ // currentDay.total - (currentDay.discharged + currentDay.deaths),
48+ // },
49+ // },
50+ // this.calculateChange
51+ // );
52+ // } catch {}
53+ // }
5454
55- calculateChange ( ) {
56- const { previousDay, currentDay } = this . state ;
57- let newObj = Object . keys ( currentDay ) . reduce ( ( a , k ) => {
58- a [ k ] = currentDay [ k ] - previousDay [ k ] ;
59- return a ;
60- } , { } ) ;
61- const newState = {
62- ...this . state ,
63- dataChanges : newObj ,
64- } ;
65- this . setState ( {
66- ...newState ,
67- } ) ;
68- }
55+ // calculateChange() {
56+ // const { previousDay, currentDay } = this.state;
57+ // let newObj = Object.keys(currentDay).reduce((a, k) => {
58+ // a[k] = currentDay[k] - previousDay[k];
59+ // return a;
60+ // }, {});
61+ // const newState = {
62+ // ...this.state,
63+ // dataChanges: newObj,
64+ // };
65+ // this.setState({
66+ // ...newState,
67+ // });
68+ // }
69+
70+ // dailyconfirmed: "1902";
71+ // dailydeceased: "69";
72+ // dailyrecovered: "610";
73+ // date: "28 April ";
74+ // totalconfirmed: "31360";
75+ // totaldeceased: "1008";
76+ // totalrecovered: "7747";
6977
7078 render ( ) {
7179 const { confirmed, recovered, deaths, activeCases } = this . state . currentDay ;
7280 const dataChange = this . state . dataChanges ;
7381 const { classes, isDarkMode } = this . props ;
82+ const { totalconfirmed, totaldeceased, totalrecovered } = this . props . data ;
83+
84+ const active =
85+ Number ( totalconfirmed ) - ( Number ( totaldeceased ) + Number ( totalrecovered ) ) ;
7486
7587 return (
7688 < div className = { classes . root } >
7789 < div className = { classes . panels } >
7890 < div className = { classes . panelContainer } >
7991 < DisplayPanels
8092 title = "Confirmed"
81- number = { confirmed }
93+ number = { totalconfirmed }
8294 isDarkMode = { isDarkMode }
8395 dataChange = { dataChange . confirmed }
8496 />
8597 </ div >
8698 < div className = { classes . panelContainer } >
8799 < DisplayPanels
88100 title = "Active"
89- number = { activeCases }
101+ number = { active }
90102 isDarkMode = { isDarkMode }
91103 dataChange = { dataChange . activeCases }
92104 />
93105 </ div >
94106 < div className = { classes . panelContainer } >
95107 < DisplayPanels
96108 title = "Recovered"
97- number = { recovered }
109+ number = { totalrecovered }
98110 isDarkMode = { isDarkMode }
99111 dataChange = { dataChange . recovered }
100112 />
101113 </ div >
102114 < div className = { classes . panelContainer } >
103115 < DisplayPanels
104116 title = "Deceased"
105- number = { deaths }
117+ number = { totaldeceased }
106118 isDarkMode = { isDarkMode }
107119 dataChange = { dataChange . deaths }
108120 />
0 commit comments