103 | )
104 | }
105 |
106 | export default LineGraph
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # COVID-19 Tracker with REACT JS
2 | ### 🔴 LIVE DEMO
3 |
4 | #### PREREQUISITES:
5 | - Install Node JS in your computer HERE
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
16 |
17 | ## Available Scripts
18 |
19 | ```
20 | npx create-react-app covid_tracker
21 | ```
22 |
23 | In the project directory, you can run:
24 | ```
25 | npm start
26 | ```
27 |
28 | Runs the app in the development mode.\
29 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
30 |
31 | The page will reload when you make changes.\
32 | You may also see any lint errors in the console.
33 | ```
34 | npm test
35 | ```
36 |
37 | Launches the test runner in the interactive watch mode.\
38 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
39 | ```
40 | npm run build
41 | ```
42 |
43 | Builds the app for production to the `build` folder.\
44 | It correctly bundles React in production mode and optimizes the build for the best performance.
45 |
46 | The build is minified and the filenames include the hashes.\
47 | Your app is ready to be deployed!
48 |
49 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
50 | ```
51 | npm run eject
52 | ```
53 |
54 | **Note: this is a one-way operation. Once you `eject`, you can't go back!**
55 |
56 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
57 |
58 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
59 |
60 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
61 |
62 |
63 | ## Available MATERIAL-UI Scripts
64 | MATERIAL-UI HERE
65 | ```
66 | npm install -f @material-ui/core
67 | ```
68 | ### 💻 Replit
69 |
70 |
71 |
72 | 
73 |
--------------------------------------------------------------------------------
/src/App.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from 'react';
2 | import './App.css';
3 | import {
4 | MenuItem,
5 | FormControl,
6 | Select,
7 | Card,
8 | CardContent,
9 | } from "@material-ui/core";
10 | import InfoBox from './components/InfoBox';
11 | import Map from './components/Map';
12 | import Table from './components/Table';
13 | import { prettyPrintStat, sortData } from './util';
14 | import LineGraph from './components/LineGraph';
15 | import "leaflet/dist/leaflet.css";
16 | import numeral from "numeral";
17 |
18 | const App = () => {
19 | const [country, setInputCountry] = useState("worldwide");
20 | const [countryInfo, setCountryInfo] = useState({});
21 | const [countries, setCountries] = useState([]);
22 | const [mapCountries, setMapCountries] = useState([]);
23 | const [tableData, setTableData] = useState([]);
24 | const [casesType, setCasesType] = useState("cases");
25 | const [mapCenter, setMapCenter] = useState({ lat: 34.80746, lng: -40.4796 });
26 | const [mapZoom, setMapZoom] = useState(3);
27 |
28 | useEffect(() => {
29 | fetch("https://disease.sh/v3/covid-19/all")
30 | .then((response) => response.json())
31 | .then((data) => {
32 | setCountryInfo(data);
33 | });
34 | }, []);
35 |
36 | useEffect(() => {
37 | const getCountriesData = async () => {
38 | fetch("https://disease.sh/v3/covid-19/countries")
39 | .then((response) => response.json())
40 | .then((data) => {
41 | const countries = data.map((country) => ({
42 | name: country.country,
43 | value: country.countryInfo.iso2,
44 | }));
45 | let sortedData = sortData(data);
46 | setCountries(countries);
47 | setMapCountries(data);
48 | setTableData(sortedData);
49 | });
50 | };
51 |
52 | getCountriesData();
53 | }, []);
54 |
55 | // console.log(casesType);
56 |
57 | const onCountryChange = async (e) => {
58 | const countryCode = e.target.value;
59 |
60 | const url =
61 | countryCode === "worldwide"
62 | ? "https://disease.sh/v3/covid-19/all"
63 | : `https://disease.sh/v3/covid-19/countries/${countryCode}`;
64 | await fetch(url)
65 | .then((response) => response.json())
66 | .then((data) => {
67 | setInputCountry(countryCode);
68 | setCountryInfo(data);
69 | setMapCenter([data.countryInfo.lat, data.countryInfo.long]);
70 | setMapZoom(4);
71 | });
72 | };
73 |
74 | return (
75 |