implement mapping update

This commit is contained in:
Bilal Catic
2019-08-28 12:44:47 +02:00
parent 4999b1323f
commit 9878b5e6b4
6 changed files with 166 additions and 23 deletions

View File

@@ -2,7 +2,7 @@
const moment = require('moment-timezone');
const { getMappingsFromDatabase, fetchOffices, fetchResources, saveNewMappingToDatabase, deleteMappingById } = require('../services/officeRnD/resources');
const { getMappingsFromDatabase, fetchOffices, fetchResources, saveNewMappingToDatabase, deleteMappingById, updateMappingById } = require('../services/officeRnD/resources');
const { getAllIncidents, getMemberPracticeSummaryReport } = require('../services/integration/reports');
const { getMembersFeesForDateRange } = require('../services/integration/invoiceIntegration');
const { deleteFeesFromORD, addFeesToORD } = require('../services/officeRnD/fees');
@@ -24,6 +24,7 @@ const getKnownOfficeResourceMappings = (req, res) => {
});
})
.catch(error => {
console.log('Error with fetching mappings : ', error);
res.status(500).send();
});
};
@@ -54,6 +55,27 @@ const deleteMapping = (req, res) => {
console.log(error);
res.status(500).send();
});
}else{
getKnownOfficeResourceMappings(req, res);
}
};
const updateMapping = (req, res) => {
const mappingId = req.params.mappingId;
const mapping = req.body && req.body.mapping ? req.body.mapping : null;
if (mappingId && parseInt(mappingId)){
updateMappingById(mappingId, mapping)
.then(() => {
getKnownOfficeResourceMappings(req, res);
})
.catch((error) => {
console.log('Error updating mapping with id = ', mappingId);
console.log(error);
res.status(500).send();
});
}else{
getKnownOfficeResourceMappings(req, res);
}
};
@@ -187,6 +209,7 @@ module.exports = {
getKnownOfficeResourceMappings,
addNewMapping,
deleteMapping,
updateMapping,
getAllIncidentsController,
getMemberIncidents,
addFees,