Skip to content

Commit

Permalink
feat(jsdoc): add JSDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
willian-viana committed Oct 28, 2024
1 parent 004b309 commit 201f188
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 4 deletions.
2 changes: 2 additions & 0 deletions components/map/components/popup/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class Popup extends Component {
componentDidUpdate(prevProps) {
const { interactionsOptions, activeDatasets } = this.props;

console.log('this.props', this.props)

if (
isEmpty(interactionsOptions) &&
!isEqual(activeDatasets?.length, prevProps.activeDatasets?.length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import PropTypes from 'prop-types';
import DynamicSentence from 'components/ui/dynamic-sentence';
import Button from 'components/ui/button';

/**
* Displays a sentence describing the area clicked by the user on the map.
* @param {string} sentence - A string with the area's description
* @param {function} onAnalyze - Function for onClick event.
*/
const BoundarySentence = ({ sentence, onAnalyze }) => (
<div className="c-boundary-sentence">
<DynamicSentence className="sentence" sentence={sentence} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import { translateText } from 'utils/lang';
const getInteractionData = (state, { data }) => data;

/**
* Returns an object with the selected location name and its area.
* Returns an object with the selected location name, its area and a sentence do be displayed.
* @param {method} createSelector - return a memoized outut selector.
* @see https://reselect.js.org/introduction/getting-started/#output-selector for implementation details
* @param {selector} getInteractionData - data from the area clicked by user
* @return {object} sentence, location name and area.
*/
export const getSentence = createSelector(
[getInteractionData],
Expand Down
10 changes: 9 additions & 1 deletion layouts/map/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import useRouter from 'utils/router';

export const setMainMapSettings = createAction('setMainMapSettings');

/**
* Push the parameters from the area clicked to the URL query
* @param {function} createThunkAction - A string with the area's description
* @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
*/
export const setMainMapAnalysisView = createThunkAction(
'setMainMapAnalysisView',
({ data, layer }) => () => {
Expand All @@ -14,7 +23,6 @@ export const setMainMapAnalysisView = createThunkAction(
const { query, pushQuery } = useRouter();
const { map, mainMap } = query || {};

// get location payload based on layer type
let payload = {};
if (data) {
if (analysisEndpoint === 'admin') {
Expand Down
11 changes: 10 additions & 1 deletion providers/geostore-provider/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ export const setGeostoreLoading = createAction('setGeostoreLoading');
export const setGeostore = createAction('setGeostore');
export const clearGeostore = createAction('clearGeostore');

/**
* Push the parameters from the area clicked to the URL query
* @param {function} createThunkAction - A string with the area's description
* @see https://redux.js.org/usage/writing-logic-thunks for implementation details
* @param {string} fetchGeostore - Action name
* @param {function} - Arrow function
* @param {object} params - Url query parameters
*/
export const fetchGeostore = createThunkAction(
'fetchGeostore',
(params) => (dispatch) => {
const { type, adm0, adm1, adm2, token } = params;
const { type, adm0, adm1 = 25, adm2 = 390, token } = params;
console.log('params', params)
if (type && adm0) {
dispatch(setGeostoreLoading({ loading: true, error: false }));
getGeostore({ type, adm0, adm1, adm2, token })
Expand Down
6 changes: 5 additions & 1 deletion services/geostore.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ const fetchGeostoreFromDataApi = ({ adm0, adm1, adm2, token }) => {

export const getGeostore = ({ type, adm0, adm1, adm2, token }) => {
if (!type || !adm0) return null;

// console.log('type', type)
// console.log('adm0', adm0)
// console.log('adm1', adm1)
// console.log('adm2', adm2)
// console.log('token', token)
switch (type) {
case 'country':
return fetchGeostoreFromDataApi({
Expand Down
5 changes: 5 additions & 0 deletions utils/gadm.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export const parseGadm36Id = (gid) => {
};
};

/**
* @param {string} adm_level - The administrative level
* @param {object} location - Location object from user's clicked area
* @return {object} - Object with area type, location and gadm properties
*/
export const getGadmLocationByLevel = ({ adm_level, ...location }) => ({
type: 'country',
...(location?.gid_0 && {
Expand Down

0 comments on commit 201f188

Please sign in to comment.