From 1052a31456992ca952193268b59881a1b790b552 Mon Sep 17 00:00:00 2001 From: wahyu Date: Tue, 29 Aug 2023 10:35:51 +0700 Subject: [PATCH] update overdue dashboard project --- src/views/Dashboard/DashboardProject.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/views/Dashboard/DashboardProject.js b/src/views/Dashboard/DashboardProject.js index b4fb6a2..1c87cbd 100644 --- a/src/views/Dashboard/DashboardProject.js +++ b/src/views/Dashboard/DashboardProject.js @@ -584,15 +584,23 @@ const DashboardProject = () => { {!isReadyOverdueActivities && } {isReadyOverdueActivities && overdueActivities && overdueActivities.length < 1 &&
No overdue activity found.
} {isReadyOverdueActivities && overdueActivities && overdueActivities.length > 0 && overdueActivities.map((item, idx) => { - let end_date = null; - let today = null; + let end_date; + let planned_end; let diffDays = 0; let message = ''; if (item.end_date && item.end_date !== null) { end_date = moment(item.end_date); - today = moment(new Date()); - diffDays = today.diff(end_date, 'days'); - message = `Overdue by ${diffDays} days`; + planned_end = moment(item.planned_end); + diffDays = end_date.diff(planned_end, 'days'); + if (isNaN(diffDays)) { + return null; + } else { + if (diffDays > 0) { + message = `Overdue by ${diffDays + 1} days`; + } else { + return null; + } + } } return })}