|
|
|
@ -4216,3 +4216,46 @@ exports.particularCategory = async (req, reply) => {
|
|
|
|
|
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 });
|
|
|
|
|
};
|
|
|
|
|