add query review page
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user