Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
feat: improved handling of missing data for behavior_per_age_group (#…
Browse files Browse the repository at this point in the history
…4191)

Co-authored-by: VWSCoronaDashboard24 <[email protected]>
Co-authored-by: J <[email protected]>
  • Loading branch information
3 people authored Apr 21, 2022
1 parent b85610c commit 6a6759a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
45 changes: 33 additions & 12 deletions packages/app/src/domain/behavior/behavior-per-age-group-tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 (
<ChartTile title={title} description={description}>
<Box spacing={4} width={breakpoints.lg ? '50%' : '100%'}>
Expand All @@ -59,7 +67,7 @@ export function BehaviorPerAgeGroup({
onChange={setCurrentId}
/>
<Box overflow="auto">
{isDefined(complianceValue) || isDefined(supportValue) ? (
{dataAvailable ? (
<Box overflow="auto">
<StyledTable>
<thead>
Expand All @@ -79,24 +87,37 @@ export function BehaviorPerAgeGroup({
<tbody>
{AGE_KEYS.map((age, index) => (
<React.Fragment key={index}>
{supportValue &&
complianceValue &&
isPresent(complianceValue[age]) &&
isPresent(supportValue[age]) && (
<tr>
<Cell>{text.shared.leeftijden.tabel[age]}</Cell>
<Cell>
{(isPresent(complianceValue[age]) ||
isPresent(supportValue[age])) && (
<tr>
<Cell>{text.shared.leeftijden.tabel[age]}</Cell>
<Cell>
{isPresent(complianceValue[age]) ? (
<PercentageBar
color={colors.data.cyan}
amount={complianceValue[age]}
/>
) : (
<Text>
{
text.shared.leeftijden.tabel
.compliance_no_data
}
</Text>
)}
{isPresent(supportValue[age]) ? (
<PercentageBar
color={colors.data.yellow}
amount={supportValue[age]}
/>
</Cell>
</tr>
)}
) : (
<Text>
{text.shared.leeftijden.tabel.support_no_data}
</Text>
)}
</Cell>
</tr>
)}
</React.Fragment>
))}
</tbody>
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
4 changes: 4 additions & 0 deletions packages/app/src/utils/keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// typesafe replacement for Object.keys() which doesn't infer more complex types for object keys correctly
export function keys<O extends object>(o: O): Array<keyof O> {
return Object.keys(o) as Array<keyof O>;
}
2 changes: 2 additions & 0 deletions packages/cms/src/lokalize/key-mutations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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,__
Expand Down

0 comments on commit 6a6759a

Please sign in to comment.