diff --git a/src/controllers/installationController.js b/src/controllers/installationController.js index 9c6d4f7a..cbaefe1d 100644 --- a/src/controllers/installationController.js +++ b/src/controllers/installationController.js @@ -8858,12 +8858,15 @@ exports.updateHardwareList = async (req, reply) => { + exports.assignCategorizeIssue = async (request, reply) => { const { supportId } = request.params; const { support_teamMemberId, category, masterHardwareId } = request.body; if (!support_teamMemberId || !category || !masterHardwareId) { - return reply.code(400).send({ error: 'support_teamMemberId, startDate, endDate, category, and masterHardwareId are required' }); + return reply.code(400).send({ + error: 'support_teamMemberId, category, and masterHardwareId are required' + }); } const support = await Support.findOne({ supportId }); @@ -8878,17 +8881,7 @@ exports.assignCategorizeIssue = async (request, reply) => { return reply.code(400).send({ error: `Team member ID ${support_teamMemberId} not found` }); } - // ✅ Parse using moment with expected format - // const start = moment(startDate, "DD-MM-YYYY HH:mm", true); - // const end = moment(endDate, "DD-MM-YYYY HH:mm", true); - - // if (!start.isValid() || !end.isValid()) { - // return reply.code(400).send({ error: 'Invalid startDate or endDate format. Use DD-MM-YYYY HH:mm' }); - // } - - // const formattedStart = start.format("DD-MM-YYYY HH:mm:ss"); - // const formattedEnd = end.format("DD-MM-YYYY HH:mm:ss"); - + const assignedAt = moment().format("DD-MM-YYYY HH:mm:ss"); let assignedCount = 0; support.categorizedIssues.forEach(issue => { @@ -8901,8 +8894,7 @@ exports.assignCategorizeIssue = async (request, reply) => { support_teamMemberId: teamMember.support_teamMemberId, phone: teamMember.phone, email: teamMember.email, - // startDate: formattedStart, - // endDate: formattedEnd + assignedAt: assignedAt }; assignedCount++; } @@ -8916,13 +8908,20 @@ exports.assignCategorizeIssue = async (request, reply) => { return reply.send({ message: `Assigned ${assignedCount} categorized issue(s) to ${teamMember.name}`, - assignedTo: teamMember.support_teamMemberId + assignedTo: { + support_teamMemberId: teamMember.support_teamMemberId, + name: teamMember.name, + phone: teamMember.phone, + email: teamMember.email, + assignedAt: assignedAt + } }); }; + exports.getCategorizedIssue = async (request, reply) => { try { const { support_teamMemberId, customerId } = request.params; diff --git a/src/models/store.js b/src/models/store.js index d7c4cbad..5e8f515f 100644 --- a/src/models/store.js +++ b/src/models/store.js @@ -282,7 +282,8 @@ const installationschema = new mongoose.Schema({ phone: String, email: String, startDate: String, - endDate: String + endDate: String, + assignedAt: String } });