Skip to content

Commit

Permalink
Merge pull request #792 from OneCommunityGlobal/Sucheta-refactor-week…
Browse files Browse the repository at this point in the history
…lySummaryRecipient-button

Sucheta- Refactor WeeklySummaryRecipient Button Functionality
  • Loading branch information
one-community authored Mar 15, 2024
2 parents e97fa9c + 9c76c68 commit fb79bcb
Show file tree
Hide file tree
Showing 43 changed files with 306 additions and 268 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/controllers/actionItemController.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const actionItemController = function (ActionItem) {

_actionItem.save()
.then(res.status(200).send('Saved'))
.catch(error => res.status(400).send(error));
.catch((error) => res.status(400).send(error));
};

return {
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/badgeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const badgeController = function (Badge) {
cache.setCache('allBadges', results);
res.status(200).send(results);
})
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
};

/**
Expand Down Expand Up @@ -166,7 +166,7 @@ const badgeController = function (Badge) {
}
res.status(201).send(results);
})
.catch(errors => res.status(500).send(errors));
.catch((errors) => res.status(500).send(errors));
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/bmdashboard/bmConsumableController.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const bmConsumableController = function (BuildingConsumable) {
.then((result) => {
res.status(200).send(result);
})
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
} catch (err) {
res.json(err);
}
Expand Down
16 changes: 8 additions & 8 deletions src/controllers/bmdashboard/bmInventoryTypeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function bmInventoryTypeController(InvType, MatType, ConsType, ReusType, ToolTyp
MatType
.find()
.exec()
.then(result => res.status(200).send(result))
.catch(error => res.status(500).send(error));
.then((result) => res.status(200).send(result))
.catch((error) => res.status(500).send(error));
} catch (err) {
res.json(err);
}
Expand All @@ -38,8 +38,8 @@ function bmInventoryTypeController(InvType, MatType, ConsType, ReusType, ToolTyp
ToolType
.find()
.exec()
.then(result => res.status(200).send(result))
.catch(error => res.status(500).send(error));
.then((result) => res.status(200).send(result))
.catch((error) => res.status(500).send(error));
} catch (err) {
res.json(err);
}
Expand Down Expand Up @@ -129,7 +129,7 @@ function bmInventoryTypeController(InvType, MatType, ConsType, ReusType, ToolTyp
});
}
})
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
} catch (error) {
res.status(500).send(error);
}
Expand All @@ -153,8 +153,8 @@ function bmInventoryTypeController(InvType, MatType, ConsType, ReusType, ToolTyp
SelectedType
.find()
.exec()
.then(result => res.status(200).send(result))
.catch(error => res.status(500).send(error));
.then((result) => res.status(200).send(result))
.catch((error) => res.status(500).send(error));
} catch (err) {
res.json(err);
}
Expand Down Expand Up @@ -193,7 +193,7 @@ function bmInventoryTypeController(InvType, MatType, ConsType, ReusType, ToolTyp
});
}
})
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
} catch (error) {
res.status(500).send(error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/bmdashboard/bmMaterialsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const bmMaterialsController = function (BuildingMaterial) {
)
.exec()
.then(() => res.status(201).send())
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
} catch (error) {
res.status(500).send(error);
}
Expand Down
10 changes: 5 additions & 5 deletions src/controllers/bmdashboard/bmNewLessonController.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ const bmNewLessonController = function (BuildingNewLesson) {
BuildingNewLesson
.find()
.populate()
.then(result => res.status(200).send(result))
.catch(error => res.status(500).send(error));
.then((result) => res.status(200).send(result))
.catch((error) => res.status(500).send(error));
} catch (err) {
res.json(err);
}
};
const bmPostLessonList = async (req, res) => {
try {
const newLesson = BuildingNewLesson.create(req.body)
.then(result => res.status(201).send(result))
.catch(error => res.status(500).send(error));
.then((result) => res.status(201).send(result))
.catch((error) => res.status(500).send(error));
} catch (err) {
res.json(err);
}
Expand Down Expand Up @@ -47,7 +47,7 @@ const bmNewLessonController = function (BuildingNewLesson) {
// Extract only allowed fields (content, tag, relatedProject and title)
const allowedFields = ['content', 'tags', 'relatedProject', 'title', 'allowedRoles', 'files'];
const filteredUpdateData = Object.keys(updateData)
.filter(key => allowedFields.includes(key))
.filter((key) => allowedFields.includes(key))
.reduce((obj, key) => {
obj[key] = updateData[key];
return obj;
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/bmdashboard/bmProjectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const bmMProjectController = function (BuildingProject) {
});
res.status(200).send(results);
})
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
} catch (err) {
res.status(500).send(err);
}
Expand All @@ -105,7 +105,7 @@ const bmMProjectController = function (BuildingProject) {
},
])
.exec()
.then(project => res.status(200).send(project))
.then((project) => res.status(200).send(project))
// TODO: uncomment this block to execute the auth check
// authenticate request by comparing userId param with buildingManager id field
// Note: _id has type object and must be converted to string
Expand All @@ -117,7 +117,7 @@ const bmMProjectController = function (BuildingProject) {
// }
// return res.status(200).send(project);
// })
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
} catch (err) {
res.json(err);
}
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/bmdashboard/bmReusableController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const mongoose = require('mongoose');
const {
reusableType: ReusableType
reusableType: ReusableType,
} = require('../../models/bmdashboard/buildingInventoryType');

function isValidDate(dateString) {
Expand Down Expand Up @@ -41,7 +41,7 @@ const bmReusableController = function (BuildingReusable) {
.then((result) => {
res.status(200).send(result);
})
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
} catch (err) {
res.json(err);
}
Expand Down
8 changes: 4 additions & 4 deletions src/controllers/bmdashboard/bmToolController.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const bmToolController = (BuildingTool) => {
},
])
.exec()
.then(tool => res.status(200).send(tool))
.catch(error => res.status(500).send(error));
.then((tool) => res.status(200).send(tool))
.catch((error) => res.status(500).send(error));
} catch (err) {
res.json(err);
}
Expand Down Expand Up @@ -84,7 +84,7 @@ const bmToolController = (BuildingTool) => {
BuildingTool
.create(newDoc)
.then(() => res.status(201).send())
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
return;
}

Expand All @@ -95,7 +95,7 @@ const bmToolController = (BuildingTool) => {
)
.exec()
.then(() => res.status(201).send())
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
} catch (error) {
res.status(500).send(error);
}
Expand Down
12 changes: 6 additions & 6 deletions src/controllers/dashBoardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const dashboardcontroller = function () {
.then(() => {
res.status(200).send("Successfully saved AI prompt.");
})
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
}
};

Expand All @@ -82,7 +82,7 @@ const dashboardcontroller = function () {
});
}
})
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
};

const monthlydata = function (req, res) {
Expand Down Expand Up @@ -133,7 +133,7 @@ const dashboardcontroller = function () {
});
}
})
.catch(error => res.status(400).send(error));
.catch((error) => res.status(400).send(error));
};

const orgData = function (req, res) {
Expand All @@ -143,7 +143,7 @@ const dashboardcontroller = function () {
.then((results) => {
res.status(200).send(results[0]);
})
.catch(error => res.status(400).send(error));
.catch((error) => res.status(400).send(error));
};

const getBugReportEmailBody = function (
Expand Down Expand Up @@ -234,7 +234,7 @@ const dashboardcontroller = function () {
let fieldaaray = [];
if (suggestionData.field.length) {
fieldaaray = suggestionData.field.map(
item => `<p>${item}</p>
(item) => `<p>${item}</p>
<p>${args[3][item]}</p>`,
);
}
Expand Down Expand Up @@ -319,7 +319,7 @@ const dashboardcontroller = function () {
}
if (req.body.action === "delete") {
suggestionData.field = suggestionData.field.filter(
item => item !== req.body.newField,
(item) => item !== req.body.newField,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/emailController.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ module.exports = {
addNonHgnEmailSubscription,
removeNonHgnEmailSubscription,
confirmNonHgnEmailSubscription,
};
};
10 changes: 5 additions & 5 deletions src/controllers/informationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const informationController = function (Information) {
cache.setCache('informations', results);
res.status(200).send(results);
})
.catch(error => res.status(404).send(error));
.catch((error) => res.status(404).send(error));
};

const addInformation = function (req, res) {
Expand All @@ -41,9 +41,9 @@ const informationController = function (Information) {
}
res.status(201).send(newInformation);
})
.catch(error => res.status(400).send(error));
.catch((error) => res.status(400).send(error));
})
.catch(error => res.status(500).send({ error }));
.catch((error) => res.status(500).send({ error }));
};

const deleteInformation = function (req, res) {
Expand All @@ -56,7 +56,7 @@ const informationController = function (Information) {
}
res.status(200).send(deletedInformation);
})
.catch(error => res.status(400).send(error));
.catch((error) => res.status(400).send(error));
};

// Update existing information by id
Expand All @@ -70,7 +70,7 @@ const informationController = function (Information) {
}
res.status(200).send(updatedInformation);
})
.catch(error => res.status(400).send(error));
.catch((error) => res.status(400).send(error));
};

return {
Expand Down
Loading

0 comments on commit fb79bcb

Please sign in to comment.