Add location repository for frontend
This commit is contained in:
parent
49bcc85116
commit
f3d2595b23
1 changed files with 34 additions and 0 deletions
34
frontend/src/repository/LocationRepository.js
Normal file
34
frontend/src/repository/LocationRepository.js
Normal 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;
|
Loading…
Reference in a new issue