From 245ada62d7204208615996fbab737723c1b1d0e8 Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Tue, 24 Jun 2025 12:14:46 +0530 Subject: [PATCH] comments changes --- src/controllers/installationController.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/controllers/installationController.js b/src/controllers/installationController.js index 9d121c50..454fa681 100644 --- a/src/controllers/installationController.js +++ b/src/controllers/installationController.js @@ -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);