diff --git a/src/controllers/installationController.js b/src/controllers/installationController.js index fd9890e8..988040fe 100644 --- a/src/controllers/installationController.js +++ b/src/controllers/installationController.js @@ -134,6 +134,42 @@ exports.createTeamMember = async (request, reply) => { }); } }; + + exports.getAllInstallers = async (request, reply) => { + try { + const { departmentName } = request.params; // Get installationId from request params + + // Check if installation exists + const installationList = await Deparments.find({ departmentName }); + + if (!installationList) { + return reply.status(404).send({ + simplydata: { + error: true, + message: "Installation not found", + }, + }); + } + + + + return reply.send({ + simplydata: { + error: false, + installationList, // Return the list of team members + }, + }); + + } catch (err) { + console.error("Error fetching team members:", err); + reply.status(500).send({ + simplydata: { + error: true, + message: "Internal server error", + }, + }); + } + }; exports.editTeamMember = async (request, reply) => { try { diff --git a/src/routes/installationRoute.js b/src/routes/installationRoute.js index 1b665cd9..caf10a6f 100644 --- a/src/routes/installationRoute.js +++ b/src/routes/installationRoute.js @@ -74,6 +74,25 @@ module.exports = function (fastify, opts, next) { handler: installationController.getTeamMembers }); + fastify.get("/api/getAllInstallers/:departmentName", { + schema: { + description: "Get All Installtion list", + tags: ["Installation"], + summary: "Get All Installtion list", + params: { + type: "object", + properties: { + departmentName: { + type: "string", + description: "departmentName to fetch Installation list" + } + }, + required: ["departmentName"] + }, + }, + handler: installationController.getAllInstallers + }); + fastify.put("/api/editTeamMember/:installationId/:teamMemberId", { schema: { description: "Update an existing team member's details",