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

Commit

Permalink
feature/COR-1521-vulnerable-groups-page-optimizations-typefix (#4757)
Browse files Browse the repository at this point in the history
* Removed the AgeDataType and ParsedCoverageData type based on PR feedback

* made TileData not exported anymore

---------

Co-authored-by: VWSCoronaDashboard21 <[email protected]>
  • Loading branch information
Amber-Taal-Work and VWSCoronaDashboard21 authored Apr 26, 2023
1 parent 9a308d1 commit d1dcbf7
Showing 1 changed file with 44 additions and 63 deletions.
107 changes: 44 additions & 63 deletions packages/app/src/pages/gemeente/[code]/vaccinaties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useState } from 'react';
import { isDefined, isPresent } from 'ts-is-present';
import { Divider, PageInformationBlock, TileList } from '~/components';
import { BorderedKpiSection } from '~/components/kpi/bordered-kpi-section';
import { BarType } from '~/components/kpi/types';
import { gmCodesByVrCode, vrCodeByGmCode } from '~/data';
import { emptyCoverageData } from '~/data/gm/vaccinations/empty-coverage-data';
import { GmLayout, Layout } from '~/domain/layout';
Expand All @@ -31,19 +30,6 @@ const selectLokalizeTexts = (siteText: SiteText) => ({

type LokalizeTexts = ReturnType<typeof selectLokalizeTexts>;

type AgeDataType = {
value: number | null;
birthyear: string | null;
title: string;
description: string;
bar: BarType;
};

type ParsedCoverageData = {
autumn2022: [AgeDataType, AgeDataType];
primarySeries: [AgeDataType, AgeDataType];
};

export { getStaticPaths } from '~/static-paths/gm';

export const getStaticProps = createGetStaticProps(
Expand Down Expand Up @@ -125,53 +111,6 @@ export const VaccinationsGmPage = (props: StaticProps<typeof getStaticProps>) =>

const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics);

const parsedVaccineCoverageData: ParsedCoverageData = {
autumn2022: [
{
value: filteredVaccination.autumn2022.vaccinated_percentage_60_plus,
birthyear: filteredVaccination.autumn2022.birthyear_range_60_plus,
title: textShared.vaccination_grade_tile.age_group_labels.age_60_plus,
description: textShared.vaccination_grade_tile.autumn_labels.description_60_plus,
bar: {
value: filteredVaccination.autumn2022.vaccinated_percentage_60_plus || 0,
color: colors.scale.blueDetailed[8],
},
},
{
value: filteredVaccination.autumn2022.vaccinated_percentage_12_plus,
birthyear: filteredVaccination.autumn2022.birthyear_range_12_plus,
title: textShared.vaccination_grade_tile.age_group_labels.age_12_plus,
description: textShared.vaccination_grade_tile.autumn_labels.description_12_plus,
bar: {
value: filteredVaccination.autumn2022.vaccinated_percentage_12_plus || 0,
color: colors.scale.blueDetailed[8],
},
},
],
primarySeries: [
{
value: filteredVaccination.primarySeries.vaccinated_percentage_18_plus,
birthyear: filteredVaccination.primarySeries.birthyear_range_18_plus,
title: textShared.vaccination_grade_tile.age_group_labels.age_18_plus,
description: textShared.vaccination_grade_tile.fully_vaccinated_labels.description_18_plus,
bar: {
value: filteredVaccination.primarySeries.vaccinated_percentage_18_plus || 0,
color: colors.scale.blueDetailed[3],
},
},
{
value: filteredVaccination.primarySeries.vaccinated_percentage_12_plus,
birthyear: filteredVaccination.primarySeries.birthyear_range_12_plus,
title: textShared.vaccination_grade_tile.age_group_labels.age_12_plus,
description: textShared.vaccination_grade_tile.fully_vaccinated_labels.description_12_plus,
bar: {
value: filteredVaccination.primarySeries.vaccinated_percentage_12_plus || 0,
color: colors.scale.blueDetailed[3],
},
},
],
};

return (
<Layout {...metadata} lastGenerated={lastGenerated}>
<GmLayout code={data.code} municipalityName={municipalityName}>
Expand Down Expand Up @@ -200,15 +139,57 @@ export const VaccinationsGmPage = (props: StaticProps<typeof getStaticProps>) =>
title={textShared.vaccination_grade_tile.autumn_labels.title}
description={textShared.vaccination_grade_tile.autumn_labels.description}
source={textShared.vaccination_grade_tile.autumn_labels.source}
tilesData={parsedVaccineCoverageData.autumn2022}
tilesData={[
{
value: filteredVaccination.autumn2022.vaccinated_percentage_60_plus,
birthyear: filteredVaccination.autumn2022.birthyear_range_60_plus,
title: textShared.vaccination_grade_tile.age_group_labels.age_60_plus,
description: textShared.vaccination_grade_tile.autumn_labels.description_60_plus,
bar: {
value: filteredVaccination.autumn2022.vaccinated_percentage_60_plus || 0,
color: colors.scale.blueDetailed[8],
},
},
{
value: filteredVaccination.autumn2022.vaccinated_percentage_12_plus,
birthyear: filteredVaccination.autumn2022.birthyear_range_12_plus,
title: textShared.vaccination_grade_tile.age_group_labels.age_12_plus,
description: textShared.vaccination_grade_tile.autumn_labels.description_12_plus,
bar: {
value: filteredVaccination.autumn2022.vaccinated_percentage_12_plus || 0,
color: colors.scale.blueDetailed[8],
},
},
]}
dateUnix={filteredVaccination.autumn2022.date_unix}
/>
)}
<BorderedKpiSection
title={textShared.vaccination_grade_tile.fully_vaccinated_labels.title}
description={textShared.vaccination_grade_tile.fully_vaccinated_labels.description}
source={textShared.vaccination_grade_tile.fully_vaccinated_labels.source}
tilesData={parsedVaccineCoverageData.primarySeries}
tilesData={[
{
value: filteredVaccination.primarySeries.vaccinated_percentage_18_plus,
birthyear: filteredVaccination.primarySeries.birthyear_range_18_plus,
title: textShared.vaccination_grade_tile.age_group_labels.age_18_plus,
description: textShared.vaccination_grade_tile.fully_vaccinated_labels.description_18_plus,
bar: {
value: filteredVaccination.primarySeries.vaccinated_percentage_18_plus || 0,
color: colors.scale.blueDetailed[3],
},
},
{
value: filteredVaccination.primarySeries.vaccinated_percentage_12_plus,
birthyear: filteredVaccination.primarySeries.birthyear_range_12_plus,
title: textShared.vaccination_grade_tile.age_group_labels.age_12_plus,
description: textShared.vaccination_grade_tile.fully_vaccinated_labels.description_12_plus,
bar: {
value: filteredVaccination.primarySeries.vaccinated_percentage_12_plus || 0,
color: colors.scale.blueDetailed[3],
},
},
]}
dateUnix={filteredVaccination.primarySeries.date_unix}
/>
<VaccineCoverageChoropleth
Expand Down

0 comments on commit d1dcbf7

Please sign in to comment.