From 1b8eb284ec6bab510f3e93a3c91beb1d9327971e Mon Sep 17 00:00:00 2001 From: HO <93981322+VWSCoronaDashboard19@users.noreply.github.com> Date: Wed, 6 Apr 2022 15:16:09 +0200 Subject: [PATCH] feat: aligned timeframe options on all charts (#4155) * feat: aligned timeframe options on all charts * feat: moved option list to a maintainable location --- .../src/components/chart-time-controls.tsx | 15 +++------ .../domain/sewer/sewer-chart/sewer-chart.tsx | 12 ++----- .../domain/tested/reproduction-chart-tile.tsx | 11 ++----- .../[code]/positief-geteste-mensen.tsx | 12 ++----- .../app/src/pages/gemeente/[code]/sterfte.tsx | 12 ++----- .../gemeente/[code]/ziekenhuis-opnames.tsx | 12 ++----- .../app/src/pages/landelijk/coronamelder.tsx | 12 ++----- .../src/pages/landelijk/gehandicaptenzorg.tsx | 32 +++---------------- .../landelijk/intensive-care-opnames.tsx | 31 +++--------------- .../landelijk/positief-geteste-mensen.tsx | 28 +++------------- packages/app/src/pages/landelijk/sterfte.tsx | 12 ++----- .../pages/landelijk/thuiswonende-ouderen.tsx | 22 ++----------- .../src/pages/landelijk/verpleeghuiszorg.tsx | 32 +++---------------- .../pages/landelijk/ziekenhuis-opnames.tsx | 31 +++--------------- .../[code]/gehandicaptenzorg.tsx | 27 +++------------- .../[code]/positief-geteste-mensen.tsx | 17 ++-------- .../pages/veiligheidsregio/[code]/sterfte.tsx | 12 ++----- .../[code]/thuiswonende-ouderen.tsx | 22 ++----------- .../[code]/verpleeghuiszorg.tsx | 32 +++---------------- .../[code]/ziekenhuis-opnames.tsx | 12 ++----- packages/common/src/utils/timeframe/index.ts | 12 +++++-- 21 files changed, 69 insertions(+), 339 deletions(-) diff --git a/packages/app/src/components/chart-time-controls.tsx b/packages/app/src/components/chart-time-controls.tsx index c9f730f519..75d666480c 100644 --- a/packages/app/src/components/chart-time-controls.tsx +++ b/packages/app/src/components/chart-time-controls.tsx @@ -1,5 +1,8 @@ import { useMemo } from 'react'; -import { TimeframeOption } from '@corona-dashboard/common'; +import { + TimeframeOption, + TimeframeOptionsList, +} from '@corona-dashboard/common'; import { Box } from '~/components/base'; import { Text } from '~/components/typography'; import { RichContentSelect } from '~/components/rich-content-select'; @@ -15,15 +18,7 @@ export function ChartTimeControls(props: ChartTimeControlsProps) { const { onChange, timeframe, - timeframeOptions = [ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ], + timeframeOptions = TimeframeOptionsList, } = props; const { commonTexts } = useIntl(); diff --git a/packages/app/src/domain/sewer/sewer-chart/sewer-chart.tsx b/packages/app/src/domain/sewer/sewer-chart/sewer-chart.tsx index dcaf6373eb..a5af14d009 100644 --- a/packages/app/src/domain/sewer/sewer-chart/sewer-chart.tsx +++ b/packages/app/src/domain/sewer/sewer-chart/sewer-chart.tsx @@ -1,7 +1,7 @@ import { NlSewer, SewerPerInstallationData, - TimeframeOption, + TimeframeOptionsList, VrSewer, } from '@corona-dashboard/common'; import { useMemo } from 'react'; @@ -100,15 +100,7 @@ export function SewerChart({ return ( ) => { metadata={{ source: textGm.bronnen.rivm, }} - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ]} + timeframeOptions={TimeframeOptionsList} > {(timeframe) => ( ) => { ) => { title={textGm.linechart_titel} description={textGm.linechart_description} metadata={{ source: textGm.bronnen.rivm }} - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ]} + timeframeOptions={TimeframeOptionsList} > {(timeframe) => ( ) => { description={ corona_melder_app.waarschuwingen_over_tijd_grafiek.description } - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ]} + timeframeOptions={TimeframeOptionsList} > {(timeframe) => ( ) => { {(timeframe) => ( @@ -307,15 +299,7 @@ const DisabilityCare = (props: StaticProps) => { metadata={{ source: textNl.besmette_locaties.bronnen.rivm, }} - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ]} + timeframeOptions={TimeframeOptionsList} description={textNl.besmette_locaties.linechart_description} > {(timeframe) => ( @@ -372,15 +356,7 @@ const DisabilityCare = (props: StaticProps) => { {(timeframe) => ( diff --git a/packages/app/src/pages/landelijk/intensive-care-opnames.tsx b/packages/app/src/pages/landelijk/intensive-care-opnames.tsx index 52ca5fd1aa..0cdfc492b7 100644 --- a/packages/app/src/pages/landelijk/intensive-care-opnames.tsx +++ b/packages/app/src/pages/landelijk/intensive-care-opnames.tsx @@ -5,6 +5,7 @@ import { NlHospitalVaccineIncidencePerAgeGroupValue, NlIntensiveCareVaccinationStatusValue, TimeframeOption, + TimeframeOptionsList, WEEK_IN_SECONDS, } from '@corona-dashboard/common'; import { Arts } from '@corona-dashboard/icons'; @@ -330,15 +331,7 @@ const IntakeIntensiveCare = (props: StaticProps) => { title={textNl.linechart_titel} description={textNl.linechart_description} metadata={{ source: textNl.bronnen.nice }} - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ]} + timeframeOptions={TimeframeOptionsList} timeframeInitialValue={TimeframeOption.THIRTY_DAYS} > {(timeframe) => ( @@ -388,15 +381,7 @@ const IntakeIntensiveCare = (props: StaticProps) => { title={textNl.chart_bedbezetting.title} description={textNl.chart_bedbezetting.description} metadata={{ source: textNl.bronnen.lnaz }} - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ]} + timeframeOptions={TimeframeOptionsList} timeframeInitialValue={TimeframeOption.THIRTY_DAYS} > {(timeframe) => ( @@ -431,15 +416,7 @@ const IntakeIntensiveCare = (props: StaticProps) => { diff --git a/packages/app/src/pages/landelijk/positief-geteste-mensen.tsx b/packages/app/src/pages/landelijk/positief-geteste-mensen.tsx index a27b4d81c8..023674ef4c 100644 --- a/packages/app/src/pages/landelijk/positief-geteste-mensen.tsx +++ b/packages/app/src/pages/landelijk/positief-geteste-mensen.tsx @@ -1,7 +1,7 @@ import { colors, NlTestedOverallValue, - TimeframeOption, + TimeframeOptionsList, } from '@corona-dashboard/common'; import { GgdTesten, Test } from '@corona-dashboard/icons'; import { GetStaticPropsContext } from 'next'; @@ -242,15 +242,7 @@ const PositivelyTestedPeople = (props: StaticProps) => { metadata={{ source: textNl.bronnen.rivm, }} - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ]} + timeframeOptions={TimeframeOptionsList} > {(timeframe) => ( ) => { ) => { ) => { ) => { metadata={{ source: positiveTestedPeopleText.bronnen.rivm }} title={positiveTestedPeopleText.linechart_titel} description={positiveTestedPeopleText.linechart_description} - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ]} + timeframeOptions={TimeframeOptionsList} > {(timeframe) => ( ) => { {(timeframe) => ( @@ -383,15 +367,7 @@ const NursingHomeCare = (props: StaticProps) => { {(timeframe) => ( diff --git a/packages/app/src/pages/landelijk/ziekenhuis-opnames.tsx b/packages/app/src/pages/landelijk/ziekenhuis-opnames.tsx index 6a5b79f97e..d0f68cea8a 100644 --- a/packages/app/src/pages/landelijk/ziekenhuis-opnames.tsx +++ b/packages/app/src/pages/landelijk/ziekenhuis-opnames.tsx @@ -5,6 +5,7 @@ import { NlHospitalVaccinationStatusValue, NlHospitalVaccineIncidencePerAgeGroupValue, TimeframeOption, + TimeframeOptionsList, WEEK_IN_SECONDS, } from '@corona-dashboard/common'; import { Ziekenhuis } from '@corona-dashboard/icons'; @@ -322,15 +323,7 @@ const IntakeHospital = (props: StaticProps) => { metadata={{ source: textNl.bronnen.nice, }} - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ]} + timeframeOptions={TimeframeOptionsList} timeframeInitialValue={TimeframeOption.THIRTY_DAYS} > {(timeframe) => ( @@ -381,15 +374,7 @@ const IntakeHospital = (props: StaticProps) => { metadata={{ source: textNl.bronnen.lnaz, }} - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ]} + timeframeOptions={TimeframeOptionsList} timeframeInitialValue={TimeframeOption.THIRTY_DAYS} > {(timeframe) => ( @@ -484,15 +469,7 @@ const IntakeHospital = (props: StaticProps) => { description={ commonTexts.hospital_admissions_per_age_group.chart_description } - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ]} + timeframeOptions={TimeframeOptionsList} timeframeInitialValue={TimeframeOption.THIRTY_DAYS} metadata={{ source: textNl.bronnen.nice }} > diff --git a/packages/app/src/pages/veiligheidsregio/[code]/gehandicaptenzorg.tsx b/packages/app/src/pages/veiligheidsregio/[code]/gehandicaptenzorg.tsx index 13ed8d5bea..9419394e98 100644 --- a/packages/app/src/pages/veiligheidsregio/[code]/gehandicaptenzorg.tsx +++ b/packages/app/src/pages/veiligheidsregio/[code]/gehandicaptenzorg.tsx @@ -1,4 +1,4 @@ -import { colors, TimeframeOption } from '@corona-dashboard/common'; +import { colors, TimeframeOptionsList } from '@corona-dashboard/common'; import { Coronavirus, GehandicaptenZorg, @@ -167,15 +167,7 @@ const DisabilityCare = (props: StaticProps) => { {(timeframe) => ( @@ -286,10 +278,7 @@ const DisabilityCare = (props: StaticProps) => { metadata={{ source: textVr.besmette_locaties.bronnen.rivm, }} - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.FIVE_WEEKS, - ]} + timeframeOptions={TimeframeOptionsList} description={textVr.besmette_locaties.linechart_description} > {(timeframe) => ( @@ -347,15 +336,7 @@ const DisabilityCare = (props: StaticProps) => { {(timeframe) => ( diff --git a/packages/app/src/pages/veiligheidsregio/[code]/positief-geteste-mensen.tsx b/packages/app/src/pages/veiligheidsregio/[code]/positief-geteste-mensen.tsx index 5b3ac6d18c..213842786a 100644 --- a/packages/app/src/pages/veiligheidsregio/[code]/positief-geteste-mensen.tsx +++ b/packages/app/src/pages/veiligheidsregio/[code]/positief-geteste-mensen.tsx @@ -1,4 +1,4 @@ -import { colors, TimeframeOption } from '@corona-dashboard/common'; +import { colors, TimeframeOptionsList } from '@corona-dashboard/common'; import { GgdTesten, Test } from '@corona-dashboard/icons'; import { GetStaticPropsContext } from 'next'; import { useRouter } from 'next/router'; @@ -254,15 +254,7 @@ const PositivelyTestedPeople = (props: StaticProps) => { metadata={{ source: textVr.bronnen.rivm, }} - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ]} + timeframeOptions={TimeframeOptionsList} > {(timeframe) => ( ) => { ) => { ) => { {(timeframe) => ( @@ -295,15 +287,7 @@ const NursingHomeCare = (props: StaticProps) => { {(timeframe) => ( @@ -366,15 +350,7 @@ const NursingHomeCare = (props: StaticProps) => { {(timeframe) => ( diff --git a/packages/app/src/pages/veiligheidsregio/[code]/ziekenhuis-opnames.tsx b/packages/app/src/pages/veiligheidsregio/[code]/ziekenhuis-opnames.tsx index 729502a9fc..f09e018c8c 100644 --- a/packages/app/src/pages/veiligheidsregio/[code]/ziekenhuis-opnames.tsx +++ b/packages/app/src/pages/veiligheidsregio/[code]/ziekenhuis-opnames.tsx @@ -1,7 +1,7 @@ import { colors, DAY_IN_SECONDS, - TimeframeOption, + TimeframeOptionsList, WEEK_IN_SECONDS, } from '@corona-dashboard/common'; import { Ziekenhuis } from '@corona-dashboard/icons'; @@ -186,15 +186,7 @@ const IntakeHospital = (props: StaticProps) => { metadata={{ source: textVr.bronnen.rivm }} title={textVr.linechart_titel} description={textVr.linechart_description} - timeframeOptions={[ - TimeframeOption.ALL, - TimeframeOption.ONE_WEEK, - TimeframeOption.TWO_WEEKS, - TimeframeOption.THIRTY_DAYS, - TimeframeOption.THREE_MONTHS, - TimeframeOption.SIX_MONTHS, - TimeframeOption.LAST_YEAR, - ]} + timeframeOptions={TimeframeOptionsList} > {(timeframe) => (