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 all 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
57 changes: 15 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';
@@ -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';

@@ -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,
@@ -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;
@@ -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,
},
@@ -125,7 +104,7 @@ export function SewerChart({
.map((option) => ({
...option,
content: (
<Box pr={2}>
<Box paddingRight={space[2]}>
<Text>{option.label}</Text>
</Box>
),
@@ -134,9 +113,12 @@ export function SewerChart({
[options]
);

const timeframeOptionsVrOrGm = TimeframeOptionsList.filter((timeframeOption) => timeframeOption !== TimeframeOption.ONE_WEEK);
const timeframeOptions = vrNameOrGmName ? timeframeOptionsVrOrGm : TimeframeOptionsList;

return (
<ChartTile
timeframeOptions={TimeframeOptionsList}
timeframeOptions={timeframeOptions}
title={text.title}
metadata={{
source: text.source,
@@ -145,7 +127,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
@@ -156,13 +138,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>
)}
{
@@ -173,11 +150,7 @@ export function SewerChart({
dataPerInstallation && selectedInstallation ? (
<TimeSeriesChart
accessibility={accessibility}
values={mergeData(
dataAverages,
dataPerInstallation,
selectedInstallation
)}
values={mergeData(dataAverages, dataPerInstallation, selectedInstallation)}
timeframe={sewerTimeframe}
seriesConfig={[
{