From 70bd975788b46738870465f3aa1002a1a2107c1e Mon Sep 17 00:00:00 2001 From: hatim dinia Date: Mon, 11 Mar 2024 10:27:18 +0100 Subject: [PATCH] fix(results): correct weekly data formatting to support 53-week years --- .../Singlestudy/explore/Results/ResultDetails/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webapp/src/components/App/Singlestudy/explore/Results/ResultDetails/index.tsx b/webapp/src/components/App/Singlestudy/explore/Results/ResultDetails/index.tsx index 425245f9db..2675d7d424 100644 --- a/webapp/src/components/App/Singlestudy/explore/Results/ResultDetails/index.tsx +++ b/webapp/src/components/App/Singlestudy/explore/Results/ResultDetails/index.tsx @@ -160,11 +160,16 @@ function ResultDetails() { return ["Annual"]; } + // Directly use API's week index (handles 53 weeks) as no formatting is required. + // !NOTE: Suboptimal: Assumes API consistency, lacks flexibility. + if (timestep === Timestep.Weekly) { + return matrixRes.data.index.map((weekNumber) => weekNumber.toString()); + } + // Original date/time format mapping for moment parsing const parseFormat = { [Timestep.Hourly]: "MM/DD HH:mm", [Timestep.Daily]: "MM/DD", - [Timestep.Weekly]: "WW", [Timestep.Monthly]: "MM", }[timestep]; @@ -172,7 +177,6 @@ function ResultDetails() { const outputFormat = { [Timestep.Hourly]: "DD MMM HH:mm I", [Timestep.Daily]: "DD MMM I", - [Timestep.Weekly]: "WW", [Timestep.Monthly]: "MMM", }[timestep];