Skip to content

Commit

Permalink
chore: update data stats API endpoint, refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
thepsalmist committed Oct 29, 2024
1 parent 309756e commit c810498
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ const CITIES_LOCATION = {
};

const API_TOKEN = process.env.NEXT_PUBLIC_APP_API_TOKEN;
const API_BASE_URL = process.env.NEXT_PUBLIC_APP_API_BASE_UR;
const API_BASE_URL = process.env.NEXT_PUBLIC_APP_API_BASE_URL;

const API = {
getAirData(city) {
return fetch(`${API_BASE_URL}/data/air/?city=${city}`, {
return fetch(`${API_BASE_URL}/data/stats/air/?city=${city}`, {
headers: {
Authorization: `Token ${API_TOKEN}`,
"Content-Type": "application/json",
Expand All @@ -193,7 +193,7 @@ const API = {
.toISOString()
.substring(0, 10);
return fetch(
`${API_BASE_URL}/data/air/?city=${city}&from=${fromDate}&interval=day&value_type=P2`,
`${API_BASE_URL}/data/stats/air/?city=${city}&from=${fromDate}&interval=day&value_type=P2`,
{
headers: {
Authorization: `Token ${API_TOKEN}`,
Expand Down
4 changes: 3 additions & 1 deletion src/components/Embeds/AirMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import React from "react";
import { CITIES_LOCATION } from "api";

function AirMap({ city }) {
const appMapUrl = process.env.NEXT_PUBLIC_APP_MAP_URL;

return (
<iframe
src={`https://v2.map.aq.sensors.africa/#${CITIES_LOCATION[city].zoom}/${CITIES_LOCATION[city].latitude}/${CITIES_LOCATION[city].longitude}`}
src={`${appMapUrl}/#${CITIES_LOCATION[city].zoom}/${CITIES_LOCATION[city].latitude}/${CITIES_LOCATION[city].longitude}`}
name={`sensors-map-${CITIES_LOCATION[city].slug}`}
title={`sensors.AFRICA | ${CITIES_LOCATION[city].name} Sensor Map`}
scrolling="no"
Expand Down
4 changes: 3 additions & 1 deletion src/components/SensorMap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const useStyles = makeStyles((theme) => ({

function Map({ zoom, latitude, longitude }) {
const classes = useStyles();
const appMapUrl = process.env.NEXT_PUBLIC_APP_MAP_URL;

return (
<Grid
container
Expand All @@ -43,7 +45,7 @@ function Map({ zoom, latitude, longitude }) {
<Grid item xs={12}>
<IframeComponent
title="Map section"
src={`//v2.map.aq.sensors.africa/#${zoom}/${latitude}/${longitude}`}
src={`${appMapUrl}/#${zoom}/${latitude}/${longitude}`}
height="500"
width="100%"
frameBorder="0"
Expand Down

0 comments on commit c810498

Please sign in to comment.