Skip to content

Commit

Permalink
Change SearchAPI for BackendAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelStardust committed Sep 18, 2024
1 parent 7ab6fda commit 8cb5f6d
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 101 deletions.
4 changes: 2 additions & 2 deletions src/pages/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/pages/search/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -52,7 +52,7 @@ class Drawer extends React.Component<Props, State> {
);

if (searchType !== "drawPolygon") {
searchAPI
BackendAPI
.requestGeofenceDetails(areaId, geofenceId)
.then((res: geofenceDetails) => {
this.setState({ geofenceArea: Number(res.total_area) });
Expand Down
8 changes: 4 additions & 4 deletions src/pages/search/drawer/Ecosystems.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -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) => ({
Expand All @@ -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]) {
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -67,7 +67,7 @@ class EcosystemDetails extends React.Component<Props, State> {
const { stopLoad } = this.state;

if (!stopLoad) {
SearchAPI.requestSECoverageByGeofence(areaId, geofenceId, SEType)
BackendAPI.requestSECoverageByGeofence(areaId, geofenceId, SEType)
.then((res) => {
if (this.mounted) {
this.setState((prev) => ({
Expand All @@ -88,7 +88,7 @@ class EcosystemDetails extends React.Component<Props, State> {
}));
});

SearchAPI.requestSEPAByGeofence(areaId, geofenceId, SEType)
BackendAPI.requestSEPAByGeofence(areaId, geofenceId, SEType)
.then((res) => {
if (this.mounted) {
this.setState((prev) => ({
Expand Down
10 changes: 5 additions & 5 deletions src/pages/search/drawer/landscape/CompensationFactor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -71,7 +71,7 @@ class CompensationFactor extends React.Component<

switchLayer("fc");

SearchAPI.requestBiomes(areaId, geofenceId)
BackendAPI.requestBiomes(areaId, geofenceId)
.then((res: Array<cfData>) => {
if (this.mounted) {
this.setState((prev) => ({
Expand All @@ -95,7 +95,7 @@ class CompensationFactor extends React.Component<
}));
});

SearchAPI.requestCompensationFactor(areaId, geofenceId)
BackendAPI.requestCompensationFactor(areaId, geofenceId)
.then((res: Array<cfData>) => {
if (this.mounted) {
this.setState((prev) => ({
Expand All @@ -119,7 +119,7 @@ class CompensationFactor extends React.Component<
}));
});

SearchAPI.requestBioticUnits(areaId, geofenceId)
BackendAPI.requestBioticUnits(areaId, geofenceId)
.then((res: Array<cfData>) => {
if (this.mounted) {
this.setState((prev) => ({
Expand All @@ -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) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -82,7 +82,7 @@ class CurrentPAConnectivity extends React.Component<Props, currentPAConnState> {

switchLayer("currentPAConn");

SearchAPI.requestCurrentPAConnectivity(areaId, geofenceId)
BackendAPI.requestCurrentPAConnectivity(areaId, geofenceId)
.then((res: Array<currentPAConn>) => {
if (this.mounted) {
const protConn = res.find((item) => item.key === "prot_conn");
Expand Down Expand Up @@ -112,7 +112,7 @@ class CurrentPAConnectivity extends React.Component<Props, currentPAConnState> {
}));
});

SearchAPI.requestDPC(areaId, geofenceId, 5)
BackendAPI.requestDPC(areaId, geofenceId, 5)
.then((res: Array<DPC>) => {
if (this.mounted) {
this.setState((prev) => ({
Expand All @@ -134,7 +134,7 @@ class CurrentPAConnectivity extends React.Component<Props, currentPAConnState> {
});

["paConnCurrent", "paConnDPC"].forEach((item) => {
SearchAPI.requestSectionTexts(item)
BackendAPI.requestSectionTexts(item)
.then((res) => {
if (this.mounted) {
this.setState((prevState) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -78,7 +78,7 @@ class CurrentSEPAConnectivity extends React.Component<Props, State> {

switchLayer("currentSEPAConn");

SearchAPI.requestCurrentSEPAConnectivity(areaId, geofenceId, "Páramo")
BackendAPI.requestCurrentSEPAConnectivity(areaId, geofenceId, "Páramo")
.then((res: Array<currentSEPAConn>) => {
if (this.mounted) {
let protParamo = 0;
Expand Down Expand Up @@ -109,7 +109,7 @@ class CurrentSEPAConnectivity extends React.Component<Props, State> {
}));
});

SearchAPI.requestCurrentSEPAConnectivity(
BackendAPI.requestCurrentSEPAConnectivity(
areaId,
geofenceId,
"Bosque Seco Tropical"
Expand Down Expand Up @@ -144,7 +144,7 @@ class CurrentSEPAConnectivity extends React.Component<Props, State> {
}));
});

SearchAPI.requestCurrentSEPAConnectivity(areaId, geofenceId, "Humedal")
BackendAPI.requestCurrentSEPAConnectivity(areaId, geofenceId, "Humedal")
.then((res: Array<currentSEPAConn>) => {
if (this.mounted) {
let protWetland = 0;
Expand Down Expand Up @@ -175,7 +175,7 @@ class CurrentSEPAConnectivity extends React.Component<Props, State> {
}));
});

SearchAPI.requestSectionTexts("paConnSE")
BackendAPI.requestSectionTexts("paConnSE")
.then((res) => {
if (this.mounted) {
this.setState({ texts: { paConnSE: res } });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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) {
Expand All @@ -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 } });
Expand Down
6 changes: 3 additions & 3 deletions src/pages/search/drawer/landscape/forest/ForestIntegrity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -134,7 +134,7 @@ class ForestIntegrity extends React.Component<Props, FIState> {

switchLayer("forestIntegrity");

SearchAPI.requestSCIHF(areaId, geofenceId)
BackendAPI.requestSCIHF(areaId, geofenceId)
.then((res: Array<SCIHF>) => {
if (this.mounted) {
if (res.length <= 0) {
Expand Down Expand Up @@ -188,7 +188,7 @@ class ForestIntegrity extends React.Component<Props, FIState> {
this.setState({ loading: "no-data" });
});

SearchAPI.requestSectionTexts("forestSCIHF")
BackendAPI.requestSectionTexts("forestSCIHF")
.then((res) => {
if (this.mounted) {
this.setState({ texts: { forestSCIHF: res } });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -193,7 +193,7 @@ export class ForestLossPersistenceController {
* @returns {Object} texts of forestLP section
*/
getForestLPTexts = (sectionName: string): Promise<textsObject> =>
SearchAPI.requestSectionTexts(sectionName)
BackendAPI.requestSectionTexts(sectionName)
.then((res) => res)
.catch(() => {
throw new Error("Error getting data");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -57,7 +57,7 @@ class CurrentFootprint extends React.Component<Props, currentHFState> {

switchLayer("hfCurrent");

SearchAPI.requestCurrentHFValue(areaId, geofenceId)
BackendAPI.requestCurrentHFValue(areaId, geofenceId)
.then((res: currentHFValue) => {
if (this.mounted) {
this.setState({
Expand All @@ -68,7 +68,7 @@ class CurrentFootprint extends React.Component<Props, currentHFState> {
})
.catch(() => {});

SearchAPI.requestCurrentHFCategories(areaId, geofenceId)
BackendAPI.requestCurrentHFCategories(areaId, geofenceId)
.then((res: Array<currentHFCategories>) => {
if (this.mounted) {
this.setState({
Expand All @@ -84,7 +84,7 @@ class CurrentFootprint extends React.Component<Props, currentHFState> {
this.setState({ message: "no-data" });
});

SearchAPI.requestSectionTexts("hfCurrent")
BackendAPI.requestSectionTexts("hfCurrent")
.then((res) => {
if (this.mounted) {
this.setState({ texts: { hfCurrent: res } });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -55,7 +55,7 @@ class PersistenceFootprint extends React.Component<Props, persistenceHFState> {

switchLayer("hfPersistence");

SearchAPI.requestHFPersistence(areaId, geofenceId)
BackendAPI.requestHFPersistence(areaId, geofenceId)
.then((res: Array<hfPersistence>) => {
if (this.mounted) {
this.setState({
Expand All @@ -71,7 +71,7 @@ class PersistenceFootprint extends React.Component<Props, persistenceHFState> {
this.setState({ message: "no-data" });
});

SearchAPI.requestSectionTexts("hfPersistence")
BackendAPI.requestSectionTexts("hfPersistence")
.then((res) => {
if (this.mounted) {
this.setState({ texts: { hfPersistence: res } });
Expand Down
Loading

0 comments on commit 8cb5f6d

Please sign in to comment.