From f320b463e80869067c81a5d34e9fd01aa386de54 Mon Sep 17 00:00:00 2001 From: VWSCoronaDashboard21 Date: Wed, 14 Dec 2022 12:03:16 +0100 Subject: [PATCH 1/3] Removed timeframeOption one week from safety region and municipality pages --- .../domain/sewer/sewer-chart/sewer-chart.tsx | 51 +++++-------------- 1 file changed, 12 insertions(+), 39 deletions(-) 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 4b582f3a96..5399a28dca 100644 --- a/packages/app/src/domain/sewer/sewer-chart/sewer-chart.tsx +++ b/packages/app/src/domain/sewer/sewer-chart/sewer-chart.tsx @@ -1,11 +1,4 @@ -import { - colors, - NlSewer, - SewerPerInstallationData, - TimeframeOption, - TimeframeOptionsList, - VrSewer, -} from '@corona-dashboard/common'; +import { colors, NlSewer, SewerPerInstallationData, TimeframeOption, TimeframeOptionsList, VrSewer } from '@corona-dashboard/common'; import { useMemo, useState } from 'react'; import { isPresent } from 'ts-is-present'; import { Warning } from '@corona-dashboard/icons'; @@ -58,16 +51,7 @@ type SewerChartProps = { timelineEvents?: TimelineEventConfig[]; }; -export function SewerChart({ - accessibility, - dataAverages, - dataPerInstallation, - text, - vrNameOrGmName, - incompleteDatesAndTexts, - warning, - timelineEvents, -}: SewerChartProps) { +export function SewerChart({ accessibility, dataAverages, dataPerInstallation, text, vrNameOrGmName, incompleteDatesAndTexts, warning, timelineEvents }: SewerChartProps) { const { options, value: selectedInstallation, @@ -88,9 +72,7 @@ export function SewerChart({ } as SewerPerInstallationData) ); - const [sewerTimeframe, setSewerTimeframe] = useState( - TimeframeOption.ALL - ); + const [sewerTimeframe, setSewerTimeframe] = useState(TimeframeOption.ALL); const { commonTexts } = useIntl(); const scopedGmName = commonTexts.gemeente_index.municipality_warning; @@ -103,12 +85,8 @@ export function SewerChart({ valueAnnotation: text.valueAnnotation, timespanAnnotations: [ { - start: parseInt( - incompleteDatesAndTexts.zeewolde_date_start_in_unix_time - ), - end: parseInt( - incompleteDatesAndTexts.zeewolde_date_end_in_unix_time - ), + start: parseInt(incompleteDatesAndTexts.zeewolde_date_start_in_unix_time), + end: parseInt(incompleteDatesAndTexts.zeewolde_date_end_in_unix_time), label: incompleteDatesAndTexts.zeewolde_label, shortLabel: incompleteDatesAndTexts.zeewolde_short_label, }, @@ -134,9 +112,13 @@ export function SewerChart({ [options] ); + const timeframeOptionsWithoutOneWeek = TimeframeOptionsList.filter((option) => option !== TimeframeOption.ONE_WEEK); + + const timeframeOptionsToUse = !vrNameOrGmName ? TimeframeOptionsList : timeframeOptionsWithoutOneWeek; + return ( - + )} { @@ -173,11 +150,7 @@ export function SewerChart({ dataPerInstallation && selectedInstallation ? ( Date: Wed, 14 Dec 2022 12:20:23 +0100 Subject: [PATCH 2/3] fix: refactor code based on code conventions --- packages/app/src/domain/sewer/sewer-chart/sewer-chart.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 5399a28dca..0ab7bfe80f 100644 --- a/packages/app/src/domain/sewer/sewer-chart/sewer-chart.tsx +++ b/packages/app/src/domain/sewer/sewer-chart/sewer-chart.tsx @@ -12,6 +12,7 @@ import { LocationTooltip } from './components/location-tooltip'; import { WarningTile } from '~/components/warning-tile'; import { mergeData, useSewerStationSelectPropsSimplified } from './logic'; import { useIntl } from '~/intl'; +import { space } from '~/style/theme'; import { useScopedWarning } from '~/utils/use-scoped-warning'; import { TimelineEventConfig } from '~/components/time-series-chart/components/timeline'; @@ -103,7 +104,7 @@ export function SewerChart({ accessibility, dataAverages, dataPerInstallation, t .map((option) => ({ ...option, content: ( - + {option.label} ), @@ -127,7 +128,7 @@ export function SewerChart({ accessibility, dataAverages, dataPerInstallation, t onSelectTimeframe={setSewerTimeframe} > {dataPerInstallation && ( - + )} {scopedWarning && scopedGmName.toUpperCase() === selectedInstallation && ( - + )} From 3575b3af2499beac7f1f482a519c18e19eb398d3 Mon Sep 17 00:00:00 2001 From: VWSCoronaDashboard21 Date: Wed, 14 Dec 2022 15:35:24 +0100 Subject: [PATCH 3/3] fix: refactored code to use a positive approach --- packages/app/src/domain/sewer/sewer-chart/sewer-chart.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 0ab7bfe80f..a8021bcb48 100644 --- a/packages/app/src/domain/sewer/sewer-chart/sewer-chart.tsx +++ b/packages/app/src/domain/sewer/sewer-chart/sewer-chart.tsx @@ -113,13 +113,12 @@ export function SewerChart({ accessibility, dataAverages, dataPerInstallation, t [options] ); - const timeframeOptionsWithoutOneWeek = TimeframeOptionsList.filter((option) => option !== TimeframeOption.ONE_WEEK); - - const timeframeOptionsToUse = !vrNameOrGmName ? TimeframeOptionsList : timeframeOptionsWithoutOneWeek; + const timeframeOptionsVrOrGm = TimeframeOptionsList.filter((timeframeOption) => timeframeOption !== TimeframeOption.ONE_WEEK); + const timeframeOptions = vrNameOrGmName ? timeframeOptionsVrOrGm : TimeframeOptionsList; return (