diff --git a/packages/app/src/domain/behavior/behavior-per-age-group-tile.tsx b/packages/app/src/domain/behavior/behavior-per-age-group-tile.tsx index 754a836da8..242ea8433d 100644 --- a/packages/app/src/domain/behavior/behavior-per-age-group-tile.tsx +++ b/packages/app/src/domain/behavior/behavior-per-age-group-tile.tsx @@ -2,12 +2,13 @@ import { colors, NlBehaviorPerAgeGroup } from '@corona-dashboard/common'; import css from '@styled-system/css'; import React from 'react'; import styled from 'styled-components'; -import { isDefined, isPresent } from 'ts-is-present'; +import { isPresent } from 'ts-is-present'; import { Box } from '~/components/base'; import { ChartTile } from '~/components/chart-tile'; import { BoldText, Text } from '~/components/typography'; import { SiteText } from '~/locale'; import { asResponsiveArray } from '~/style/utils'; +import { keys } from '~/utils'; import { assert } from '~/utils/assert'; import { useBreakpoints } from '~/utils/use-breakpoints'; import { SelectBehavior } from './components/select-behavior'; @@ -50,6 +51,13 @@ export function BehaviorPerAgeGroup({ `[${BehaviorPerAgeGroup.name}] There is a problem by filtering the numbers out (supportValue)` ); + const hasComplianceValues = + keys(complianceValue).every((key) => complianceValue[key] === null) === + false; + const hasSupportValues = + keys(supportValue).every((key) => supportValue[key] === null) === false; + const dataAvailable = hasComplianceValues || hasSupportValues; + return ( @@ -59,7 +67,7 @@ export function BehaviorPerAgeGroup({ onChange={setCurrentId} /> - {isDefined(complianceValue) || isDefined(supportValue) ? ( + {dataAvailable ? ( @@ -79,24 +87,37 @@ export function BehaviorPerAgeGroup({ {AGE_KEYS.map((age, index) => ( - {supportValue && - complianceValue && - isPresent(complianceValue[age]) && - isPresent(supportValue[age]) && ( - - {text.shared.leeftijden.tabel[age]} - + {(isPresent(complianceValue[age]) || + isPresent(supportValue[age])) && ( + + {text.shared.leeftijden.tabel[age]} + + {isPresent(complianceValue[age]) ? ( + ) : ( + + { + text.shared.leeftijden.tabel + .compliance_no_data + } + + )} + {isPresent(supportValue[age]) ? ( - - - )} + ) : ( + + {text.shared.leeftijden.tabel.support_no_data} + + )} + + + )} ))} diff --git a/packages/app/src/utils/index.ts b/packages/app/src/utils/index.ts index c9161eff6c..7b53fd5ad5 100644 --- a/packages/app/src/utils/index.ts +++ b/packages/app/src/utils/index.ts @@ -10,3 +10,4 @@ export { cutValuesFromTimeframe } from './cut-values-from-timeframe'; export { getBoundaryDateStartUnix } from './get-boundary-date-start-unix'; export { trimNullValues } from './trim-null-values'; export { getAverageSplitPoints } from './get-avarage-split-points'; +export { keys } from './keys'; diff --git a/packages/app/src/utils/keys.ts b/packages/app/src/utils/keys.ts new file mode 100644 index 0000000000..a47724c159 --- /dev/null +++ b/packages/app/src/utils/keys.ts @@ -0,0 +1,4 @@ +// typesafe replacement for Object.keys() which doesn't infer more complex types for object keys correctly +export function keys(o: O): Array { + return Object.keys(o) as Array; +} diff --git a/packages/cms/src/lokalize/key-mutations.csv b/packages/cms/src/lokalize/key-mutations.csv index 15fa89c95e..372361739a 100755 --- a/packages/cms/src/lokalize/key-mutations.csv +++ b/packages/cms/src/lokalize/key-mutations.csv @@ -44,6 +44,8 @@ timestamp,action,key,document_id,move_to 2022-04-14T08:55:50.896Z,move,pages.vaccinationsPage.nl.four_kpi_section.total_booster_and_third_shots.sources.href,eExb1tVTD1y5h6ShWfEAqa,pages.vaccinationsPage.nl.four_kpi_section.total_booster_shots.sources.href 2022-04-14T08:55:50.896Z,move,pages.vaccinationsPage.nl.four_kpi_section.total_booster_and_third_shots.sources.text,eExb1tVTD1y5h6ShWfEB3y,pages.vaccinationsPage.nl.four_kpi_section.total_booster_shots.sources.text 2022-04-14T08:55:50.896Z,move,pages.vaccinationsPage.nl.four_kpi_section.total_booster_and_third_shots.title,eExb1tVTD1y5h6ShWfEAB5,pages.vaccinationsPage.nl.four_kpi_section.total_booster_shots.title +2022-04-20T11:56:09.423Z,add,pages.behaviorPage.shared.leeftijden.tabel.compliance_no_data,A5Y41hFe5J3wNnB7Np5dWd,__ +2022-04-20T11:56:10.610Z,add,pages.behaviorPage.shared.leeftijden.tabel.support_no_data,X8Z1HTDxqJ9pM59361JkzO,__ 2022-04-14T11:35:18.085Z,add,pages.sewerPage.gm.zeewolde_incomplete_manualy_override.zeewolde_date_start_in_unix_time,T6FOC3TDR34eMSB5nyzsA8,__ 2022-04-14T11:35:19.285Z,add,pages.sewerPage.gm.zeewolde_incomplete_manualy_override.zeewolde_date_end_in_unix_time,BarLwW8hBDpE0bK0rLm9Kv,__ 2022-04-14T11:35:20.492Z,add,pages.sewerPage.gm.zeewolde_incomplete_manualy_override.zeewolde_label,T6FOC3TDR34eMSB5nyztO0,__