Skip to content

Commit

Permalink
feat(gadm): add source provider and source version to v2/area endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
willian-viana committed Jan 16, 2025
1 parent a690c02 commit 200de30
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions services/areas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { apiAuthRequest } from 'utils/request';
import { trackEvent } from 'utils/analytics';

const REQUEST_URL = '/v2/area';
const SOURCE = `?application=gfw&source[provider]=gadm&source[version]=3.6`; // these values will come from Redux

export const getArea = (id, userToken = null) =>
apiAuthRequest
.get(`${REQUEST_URL}/${id}`, {
.get(`${REQUEST_URL}/${id}${SOURCE}`, {
headers: {
...(userToken && {
Authorization: `Bearer ${userToken}`,
Expand Down Expand Up @@ -36,7 +37,7 @@ export const getArea = (id, userToken = null) =>
});

export const getAreas = () =>
apiAuthRequest.get(REQUEST_URL).then((areasResponse) => {
apiAuthRequest.get(`${REQUEST_URL}${SOURCE}`).then((areasResponse) => {
const { data: areas } = areasResponse.data;

return areas.map((area) => {
Expand Down Expand Up @@ -67,7 +68,9 @@ export const getAreas = () =>
export const saveArea = (data) =>
apiAuthRequest({
method: data.id ? 'PATCH' : 'POST',
url: data.id ? `${REQUEST_URL}/${data.id}` : REQUEST_URL,
url: data.id
? `${REQUEST_URL}/${data.id}${SOURCE}`
: `${REQUEST_URL}${SOURCE}`,
data,
}).then((areaResponse) => {
const { data: area } = areaResponse.data;
Expand All @@ -90,5 +93,5 @@ export const deleteArea = (id) => {
action: 'User deletes aoi',
label: id,
});
return apiAuthRequest.delete(`${REQUEST_URL}/${id}`);
return apiAuthRequest.delete(`${REQUEST_URL}/${id}${SOURCE}`);
};

0 comments on commit 200de30

Please sign in to comment.