Add location repository for frontend

This commit is contained in:
Dana Lambert 2021-10-22 16:02:36 +13:00
parent 49bcc85116
commit f3d2595b23

View file

@ -0,0 +1,34 @@
import API from "./Repository";
const LocationRepsostory = {
getSoilDetails(filters) {
return API.get(`/soil/`, { params: filters });
},
getEcologicalDistrictDetails(filters) {
return API.get(`/ecologicaldistrict/`, { params: filters });
},
getPropertyDetails(filters) {
return API.get(`/address/`, { params: filters });
},
async getLocationData(filters) {
const [soilDetails, ecologicalDistrictDetails, propertyDetails] = await Promise.all([
this.getSoilDetails(filters),
this.getEcologicalDistrictDetails(filters),
this.getPropertyDetails(filters)
]);
let locationData = {};
locationData = soilDetails.status === 200 ? Object.assign(locationData, soilDetails.data[0]) : locationData;
locationData = ecologicalDistrictDetails.status === 200 ? Object.assign(locationData, ecologicalDistrictDetails.data[0]) : locationData;
locationData = propertyDetails.status === 200 ? Object.assign(locationData, propertyDetails.data) : locationData;
return locationData
}
}
export default LocationRepsostory;