From 3f6302d08c024c3acc3e4c30a6f92b2c835dc937 Mon Sep 17 00:00:00 2001 From: hatim dinia Date: Mon, 11 Mar 2024 10:27:18 +0100 Subject: [PATCH] fix(outputs-ui): correct weekly data formatting to support 53-week years (cherry picked from commit 70bd975788b46738870465f3aa1002a1a2107c1e) --- docs/CHANGELOG.md | 1 + .../Singlestudy/explore/Results/ResultDetails/index.tsx | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 89c3218b06..a64b8ad2a5 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -16,6 +16,7 @@ v2.16.8 (2024-04-19) * **variants:** avoid recursive error when creating big variant tree [`#1967`](https://github.com/AntaresSimulatorTeam/AntaREST/pull/1967) * **outputs:** build outputs config even when using cache [`#1958`](https://github.com/AntaresSimulatorTeam/AntaREST/pull/1958) * **comments:** use a command to update comments on a variant [`#1959`](https://github.com/AntaresSimulatorTeam/AntaREST/pull/1959) +* **outputs (ui):** correct weekly data formatting to support 53-week years [`#1975`](https://github.com/AntaresSimulatorTeam/AntaREST/pull/1975) v2.16.7 (2024-03-05) 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 e1c3748b73..763405900a 100644 --- a/webapp/src/components/App/Singlestudy/explore/Results/ResultDetails/index.tsx +++ b/webapp/src/components/App/Singlestudy/explore/Results/ResultDetails/index.tsx @@ -158,11 +158,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]; @@ -170,7 +175,6 @@ function ResultDetails() { const outputFormat = { [Timestep.Hourly]: "DD MMM HH:mm I", [Timestep.Daily]: "DD MMM I", - [Timestep.Weekly]: "WW", [Timestep.Monthly]: "MMM", }[timestep];