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

bugfix/COR-1050-removed-timeframeOption-one-week-safety-region-municipality #4534

Merged
merged 3 commits into from
Dec 15, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 16 additions & 42 deletions packages/app/src/domain/sewer/sewer-chart/sewer-chart.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -19,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';

Expand Down Expand Up @@ -58,16 +52,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,
Expand All @@ -88,9 +73,7 @@ export function SewerChart({
} as SewerPerInstallationData)
);

const [sewerTimeframe, setSewerTimeframe] = useState<TimeframeOption>(
TimeframeOption.ALL
);
const [sewerTimeframe, setSewerTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);

const { commonTexts } = useIntl();
const scopedGmName = commonTexts.gemeente_index.municipality_warning;
Expand All @@ -103,12 +86,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,
},
Expand All @@ -125,7 +104,7 @@ export function SewerChart({
.map((option) => ({
...option,
content: (
<Box pr={2}>
<Box paddingRight={space[2]}>
<Text>{option.label}</Text>
</Box>
),
Expand All @@ -134,9 +113,13 @@ export function SewerChart({
[options]
);

const timeframeOptionsWithoutOneWeek = TimeframeOptionsList.filter((option) => option !== TimeframeOption.ONE_WEEK);

const timeframeOptionsToUse = !vrNameOrGmName ? TimeframeOptionsList : timeframeOptionsWithoutOneWeek;
Amber-Taal-Work marked this conversation as resolved.
Show resolved Hide resolved

return (
<ChartTile
timeframeOptions={TimeframeOptionsList}
timeframeOptions={timeframeOptionsToUse}
title={text.title}
metadata={{
source: text.source,
Expand All @@ -145,7 +128,7 @@ export function SewerChart({
onSelectTimeframe={setSewerTimeframe}
>
{dataPerInstallation && (
<Box alignSelf="flex-start" mb={3} minWidth={207}>
<Box alignSelf="flex-start" marginBottom={space[3]} minWidth={207}>
<RichContentSelect
label={text.selectPlaceholder}
visuallyHiddenLabel
Expand All @@ -156,13 +139,8 @@ export function SewerChart({
</Box>
)}
{scopedWarning && scopedGmName.toUpperCase() === selectedInstallation && (
<Box mt={2} mb={4}>
<WarningTile
variant="emphasis"
message={scopedWarning}
icon={Warning}
isFullWidth
/>
<Box marginTop={space[2]} marginBottom={space[4]}>
<WarningTile variant="emphasis" message={scopedWarning} icon={Warning} isFullWidth />
</Box>
)}
{
Expand All @@ -173,11 +151,7 @@ export function SewerChart({
dataPerInstallation && selectedInstallation ? (
<TimeSeriesChart
accessibility={accessibility}
values={mergeData(
dataAverages,
dataPerInstallation,
selectedInstallation
)}
values={mergeData(dataAverages, dataPerInstallation, selectedInstallation)}
timeframe={sewerTimeframe}
seriesConfig={[
{
Expand Down