diff --git a/src/App.js b/src/App.js index ad37cfa..0cf258a 100644 --- a/src/App.js +++ b/src/App.js @@ -4,7 +4,7 @@ import Table from "./components/table"; import Counter from "./components/counter"; import Charts from "./components/charts"; import axios from "axios"; -import lang from "./components/lang"; +import { lang } from "./constants"; import { hot } from "react-hot-loader"; function App() { @@ -52,8 +52,19 @@ function App() { "https://keralastats.coronasafe.live/zones.json" ); let zones = response.data.districts; - let hotspots = {}; - Object.keys(dist.summary); + response = await axios.get( + "https://keralastats.coronasafe.live/hotspots.json" + ); + let k1 = "district"; + let k2 = "lsgd"; + let hpts = response.data.hotspots.reduce( + (a, b) => ({ + ...a, + [b[k1]]: a[b[k1]] ? a[b[k1]].concat(b[k2]) : [b[k2]], + }), + {} + ); + setHotspots(hpts); setChartData(tmp); setMaxActive(mx); setHistory(hist); diff --git a/src/components/chart.js b/src/components/chart.js index 67b34e3..2fe827a 100644 --- a/src/components/chart.js +++ b/src/components/chart.js @@ -8,7 +8,7 @@ import { Legend, ResponsiveContainer, } from "recharts"; -import lang from "./lang"; +import { lang } from "../constants"; function Chart({ data, dataKey, stroke }) { const CustomizedXAxisTick = ({ x, y, payload }) => { diff --git a/src/components/counter.js b/src/components/counter.js index 90d2495..9323fa9 100644 --- a/src/components/counter.js +++ b/src/components/counter.js @@ -1,21 +1,14 @@ import React from "react"; -import lang from "./lang"; +import { lang, statColor } from "../constants"; function Counter({ data }) { - const topBox = { - confirmed: "bg-red-500", - active: "bg-yellow-500", - recovered: "bg-green-500", - deceased: "bg-gray-500", - }; - return (
diff --git a/src/components/lang.js b/src/components/lang.js deleted file mode 100644 index 398ddb8..0000000 --- a/src/components/lang.js +++ /dev/null @@ -1,13 +0,0 @@ -const lang = { - district: "District", - confirmed: "Confirmed", - active: "Active", - recovered: "Recovered", - deceased: "Deaths", - total_obs: "Under Observation", - hospital_obs: "Hospital Isolation", - home_obs: "Home Isolation", - hospital_today: "Hospitalized Today", -}; - -export default lang; diff --git a/src/components/map.js b/src/components/map.js index 54693cb..521de78 100644 --- a/src/components/map.js +++ b/src/components/map.js @@ -2,7 +2,7 @@ import React, { useState, useEffect, useCallback, useRef } from "react"; import * as d3 from "d3"; import { legendColor } from "d3-svg-legend"; import * as topojson from "topojson"; -import lang from "./lang"; +import { lang, zoneColor } from "../constants"; import { useWindowWidth } from "@react-hook/window-size/throttled"; function Map({ districts, summary, maxActive, zones }) { @@ -13,12 +13,6 @@ function Map({ districts, summary, maxActive, zones }) { const [legendPos, setLegendPos] = useState(0); const width = useWindowWidth(450, { fps: 30, leading: true, wait: 0 }); const map = useRef(null); - const color = { - containment: "text-blue-600", - red: "text-red-600", - orange: "text-orange-600", - green: "text-green-600", - }; useEffect(() => { if (renderData) { @@ -214,7 +208,7 @@ function Map({ districts, summary, maxActive, zones }) {
Zone