Skip to content

Commit

Permalink
Merge pull request #992 from OneCommunityGlobal/Shereen_Equipment_Lis…
Browse files Browse the repository at this point in the history
…tView_backend

Shereen - Equipment List View
  • Loading branch information
one-community authored Jul 7, 2024
2 parents 81c9102 + 2f7f780 commit ce96b31
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/controllers/bmdashboard/bmEquipmentController.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,45 @@ const bmEquipmentController = (BuildingEquipment) => {
}
};

const fetchBMEquipments = async (req, res) => {
try {
BuildingEquipment
.find()
.populate([
{
path: 'project',
select: '_id name',
},
{
path: 'itemType',
select: '_id name',
},
{
path: 'updateRecord',
populate: {
path: 'createdBy',
select: '_id firstName lastName',
},
},
{
path: 'purchaseRecord',
populate: {
path: 'requestedBy',
select: '_id firstName lastName',
},
},
])
.exec()
.then((result) => {
res.status(200).send(result);
})
.catch((error) => res.status(500).send(error));
} catch (err) {
res.json(err);
}
};


const bmPurchaseEquipments = async function (req, res) {
const {
projectId,
Expand Down Expand Up @@ -103,6 +142,7 @@ const bmEquipmentController = (BuildingEquipment) => {
return {
fetchSingleEquipment,
bmPurchaseEquipments,
fetchBMEquipments,
};
};

Expand Down
2 changes: 2 additions & 0 deletions src/routes/bmdashboard/bmEquipmentRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const routes = function (BuildingEquipment) {

equipmentRouter.route('/equipment/purchase').post(controller.bmPurchaseEquipments);

equipmentRouter.route('/equipments').get(controller.fetchBMEquipments);

return equipmentRouter;
};

Expand Down

0 comments on commit ce96b31

Please sign in to comment.