Fix for loading
This commit is contained in:
@@ -45,6 +45,30 @@ const fetchResources = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const getResourceMappings = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fetchJobs = [fetchOffices(), fetchResources()];
|
||||
|
||||
Promise.all(fetchJobs)
|
||||
.then((mappings) => {
|
||||
const offices = mappings[0];
|
||||
const resources = mappings[1];
|
||||
|
||||
const officesMap = {};
|
||||
const resourcesMap = {};
|
||||
|
||||
offices.forEach((office) => officesMap[office.officeId] = office);
|
||||
resources.forEach((resource) => resourcesMap[resource.resourceId] = resource);
|
||||
|
||||
resolve({
|
||||
officesMap,
|
||||
resourcesMap,
|
||||
});
|
||||
})
|
||||
.catch((error) => reject(error));
|
||||
});
|
||||
};
|
||||
|
||||
const getMappingsFromDatabase = () => {
|
||||
return db.officeResourceMapping.findAll();
|
||||
};
|
||||
@@ -57,5 +81,6 @@ module.exports = {
|
||||
getMappingsFromDatabase,
|
||||
fetchOffices,
|
||||
fetchResources,
|
||||
getResourceMappings,
|
||||
saveNewMappingToDatabase,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user