diff --git a/src/pages/Search.jsx b/src/pages/Search.jsx index 043a1a557..de939cbdc 100644 --- a/src/pages/Search.jsx +++ b/src/pages/Search.jsx @@ -16,7 +16,7 @@ import GeoServerAPI from 'utils/geoServerAPI'; import matchColor from 'utils/matchColor'; import RestAPI from 'utils/restAPI'; import BackendStacAPI from 'utils/backendStacAPI'; -import SearchAPI from 'utils/searchAPI'; +import BackendAPI from 'utils/backendAPI'; import GradientLegend from 'pages/search/shared_components/GradientLegend'; import MapViewer from 'pages/search/MapViewer'; @@ -793,7 +793,7 @@ class Search extends Component { } else if (/portfoliosCA*/.test(layerName)) { const [,,portfolioId] = layerName.split("|", 3); reqPromise = () => - SearchAPI.requestPortfoliosCALayer( + BackendAPI.requestPortfoliosCALayer( selectedAreaTypeId, selectedAreaId, portfolioId diff --git a/src/pages/search/Drawer.tsx b/src/pages/search/Drawer.tsx index 7d467dbb0..3bed2453b 100644 --- a/src/pages/search/Drawer.tsx +++ b/src/pages/search/Drawer.tsx @@ -12,7 +12,7 @@ import Species from "pages/search/drawer/Species"; import Ecosystems from "pages/search/drawer/Ecosystems"; import Portfolios from "pages/search/drawer/Portfolios"; import formatNumber from "utils/format"; -import searchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import TabContainer from "pages/search/shared_components/TabContainer"; import { geofenceDetails } from "pages/search/types/drawer"; @@ -52,7 +52,7 @@ class Drawer extends React.Component { ); if (searchType !== "drawPolygon") { - searchAPI + BackendAPI .requestGeofenceDetails(areaId, geofenceId) .then((res: geofenceDetails) => { this.setState({ geofenceArea: Number(res.total_area) }); diff --git a/src/pages/search/drawer/Ecosystems.jsx b/src/pages/search/drawer/Ecosystems.jsx index 231fe2ea0..82cddbce5 100644 --- a/src/pages/search/drawer/Ecosystems.jsx +++ b/src/pages/search/drawer/Ecosystems.jsx @@ -16,7 +16,7 @@ import SearchContext from 'pages/search/SearchContext'; import formatNumber from 'utils/format'; import matchColor from 'utils/matchColor'; import RestAPI from 'utils/restAPI'; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import SmallStackedBar from 'pages/search/shared_components/charts/SmallStackedBar'; /** @@ -73,7 +73,7 @@ class Ecosystems extends React.Component { switchLayer('coverages'); - SearchAPI.requestCoverage(areaId, geofenceId) + BackendAPI.requestCoverage(areaId, geofenceId) .then((res) => { if (this.mounted) { this.setState((prev) => ({ @@ -94,7 +94,7 @@ class Ecosystems extends React.Component { })); }); - SearchAPI.requestProtectedAreas(areaId, geofenceId) + BackendAPI.requestProtectedAreas(areaId, geofenceId) .then((res) => { if (this.mounted) { if (Array.isArray(res) && res[0]) { @@ -128,7 +128,7 @@ class Ecosystems extends React.Component { })); }); - SearchAPI.requestStrategicEcosystems(areaId, geofenceId) + BackendAPI.requestStrategicEcosystems(areaId, geofenceId) .then((res) => { if (this.mounted) { if (Array.isArray(res)) { diff --git a/src/pages/search/drawer/ecosystems/ecosystemsBox/EcosystemDetails.tsx b/src/pages/search/drawer/ecosystems/ecosystemsBox/EcosystemDetails.tsx index 5c8bf5100..2a2b829fd 100644 --- a/src/pages/search/drawer/ecosystems/ecosystemsBox/EcosystemDetails.tsx +++ b/src/pages/search/drawer/ecosystems/ecosystemsBox/EcosystemDetails.tsx @@ -14,7 +14,7 @@ import { SEPADataExt, coverageLabels, } from "pages/search/types/ecosystems"; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import SmallStackedBar from "pages/search/shared_components/charts/SmallStackedBar"; import { wrapperMessage } from "pages/search/types/charts"; @@ -67,7 +67,7 @@ class EcosystemDetails extends React.Component { const { stopLoad } = this.state; if (!stopLoad) { - SearchAPI.requestSECoverageByGeofence(areaId, geofenceId, SEType) + BackendAPI.requestSECoverageByGeofence(areaId, geofenceId, SEType) .then((res) => { if (this.mounted) { this.setState((prev) => ({ @@ -88,7 +88,7 @@ class EcosystemDetails extends React.Component { })); }); - SearchAPI.requestSEPAByGeofence(areaId, geofenceId, SEType) + BackendAPI.requestSEPAByGeofence(areaId, geofenceId, SEType) .then((res) => { if (this.mounted) { this.setState((prev) => ({ diff --git a/src/pages/search/drawer/landscape/CompensationFactor.tsx b/src/pages/search/drawer/landscape/CompensationFactor.tsx index 3fc64db0e..23e1e2aff 100644 --- a/src/pages/search/drawer/landscape/CompensationFactor.tsx +++ b/src/pages/search/drawer/landscape/CompensationFactor.tsx @@ -5,7 +5,7 @@ import ShortInfo from "components/ShortInfo"; import { IconTooltip } from "pages/search/shared_components/Tooltips"; import matchColor from "utils/matchColor"; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import TextBoxes from "pages/search/shared_components/TextBoxes"; import SearchContext, { SearchContextValues } from "pages/search/SearchContext"; import { cfData } from "pages/search/types/compensationFactor"; @@ -71,7 +71,7 @@ class CompensationFactor extends React.Component< switchLayer("fc"); - SearchAPI.requestBiomes(areaId, geofenceId) + BackendAPI.requestBiomes(areaId, geofenceId) .then((res: Array) => { if (this.mounted) { this.setState((prev) => ({ @@ -95,7 +95,7 @@ class CompensationFactor extends React.Component< })); }); - SearchAPI.requestCompensationFactor(areaId, geofenceId) + BackendAPI.requestCompensationFactor(areaId, geofenceId) .then((res: Array) => { if (this.mounted) { this.setState((prev) => ({ @@ -119,7 +119,7 @@ class CompensationFactor extends React.Component< })); }); - SearchAPI.requestBioticUnits(areaId, geofenceId) + BackendAPI.requestBioticUnits(areaId, geofenceId) .then((res: Array) => { if (this.mounted) { this.setState((prev) => ({ @@ -145,7 +145,7 @@ class CompensationFactor extends React.Component< }); ["cf", "biomes", "bioticRegions"].forEach((item) => { - SearchAPI.requestSectionTexts(item) + BackendAPI.requestSectionTexts(item) .then((res) => { if (this.mounted) { this.setState((prevState) => ({ diff --git a/src/pages/search/drawer/landscape/connectivity/CurrentPAConnectivity.tsx b/src/pages/search/drawer/landscape/connectivity/CurrentPAConnectivity.tsx index afd484e38..4daea8c8b 100644 --- a/src/pages/search/drawer/landscape/connectivity/CurrentPAConnectivity.tsx +++ b/src/pages/search/drawer/landscape/connectivity/CurrentPAConnectivity.tsx @@ -6,7 +6,7 @@ import ShortInfo from "components/ShortInfo"; import { IconTooltip } from "pages/search/shared_components/Tooltips"; import SearchContext, { SearchContextValues } from "pages/search/SearchContext"; import matchColor from "utils/matchColor"; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import formatNumber from "utils/format"; import TextBoxes from "pages/search/shared_components/TextBoxes"; @@ -82,7 +82,7 @@ class CurrentPAConnectivity extends React.Component { switchLayer("currentPAConn"); - SearchAPI.requestCurrentPAConnectivity(areaId, geofenceId) + BackendAPI.requestCurrentPAConnectivity(areaId, geofenceId) .then((res: Array) => { if (this.mounted) { const protConn = res.find((item) => item.key === "prot_conn"); @@ -112,7 +112,7 @@ class CurrentPAConnectivity extends React.Component { })); }); - SearchAPI.requestDPC(areaId, geofenceId, 5) + BackendAPI.requestDPC(areaId, geofenceId, 5) .then((res: Array) => { if (this.mounted) { this.setState((prev) => ({ @@ -134,7 +134,7 @@ class CurrentPAConnectivity extends React.Component { }); ["paConnCurrent", "paConnDPC"].forEach((item) => { - SearchAPI.requestSectionTexts(item) + BackendAPI.requestSectionTexts(item) .then((res) => { if (this.mounted) { this.setState((prevState) => ({ diff --git a/src/pages/search/drawer/landscape/connectivity/CurrentSEPAConnectivity.tsx b/src/pages/search/drawer/landscape/connectivity/CurrentSEPAConnectivity.tsx index 777d01249..28c55b746 100644 --- a/src/pages/search/drawer/landscape/connectivity/CurrentSEPAConnectivity.tsx +++ b/src/pages/search/drawer/landscape/connectivity/CurrentSEPAConnectivity.tsx @@ -7,7 +7,7 @@ import { IconTooltip } from "pages/search/shared_components/Tooltips"; import SearchContext, { SearchContextValues } from "pages/search/SearchContext"; import formatNumber from "utils/format"; import matchColor from "utils/matchColor"; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import TextBoxes from "pages/search/shared_components/TextBoxes"; import { @@ -78,7 +78,7 @@ class CurrentSEPAConnectivity extends React.Component { switchLayer("currentSEPAConn"); - SearchAPI.requestCurrentSEPAConnectivity(areaId, geofenceId, "Páramo") + BackendAPI.requestCurrentSEPAConnectivity(areaId, geofenceId, "Páramo") .then((res: Array) => { if (this.mounted) { let protParamo = 0; @@ -109,7 +109,7 @@ class CurrentSEPAConnectivity extends React.Component { })); }); - SearchAPI.requestCurrentSEPAConnectivity( + BackendAPI.requestCurrentSEPAConnectivity( areaId, geofenceId, "Bosque Seco Tropical" @@ -144,7 +144,7 @@ class CurrentSEPAConnectivity extends React.Component { })); }); - SearchAPI.requestCurrentSEPAConnectivity(areaId, geofenceId, "Humedal") + BackendAPI.requestCurrentSEPAConnectivity(areaId, geofenceId, "Humedal") .then((res: Array) => { if (this.mounted) { let protWetland = 0; @@ -175,7 +175,7 @@ class CurrentSEPAConnectivity extends React.Component { })); }); - SearchAPI.requestSectionTexts("paConnSE") + BackendAPI.requestSectionTexts("paConnSE") .then((res) => { if (this.mounted) { this.setState({ texts: { paConnSE: res } }); diff --git a/src/pages/search/drawer/landscape/connectivity/TimelinePAConnectivity.tsx b/src/pages/search/drawer/landscape/connectivity/TimelinePAConnectivity.tsx index d918cb3ba..811881229 100644 --- a/src/pages/search/drawer/landscape/connectivity/TimelinePAConnectivity.tsx +++ b/src/pages/search/drawer/landscape/connectivity/TimelinePAConnectivity.tsx @@ -12,7 +12,7 @@ import { timeLinePAConnValues, } from "pages/search/types/connectivity"; import { textsObject } from "pages/search/types/texts"; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import Lines from "pages/search/shared_components/charts/Lines"; import { wrapperMessage } from "pages/search/types/charts"; @@ -60,8 +60,8 @@ class TimelinePAConnectivity extends React.Component< switchLayer("timelinePAConn"); Promise.all([ - SearchAPI.requestTimelinePAConnectivity(areaId, geofenceId, "prot"), - SearchAPI.requestTimelinePAConnectivity(areaId, geofenceId, "prot_conn"), + BackendAPI.requestTimelinePAConnectivity(areaId, geofenceId, "prot"), + BackendAPI.requestTimelinePAConnectivity(areaId, geofenceId, "prot_conn"), ]) .then((res) => { if (this.mounted) { @@ -82,7 +82,7 @@ class TimelinePAConnectivity extends React.Component< this.setState({ message: "no-data" }); }); - SearchAPI.requestSectionTexts("paConnTimeline") + BackendAPI.requestSectionTexts("paConnTimeline") .then((res: textsObject) => { if (this.mounted) { this.setState({ texts: { paConnTimeline: res } }); diff --git a/src/pages/search/drawer/landscape/forest/ForestIntegrity.tsx b/src/pages/search/drawer/landscape/forest/ForestIntegrity.tsx index e75732bd3..957aec724 100644 --- a/src/pages/search/drawer/landscape/forest/ForestIntegrity.tsx +++ b/src/pages/search/drawer/landscape/forest/ForestIntegrity.tsx @@ -11,7 +11,7 @@ import TextBoxes from "pages/search/shared_components/TextBoxes"; import { IconTooltip } from "pages/search/shared_components/Tooltips"; import matchColor from "utils/matchColor"; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import SearchContext, { SearchContextValues } from "pages/search/SearchContext"; import { SCICats, HFCats, SCIHF } from "pages/search/types/forest"; @@ -134,7 +134,7 @@ class ForestIntegrity extends React.Component { switchLayer("forestIntegrity"); - SearchAPI.requestSCIHF(areaId, geofenceId) + BackendAPI.requestSCIHF(areaId, geofenceId) .then((res: Array) => { if (this.mounted) { if (res.length <= 0) { @@ -188,7 +188,7 @@ class ForestIntegrity extends React.Component { this.setState({ loading: "no-data" }); }); - SearchAPI.requestSectionTexts("forestSCIHF") + BackendAPI.requestSectionTexts("forestSCIHF") .then((res) => { if (this.mounted) { this.setState({ texts: { forestSCIHF: res } }); diff --git a/src/pages/search/drawer/landscape/forest/ForestLossPersistenceController.ts b/src/pages/search/drawer/landscape/forest/ForestLossPersistenceController.ts index 3ef4bb544..63dc79b1e 100644 --- a/src/pages/search/drawer/landscape/forest/ForestLossPersistenceController.ts +++ b/src/pages/search/drawer/landscape/forest/ForestLossPersistenceController.ts @@ -2,7 +2,7 @@ import { SmallBarsData, SmallBarsDataDetails, } from "pages/search/shared_components/charts/SmallBars"; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import BackendStacAPI from "utils/backendStacAPI"; import { ForestLPExt, @@ -114,7 +114,7 @@ export class ForestLossPersistenceController { throw new Error("Error getting data"); }); } else { - return SearchAPI.requestForestLP(areaType, areaId) + return BackendAPI.requestForestLP(areaType, areaId) .then((data) => { const forestLP = data.map((item) => ({ ...item, @@ -193,7 +193,7 @@ export class ForestLossPersistenceController { * @returns {Object} texts of forestLP section */ getForestLPTexts = (sectionName: string): Promise => - SearchAPI.requestSectionTexts(sectionName) + BackendAPI.requestSectionTexts(sectionName) .then((res) => res) .catch(() => { throw new Error("Error getting data"); diff --git a/src/pages/search/drawer/landscape/humanFootprint/CurrentFootprint.tsx b/src/pages/search/drawer/landscape/humanFootprint/CurrentFootprint.tsx index c4cb95df3..ac31add84 100644 --- a/src/pages/search/drawer/landscape/humanFootprint/CurrentFootprint.tsx +++ b/src/pages/search/drawer/landscape/humanFootprint/CurrentFootprint.tsx @@ -6,7 +6,7 @@ import SearchContext, { SearchContextValues } from "pages/search/SearchContext"; import ShortInfo from "components/ShortInfo"; import { IconTooltip } from "pages/search/shared_components/Tooltips"; import matchColor from "utils/matchColor"; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import TextBoxes from "pages/search/shared_components/TextBoxes"; import { @@ -57,7 +57,7 @@ class CurrentFootprint extends React.Component { switchLayer("hfCurrent"); - SearchAPI.requestCurrentHFValue(areaId, geofenceId) + BackendAPI.requestCurrentHFValue(areaId, geofenceId) .then((res: currentHFValue) => { if (this.mounted) { this.setState({ @@ -68,7 +68,7 @@ class CurrentFootprint extends React.Component { }) .catch(() => {}); - SearchAPI.requestCurrentHFCategories(areaId, geofenceId) + BackendAPI.requestCurrentHFCategories(areaId, geofenceId) .then((res: Array) => { if (this.mounted) { this.setState({ @@ -84,7 +84,7 @@ class CurrentFootprint extends React.Component { this.setState({ message: "no-data" }); }); - SearchAPI.requestSectionTexts("hfCurrent") + BackendAPI.requestSectionTexts("hfCurrent") .then((res) => { if (this.mounted) { this.setState({ texts: { hfCurrent: res } }); diff --git a/src/pages/search/drawer/landscape/humanFootprint/PersistenceFootprint.tsx b/src/pages/search/drawer/landscape/humanFootprint/PersistenceFootprint.tsx index 41853f57e..856e0530d 100644 --- a/src/pages/search/drawer/landscape/humanFootprint/PersistenceFootprint.tsx +++ b/src/pages/search/drawer/landscape/humanFootprint/PersistenceFootprint.tsx @@ -5,7 +5,7 @@ import SearchContext, { SearchContextValues } from "pages/search/SearchContext"; import ShortInfo from "components/ShortInfo"; import { IconTooltip } from "pages/search/shared_components/Tooltips"; import matchColor from "utils/matchColor"; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import TextBoxes from "pages/search/shared_components/TextBoxes"; import { hfPersistence } from "pages/search/types/humanFootprint"; @@ -55,7 +55,7 @@ class PersistenceFootprint extends React.Component { switchLayer("hfPersistence"); - SearchAPI.requestHFPersistence(areaId, geofenceId) + BackendAPI.requestHFPersistence(areaId, geofenceId) .then((res: Array) => { if (this.mounted) { this.setState({ @@ -71,7 +71,7 @@ class PersistenceFootprint extends React.Component { this.setState({ message: "no-data" }); }); - SearchAPI.requestSectionTexts("hfPersistence") + BackendAPI.requestSectionTexts("hfPersistence") .then((res) => { if (this.mounted) { this.setState({ texts: { hfPersistence: res } }); diff --git a/src/pages/search/drawer/landscape/humanFootprint/TimelineFootprint.tsx b/src/pages/search/drawer/landscape/humanFootprint/TimelineFootprint.tsx index 3c70363ea..4a3d2cbe3 100644 --- a/src/pages/search/drawer/landscape/humanFootprint/TimelineFootprint.tsx +++ b/src/pages/search/drawer/landscape/humanFootprint/TimelineFootprint.tsx @@ -7,7 +7,7 @@ import SearchContext, { SearchContextValues } from "pages/search/SearchContext"; import formatNumber from "utils/format"; import matchColor from "utils/matchColor"; import processDataCsv from "utils/processDataCsv"; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import TextBoxes from "pages/search/shared_components/TextBoxes"; import { hfTimeline } from "pages/search/types/humanFootprint"; @@ -108,10 +108,10 @@ class TimelineFootprint extends React.Component { switchLayer("hfTimeline"); Promise.all([ - SearchAPI.requestSEHFTimeline(areaId, geofenceId, "Páramo"), - SearchAPI.requestSEHFTimeline(areaId, geofenceId, "Humedal"), - SearchAPI.requestSEHFTimeline(areaId, geofenceId, "Bosque Seco Tropical"), - SearchAPI.requestTotalHFTimeline(areaId, geofenceId), + BackendAPI.requestSEHFTimeline(areaId, geofenceId, "Páramo"), + BackendAPI.requestSEHFTimeline(areaId, geofenceId, "Humedal"), + BackendAPI.requestSEHFTimeline(areaId, geofenceId, "Bosque Seco Tropical"), + BackendAPI.requestTotalHFTimeline(areaId, geofenceId), ]) .then(([paramo, wetland, dryForest, aTotal]) => { if (this.mounted) { @@ -125,7 +125,7 @@ class TimelineFootprint extends React.Component { this.setState({ message: "no-data" }); }); - SearchAPI.requestSectionTexts("hfTimeline") + BackendAPI.requestSectionTexts("hfTimeline") .then((res) => { if (this.mounted) { this.setState({ texts: { hfTimeline: res } }); @@ -159,7 +159,7 @@ class TimelineFootprint extends React.Component { setSelectedEcosystem = (seType: string) => { const { areaId, geofenceId } = this.context as SearchContextValues; if (seType !== "aTotal") { - SearchAPI.requestSEDetailInArea( + BackendAPI.requestSEDetailInArea( areaId, geofenceId, this.getLabel(seType) diff --git a/src/pages/search/drawer/portfolios/conservationAreas/TargetsController.ts b/src/pages/search/drawer/portfolios/conservationAreas/TargetsController.ts index 1f2505062..e3927923c 100644 --- a/src/pages/search/drawer/portfolios/conservationAreas/TargetsController.ts +++ b/src/pages/search/drawer/portfolios/conservationAreas/TargetsController.ts @@ -9,7 +9,7 @@ import { } from "pages/search/types/portfolios"; import { SmallBarTooltip } from "pages/search/types/charts"; import formatNumber from "utils/format"; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import { textsObject } from "pages/search/types/texts"; export class TargetsController { @@ -30,7 +30,7 @@ export class TargetsController { * @returns List of portfolios */ getPortolfiosList() { - return SearchAPI.requestPortfoliosList(); + return BackendAPI.requestPortfoliosList(); } /** @@ -41,10 +41,10 @@ export class TargetsController { * @returns Array of promises to be resolved with data for each target */ async getData(areaType: string, areaId: string | number) { - const targets = await SearchAPI.requestTargetsList(areaType, areaId); + const targets = await BackendAPI.requestTargetsList(areaType, areaId); this.targets = targets; return targets.map((target) => - SearchAPI.requestPortfoliosByTarget(areaType, areaId, target.id).then( + BackendAPI.requestPortfoliosByTarget(areaType, areaId, target.id).then( (res) => { const ids = new Set(); res.portfolios_data.forEach((portfolio) => { @@ -192,7 +192,7 @@ export class TargetsController { "portfoliosBCAN", "portfoliosACCBA", ].forEach((item) => { - SearchAPI.requestSectionTexts(item) + BackendAPI.requestSectionTexts(item) .then((res) => { portfoliosTexts.push({ textKey: item, description: res.info }); }) @@ -218,7 +218,7 @@ export class TargetsController { "targetAvoidedDeforestation", "targetRestoration", ].forEach((item) => { - SearchAPI.requestSectionTexts(item) + BackendAPI.requestSectionTexts(item) .then((res) => { targetsTexts.push({ textKey: item, diff --git a/src/pages/search/drawer/species/richness/NumberOfSpecies.tsx b/src/pages/search/drawer/species/richness/NumberOfSpecies.tsx index 06c8c42b2..55f56e60d 100644 --- a/src/pages/search/drawer/species/richness/NumberOfSpecies.tsx +++ b/src/pages/search/drawer/species/richness/NumberOfSpecies.tsx @@ -25,7 +25,7 @@ import Bullet from "pages/search/shared_components/charts/Bullet"; import { wrapperMessage } from "pages/search/types/charts"; import { helperText, textsObject } from "pages/search/types/texts"; import { NOSGroups, NOSNational } from "pages/search/types/richness"; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; const NOSTexts = { inferred: { info: "", cons: "", meto: "", quote: "" }, @@ -177,9 +177,9 @@ class NumberOfSpecies extends React.Component { const { areaId, geofenceId } = this.context as SearchContextValues; Promise.all([ - SearchAPI.requestNumberOfSpecies(areaId, geofenceId, "all"), - SearchAPI.requestNSThresholds(areaId, geofenceId, "all"), - SearchAPI.requestNSNationalMax(areaId, "all"), + BackendAPI.requestNumberOfSpecies(areaId, geofenceId, "all"), + BackendAPI.requestNSThresholds(areaId, geofenceId, "all"), + BackendAPI.requestNSNationalMax(areaId, "all"), ]) .then(([values, thresholds, nationalMax]) => { const data: Array = []; @@ -269,7 +269,7 @@ class NumberOfSpecies extends React.Component { } }); - SearchAPI.requestSectionTexts("nosInferred") + BackendAPI.requestSectionTexts("nosInferred") .then((res) => { if (this.mounted) { NOSTexts.inferred = res as textsObject; @@ -280,7 +280,7 @@ class NumberOfSpecies extends React.Component { }) .catch(() => {}); - SearchAPI.requestSectionTexts("nosObserved") + BackendAPI.requestSectionTexts("nosObserved") .then((res) => { if (this.mounted) { NOSTexts.observed = res; @@ -288,7 +288,7 @@ class NumberOfSpecies extends React.Component { }) .catch(() => {}); - SearchAPI.requestHelperTexts("nos") + BackendAPI.requestHelperTexts("nos") .then((res) => { if (this.mounted) { this.setState({ diff --git a/src/pages/search/drawer/species/richness/SpeciesRecordsGaps.tsx b/src/pages/search/drawer/species/richness/SpeciesRecordsGaps.tsx index 47bdea290..e711616ca 100644 --- a/src/pages/search/drawer/species/richness/SpeciesRecordsGaps.tsx +++ b/src/pages/search/drawer/species/richness/SpeciesRecordsGaps.tsx @@ -15,7 +15,7 @@ import TextBoxes from "pages/search/shared_components/TextBoxes"; import Bullet from "pages/search/shared_components/charts/Bullet"; import { wrapperMessage } from "pages/search/types/charts"; import { textsObject } from "pages/search/types/texts"; -import SearchAPI from "utils/searchAPI"; +import BackendAPI from "utils/backendAPI"; import { concentration, gapLimitKeys, @@ -155,7 +155,7 @@ class SpeciesRecordsGaps extends React.Component { switchLayer("speciesRecordsGaps"); - SearchAPI.requestGaps(areaId, geofenceId) + BackendAPI.requestGaps(areaId, geofenceId) .then((res) => { if (this.mounted) { const showErrorMessage = @@ -176,7 +176,7 @@ class SpeciesRecordsGaps extends React.Component { this.setState({ messageGaps: "no-data" }); }); - SearchAPI.requestConcentration(areaId, geofenceId) + BackendAPI.requestConcentration(areaId, geofenceId) .then((res) => { if (this.mounted) { const { region, ...data } = this.transformData(res, "concentration"); @@ -192,7 +192,7 @@ class SpeciesRecordsGaps extends React.Component { this.setState({ messageConc: "no-data" }); }); - SearchAPI.requestSectionTexts("gaps") + BackendAPI.requestSectionTexts("gaps") .then((res) => { if (this.mounted) { this.setState({ texts: { gaps: res } }); diff --git a/src/utils/searchAPI.ts b/src/utils/backendAPI.ts similarity index 91% rename from src/utils/searchAPI.ts rename to src/utils/backendAPI.ts index 9f8b26eb8..5ad3d5aed 100644 --- a/src/utils/searchAPI.ts +++ b/src/utils/backendAPI.ts @@ -31,7 +31,7 @@ import { targetOrPortfolio, } from "pages/search/types/portfolios"; import { geofenceDetails } from "pages/search/types/drawer"; -class SearchAPI { +class BackendAPI { /** ****** */ /** FOREST */ /** ****** */ @@ -48,7 +48,7 @@ class SearchAPI { areaType: string, areaId: string | number ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `forest/sci/hf?areaType=${areaType}&areaId=${areaId}` ); } @@ -65,7 +65,7 @@ class SearchAPI { areaType: string, areaId: string | number ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `forest/lp?areaType=${areaType}&areaId=${areaId}` ); } @@ -85,7 +85,7 @@ class SearchAPI { areaType: string, areaId: string | number ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `connectivity/current?areaType=${areaType}&areaId=${areaId}` ); } @@ -105,7 +105,7 @@ class SearchAPI { areaId: string | number, seType: string | number ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `connectivity/current/se?areaType=${areaType}&areaId=${areaId}&seType=${seType}` ); } @@ -123,7 +123,7 @@ class SearchAPI { areaId: string | number, paNumber: number ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `connectivity/dpc?areaType=${areaType}&areaId=${areaId}&paNumber=${paNumber}` ); } @@ -142,7 +142,7 @@ class SearchAPI { areaId: string | number, category: string ): Promise { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `connectivity/timeline?areaType=${areaType}&areaId=${areaId}&category=${category}` ); } @@ -159,7 +159,7 @@ class SearchAPI { areaType: string, areaId: string | number ): Promise> { - return SearchAPI.makeGetRequest(`${areaType}/${areaId}/generalBiome`); + return BackendAPI.makeGetRequest(`${areaType}/${areaId}/generalBiome`); } /** @@ -171,7 +171,7 @@ class SearchAPI { areaType: string, areaId: string | number ): Promise> { - return SearchAPI.makeGetRequest(`${areaType}/${areaId}/bioticUnit`); + return BackendAPI.makeGetRequest(`${areaType}/${areaId}/bioticUnit`); } /** @@ -183,7 +183,7 @@ class SearchAPI { areaType: string, areaId: string | number ): Promise> { - return SearchAPI.makeGetRequest(`${areaType}/${areaId}/compensationFactor`); + return BackendAPI.makeGetRequest(`${areaType}/${areaId}/compensationFactor`); } /** *************** */ @@ -201,7 +201,7 @@ class SearchAPI { areaType: string, areaId: string | number ): Promise { - return SearchAPI.makeGetRequest(`${areaType}/${areaId}/hf/current/value`); + return BackendAPI.makeGetRequest(`${areaType}/${areaId}/hf/current/value`); } /** @@ -216,7 +216,7 @@ class SearchAPI { areaType: string, areaId: string | number ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `${areaType}/${areaId}/hf/current/categories` ); } @@ -233,7 +233,7 @@ class SearchAPI { areaType: string, areaId: string | number ): Promise> { - return SearchAPI.makeGetRequest(`${areaType}/${areaId}/hf/persistence`); + return BackendAPI.makeGetRequest(`${areaType}/${areaId}/hf/persistence`); } /** @@ -248,7 +248,7 @@ class SearchAPI { areaType: string, areaId: string | number ): Promise { - return SearchAPI.makeGetRequest(`${areaType}/${areaId}/hf/timeline`); + return BackendAPI.makeGetRequest(`${areaType}/${areaId}/hf/timeline`); } /** @@ -266,7 +266,7 @@ class SearchAPI { areaId: string | number, seType: string ): Promise { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `${areaType}/${areaId}/se/${seType}/hf/timeline` ); } @@ -285,7 +285,7 @@ class SearchAPI { areaId: string | number, seType: string ): Promise { - return SearchAPI.makeGetRequest(`${areaType}/${areaId}/se/${seType}`); + return BackendAPI.makeGetRequest(`${areaType}/${areaId}/se/${seType}`); } /** @@ -300,7 +300,7 @@ class SearchAPI { areaId: string | number, seType: string ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `ecosystems/coverage/se?areaType=${areaType}&areaId=${areaId}&seType=${seType}` ); } @@ -317,7 +317,7 @@ class SearchAPI { areaId: string | number, seType: string ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `/pa/se?areaType=${areaType}&areaId=${areaId}&seType=${seType}` ); } @@ -331,7 +331,7 @@ class SearchAPI { areaType: string, areaId: string | number ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `ecosystems/se?areaType=${areaType}&areaId=${areaId}` ); } @@ -345,7 +345,7 @@ class SearchAPI { areaType: string, areaId: string | number ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `/pa?areaType=${areaType}&areaId=${areaId}` ); } @@ -359,7 +359,7 @@ class SearchAPI { areaType: string, areaId: string | number ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `ecosystems/coverage?areaType=${areaType}&areaId=${areaId}` ); } @@ -382,7 +382,7 @@ class SearchAPI { areaId: number | string, group: string ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `richness/number-species?areaType=${areaType}&areaId=${areaId}${ group ? `&group=${group}` : "" }` @@ -404,7 +404,7 @@ class SearchAPI { areaId: number | string, group: string ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `richness/number-species/thresholds?areaType=${areaType}&areaId=${areaId}${ group ? `&group=${group}` : "" }` @@ -424,7 +424,7 @@ class SearchAPI { areaType: string, group: string ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `richness/number-species/nationalMax?areaType=${areaType}${ group ? `&group=${group}` : "" }` @@ -443,7 +443,7 @@ class SearchAPI { areaType: string, areaId: number | string ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `richness/gaps?areaType=${areaType}&areaId=${areaId}` ); } @@ -460,7 +460,7 @@ class SearchAPI { areaType: string, areaId: number | string ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `richness/concentration?areaType=${areaType}&areaId=${areaId}` ); } @@ -483,7 +483,7 @@ class SearchAPI { areaId: number | string, targetId: number ): Promise { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `portfolios-ca/targets/${targetId}/values?areaType=${areaType}&areaId=${areaId}` ); } @@ -500,7 +500,7 @@ class SearchAPI { areaType: string, areaId: number | string ): Promise> { - return SearchAPI.makeGetRequest( + return BackendAPI.makeGetRequest( `portfolios-ca/targets/list?areaType=${areaType}&areaId=${areaId}` ); } @@ -511,7 +511,7 @@ class SearchAPI { * @return {Promise} Array of objects with targets list */ static requestPortfoliosList(): Promise> { - return SearchAPI.makeGetRequest(`portfolios-ca/portfolios/list`); + return BackendAPI.makeGetRequest(`portfolios-ca/portfolios/list`); } /** @@ -531,7 +531,7 @@ class SearchAPI { ): { request: Promise; source: CancelTokenSource } { const source = axios.CancelToken.source(); return { - request: SearchAPI.makeGetRequest( + request: BackendAPI.makeGetRequest( `portfolios-ca/portfolios/layer?areaType=${areaType}&areaId=${areaId}&portfolioId=${portfolioId}`, { cancelToken: source.token, responseType: "arraybuffer" }, true @@ -552,17 +552,17 @@ class SearchAPI { * @return {Promise} Object with texts */ static requestTexts(key: string): Promise { - return SearchAPI.makeGetRequest(`util/texts?key=${key}`); + return BackendAPI.makeGetRequest(`util/texts?key=${key}`); } /** Same as previous function, but specifically for section texts */ static requestSectionTexts(key: string): Promise { - return SearchAPI.requestTexts(key) as Promise; + return BackendAPI.requestTexts(key) as Promise; } /** Same as previous function, but specifically for helper texts */ static requestHelperTexts(key: string): Promise { - return SearchAPI.requestTexts(key) as Promise; + return BackendAPI.requestTexts(key) as Promise; } /** ************** */ @@ -612,8 +612,8 @@ class SearchAPI { idArea: string | number, idGeofence: string | number ): Promise { - return SearchAPI.makeGetRequest(`${idArea}/${idGeofence}`); + return BackendAPI.makeGetRequest(`${idArea}/${idGeofence}`); } } -export default SearchAPI; +export default BackendAPI;