|
|
@ -8799,6 +8799,70 @@ exports.particularCategory = async (req, reply) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.updateHardwareList = async (req, reply) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const { supportId, customerId, hardwareId } = req.params;
|
|
|
|
|
|
|
|
const { hardwareList } = req.body;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!supportId || !customerId || !hardwareId) {
|
|
|
|
|
|
|
|
return reply.code(400).send({
|
|
|
|
|
|
|
|
error: "supportId, customerId, and hardwareId are required in path params",
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!hardwareList || typeof hardwareList !== "object") {
|
|
|
|
|
|
|
|
return reply.code(400).send({
|
|
|
|
|
|
|
|
error: "hardwareList must be a valid object in request body",
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ✅ Check if support record exists
|
|
|
|
|
|
|
|
const support = await Support.findOne({ supportId }).lean();
|
|
|
|
|
|
|
|
if (!support) {
|
|
|
|
|
|
|
|
return reply.code(404).send({ error: "Support record not found" });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ✅ Ensure at least one escalation issue exists for that hardware and customer
|
|
|
|
|
|
|
|
const escalationIssue = (support.categorizedIssues || []).find(issue =>
|
|
|
|
|
|
|
|
issue.category === "Escalation" &&
|
|
|
|
|
|
|
|
issue.hardwareId === hardwareId
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!escalationIssue) {
|
|
|
|
|
|
|
|
return reply.code(403).send({
|
|
|
|
|
|
|
|
error: "Update not allowed. Escalation issue not found for this supportId and hardwareId.",
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ✅ Check if the Insensors document exists
|
|
|
|
|
|
|
|
const sensor = await Insensors.findOne({ customerId, hardwareId });
|
|
|
|
|
|
|
|
if (!sensor) {
|
|
|
|
|
|
|
|
return reply.code(404).send({ message: "Insensor not found for the given customerId and hardwareId" });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ✅ Update hardwareList
|
|
|
|
|
|
|
|
sensor.hardwareList = hardwareList;
|
|
|
|
|
|
|
|
await sensor.save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return reply.send({
|
|
|
|
|
|
|
|
status_code: 200,
|
|
|
|
|
|
|
|
message: "Hardware list updated successfully for escalated issue",
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
supportId,
|
|
|
|
|
|
|
|
customerId,
|
|
|
|
|
|
|
|
hardwareId,
|
|
|
|
|
|
|
|
hardwareList: sensor.hardwareList
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error("Error updating hardware list:", error);
|
|
|
|
|
|
|
|
return reply.code(500).send({ error: "Internal server error" });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.assignCategorizeIssue = async (request, reply) => {
|
|
|
|
exports.assignCategorizeIssue = async (request, reply) => {
|
|
|
|
const { supportId } = request.params;
|
|
|
|
const { supportId } = request.params;
|
|
|
|
const { support_teamMemberId, startDate, endDate, category, masterHardwareId } = request.body;
|
|
|
|
const { support_teamMemberId, startDate, endDate, category, masterHardwareId } = request.body;
|
|
|
|