From 803d4c3251b3ce6b7014bc6e168adb0b01e130e2 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Mon, 26 Jun 2023 15:41:40 +0700 Subject: [PATCH] Fix progress s curve --- src/views/Dashboard/DashboardProject.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/views/Dashboard/DashboardProject.js b/src/views/Dashboard/DashboardProject.js index 74a55cb..2c82a21 100644 --- a/src/views/Dashboard/DashboardProject.js +++ b/src/views/Dashboard/DashboardProject.js @@ -281,8 +281,11 @@ const DashboardProject = () => { setEstAtCompletion(result.data.data[0].data.budget_control.estimated_at_completion?.toString()) setCostDeviation(result.data.data[0].data.budget_control.cost_deviation?.toString()) } + let now = new Date().toISOString().slice(0, 10); + let dates = result.data.data[0].data?.date; + let n = dates.findIndex(element => new Date(now) < new Date(element[0])) - 1; if (result.data.data.length > 0 && result.data.data[0].data?.percentagePlan && result.data.data[0].data?.percentagePlan.length > 0) { - planningProgress = result.data.data[0].data?.percentagePlan[result.data.data[0].data?.percentagePlan.length - 1]; + planningProgress = result.data.data[0].data?.percentagePlan[n]; setPlanningProgress(planningProgress); } if (result.data.data.length > 0 && result.data.data[0].data?.percentageReal && result.data.data[0].data?.percentageReal.length > 0) {