|
|
@ -8296,6 +8296,99 @@ exports.deleteTeamMemberSupport = async (req, reply)=> {
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// };
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// exports.moveIssueToCategory = async (req, reply) => {
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// const { supportId } = req.params;
|
|
|
|
|
|
|
|
// const { category, hardwareId } = req.body;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (!supportId || !category || !hardwareId) {
|
|
|
|
|
|
|
|
// return reply.code(400).send({
|
|
|
|
|
|
|
|
// message: "supportId (path), category and hardwareId (body) are required",
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const support = await Support.findOne({ supportId });
|
|
|
|
|
|
|
|
// if (!support) {
|
|
|
|
|
|
|
|
// return reply.code(404).send({ message: "Support record not found" });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let issueMoved = false;
|
|
|
|
|
|
|
|
// const nowTime = moment().tz("Asia/Kolkata").format("YYYY-MM-DD HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (!Array.isArray(support.categorizedIssues)) {
|
|
|
|
|
|
|
|
// support.categorizedIssues = [];
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const index = support.issues.findIndex((issue) => {
|
|
|
|
|
|
|
|
// if (issue.hardwareId === hardwareId) return true;
|
|
|
|
|
|
|
|
// if (Array.isArray(issue.hardwareIds) && issue.hardwareIds.includes(hardwareId)) return true;
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (index === -1) {
|
|
|
|
|
|
|
|
// return reply.code(404).send({ message: "No matching issue found to move" });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const issue = support.issues[index];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // Normalize type if it's invalid
|
|
|
|
|
|
|
|
// const normalizedType =
|
|
|
|
|
|
|
|
// issue.type === "GSM or LoRa Disconnected" ? "GSM Disconnected" : issue.type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (issue.hardwareId === hardwareId) {
|
|
|
|
|
|
|
|
// issue.movedToCategory = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// support.categorizedIssues.push({
|
|
|
|
|
|
|
|
// type: normalizedType,
|
|
|
|
|
|
|
|
// hardwareId: issue.hardwareId,
|
|
|
|
|
|
|
|
// masterHardwareId: issue.masterHardwareId || issue.hardwareId,
|
|
|
|
|
|
|
|
// category,
|
|
|
|
|
|
|
|
// //ticketId : issue.ticketId,
|
|
|
|
|
|
|
|
// movedAt: nowTime,
|
|
|
|
|
|
|
|
// movedToCategory: true,
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// support.issues.splice(index, 1);
|
|
|
|
|
|
|
|
// issueMoved = true;
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// const slaveIndex = issue.hardwareIds.indexOf(hardwareId);
|
|
|
|
|
|
|
|
// if (slaveIndex !== -1) {
|
|
|
|
|
|
|
|
// const slaveName = issue.slaveNames?.[slaveIndex] || "Unknown";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// support.categorizedIssues.push({
|
|
|
|
|
|
|
|
// type: normalizedType,
|
|
|
|
|
|
|
|
// hardwareId,
|
|
|
|
|
|
|
|
// masterHardwareId: issue.masterHardwareId || issue.hardwareId,
|
|
|
|
|
|
|
|
// slaveName,
|
|
|
|
|
|
|
|
// category,
|
|
|
|
|
|
|
|
// //ticketId : issue.ticketId,
|
|
|
|
|
|
|
|
// movedAt: nowTime,
|
|
|
|
|
|
|
|
// movedToCategory: true,
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// issue.hardwareIds.splice(slaveIndex, 1);
|
|
|
|
|
|
|
|
// issue.slaveNames.splice(slaveIndex, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (issue.hardwareIds.length === 0) {
|
|
|
|
|
|
|
|
// support.issues.splice(index, 1);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// issueMoved = true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (issueMoved) {
|
|
|
|
|
|
|
|
// await support.save();
|
|
|
|
|
|
|
|
// return reply.send({ message: "Issue moved to category successfully" });
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// return reply.code(404).send({ message: "No matching issue found to move" });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } catch (err) {
|
|
|
|
|
|
|
|
// console.error("Error moving issue:", err);
|
|
|
|
|
|
|
|
// return reply.code(500).send({ error: "Internal Server Error" });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
exports.moveIssueToCategory = async (req, reply) => {
|
|
|
|
exports.moveIssueToCategory = async (req, reply) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const { supportId } = req.params;
|
|
|
|
const { supportId } = req.params;
|
|
|
@ -8343,7 +8436,6 @@ exports.moveIssueToCategory = async (req, reply) => {
|
|
|
|
hardwareId: issue.hardwareId,
|
|
|
|
hardwareId: issue.hardwareId,
|
|
|
|
masterHardwareId: issue.masterHardwareId || issue.hardwareId,
|
|
|
|
masterHardwareId: issue.masterHardwareId || issue.hardwareId,
|
|
|
|
category,
|
|
|
|
category,
|
|
|
|
//ticketId : issue.ticketId,
|
|
|
|
|
|
|
|
movedAt: nowTime,
|
|
|
|
movedAt: nowTime,
|
|
|
|
movedToCategory: true,
|
|
|
|
movedToCategory: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -8361,7 +8453,6 @@ exports.moveIssueToCategory = async (req, reply) => {
|
|
|
|
masterHardwareId: issue.masterHardwareId || issue.hardwareId,
|
|
|
|
masterHardwareId: issue.masterHardwareId || issue.hardwareId,
|
|
|
|
slaveName,
|
|
|
|
slaveName,
|
|
|
|
category,
|
|
|
|
category,
|
|
|
|
//ticketId : issue.ticketId,
|
|
|
|
|
|
|
|
movedAt: nowTime,
|
|
|
|
movedAt: nowTime,
|
|
|
|
movedToCategory: true,
|
|
|
|
movedToCategory: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -8389,7 +8480,6 @@ exports.moveIssueToCategory = async (req, reply) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// exports.particularCategory = async (req, reply) => {
|
|
|
|
// exports.particularCategory = async (req, reply) => {
|
|
|
|
// try {
|
|
|
|
// try {
|
|
|
|
// const { supportId, category } = req.params;
|
|
|
|
// const { supportId, category } = req.params;
|
|
|
|