From a307042abd26d58c953c570a652d11e81782baa6 Mon Sep 17 00:00:00 2001 From: braimbault Date: Mon, 25 Nov 2024 16:39:10 +0100 Subject: [PATCH] feat: getRelativePeriodsMap --- src/components/PeriodDimension/utils/relativePeriods.js | 9 +++++++++ src/index.js | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/PeriodDimension/utils/relativePeriods.js b/src/components/PeriodDimension/utils/relativePeriods.js index a0fb2463a..6789f2934 100644 --- a/src/components/PeriodDimension/utils/relativePeriods.js +++ b/src/components/PeriodDimension/utils/relativePeriods.js @@ -162,3 +162,12 @@ export const getRelativePeriodIds = () => Object.values(getOptions()) .map((option) => option.getPeriods().map((period) => period.id)) .flat() + +export const getRelativePeriodsMap = () => + Object.values(getOptions()) + .map((option) => option.getPeriods()) + .flat() + .reduce((acc, period) => { + acc[period.id] = period.name + return acc + }, {}) diff --git a/src/index.js b/src/index.js index 4518b2c1a..2484bfc11 100644 --- a/src/index.js +++ b/src/index.js @@ -338,7 +338,7 @@ export { } from './components/PeriodDimension/utils/index.js' export { getRelativePeriodsOptionsById, - getRelativePeriodIds, + getRelativePeriodsMap, } from './components/PeriodDimension/utils/relativePeriods.js' export { getFixedPeriodsOptionsById } from './components/PeriodDimension/utils/fixedPeriods.js'