|
|
@ -8468,11 +8468,12 @@ exports.moveIssueToCategory = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
|
|
const issue = support.issues[index];
|
|
|
|
const issue = support.issues[index];
|
|
|
|
|
|
|
|
|
|
|
|
// Normalize type if it's invalid
|
|
|
|
// Normalize type if needed
|
|
|
|
const normalizedType =
|
|
|
|
const normalizedType =
|
|
|
|
issue.type === "GSM or LoRa Disconnected" ? "GSM Disconnected" : issue.type;
|
|
|
|
issue.type === "GSM or LoRa Disconnected" ? "GSM Disconnected" : issue.type;
|
|
|
|
|
|
|
|
|
|
|
|
if (issue.hardwareId === hardwareId) {
|
|
|
|
if (issue.hardwareId === hardwareId) {
|
|
|
|
|
|
|
|
// Master issue
|
|
|
|
issue.movedToCategory = true;
|
|
|
|
issue.movedToCategory = true;
|
|
|
|
|
|
|
|
|
|
|
|
support.categorizedIssues.push({
|
|
|
|
support.categorizedIssues.push({
|
|
|
@ -8487,6 +8488,7 @@ exports.moveIssueToCategory = async (req, reply) => {
|
|
|
|
support.issues.splice(index, 1);
|
|
|
|
support.issues.splice(index, 1);
|
|
|
|
issueMoved = true;
|
|
|
|
issueMoved = true;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Slave issue
|
|
|
|
const slaveIndex = issue.hardwareIds.indexOf(hardwareId);
|
|
|
|
const slaveIndex = issue.hardwareIds.indexOf(hardwareId);
|
|
|
|
if (slaveIndex !== -1) {
|
|
|
|
if (slaveIndex !== -1) {
|
|
|
|
const slaveName = issue.slaveNames?.[slaveIndex] || "Unknown";
|
|
|
|
const slaveName = issue.slaveNames?.[slaveIndex] || "Unknown";
|
|
|
@ -8504,6 +8506,7 @@ exports.moveIssueToCategory = async (req, reply) => {
|
|
|
|
issue.hardwareIds.splice(slaveIndex, 1);
|
|
|
|
issue.hardwareIds.splice(slaveIndex, 1);
|
|
|
|
issue.slaveNames.splice(slaveIndex, 1);
|
|
|
|
issue.slaveNames.splice(slaveIndex, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Remove full issue if no more slaves are left
|
|
|
|
if (issue.hardwareIds.length === 0) {
|
|
|
|
if (issue.hardwareIds.length === 0) {
|
|
|
|
support.issues.splice(index, 1);
|
|
|
|
support.issues.splice(index, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -8513,6 +8516,15 @@ exports.moveIssueToCategory = async (req, reply) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (issueMoved) {
|
|
|
|
if (issueMoved) {
|
|
|
|
|
|
|
|
await support.save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 🧹 Cleanup any duplicate issues with same hardwareId (master or slave)
|
|
|
|
|
|
|
|
support.issues = support.issues.filter((i) => {
|
|
|
|
|
|
|
|
const isMaster = i.hardwareId === hardwareId;
|
|
|
|
|
|
|
|
const isSlave = Array.isArray(i.hardwareIds) && i.hardwareIds.includes(hardwareId);
|
|
|
|
|
|
|
|
return !isMaster && !isSlave;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
await support.save();
|
|
|
|
await support.save();
|
|
|
|
return reply.send({ message: "Issue moved to category successfully" });
|
|
|
|
return reply.send({ message: "Issue moved to category successfully" });
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -8524,6 +8536,7 @@ 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;
|
|
|
|