|
|
|
@ -9158,12 +9158,19 @@ exports.updateComments = async (req, reply) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Step 4: Append comment object with formatted createdAt
|
|
|
|
|
// const commentObj = {
|
|
|
|
|
// text: trimmedComment,
|
|
|
|
|
// customerId,
|
|
|
|
|
// hardwareId,
|
|
|
|
|
// createdAt: moment().format("DD-MM-YYYY HH:mm")
|
|
|
|
|
// };
|
|
|
|
|
const commentObj = {
|
|
|
|
|
text: trimmedComment,
|
|
|
|
|
customerId,
|
|
|
|
|
hardwareId,
|
|
|
|
|
createdAt: moment().format("DD-MM-YYYY HH:mm")
|
|
|
|
|
};
|
|
|
|
|
text: trimmedComment,
|
|
|
|
|
customerId,
|
|
|
|
|
hardwareId,
|
|
|
|
|
createdAt: new Date() // ✅ correct Date object
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Array.isArray(supportRecord.comments)) {
|
|
|
|
|
supportRecord.comments = [];
|
|
|
|
@ -9173,7 +9180,10 @@ exports.updateComments = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
await supportRecord.save();
|
|
|
|
|
|
|
|
|
|
return reply.send({ message: "Comment added successfully", comment: commentObj });
|
|
|
|
|
return reply.send({ message: "Comment added successfully", comment: {
|
|
|
|
|
...commentObj,
|
|
|
|
|
createdAt: moment(commentObj.createdAt).format("DD-MM-YYYY HH:mm")
|
|
|
|
|
}});
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Error updating comments:", error);
|
|
|
|
|