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

Commit

Permalink
fix(COR-1921): Fixed code being wrong in JSON metric links (#5000)
Browse files Browse the repository at this point in the history
  • Loading branch information
VWSCoronaDashboard30 authored Mar 5, 2024
1 parent 78c1415 commit 4c041a0
Show file tree
Hide file tree
Showing 25 changed files with 128 additions and 63 deletions.
8 changes: 3 additions & 5 deletions packages/app/src/pages/gemeente/[code]/de-coronaprik.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { PageInformationBlock } from '~/components/page-information-block/page-i
import { TileList } from '~/components/tile-list';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';
import { useIntl } from '~/intl';
import { useRouter } from 'next/router';
import { useState } from 'react';
import { Vaccinaties as VaccinatieIcon } from '@corona-dashboard/icons';
import { VaccineCoverageChoropleth } from '~/domain/vaccine/vaccine-coverage-choropleth';
Expand Down Expand Up @@ -86,7 +85,6 @@ export const getStaticProps = createGetStaticProps(
);

export const VaccinationsGmPage = (props: StaticProps<typeof getStaticProps>) => {
const router = useRouter();
const { pageText, archivedChoropleth, municipalityName, selectedGmData: currentData, selectedArchivedGmData: archivedData, content, lastGenerated } = props;
const { commonTexts } = useIntl();
const { formatPercentageAsNumber } = useFormatLokalizePercentage();
Expand Down Expand Up @@ -143,9 +141,9 @@ export const VaccinationsGmPage = (props: StaticProps<typeof getStaticProps>) =>
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textShared.bronnen.rivm],
jsonSources: [
getMunicipalityJsonLink(router.query.code as string, jsonText.metrics_municipality_json),
getMunicipalityJsonLink(router.query.code as string, jsonText.metrics_archived_municipality_json),
jsonText.metrics_archived_gm_collection_json,
getMunicipalityJsonLink(reverseRouter.json.municipality(currentData.code), jsonText.metrics_municipality_json.text),
getMunicipalityJsonLink(reverseRouter.json.archivedMunicipality(currentData.code), jsonText.metrics_archived_municipality_json.text),
{ href: reverseRouter.json.archivedGmCollection(), text: jsonText.metrics_archived_gm_collection_json.text },
],
}}
vrNameOrGmName={municipalityName}
Expand Down
8 changes: 3 additions & 5 deletions packages/app/src/pages/gemeente/[code]/patienten-in-beeld.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { TimeSeriesChart } from '~/components/time-series-chart/time-series-char
import { TwoKpiSection } from '~/components/two-kpi-section';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';
import { useIntl } from '~/intl';
import { useRouter } from 'next/router';
import { useState } from 'react';
import { Ziekenhuis } from '@corona-dashboard/icons';

Expand Down Expand Up @@ -79,7 +78,6 @@ export const getStaticProps = createGetStaticProps(
);

function IntakeHospital(props: StaticProps<typeof getStaticProps>) {
const router = useRouter();
const { pageText, selectedArchivedGmData: data, archivedChoropleth, municipalityName, content, lastGenerated } = props;
const [isArchivedContentShown, setIsArchivedContentShown] = useState<boolean>(false);

Expand Down Expand Up @@ -129,9 +127,9 @@ function IntakeHospital(props: StaticProps<typeof getStaticProps>) {
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textGm.bronnen.rivm],
jsonSources: [
getMunicipalityJsonLink(router.query.code as string, jsonText.metrics_municipality_json),
jsonText.metrics_gm_collection_json,
jsonText.metrics_archived_gm_collection_json,
getMunicipalityJsonLink(reverseRouter.json.municipality(data.code), jsonText.metrics_municipality_json.text),
{ href: reverseRouter.json.gmCollection(), text: jsonText.metrics_gm_collection_json.text },
{ href: reverseRouter.json.archivedGmCollection(), text: jsonText.metrics_archived_gm_collection_json.text },
],
}}
pageLinks={content.links}
Expand Down
8 changes: 3 additions & 5 deletions packages/app/src/pages/gemeente/[code]/positieve-testen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { TimeSeriesChart } from '~/components/time-series-chart/time-series-char
import { TwoKpiSection } from '~/components/two-kpi-section';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';
import { useIntl } from '~/intl';
import { useRouter } from 'next/router';
import { useState } from 'react';
import { WarningTile } from '~/components/warning-tile';

Expand Down Expand Up @@ -81,7 +80,6 @@ export const getStaticProps = createGetStaticProps(
);

function PositivelyTestedPeople(props: StaticProps<typeof getStaticProps>) {
const router = useRouter();
const { pageText, selectedGmData: data, selectedArchivedGmData: archivedData, archivedChoropleth, municipalityName, content, lastGenerated } = props;
const [positivelyTestedPeopleTimeframe, setpositivelyTestedPeopleTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);
const { commonTexts, formatNumber, formatDateFromSeconds } = useIntl();
Expand Down Expand Up @@ -119,9 +117,9 @@ function PositivelyTestedPeople(props: StaticProps<typeof getStaticProps>) {
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textGm.bronnen.rivm],
jsonSources: [
getMunicipalityJsonLink(router.query.code as string, jsonText.metrics_municipality_json),
getMunicipalityJsonLink(router.query.code as string, jsonText.metrics_archived_municipality_json),
jsonText.metrics_archived_gm_collection_json,
getMunicipalityJsonLink(reverseRouter.json.municipality(data.code), jsonText.metrics_municipality_json.text),
getMunicipalityJsonLink(reverseRouter.json.archivedMunicipality(data.code), jsonText.metrics_archived_municipality_json.text),
{ href: reverseRouter.json.archivedGmCollection(), text: jsonText.metrics_archived_gm_collection_json.text },
],
}}
vrNameOrGmName={municipalityName}
Expand Down
8 changes: 5 additions & 3 deletions packages/app/src/pages/gemeente/[code]/rioolwater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { TileList } from '~/components/tile-list';
import { TwoKpiSection } from '~/components/two-kpi-section';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';
import { useIntl } from '~/intl';
import { useRouter } from 'next/router';
import { useReverseRouter } from '~/utils';
import { WarningTile } from '~/components/warning-tile';

const pageMetrics = ['sewer_per_installation', 'sewer'];
Expand Down Expand Up @@ -63,7 +63,9 @@ const SewerWater = (props: StaticProps<typeof getStaticProps>) => {

const { commonTexts, formatNumber } = useIntl();
const { textGm, textShared, jsonText } = useDynamicLokalizeTexts<LokalizeTexts>(pageText, selectLokalizeTexts);
const router = useRouter();

const reverseRouter = useReverseRouter();

const sewerAverages = data.sewer;
const sewerInstallationMeasurement = data.sewer_installation_measurement;
const populationCountConnectedToRWZIS = data.static_values.population_count_connected_to_rwzis;
Expand Down Expand Up @@ -108,7 +110,7 @@ const SewerWater = (props: StaticProps<typeof getStaticProps>) => {
},
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textGm.bronnen.rivm],
jsonSources: [getMunicipalityJsonLink(router.query.code as string, jsonText.metrics_municipality_json)],
jsonSources: [getMunicipalityJsonLink(reverseRouter.json.municipality(data.code), jsonText.metrics_municipality_json.text)],
}}
vrNameOrGmName={municipalityName}
warning={textGm.warning}
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/pages/gemeente/[code]/sterfte.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ import { Languages, SiteText } from '~/locale';
import { PageArticlesTile } from '~/components/articles/page-articles-tile';
import { PageFaqTile } from '~/components/page-faq-tile';
import { PageInformationBlock } from '~/components/page-information-block/page-information-block';
import { replaceVariablesInText } from '~/utils';
import { replaceVariablesInText, useReverseRouter } from '~/utils';
import { StaticProps, createGetStaticProps } from '~/static-props/create-get-static-props';
import { TileList } from '~/components/tile-list';
import { TimeframeOption, TimeframeOptionsList, colors } from '@corona-dashboard/common';
import { TimeSeriesChart } from '~/components/time-series-chart/time-series-chart';
import { TwoKpiSection } from '~/components/two-kpi-section';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';
import { useIntl } from '~/intl';
import { useRouter } from 'next/router';
import { useState } from 'react';
import { WarningTile } from '~/components/warning-tile';

Expand Down Expand Up @@ -68,7 +67,8 @@ export const getStaticProps = createGetStaticProps(
);

const DeceasedMunicipalPage = (props: StaticProps<typeof getStaticProps>) => {
const router = useRouter();
const reverseRouter = useReverseRouter();

const { pageText, municipalityName, selectedArchivedGmData: data, content, lastGenerated } = props;

const [deceasedMunicipalTimeframe, setDeceasedMunicipalTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);
Expand Down Expand Up @@ -107,7 +107,7 @@ const DeceasedMunicipalPage = (props: StaticProps<typeof getStaticProps>) => {
dateOrRange: data.deceased_rivm_archived_20221231.last_value.date_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textGm.section_deceased_rivm.bronnen.rivm],
jsonSources: [getMunicipalityJsonLink(router.query.code as string, jsonText.metrics_archived_municipality_json)],
jsonSources: [getMunicipalityJsonLink(reverseRouter.json.municipality(data.code), jsonText.metrics_archived_municipality_json.text)],
}}
vrNameOrGmName={municipalityName}
warning={textGm.warning}
Expand Down
29 changes: 16 additions & 13 deletions packages/app/src/pages/landelijk/besmettelijke-mensen.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import { ArticleParts, PagePartQueryResult } from '~/types/cms';
import { ChartTile } from '~/components/chart-tile';
import { colors, getLastFilledValue } from '@corona-dashboard/common';
import { Ziektegolf } from '@corona-dashboard/icons';
import { createGetContent, getLastGeneratedDate, getLokalizeTexts, selectArchivedNlData } from '~/static-props/get-data';
import { createGetStaticProps, StaticProps } from '~/static-props/create-get-static-props';
import { getArticleParts, getDataExplainedParts, getFaqParts, getPagePartsQuery } from '~/queries/get-page-parts-query';
import { getPageInformationHeaderContent } from '~/utils/get-page-information-header-content';
import { GetStaticPropsContext } from 'next';
import { ChartTile } from '~/components/chart-tile';
import { InView } from '~/components/in-view';
import { Languages, SiteText } from '~/locale';
import { Layout } from '~/domain/layout/layout';
import { NlLayout } from '~/domain/layout/nl-layout';
import { PageArticlesTile } from '~/components/articles/page-articles-tile';
import { PageFaqTile } from '~/components/page-faq-tile';
import { PageInformationBlock } from '~/components/page-information-block';
import { TileList } from '~/components/tile-list';
import { TimeSeriesChart } from '~/components/time-series-chart';
import { WarningTile } from '~/components/warning-tile';
import { Layout } from '~/domain/layout/layout';
import { NlLayout } from '~/domain/layout/nl-layout';
import { useIntl } from '~/intl';
import { Languages, SiteText } from '~/locale';
import { getArticleParts, getDataExplainedParts, getFaqParts, getPagePartsQuery } from '~/queries/get-page-parts-query';
import { createGetStaticProps, StaticProps } from '~/static-props/create-get-static-props';
import { createGetContent, getLastGeneratedDate, getLokalizeTexts, selectArchivedNlData } from '~/static-props/get-data';
import { ArticleParts, PagePartQueryResult } from '~/types/cms';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';
import { getPageInformationHeaderContent } from '~/utils/get-page-information-header-content';
import { useIntl } from '~/intl';
import { useReverseRouter } from '~/utils';
import { WarningTile } from '~/components/warning-tile';
import { Ziektegolf } from '@corona-dashboard/icons';

const selectLokalizeTexts = (siteText: SiteText) => ({
metadataTexts: siteText.pages.topical_page.nl.nationaal_metadata,
Expand Down Expand Up @@ -50,6 +51,8 @@ const InfectiousPeople = (props: StaticProps<typeof getStaticProps>) => {
const { commonTexts } = useIntl();
const { metadataTexts, textNl, jsonText } = useDynamicLokalizeTexts<LokalizeTexts>(pageText, selectLokalizeTexts);

const reverseRouter = useReverseRouter();

const lastFullValue = getLastFilledValue(data.infectious_people_archived_20210709);

const metadata = {
Expand All @@ -75,7 +78,7 @@ const InfectiousPeople = (props: StaticProps<typeof getStaticProps>) => {
dateOrRange: lastFullValue.date_unix,
dateOfInsertionUnix: lastFullValue.date_of_insertion_unix,
dataSources: [textNl.bronnen.rivm],
jsonSources: [jsonText.metrics_archived_national_json],
jsonSources: [{ href: reverseRouter.json.archivedNational(), text: jsonText.metrics_archived_national_json.text }],
}}
pageInformationHeader={getPageInformationHeaderContent({
dataExplained: content.dataExplained,
Expand Down
5 changes: 4 additions & 1 deletion packages/app/src/pages/landelijk/corona-thermometer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { Timeline } from '~/components/severity-indicator-tile/components/timeli
import { TimelineMarker } from '~/components/time-series-chart/components/timeline';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';
import { useIntl } from '~/intl';
import { useReverseRouter } from '~/utils';
import styled from 'styled-components';

const selectLokalizeTexts = (siteText: SiteText) => ({
Expand Down Expand Up @@ -68,6 +69,8 @@ const CoronaThermometer = (props: StaticProps<typeof getStaticProps>) => {

const { textNl, jsonText } = useDynamicLokalizeTexts<LokalizeTexts>(pageText, selectLokalizeTexts);

const reverseRouter = useReverseRouter();

const metadata = {
...textNl.metadata,
title: textNl.metadata.title,
Expand Down Expand Up @@ -104,7 +107,7 @@ const CoronaThermometer = (props: StaticProps<typeof getStaticProps>) => {
dateOrRange: endDate,
dateOfInsertionUnix: endDate,
dataSources: [textNl.bronnen.rivm],
jsonSources: [jsonText.metrics_archived_national_json],
jsonSources: [{ href: reverseRouter.json.archivedNational(), text: jsonText.metrics_archived_national_json.text }],
}}
pageInformationHeader={getPageInformationHeaderContent({
dataExplained: content.dataExplained,
Expand Down
5 changes: 4 additions & 1 deletion packages/app/src/pages/landelijk/coronamelder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { TileList } from '~/components/tile-list';
import { TimeSeriesChart } from '~/components/time-series-chart';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';
import { useIntl } from '~/intl';
import { useReverseRouter } from '~/utils';
import { useState } from 'react';
import { WarningTile } from '~/components/warning-tile';

Expand All @@ -33,6 +34,8 @@ const CoronamelderPage = (props: StaticProps<typeof getStaticProps>) => {
const [coronamelderTimeframe, setCoronamelderTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);
const { commonTexts } = useIntl();

const reverseRouter = useReverseRouter();

const { pageText, selectedArchivedNlData: data, lastGenerated } = props;
const { corona_melder_app } = commonTexts;
const { metadataTexts, textNl, jsonText } = useDynamicLokalizeTexts<LokalizeTexts>(pageText, selectLokalizeTexts);
Expand Down Expand Up @@ -62,7 +65,7 @@ const CoronamelderPage = (props: StaticProps<typeof getStaticProps>) => {
dateOrRange: warningLastValue.date_unix,
dateOfInsertionUnix: warningLastValue.date_of_insertion_unix,
dataSources: [corona_melder_app.header.bronnen.rivm],
jsonSources: [jsonText.metrics_archived_national_json],
jsonSources: [{ href: reverseRouter.json.archivedNational(), text: jsonText.metrics_archived_national_json.text }],
}}
/>

Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/pages/landelijk/de-coronaprik.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ function VaccinationPage(props: StaticProps<typeof getStaticProps>) {
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textShared.bronnen.rivm],
jsonSources: [
jsonText.metrics_national_json,
jsonText.metrics_archived_national_json,
jsonText.metrics_gm_collection_json,
jsonText.metrics_archived_gm_collection_json,
{ href: reverseRouter.json.national(), text: jsonText.metrics_national_json.text },
{ href: reverseRouter.json.archivedNational(), text: jsonText.metrics_archived_national_json.text },
{ href: reverseRouter.json.gmCollection(), text: jsonText.metrics_gm_collection_json.text },
{ href: reverseRouter.json.archivedGmCollection(), text: jsonText.metrics_archived_gm_collection_json.text },
],
}}
pageInformationHeader={getPageInformationHeaderContent({
Expand Down
5 changes: 4 additions & 1 deletion packages/app/src/pages/landelijk/gedrag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { useBehaviorLookupKeys } from '~/domain/behavior/logic/use-behavior-look
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';
import { useIntl } from '~/intl';
import { useMemo, useRef, useState } from 'react';
import { useReverseRouter } from '~/utils';
import { WarningTile } from '~/components/warning-tile';

const pageMetrics = ['behavior_archived_20230411', 'behavior_annotations_archived_20230412', 'behavior_per_age_group_archived_20230411'];
Expand Down Expand Up @@ -67,6 +68,8 @@ export default function BehaviorPage(props: StaticProps<typeof getStaticProps>)
const behaviorAnnotations = data.behavior_annotations_archived_20230412;
const behaviorPerAgeGroup = data.behavior_per_age_group_archived_20230411;

const reverseRouter = useReverseRouter();

const { commonTexts, formatNumber, formatDateFromSeconds, formatPercentage, locale } = useIntl();
const { metadataTexts, text, textNl, jsonText } = useDynamicLokalizeTexts<LokalizeTexts>(pageText, selectLokalizeTexts);

Expand Down Expand Up @@ -132,7 +135,7 @@ export default function BehaviorPage(props: StaticProps<typeof getStaticProps>)
},
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textNl.bronnen.rivm],
jsonSources: [jsonText.metrics_archived_national_json],
jsonSources: [{ href: reverseRouter.json.archivedNational(), text: jsonText.metrics_archived_national_json.text }],
}}
pageInformationHeader={getPageInformationHeaderContent({
dataExplained: content.dataExplained,
Expand Down
8 changes: 7 additions & 1 deletion packages/app/src/pages/landelijk/gehandicaptenzorg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { TileList } from '~/components/tile-list';
import { TimeSeriesChart } from '~/components/time-series-chart';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';
import { useIntl } from '~/intl';
import { useReverseRouter } from '~/utils';
import { useState } from 'react';
import { WarningTile } from '~/components/warning-tile';

Expand Down Expand Up @@ -75,6 +76,8 @@ export const getStaticProps = createGetStaticProps(
function DisabilityCare(props: StaticProps<typeof getStaticProps>) {
const { pageText, selectedArchivedNlData: data, archivedChoropleth, lastGenerated, content } = props;

const reverseRouter = useReverseRouter();

const [disabilityCareConfirmedCasesTimeframe, setDisabilityCareConfirmedCasesTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);
const [disabilityCareInfectedLocationsTimeframe, setDisabilityCareInfectedLocationsTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);
const [disabilityCareDeceasedTimeframe, setDisabilityCareDeceasedTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);
Expand Down Expand Up @@ -109,7 +112,10 @@ function DisabilityCare(props: StaticProps<typeof getStaticProps>) {
dateOrRange: lastValue.date_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textNl.positief_geteste_personen.bronnen.rivm],
jsonSources: [jsonText.metrics_archived_national_json, jsonText.metrics_archived_gm_collection_json],
jsonSources: [
{ href: reverseRouter.json.archivedNational(), text: jsonText.metrics_archived_national_json.text },
{ href: reverseRouter.json.archivedGmCollection(), text: jsonText.metrics_archived_gm_collection_json.text },
],
}}
pageInformationHeader={getPageInformationHeaderContent({
dataExplained: content.dataExplained,
Expand Down
Loading

0 comments on commit 4c041a0

Please sign in to comment.