add query review page

This commit is contained in:
Bilal Catic
2019-05-19 12:29:55 +02:00
parent 2c415bbd79
commit 70ddc1f734
6 changed files with 152 additions and 9 deletions

View File

@@ -876,16 +876,37 @@ const getRegions = () => {
return regions.map( (g) => ({ name: g.name, id: g.id, olxid: g.olxid }) );
};
const getRegion = (regionId) => {
return regions.find(region => region.id === regionId);
};
const getRegionName = (regionId) => {
const region = getRegion(regionId);
return (region && region.name) ? region.name : null;
};
const getMunicipalitiesForRegion = (regionId) => {
for (geo of regions) {
if(geo.id === regionId) {
return geo.municipalities;
}
}
return null;
const region = getRegion(regionId);
return (region && region.municipalities) ? region.municipalities : null;
};
const getMunicipalityName = (regionId, municipalityId) => {
const region = getRegion(regionId);
if (!region){
return null;
}
const municipality = region.municipalities.find(municipality => municipality.id === municipalityId);
if (!municipality) {
return null;
}
return municipality.name;
};
module.exports = {
getRegions,
getMunicipalitiesForRegion
getRegionName,
getMunicipalitiesForRegion,
getMunicipalityName,
};