Skip to content

Commit

Permalink
moved urls from .env
Browse files Browse the repository at this point in the history
  • Loading branch information
AKATWIJUKA-ELIA committed Mar 5, 2025
1 parent 451ce1d commit 52389a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/netmanager-app/core/apis/MapData.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import axios from "axios";
const AirQuoData = process.env.NEXT_PUBLIC_AIRQUO_DATA
const SUGGESTIONS = process.env.NEXT_PUBLIC_SUGGESTIONS
const SEARCH = process.env.NEXT_PUBLIC_SEARCH
export const token = process.env.NEXT_PUBLIC_MAP_API_TOKEN
export const AirQoToken = process.env.NEXT_PUBLIC_AIRQO_DATA_TOKEN
import {AIRQUO_DATA,MAP_BOX_SUGGESTIONS,MAP_BOX_SEARCH} from "../urls"
import Node from '@/public/images/map/Node.webp';
import Emoji from '@/public/images/map/Emoji.webp';
import Heatmap from '@/public/images/map/Heatmap.webp';
Expand All @@ -18,7 +16,7 @@ import StreetsMode from '@/public/images/map/street.webp';
export const GetAirQuoData = async (token: string) =>{
try {
if(token){
const response = await axios.get(`${AirQuoData}?token=${token}`);
const response = await axios.get(`${AIRQUO_DATA}?token=${token}`);
const data = response.data;
return data;
}
Expand All @@ -43,7 +41,7 @@ export const FetchSuggestions=async(value:string,access_token:string,sessionTok
if (latitude !== undefined && longitude !== undefined) {
try{
const proximityParam = `${longitude},${latitude}`;
const response = await axios.get(`${SUGGESTIONS}?q=${value.toLowerCase()}&access_token=${access_token}&proximity=${proximityParam}&session_token=${sessionToken}`)
const response = await axios.get(`${MAP_BOX_SUGGESTIONS}?q=${value.toLowerCase()}&access_token=${access_token}&proximity=${proximityParam}&session_token=${sessionToken}`)
const data = await response.data;

console.log("data :",data.suggestions)
Expand All @@ -64,7 +62,7 @@ export const UserClick = async(access_token:string,sessionToken:string,locationi
return;
}

const response = await axios.get((`${SEARCH}/${locationid}?&access_token=${access_token}&session_token=${sessionToken}`))
const response = await axios.get((`${MAP_BOX_SEARCH}/${locationid}?&access_token=${access_token}&session_token=${sessionToken}`))
const data = response.data;
if(data){
return data;
Expand Down Expand Up @@ -115,7 +113,7 @@ export const mapStyles = [
export const UserGroups = async (token: string) =>{
try {
if(token){
const response = await axios.get(`${AirQuoData}?token=${token}`);
const response = await axios.get(`${AIRQUO_DATA}?token=${token}`);
const data = response.data;
return data;
}
Expand Down
6 changes: 6 additions & 0 deletions src/netmanager-app/core/urls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ import { stripTrailingSlash } from "@/lib/utils";
export const BASE_API_URL = stripTrailingSlash(
process.env.NEXT_PUBLIC_API_URL || ""
);
export const MAP_BOX_BASE_API_URL = stripTrailingSlash(
process.env.NEXT_PUBLIC_MAPBOX_URL || ""
);
export const USERS_MGT_URL = `${BASE_API_URL}/users`;
export const DEVICES_MGT_URL = `${BASE_API_URL}/devices`;
export const SITES_MGT_URL = `${BASE_API_URL}/devices/sites`;
export const ANALYTICS_MGT_URL = `${BASE_API_URL}/analytics`;
export const EXCEEDANCES_DATA_URI = `${ANALYTICS_MGT_URL}/exceedances`;
export const DEVICE_EXCEEDANCES_URI = `${ANALYTICS_MGT_URL}/dashboard/exceedances-devices`;
export const AIRQUO_DATA = `${DEVICES_MGT_URL}/readings/map`;
export const MAP_BOX_SUGGESTIONS = `${MAP_BOX_BASE_API_URL}/search/searchbox/v1/suggest`;
export const MAP_BOX_SEARCH = `${MAP_BOX_BASE_API_URL}/search/searchbox/v1/retrieve`;

0 comments on commit 52389a0

Please sign in to comment.