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

Commit

Permalink
COR-1499-safety-region-removal-navigation-and-router (#4724)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorrik-Klijnsma-Work authored Apr 5, 2023
1 parent 694a020 commit 5a152ff
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 245 deletions.
71 changes: 0 additions & 71 deletions packages/app/src/components/choropleth/logic/thresholds.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { colors } from '@corona-dashboard/common';
import { MapType } from '~/components/choropleth/logic';
import { BehaviorIdentifier, behaviorIdentifiers } from '~/domain/behavior/logic/behavior-types';

const positiveTestedThresholds: ChoroplethThresholdsValue[] = [
{
Expand Down Expand Up @@ -203,68 +202,6 @@ const infectedLocationsPercentageThresholds: ChoroplethThresholdsValue[] = [
},
];

const behaviorComplianceThresholds: ChoroplethThresholdsValue[] = [
{
color: colors.scale.blue[0],
threshold: 0,
},
{
color: colors.scale.blue[1],
threshold: 40,
},
{
color: colors.scale.blue[2],
threshold: 50,
},
{
color: colors.scale.blue[3],
threshold: 60,
},
{
color: colors.scale.blue[4],
threshold: 70,
},
{
color: colors.scale.blue[5],
threshold: 80,
},
{
color: colors.scale.blue[6],
threshold: 90,
},
];

const behaviorSupportThresholds: ChoroplethThresholdsValue[] = [
{
color: colors.scale.yellow[0],
threshold: 0,
},
{
color: colors.scale.yellow[1],
threshold: 40,
},
{
color: colors.scale.yellow[2],
threshold: 50,
},
{
color: colors.scale.yellow[3],
threshold: 60,
},
{
color: colors.scale.yellow[4],
threshold: 70,
},
{
color: colors.scale.yellow[5],
threshold: 80,
},
{
color: colors.scale.yellow[6],
threshold: 90,
},
];

const vaccineCoverageThresholds: ChoroplethThresholdsValue[] = [
{
color: colors.scale.blue[0],
Expand Down Expand Up @@ -404,14 +341,6 @@ export const thresholds: Thresholds = {
vaccinated_percentage_18_plus: vaccineCoveragePercentageThresholds,
vaccinated_percentage_60_plus: vaccineCoveragePercentageThresholds,
other: situationsThreshold,
...(Object.fromEntries(behaviorIdentifiers.map((key) => [`${key}_support`, behaviorSupportThresholds])) as Record<
`${BehaviorIdentifier}_support`,
ChoroplethThresholdsValue[]
>),
...(Object.fromEntries(behaviorIdentifiers.map((key) => [`${key}_compliance`, behaviorComplianceThresholds])) as Record<
`${BehaviorIdentifier}_compliance`,
ChoroplethThresholdsValue[]
>),
},
};

Expand Down
2 changes: 0 additions & 2 deletions packages/app/src/components/choropleth/logic/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type {
GmCollectionTestedOverall,
GmCollectionVaccineCoveragePerAgeGroup,
VrCollection,
VrCollectionBehaviorArchived_20221019,
VrCollectionDisabilityCareArchived_20230126,
VrCollectionElderlyAtHomeArchived_20230126,
VrCollectionHospitalNice,
Expand Down Expand Up @@ -62,7 +61,6 @@ export type VrDataCollection =
| VrCollectionNursingHomeArchived_20230126[]
| VrCollectionVulnerableNursingHome[]
| VrCollectionSewer[]
| VrCollectionBehaviorArchived_20221019[]
| VrCollectionDisabilityCareArchived_20230126[]
| VrCollectionElderlyAtHomeArchived_20230126[]
| VrCollectionSituations[]
Expand Down
99 changes: 0 additions & 99 deletions packages/app/src/domain/behavior/tooltip/vr-behavior-tooltip.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export const VaccineCoverageChoropleth = ({ data }: VaccineCoverageChoroplethPro
}}
dataOptions={{
isPercentage: true,
getLink: (vrcode) => reverseRouter.vr.vaccinaties(vrcode),
}}
formatTooltip={(context) => <ChoroplethTooltip data={context} ageGroups={matchingAgeGroups[selectedCoverageKind]} selectedCoverageKind={selectedCoverageKind} />}
/>
Expand Down
45 changes: 10 additions & 35 deletions packages/app/src/utils/__tests__/use-reverse-router.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { cleanup, render } from '@testing-library/react';
import {
cleanup as cleanupHooks,
renderHook,
} from '@testing-library/react-hooks';
import { cleanup as cleanupHooks, renderHook } from '@testing-library/react-hooks';
import injectJsDom from 'jsdom-global';
import * as sinon from 'sinon';
import { ThemeProvider } from 'styled-components';
Expand All @@ -15,7 +12,6 @@ import { useReverseRouter } from '../use-reverse-router';
const UseReverseRouter = suite('useReverseRouter');

let largeScreen = false;
const vrCode = 'VR25';
const gmCode = 'GM001';

UseReverseRouter.before((context) => {
Expand Down Expand Up @@ -61,52 +57,31 @@ const TestBed = () => {
return (
<>
<div data-testid="nl">{router.nl.index()}</div>
<div data-testid="vr">{router.vr.index(vrCode)}</div>
<div data-testid="gm">{router.gm.index(gmCode)}</div>
</>
);
};

UseReverseRouter(
'indexes should link to the actual index on small screens',
() => {
largeScreen = false;
const result = render(<TestContainer />);
const nlDiv = result.getByTestId('nl');
const vrDiv = result.getByTestId('vr');
const gmDiv = result.getByTestId('gm');

assert.equal(nlDiv.textContent?.endsWith('/landelijk'), true);
assert.equal(vrDiv.textContent?.endsWith(vrCode), true);
assert.equal(gmDiv.textContent?.endsWith(gmCode), true);
}
);
UseReverseRouter('indexes should link to the actual index on small screens', () => {
largeScreen = false;
const result = render(<TestContainer />);
const nlDiv = result.getByTestId('nl');
const gmDiv = result.getByTestId('gm');

assert.equal(nlDiv.textContent?.endsWith('/landelijk'), true);
assert.equal(gmDiv.textContent?.endsWith(gmCode), true);
});

UseReverseRouter("indexes should 'redirect' to child pages", () => {
largeScreen = true;
const result = render(<TestContainer />);
const nlDiv = result.getByTestId('nl');
const vrDiv = result.getByTestId('vr');
const gmDiv = result.getByTestId('gm');

assert.equal(nlDiv.textContent?.endsWith('/vaccinaties'), true);
assert.equal(vrDiv.textContent?.endsWith('/vaccinaties'), true);
assert.equal(gmDiv.textContent?.endsWith('/vaccinaties'), true);
});

UseReverseRouter('VR routes should have the VR code in them', () => {
const { result } = renderHook(() => useReverseRouter());

const keys = Object.keys(result.current.vr);
keys.forEach((name) => {
const route = (result.current.vr as any)[name](vrCode);
assert.equal(route.indexOf(vrCode) > -1, true);
});

const route = result.current.vr.rioolwater(vrCode);
assert.equal(route.indexOf(vrCode) > -1, true);
});

UseReverseRouter('GM routes should have the GM code in them', () => {
const { result } = renderHook(() => useReverseRouter());

Expand Down
14 changes: 3 additions & 11 deletions packages/app/src/utils/get-current-page-scope.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import { DataScopeKey } from '@corona-dashboard/common';
import { DataScopeKeyForRouter } from '@corona-dashboard/common';
import { NextRouter } from 'next/router';

/**
* Returns a typed DataScope based on the current route's path
*/
export function getCurrentPageScope(
router: NextRouter
): DataScopeKey | undefined {
return router.pathname.startsWith('/landelijk')
? 'nl'
: router.pathname.startsWith('/veiligheidsregio')
? 'vr'
: router.pathname.startsWith('/gemeente')
? 'gm'
: undefined;
export function getCurrentPageScope(router: NextRouter): DataScopeKeyForRouter | undefined {
return router.pathname.startsWith('/landelijk') ? 'nl' : router.pathname.startsWith('/gemeente') ? 'gm' : undefined;
}
2 changes: 2 additions & 0 deletions packages/cms/src/lokalize/key-mutations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,5 @@ timestamp,action,key,document_id,move_to
2023-03-27T13:01:45.445Z,delete,common.accessibility.charts.elderly_at_home_deceased_over_time_chart.label,G1DXw0RdifOml06twMjRl8,__
2023-03-28T13:00:33.765Z,delete,common.accessibility.charts.sewer_region_choropleth.description,cl0A2qFve1QxscrDIqKL1F,__
2023-03-28T13:00:33.766Z,delete,common.accessibility.charts.sewer_region_choropleth.label,Z3v1SKYekK4CLDpzUPc5x5,__
2023-04-03T15:45:47.784Z,delete,pages.behavior_page.nl.tooltip_labels.compliance,uFGMarfssEPhdNlk3s6Avk,__
2023-04-03T15:45:47.785Z,delete,pages.behavior_page.nl.tooltip_labels.support,EaUS1FZKh46VBcUuh47mI4,__
12 changes: 0 additions & 12 deletions packages/common/src/data/reverse-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ export function getReverseRouter(isMobile: boolean) {
varianten: () => `/landelijk/varianten`,
},

vr: {
index: (code?: string) => (code ? (isMobile ? `/veiligheidsregio/${code}` : reverseRouter.vr.rioolwater(code)) : '/veiligheidsregio'),
vaccinaties: (code: string) => `/veiligheidsregio/${code}/vaccinaties`,
positiefGetesteMensen: (code: string) => `/veiligheidsregio/${code}/positief-geteste-mensen`,
sterfte: (code: string) => `/veiligheidsregio/${code}/sterfte`,
ziekenhuisopnames: (code: string) => `/veiligheidsregio/${code}/ziekenhuis-opnames`,
thuiswonendeOuderen: (code: string) => `/veiligheidsregio/${code}/thuiswonende-ouderen`,
rioolwater: (code: string) => `/veiligheidsregio/${code}/rioolwater`,
gedrag: (code: string) => `/veiligheidsregio/${code}/gedrag`,
brononderzoek: (code: string) => `/veiligheidsregio/${code}/brononderzoek`,
},

gm: {
index: (code?: string) => (code ? (isMobile ? `/gemeente/${code}` : reverseRouter.gm.rioolwater(code)) : '/gemeente'),
positiefGetesteMensen: (code: string) => `/gemeente/${code}/positief-geteste-mensen`,
Expand Down
6 changes: 0 additions & 6 deletions packages/common/src/feature-flags/features.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { Feature } from '..';

export const features: Feature[] = [
{
name: 'archivedBehavior',
isEnabled: false,
metricName: 'behavior_archived_20221019',
dataScopes: ['vr'],
},
{
name: 'nlVaccinationCoveragePerAgeGroupAutumn2022',
isEnabled: false,
Expand Down
17 changes: 9 additions & 8 deletions packages/common/src/types/data-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ import { Gm, Nl, Vr } from '.';
export type ScopedData = {
gm: Gm;
nl: Nl;
/** TODO: when this gets removed, also remove the type "DataScopeKeyForRouter".
** It was created for COR-1499, because the router needed to have the VR excluded.
** When picking up ticket COR-1504 this line scoped data should be adjusted for the validation of the VR JSONS.
** The clean up of "DataScopeKeyForRouter" described above needs to happen as well.
**/
vr: Vr;
};

export type DataScopeKeyForRouter = 'gm' | 'nl';

export type DataScopeKey = keyof ScopedData;

export type DataScope = ScopedData[DataScopeKey];

export type MetricKeys<T> = keyof Omit<
T,
'last_generated' | 'proto_name' | 'name' | 'code'
>;
export type MetricKeys<T> = keyof Omit<T, 'last_generated' | 'proto_name' | 'name' | 'code'>;

export type MetricName = MetricKeys<Nl & Vr & Gm>;

Expand All @@ -35,7 +39,4 @@ type ValueKeys<T> = T extends ValuesMetric<infer V> ? ValueKeys<V> : keyof T;
/**
* The metric properties of metric M in data scope S (scope being In/Nl/Vr/Gm)
*/
export type MetricProperty<
S extends DataScope,
M extends MetricKeys<S>
> = ValueKeys<S[M]>;
export type MetricProperty<S extends DataScope, M extends MetricKeys<S>> = ValueKeys<S[M]>;

0 comments on commit 5a152ff

Please sign in to comment.