Skip to content

Commit

Permalink
Feat/modal check (#35)
Browse files Browse the repository at this point in the history
* Modal to recruit user (airtable)

* airtable: prevent giving a description if 'other' field is not selected

* updates in user recruitment  modal

* user modal local storage function
  • Loading branch information
mluena authored Jun 7, 2021
1 parent 4f80f66 commit 3be5816
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/explore/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import throttle from 'lodash/debounce';

import { Router } from 'lib/routes';
import { logEvent } from 'utils/analytics';
import { isFirstVisit } from 'utils/explore';
import { isModalShown } from 'utils/explore';
import { useHasMounted, useDesktop } from 'utils/hooks';
import { toggleBasemap, toggleLabels, toggleRoads } from 'utils/map';
import {
Expand Down Expand Up @@ -80,7 +80,7 @@ const Explore = ({

// User recruitment modal. This modal should appear just the first time the user
// visits the map section
const [userModalOpen, setUserModalOpen] = useState(isFirstVisit());
const [userModalOpen, setUserModalOpen] = useState(isModalShown());

const handleModalClose = () => {
setUserModalOpen(false);
Expand Down
1 change: 1 addition & 0 deletions components/forms/radio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const Radio = ({ id, name, disabled, checked, onChange, children, className, req
</label>
</div>
);

Radio.propTypes = {
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
Expand Down
1 change: 1 addition & 0 deletions components/user-modal/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@
}
}


23 changes: 23 additions & 0 deletions utils/explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,26 @@ export const isFirstVisit = () => {

return isFirstVisit;
};

/* This function tracks the first time the app shows the recruitment modal to users */

export const isModalShown = () => {
let modalShown = true;

try {
const storedValue = localStorage.getItem('showUserRecruitmentModal');
modalShown = storedValue !== 'false';
} catch (e) {
console.error('Unable to access the localStorage.');
}

if (modalShown) {
try {
localStorage.setItem('showUserRecruitmentModal', 'false');
} catch (e) {
console.error('Unable to access the localStorage.');
}
}

return modalShown;
};

0 comments on commit 3be5816

Please sign in to comment.