Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 20 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const App = () => {
const [tableData, setTableData] = useState([]);
const [casesType, setCasesType] = useState("cases");
const [mapCenter, setMapCenter] = useState({ lat: 34.80746, lng: -40.4796 });
const [mapZoom, setMapZoom] = useState(3);
const [mapZoom, setMapZoom] = useState(2);

useEffect(() => {
fetch("https://disease.sh/v3/covid-19/all")
Expand Down Expand Up @@ -66,8 +66,23 @@ const App = () => {
.then((data) => {
setInputCountry(countryCode);
setCountryInfo(data);
setMapCenter([data.countryInfo.lat, data.countryInfo.long]);
setMapZoom(4);
console.log("Country data: ",data);

if(countryCode === "worldwide"){
setMapCenter({ lat: 34.80746, lng: -40.4796 });
setMapZoom(2);
}
else{
setMapCenter([data.countryInfo.lat, data.countryInfo.long]);
setMapZoom(4);
}
// countryCode === "worldwide" ? (
// setMapCenter({ lat: 34.80746, lng: -40.4796 });
// setMapZoom(3);
// ) : (
// setMapCenter([data.countryInfo.lat, data.countryInfo.long]);
// setMapZoom(4);
// )
});
};

Expand All @@ -83,8 +98,8 @@ const App = () => {
onChange={onCountryChange}
>
<MenuItem value="worldwide">Worldwide</MenuItem>
{countries.map((country) => (
<MenuItem value={country.value}>{country.name}</MenuItem>
{countries.map((country,i) => (
<MenuItem key = {i} value={country.value}>{country.name}</MenuItem>
))}
</Select>
</FormControl>
Expand Down
4 changes: 2 additions & 2 deletions src/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import numeral from "numeral";
function Table({ countries }) {
return (
<div className="table">
{countries.map((country) => (
<tr>
{countries.map((country,i) => (
<tr key ={i}>
<td>{country.country}</td>
<td>
<strong>{numeral(country.cases).format("0,0")}</strong>
Expand Down
3 changes: 2 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ export const prettyPrintStat = (stat) =>
stat ? `+${numeral(stat).format("0.0a")}` : "+0";

export const showDataOnMap = (data, casesType = "cases") =>
data.map((country) => (
data.map((country,i) => (
<Circle
key = {i}
center={[country.countryInfo.lat, country.countryInfo.long]}
color={casesTypeColors[casesType].hex}
fillColor={casesTypeColors[casesType].hex}
Expand Down