From 89b4575ea24e32f645c0b3a810bffd5a865df1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Henrik=20=C3=98verland?= Date: Thu, 9 Nov 2023 11:48:33 +0100 Subject: [PATCH] fix: use right param --- src/i18n-keys.js | 2 +- src/pages/analytics/analytics.conf.js | 19 ++++++++++--------- src/pages/analytics/use-checkboxes.js | 12 ++---------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/i18n-keys.js b/src/i18n-keys.js index 6771df1d..68cd7b51 100644 --- a/src/i18n-keys.js +++ b/src/i18n-keys.js @@ -104,7 +104,7 @@ export const i18nKeys = { skipOrgUnitOwnership: i18n.t( 'Skip generation of organisation unit ownership data' ), - executeTei: i18n.t('Generate outlier data'), + skipOutliers: i18n.t('Skip generation of outlier data'), }, }, dataStatistics: { diff --git a/src/pages/analytics/analytics.conf.js b/src/pages/analytics/analytics.conf.js index 620ff323..8913c93a 100644 --- a/src/pages/analytics/analytics.conf.js +++ b/src/pages/analytics/analytics.conf.js @@ -28,13 +28,14 @@ export const lastYearElements = lastYearValues /* Form checkboxes */ export const analyticsCheckboxes = [ - 'skipAggregate', - 'skipResourceTables', - 'skipEvents', - 'skipEnrollment', - 'skipOrgUnitOwnership', - 'executeTei', -].map((key) => ({ - key, - label: i18nKeys.analytics.checkboxes[key], + { key: 'skipAggregate' }, + { key: 'skipResourceTables' }, + { key: 'skipEvents' }, + { key: 'skipEnrollment' }, + { key: 'skipOrgUnitOwnership' }, + { key: 'skipOutliers', checked: true }, +].map((obj) => ({ + key: obj.key, + checked: Boolean(obj.checked), + label: i18nKeys.analytics.checkboxes[obj.key], })) diff --git a/src/pages/analytics/use-checkboxes.js b/src/pages/analytics/use-checkboxes.js index 4dc12058..dd634287 100644 --- a/src/pages/analytics/use-checkboxes.js +++ b/src/pages/analytics/use-checkboxes.js @@ -2,16 +2,8 @@ import { useState } from 'react' import { analyticsCheckboxes } from './analytics.conf.js' export const useCheckboxes = () => { - const [checkboxes, setCheckboxes] = useState(() => { - const checkboxes = {} - analyticsCheckboxes.forEach((checkbox) => { - checkboxes[checkbox.key] = { - checked: false, - label: checkbox.label, - } - }) - return checkboxes - }) + const [checkboxes, setCheckboxes] = useState(analyticsCheckboxes) + const toggleCheckbox = (key) => { setCheckboxes({ ...checkboxes,