comments changes

master^2
Bhaskar 3 months ago
parent ee8b16d484
commit 245ada62d7

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

Loading…
Cancel
Save