Skip to content

Commit

Permalink
fix: calculation of the toilet filter mask by checking for undefined,…
Browse files Browse the repository at this point in the history
… not null on toilet properties
  • Loading branch information
ob6160 authored and Rupert Redington committed Nov 22, 2021
1 parent b3b78cb commit 8a5530f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
26 changes: 14 additions & 12 deletions src/api/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,40 +125,41 @@ const resolvers = {
const FILTER_BABY_CHNG = 0b00010000;
const FILTER_RADAR = 0b00100000;
const FILTER_UOL = 0b01000000;

let count = 0;
const genLooFilterMask = (loo) => {
const noPayment =
loo.properties.noPayment === null ||
loo.properties.noPayment === undefined ||
loo.properties.noPayment === false
? 0
: FILTER_NO_PAYMENT;
const allGender =
loo.properties.allGender === null ||
loo.properties.allGender === undefined ||
loo.properties.allGender === false
? 0
: FILTER_ALL_GENDER;
: FILTER_AUTOMATIC;

const automatic =
loo.properties.automatic === null ||
loo.properties.automatic === undefined ||
loo.properties.automatic === false
? 0
: FILTER_AUTOMATIC;
const accessible =
loo.properties.accessible === null ||
loo.properties.accessible === undefined ||
loo.properties.accessible === false
? 0
: FILTER_ACCESSIBLE;
const babyChange =
loo.properties.babyChange === null ||
loo.properties.babyChange === undefined ||
loo.properties.babyChange === false
? 0
: FILTER_BABY_CHNG;
const radar =
loo.properties.radar === null || loo.properties.radar === false
loo.properties.radar === undefined || loo.properties.radar === false
? 0
: FILTER_RADAR;
const campaignUOL =
loo.properties.campaignUOL === null ||
loo.properties.allGender === false
loo.properties.campaignUOL === undefined ||
loo.properties.campaignUOL === false
? 0
: FILTER_UOL;

Expand All @@ -173,13 +174,14 @@ const resolvers = {
);
};

return loos.map((loo) => {
return `${loo.id.s}|${loo.properties.geometry.coordinates[0].toFixed(
const mapped = loos.map((loo) => {
return `${loo.id}|${loo.properties.geometry.coordinates[0].toFixed(
4
)}|${loo.properties.geometry.coordinates[1].toFixed(4)}|${
loo.properties.name ? loo.properties.name.replace('|', ' ') : ''
}|${genLooFilterMask(loo)}`;
});
return mapped;
},
areas: async (parent, args) => {
const data = await Area.find({}, { name: 1, type: 1 }).exec();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const LooMap = dynamic(() => import('../components/LooMap'), {
const HomePage: PageUkLooMarkersComp = (props) => {
const [mapState, setMapState] = useMapState();

const { filters, setFilters, filtered } = useFilters([]);
const { filters, setFilters } = useFilters([]);

const pageTitle = config.getTitle('Home');

Expand Down
1 change: 1 addition & 0 deletions src/pages/loos/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const LooPage: PageFindLooByIdComp = (props) => {
onViewportChanged={setMapState}
controlsOffset={0}
focus={props?.data?.loo}
filters={filters}
/>
{props?.data?.loo && (
<Box
Expand Down

0 comments on commit 8a5530f

Please sign in to comment.