Room Office Mapping / Home screen now functional / Bugfixes
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
const moment = require('moment-timezone');
|
||||
|
||||
const { getMappingsFromDatabase, fetchOffices, fetchResources, saveNewMappingToDatabase } = 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');
|
||||
@@ -13,7 +13,7 @@ const { checkIfProcessing } = require('../services/integration/processingStatus'
|
||||
const { UI_TIMEZONE } = require('../constants/constants');
|
||||
|
||||
const getKnownOfficeResourceMappings = (req, res) => {
|
||||
const dataToFetch = [getMappingsFromDatabase(), fetchOffices(), fetchResources() ];
|
||||
const dataToFetch = [getMappingsFromDatabase(), fetchOffices(), fetchResources()];
|
||||
|
||||
Promise.all(dataToFetch)
|
||||
.then(result => {
|
||||
@@ -24,6 +24,7 @@ const getKnownOfficeResourceMappings = (req, res) => {
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.log('Error with fetching mappings : ', error);
|
||||
res.status(500).send();
|
||||
});
|
||||
};
|
||||
@@ -41,6 +42,43 @@ const addNewMapping = (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
const deleteMapping = (req, res) => {
|
||||
const mappingId = req.params.mappingId;
|
||||
|
||||
if (mappingId && parseInt(mappingId)){
|
||||
deleteMappingById(mappingId)
|
||||
.then(() => {
|
||||
getKnownOfficeResourceMappings(req, res);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('Error deleting mapping with id = ', mappingId);
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
const getAllIncidentsController = (req, res) => {
|
||||
const dateRange = {
|
||||
startDate: req.params.startDate,
|
||||
@@ -170,6 +208,8 @@ const getPracticeSummaryReport = (req, res) => {
|
||||
module.exports = {
|
||||
getKnownOfficeResourceMappings,
|
||||
addNewMapping,
|
||||
deleteMapping,
|
||||
updateMapping,
|
||||
getAllIncidentsController,
|
||||
getMemberIncidents,
|
||||
addFees,
|
||||
|
||||
Reference in New Issue
Block a user