From d1dcbf791cdd2b687b0c485a06d3319e43347da9 Mon Sep 17 00:00:00 2001 From: AT <93994194+VWSCoronaDashboard21@users.noreply.github.com> Date: Wed, 26 Apr 2023 13:28:50 +0200 Subject: [PATCH] feature/COR-1521-vulnerable-groups-page-optimizations-typefix (#4757) * Removed the AgeDataType and ParsedCoverageData type based on PR feedback * made TileData not exported anymore --------- Co-authored-by: VWSCoronaDashboard21 --- .../src/pages/gemeente/[code]/vaccinaties.tsx | 107 +++++++----------- 1 file changed, 44 insertions(+), 63 deletions(-) diff --git a/packages/app/src/pages/gemeente/[code]/vaccinaties.tsx b/packages/app/src/pages/gemeente/[code]/vaccinaties.tsx index 2583cfe52b..e0bbd6983b 100644 --- a/packages/app/src/pages/gemeente/[code]/vaccinaties.tsx +++ b/packages/app/src/pages/gemeente/[code]/vaccinaties.tsx @@ -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'; @@ -31,19 +30,6 @@ const selectLokalizeTexts = (siteText: SiteText) => ({ type LokalizeTexts = ReturnType; -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( @@ -125,53 +111,6 @@ export const VaccinationsGmPage = (props: StaticProps) => 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 ( @@ -200,7 +139,28 @@ export const VaccinationsGmPage = (props: StaticProps) => 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} /> )} @@ -208,7 +168,28 @@ export const VaccinationsGmPage = (props: StaticProps) => 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} />