From 57d481be369ea204139459a53853e15eeb2c1ccd Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Thu, 22 May 2025 17:52:30 +0530 Subject: [PATCH] status maintain in team member for support --- src/controllers/installationController.js | 43 +++++++++++++++++++++++ src/routes/installationRoute.js | 30 ++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/src/controllers/installationController.js b/src/controllers/installationController.js index 004794ad..383ac2f5 100644 --- a/src/controllers/installationController.js +++ b/src/controllers/installationController.js @@ -5468,3 +5468,46 @@ exports.getCategorizedIssue = async (request, reply) => { return reply.code(500).send({ error: "Internal server error" }); } }; + + +exports.StatusTeamMember = async (request, reply) => { + try { + const { supportId, support_teamMemberId } = request.params; + const { status } = request.body; + + if (!supportId || !support_teamMemberId || !status) { + return reply.code(400).send({ + success: false, + message: "supportId, support_teamMemberId, and status are required." + }); + } + + const result = await Support.findOneAndUpdate( + { supportId, 'team_member.team_member.support_teamMemberId': support_teamMemberId }, + { $set: { 'team_member.team_member.$.status': status } }, + { new: true } + ); + + if (!result) { + return reply.code(404).send({ + success: false, + message: "Team member not found with given supportId and support_teamMemberId." + }); + } + + return reply.send({ + success: true, + message: "Team member status updated successfully.", + updatedMember: result.team_member.team_member.find( + tm => tm.support_teamMemberId === support_teamMemberId + ) + }); + + } catch (error) { + console.error("Error updating team member status:", error); + return reply.code(500).send({ + success: false, + message: "Internal Server Error" + }); + } +}; diff --git a/src/routes/installationRoute.js b/src/routes/installationRoute.js index ba5fe46e..c753b057 100644 --- a/src/routes/installationRoute.js +++ b/src/routes/installationRoute.js @@ -812,6 +812,36 @@ module.exports = function (fastify, opts, next) { }, handler: installationController.getCategorizedIssue }); + + fastify.post("/api/assignTeammember/:supportId/:support_teamMemberId", { + schema: { + description: "Team Member status matain for support", + tags: ["Support"], + summary: "Team Member status matain for support", + params: { + type: "object", + properties: { + supportId: { + type: "string", + }, + support_teamMemberId: { + type: "string", + } + }, + }, + body: { + type: "object", + properties: { + status: { + type: "string", + }, + + }, + // required: ["teamMemberId"] + }, + }, + handler: installationController.StatusTeamMember + }); next(); } \ No newline at end of file