From 3c433f09012d43646a84ba2d0c61cbb90171bb43 Mon Sep 17 00:00:00 2001 From: Arnaud AMBROSELLI Date: Mon, 19 Feb 2024 15:38:14 +0100 Subject: [PATCH] remove fix --- dashboard/src/components/ActionModal.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dashboard/src/components/ActionModal.js b/dashboard/src/components/ActionModal.js index 82a329d50..3fe7b02c8 100644 --- a/dashboard/src/components/ActionModal.js +++ b/dashboard/src/components/ActionModal.js @@ -274,12 +274,15 @@ function ActionContent({ onClose, action, personId = null, personIds = null, isM const body = { ...data }; body.teams = Array.isArray(data.teams) ? data.teams : [data.team]; if (!data.teams?.length) return toast.error('Une action doit être associée à au moins une équipe.'); - if ([DONE, CANCEL].includes(data.status)) { - // When status changed to finished (done, cancel) completedAt we set it to now if not set. - body.completedAt = data.completedAt || now(); - } else { - // When status just changed to "todo" we set completedAt to null (since it's not done yet). - body.completedAt = null; + const statusChanged = data.status && action.status !== data.status; + if (statusChanged) { + if ([DONE, CANCEL].includes(data.status)) { + // When status changed to finished (done, cancel) completedAt we set it to now if not set. + body.completedAt = data.completedAt || now(); + } else { + // When status just changed to "todo" we set completedAt to null (since it's not done yet). + body.completedAt = null; + } } if (data.completedAt && outOfBoundariesDate(data.completedAt)) return toast.error('La date de complétion est hors limites (entre 1900 et 2100)'); if (data.dueAt && outOfBoundariesDate(data.dueAt)) return toast.error("La date d'échéance est hors limites (entre 1900 et 2100)");