Skip to content
Merged
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
Change api endpoint
  • Loading branch information
PrinceSumberia committed Aug 26, 2021
commit c797747a7ab4f5be01080022212eff80aa9bc6ed
9 changes: 5 additions & 4 deletions src/components/CovidApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,20 @@ class CovidApp extends Component {

async fetchData() {
this.setState({ isLoading: !this.state.isLoading });
const countryData = axios.get('https://api.covid19india.org/data.json');
const countryData = axios.get('https://data.covid19india.org/data.json');
const districtLevel = axios.get(
'https://api.covid19india.org/v2/state_district_wise.json'
'https://data.covid19india.org/v2/state_district_wise.json'
);
const stateChanges = axios.get(
'https://api.covid19india.org/states_daily.json'
'https://data.covid19india.org/states_daily.json'
);
const updates = axios.get(
'https://api.covid19india.org/updatelog/log.json'
'https://data.covid19india.org/updatelog/log.json'
);

axios.all([countryData, districtLevel, stateChanges, updates]).then(
axios.spread((...responses) => {
console.log(responses);
const countryData = responses[0].data;
const districtLevel = responses[1].data;
const updates = responses[3].data;
Expand Down
46 changes: 23 additions & 23 deletions src/components/Help.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import React, { Component } from "react";
import axios from "axios";
import FadeIn from "react-fade-in";
import { withStyles } from "@material-ui/styles";
import { faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React, { Component } from 'react';
import axios from 'axios';
import FadeIn from 'react-fade-in';
import { withStyles } from '@material-ui/styles';
import { faExternalLinkAlt } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import Form from "./Form";
import Placeholder from "./Placeholder";
import Form from './Form';
import Placeholder from './Placeholder';

import styles from "../styles/HelpStyles";
import styles from '../styles/HelpStyles';

class Help extends Component {
constructor(props) {
super(props);
this.state = {
query: "",
query: '',
data: {},
currentResources: [],
loadingStatus: null,
Expand All @@ -31,21 +31,21 @@ class Help extends Component {
async fetchResources() {
try {
const [response] = await Promise.all([
axios.get("https://api.covid19india.org/resources/resources.json"),
axios.get('https://data.covid19india.org/resources/resources.json'),
]);
const hashmap = {};
response.data.resources.forEach((x) => {
if (typeof hashmap[x["state"]] === "undefined")
hashmap[x["state"]] = {};
if (typeof hashmap[x["state"]][x["city"]] === "undefined")
hashmap[x["state"]][x["city"]] = {};
if (typeof hashmap[x['state']] === 'undefined')
hashmap[x['state']] = {};
if (typeof hashmap[x['state']][x['city']] === 'undefined')
hashmap[x['state']][x['city']] = {};

if (
typeof hashmap[x["state"]][x["city"]][x["category"]] === "undefined"
typeof hashmap[x['state']][x['city']][x['category']] === 'undefined'
)
hashmap[x["state"]][x["city"]][x["category"]] = [];
if (Array.isArray(hashmap[x["state"]][x["city"]][x["category"]]))
hashmap[x["state"]][x["city"]][x["category"]].push(x);
hashmap[x['state']][x['city']][x['category']] = [];
if (Array.isArray(hashmap[x['state']][x['city']][x['category']]))
hashmap[x['state']][x['city']][x['category']].push(x);
});
this.setState({ data: hashmap });
} catch (err) {}
Expand All @@ -56,7 +56,7 @@ class Help extends Component {
}

handleLoading() {
this.setState({ loadingStatus: "loading" });
this.setState({ loadingStatus: 'loading' });
}

getData() {
Expand All @@ -73,7 +73,7 @@ class Help extends Component {
}
}
this.setState({ currentResources: resources });
setTimeout(() => this.setState({ loadingStatus: "completeLoading" }), 2000);
setTimeout(() => this.setState({ loadingStatus: 'completeLoading' }), 2000);
}

render() {
Expand Down Expand Up @@ -128,14 +128,14 @@ class Help extends Component {
handleQuery={this.handleQuery}
handleLoading={this.handleLoading}
/>
{this.state.loadingStatus === "loading" && (
{this.state.loadingStatus === 'loading' && (
<div className={classes.container}>
<Placeholder />
<Placeholder />
<Placeholder />
</div>
)}
{this.state.loadingStatus === "completeLoading" && (
{this.state.loadingStatus === 'completeLoading' && (
<div className={classes.container}>{res}</div>
)}
</div>
Expand Down