assign the categorize issues team member

master^2
Bhaskar 5 months ago
parent c745b56536
commit f25cf11e8d

@ -4216,3 +4216,46 @@ exports.particularCategory = async (req, reply) => {
return reply.code(500).send({ error: "Internal server error" }); return reply.code(500).send({ error: "Internal server error" });
} }
}; };
exports.assignCategorizeIssue = async (request, reply) => {
const { supportId } = request.params;
const { categorizedIssueId, support_teamMemberId } = request.body;
if (!categorizedIssueId || !support_teamMemberId) {
return reply.code(400).send({ error: 'categorizedIssueId and support_teamMemberId are required' });
}
//const Support = Support.model('Support'); // your model name here
const support = await Support.findOne({ supportId });
if (!support) {
return reply.code(404).send({ error: 'Support record not found' });
}
// Find the team member in the support team_member array
const teamMembers = support.team_member?.team_member || [];
const teamMember = teamMembers.find(m => m.support_teamMemberId === support_teamMemberId);
if (!teamMember) {
return reply.code(400).send({ error: `Team member ID ${support_teamMemberId} not found` });
}
// Find the categorized issue to assign
const issue = support.categorizedIssues.id(categorizedIssueId);
if (!issue) {
return reply.code(404).send({ error: `Categorized issue with ID ${categorizedIssueId} not found` });
}
// Assign the team member info to the issue
issue.assignedTo = {
name: teamMember.name,
support_teamMemberId: teamMember.support_teamMemberId,
phone: teamMember.phone,
email: teamMember.email,
};
await support.save();
return reply.send({ message: 'Issue assigned successfully', issue });
};

@ -264,6 +264,12 @@ const installationschema = new mongoose.Schema({
movedAt: { movedAt: {
type: String, // or Date, depending on your preference type: String, // or Date, depending on your preference
required: true required: true
},
assignedTo: {
name: String,
support_teamMemberId: String,
phone: String,
email: String,
} }
} }
], ],

@ -702,7 +702,29 @@ module.exports = function (fastify, opts, next) {
}); });
fastify.post("/api/assignTeamMemberIssueToCategory/:supportId", {
schema: {
description: "Assign the team member categorize issue",
tags: ["Support"],
summary: "Assign the team member categorize issue",
params: {
type: "object",
required: ["supportId"],
properties: {
supportId: { type: "string" },
},
},
body: {
type: "object",
required: ["categorizedIssueId", "support_teamMemberId"],
properties: {
categorizedIssueId: { type: "string" },
support_teamMemberId: { type: "string" },
},
},
},
handler: installationController.assignCategorizeIssue
});
next(); next();
} }
Loading…
Cancel
Save