Skip to content

Commit

Permalink
chore(wdpa): remove cartodb_id as an option for wdpa
Browse files Browse the repository at this point in the history
  • Loading branch information
willian-viana committed Oct 28, 2024
1 parent 201f188 commit 1ba8681
Showing 1 changed file with 42 additions and 41 deletions.
83 changes: 42 additions & 41 deletions layouts/map/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,55 +12,56 @@ export const setMainMapSettings = createAction('setMainMapSettings');
* @see https://redux.js.org/usage/writing-logic-thunks for implementation details
* @param {string} setMainMapAnalysisView - Action name
* @param {function} - Arrow function
* @param {object} data - area data (adm_level, gid_0, country, ...)
* @param {object} layer - political boundaries obejct from Layer API
* @param {object} data - area data (adm_level, gid_0, country, ...)
* @param {object} layer - political boundaries obejct from Layer API
*/
export const setMainMapAnalysisView = createThunkAction(
'setMainMapAnalysisView',
({ data, layer }) => () => {
const { cartodb_id, wdpaid } = data || {};
const { analysisEndpoint, tableName } = layer || {};
const { query, pushQuery } = useRouter();
const { map, mainMap } = query || {};
({ data, layer }) =>
() => {
const { cartodb_id, wdpaid } = data || {};
const { analysisEndpoint, tableName } = layer || {};
const { query, pushQuery } = useRouter();
const { map, mainMap } = query || {};

let payload = {};
if (data) {
if (analysisEndpoint === 'admin') {
payload = {
type: 'country',
...getGadmLocationByLevel(data),
};
} else if (analysisEndpoint === 'wdpa' && (cartodb_id || wdpaid)) {
payload = {
type: analysisEndpoint,
adm0: wdpaid || cartodb_id,
};
} else if (cartodb_id && tableName) {
payload = {
type: 'use',
adm0: tableName,
adm1: cartodb_id,
};
let payload = {};
if (data) {
if (analysisEndpoint === 'admin') {
payload = {
type: 'country',
...getGadmLocationByLevel(data),
};
} else if (analysisEndpoint === 'wdpa' && wdpaid) {
payload = {
type: analysisEndpoint,
adm0: wdpaid,
};
} else if (cartodb_id && tableName) {
payload = {
type: 'use',
adm0: tableName,
adm1: cartodb_id,
};
}
}
}

if (payload && payload.adm0) {
pushQuery({
pathname: `/map/${compact(Object.values(payload))?.join('/')}/`,
query: {
...query,
map: {
...map,
canBound: true,
},
mainMap: {
...mainMap,
showAnalysis: true,
if (payload && payload.adm0) {
pushQuery({
pathname: `/map/${compact(Object.values(payload))?.join('/')}/`,
query: {
...query,
map: {
...map,
canBound: true,
},
mainMap: {
...mainMap,
showAnalysis: true,
},
},
},
});
});
}
}
}
);

export const setDrawnGeostore = createThunkAction(
Expand Down

0 comments on commit 1ba8681

Please sign in to comment.