diff --git a/packages/app/src/pages/gemeente/[code]/de-coronaprik.tsx b/packages/app/src/pages/gemeente/[code]/de-coronaprik.tsx index bc5106255b..5d5d5ed9c1 100644 --- a/packages/app/src/pages/gemeente/[code]/de-coronaprik.tsx +++ b/packages/app/src/pages/gemeente/[code]/de-coronaprik.tsx @@ -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'; @@ -86,7 +85,6 @@ export const getStaticProps = createGetStaticProps( ); export const VaccinationsGmPage = (props: StaticProps) => { - const router = useRouter(); const { pageText, archivedChoropleth, municipalityName, selectedGmData: currentData, selectedArchivedGmData: archivedData, content, lastGenerated } = props; const { commonTexts } = useIntl(); const { formatPercentageAsNumber } = useFormatLokalizePercentage(); @@ -143,9 +141,9 @@ export const VaccinationsGmPage = (props: StaticProps) => 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} diff --git a/packages/app/src/pages/gemeente/[code]/patienten-in-beeld.tsx b/packages/app/src/pages/gemeente/[code]/patienten-in-beeld.tsx index ab9e1ef14f..3c9e5f0748 100644 --- a/packages/app/src/pages/gemeente/[code]/patienten-in-beeld.tsx +++ b/packages/app/src/pages/gemeente/[code]/patienten-in-beeld.tsx @@ -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'; @@ -79,7 +78,6 @@ export const getStaticProps = createGetStaticProps( ); function IntakeHospital(props: StaticProps) { - const router = useRouter(); const { pageText, selectedArchivedGmData: data, archivedChoropleth, municipalityName, content, lastGenerated } = props; const [isArchivedContentShown, setIsArchivedContentShown] = useState(false); @@ -129,9 +127,9 @@ function IntakeHospital(props: StaticProps) { 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} diff --git a/packages/app/src/pages/gemeente/[code]/positieve-testen.tsx b/packages/app/src/pages/gemeente/[code]/positieve-testen.tsx index bed3ba7ca8..1d3426a342 100644 --- a/packages/app/src/pages/gemeente/[code]/positieve-testen.tsx +++ b/packages/app/src/pages/gemeente/[code]/positieve-testen.tsx @@ -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'; @@ -81,7 +80,6 @@ export const getStaticProps = createGetStaticProps( ); function PositivelyTestedPeople(props: StaticProps) { - const router = useRouter(); const { pageText, selectedGmData: data, selectedArchivedGmData: archivedData, archivedChoropleth, municipalityName, content, lastGenerated } = props; const [positivelyTestedPeopleTimeframe, setpositivelyTestedPeopleTimeframe] = useState(TimeframeOption.ALL); const { commonTexts, formatNumber, formatDateFromSeconds } = useIntl(); @@ -119,9 +117,9 @@ function PositivelyTestedPeople(props: StaticProps) { 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} diff --git a/packages/app/src/pages/gemeente/[code]/rioolwater.tsx b/packages/app/src/pages/gemeente/[code]/rioolwater.tsx index 29133598ec..c7f63eed90 100644 --- a/packages/app/src/pages/gemeente/[code]/rioolwater.tsx +++ b/packages/app/src/pages/gemeente/[code]/rioolwater.tsx @@ -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']; @@ -63,7 +63,9 @@ const SewerWater = (props: StaticProps) => { const { commonTexts, formatNumber } = useIntl(); const { textGm, textShared, jsonText } = useDynamicLokalizeTexts(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; @@ -108,7 +110,7 @@ const SewerWater = (props: StaticProps) => { }, 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} diff --git a/packages/app/src/pages/gemeente/[code]/sterfte.tsx b/packages/app/src/pages/gemeente/[code]/sterfte.tsx index f7e141afbb..6e9552dd5a 100644 --- a/packages/app/src/pages/gemeente/[code]/sterfte.tsx +++ b/packages/app/src/pages/gemeente/[code]/sterfte.tsx @@ -16,7 +16,7 @@ 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'; @@ -24,7 +24,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'; @@ -68,7 +67,8 @@ export const getStaticProps = createGetStaticProps( ); const DeceasedMunicipalPage = (props: StaticProps) => { - const router = useRouter(); + const reverseRouter = useReverseRouter(); + const { pageText, municipalityName, selectedArchivedGmData: data, content, lastGenerated } = props; const [deceasedMunicipalTimeframe, setDeceasedMunicipalTimeframe] = useState(TimeframeOption.ALL); @@ -107,7 +107,7 @@ const DeceasedMunicipalPage = (props: StaticProps) => { 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} diff --git a/packages/app/src/pages/landelijk/besmettelijke-mensen.tsx b/packages/app/src/pages/landelijk/besmettelijke-mensen.tsx index 2f06fb006b..5628754f45 100644 --- a/packages/app/src/pages/landelijk/besmettelijke-mensen.tsx +++ b/packages/app/src/pages/landelijk/besmettelijke-mensen.tsx @@ -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, @@ -50,6 +51,8 @@ const InfectiousPeople = (props: StaticProps) => { const { commonTexts } = useIntl(); const { metadataTexts, textNl, jsonText } = useDynamicLokalizeTexts(pageText, selectLokalizeTexts); + const reverseRouter = useReverseRouter(); + const lastFullValue = getLastFilledValue(data.infectious_people_archived_20210709); const metadata = { @@ -75,7 +78,7 @@ const InfectiousPeople = (props: StaticProps) => { 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, diff --git a/packages/app/src/pages/landelijk/corona-thermometer.tsx b/packages/app/src/pages/landelijk/corona-thermometer.tsx index 1445a7fb95..925d60780d 100644 --- a/packages/app/src/pages/landelijk/corona-thermometer.tsx +++ b/packages/app/src/pages/landelijk/corona-thermometer.tsx @@ -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) => ({ @@ -68,6 +69,8 @@ const CoronaThermometer = (props: StaticProps) => { const { textNl, jsonText } = useDynamicLokalizeTexts(pageText, selectLokalizeTexts); + const reverseRouter = useReverseRouter(); + const metadata = { ...textNl.metadata, title: textNl.metadata.title, @@ -104,7 +107,7 @@ const CoronaThermometer = (props: StaticProps) => { 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, diff --git a/packages/app/src/pages/landelijk/coronamelder.tsx b/packages/app/src/pages/landelijk/coronamelder.tsx index 451e35d614..e0fc07f031 100644 --- a/packages/app/src/pages/landelijk/coronamelder.tsx +++ b/packages/app/src/pages/landelijk/coronamelder.tsx @@ -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'; @@ -33,6 +34,8 @@ const CoronamelderPage = (props: StaticProps) => { const [coronamelderTimeframe, setCoronamelderTimeframe] = useState(TimeframeOption.ALL); const { commonTexts } = useIntl(); + const reverseRouter = useReverseRouter(); + const { pageText, selectedArchivedNlData: data, lastGenerated } = props; const { corona_melder_app } = commonTexts; const { metadataTexts, textNl, jsonText } = useDynamicLokalizeTexts(pageText, selectLokalizeTexts); @@ -62,7 +65,7 @@ const CoronamelderPage = (props: StaticProps) => { 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 }], }} /> diff --git a/packages/app/src/pages/landelijk/de-coronaprik.tsx b/packages/app/src/pages/landelijk/de-coronaprik.tsx index 5878cff5f3..dd3dc5134f 100644 --- a/packages/app/src/pages/landelijk/de-coronaprik.tsx +++ b/packages/app/src/pages/landelijk/de-coronaprik.tsx @@ -181,10 +181,10 @@ function VaccinationPage(props: StaticProps) { 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({ diff --git a/packages/app/src/pages/landelijk/gedrag.tsx b/packages/app/src/pages/landelijk/gedrag.tsx index 40e6a5ae12..90da513894 100644 --- a/packages/app/src/pages/landelijk/gedrag.tsx +++ b/packages/app/src/pages/landelijk/gedrag.tsx @@ -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']; @@ -67,6 +68,8 @@ export default function BehaviorPage(props: StaticProps) 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(pageText, selectLokalizeTexts); @@ -132,7 +135,7 @@ export default function BehaviorPage(props: StaticProps) }, 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, diff --git a/packages/app/src/pages/landelijk/gehandicaptenzorg.tsx b/packages/app/src/pages/landelijk/gehandicaptenzorg.tsx index daecaa1990..7ee464746e 100644 --- a/packages/app/src/pages/landelijk/gehandicaptenzorg.tsx +++ b/packages/app/src/pages/landelijk/gehandicaptenzorg.tsx @@ -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'; @@ -75,6 +76,8 @@ export const getStaticProps = createGetStaticProps( function DisabilityCare(props: StaticProps) { const { pageText, selectedArchivedNlData: data, archivedChoropleth, lastGenerated, content } = props; + const reverseRouter = useReverseRouter(); + const [disabilityCareConfirmedCasesTimeframe, setDisabilityCareConfirmedCasesTimeframe] = useState(TimeframeOption.ALL); const [disabilityCareInfectedLocationsTimeframe, setDisabilityCareInfectedLocationsTimeframe] = useState(TimeframeOption.ALL); const [disabilityCareDeceasedTimeframe, setDisabilityCareDeceasedTimeframe] = useState(TimeframeOption.ALL); @@ -109,7 +112,10 @@ function DisabilityCare(props: StaticProps) { 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, diff --git a/packages/app/src/pages/landelijk/infectieradar.tsx b/packages/app/src/pages/landelijk/infectieradar.tsx index 594fa3fa8f..2d637b4d80 100644 --- a/packages/app/src/pages/landelijk/infectieradar.tsx +++ b/packages/app/src/pages/landelijk/infectieradar.tsx @@ -18,7 +18,7 @@ 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 { replaceVariablesInText } from '~/utils'; +import { replaceVariablesInText, useReverseRouter } from '~/utils'; import { TileList } from '~/components/tile-list'; import { TimeSeriesChart } from '~/components/time-series-chart'; import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts'; @@ -64,6 +64,8 @@ export const getStaticProps = createGetStaticProps( const InfectionRadar = (props: StaticProps) => { const { pageText, selectedNlData: data, content, lastGenerated } = props; + const reverseRouter = useReverseRouter(); + const [confirmedCasesSelfTestedTimeframe, setConfirmedCasesSelfTestedTimeframe] = useState(TimeframeOption.SIX_MONTHS); const [confirmedCasesCovidSymptomsPerAgeTimeFrame, setConfirmedCasesCovidSymptomsPerAgeTimeFrame] = useState(TimeframeOption.THREE_MONTHS); @@ -100,7 +102,7 @@ const InfectionRadar = (props: StaticProps) => { }, dateOfInsertionUnix: lastInsertionDateOfPage, dataSources: [textNl.sources.rivm], - jsonSources: [jsonText.metrics_national_json], + jsonSources: [{ href: reverseRouter.json.national(), text: jsonText.metrics_national_json.text }], }} pageInformationHeader={getPageInformationHeaderContent({ dataExplained: content.dataExplained, diff --git a/packages/app/src/pages/landelijk/klachten-bij-huisartsen.tsx b/packages/app/src/pages/landelijk/klachten-bij-huisartsen.tsx index 709a6e7f3f..d308e11018 100644 --- a/packages/app/src/pages/landelijk/klachten-bij-huisartsen.tsx +++ b/packages/app/src/pages/landelijk/klachten-bij-huisartsen.tsx @@ -11,6 +11,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 { WarningTile } from '~/components/warning-tile'; const selectLokalizeTexts = (siteText: SiteText) => ({ @@ -28,6 +29,8 @@ export const getStaticProps = createGetStaticProps( const SuspectedPatients = (props: StaticProps) => { const { pageText, selectedArchivedNlData: archivedData, lastGenerated } = props; + const reverseRouter = useReverseRouter(); + const lastValue = archivedData.doctor_archived_20210903.last_value; const { metadataTexts, jsonText } = useDynamicLokalizeTexts(pageText, selectLokalizeTexts); const { commonTexts } = useIntl(); @@ -56,7 +59,7 @@ const SuspectedPatients = (props: StaticProps) => { dateOrRange: lastValue.date_end_unix, dateOfInsertionUnix: lastValue.date_of_insertion_unix, dataSources: [text.bronnen.nivel], - jsonSources: [jsonText.metrics_archived_national_json], + jsonSources: [{ href: reverseRouter.json.archivedNational(), text: jsonText.metrics_archived_national_json.text }], }} /> diff --git a/packages/app/src/pages/landelijk/kwetsbare-groepen-70-plussers.tsx b/packages/app/src/pages/landelijk/kwetsbare-groepen-70-plussers.tsx index b04e79175e..0333911ab4 100644 --- a/packages/app/src/pages/landelijk/kwetsbare-groepen-70-plussers.tsx +++ b/packages/app/src/pages/landelijk/kwetsbare-groepen-70-plussers.tsx @@ -31,6 +31,7 @@ import { TimeSeriesChart } from '~/components/time-series-chart'; import { TwoKpiSection } from '~/components/two-kpi-section'; 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'; @@ -93,6 +94,8 @@ export const getStaticProps = createGetStaticProps( function VulnerableGroups(props: StaticProps) { const { pageText, selectedArchivedNlData: data, archivedChoropleth, lastGenerated, content } = props; + const reverseRouter = useReverseRouter(); + const [nursingHomeConfirmedCasesTimeframe, setNursingHomeConfirmedCasesTimeframe] = useState(TimeframeOption.ALL); const [nursingHomeInfectedLocationsTimeframe, setNursingHomeInfectedLocationsTimeframe] = useState(TimeframeOption.ALL); @@ -137,7 +140,10 @@ function VulnerableGroups(props: StaticProps) { dateOrRange: vulnerableNursingHomeDataLastValue.date_unix, dateOfInsertionUnix: lastInsertionDateOfPage, dataSources: [positiveTestedPeopleText.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, diff --git a/packages/app/src/pages/landelijk/patienten-in-beeld.tsx b/packages/app/src/pages/landelijk/patienten-in-beeld.tsx index 1ad37d5f70..abfdbeb6f4 100644 --- a/packages/app/src/pages/landelijk/patienten-in-beeld.tsx +++ b/packages/app/src/pages/landelijk/patienten-in-beeld.tsx @@ -150,7 +150,10 @@ const PatientsPage = (props: StaticProps) => { dateOrRange: lastValueNice.date_unix, dateOfInsertionUnix: lastInsertionDateOfPage, dataSources: [textNl.sources.nice], - jsonSources: [jsonText.metrics_national_json, jsonText.metrics_archived_gm_collection_json], + jsonSources: [ + { href: reverseRouter.json.national(), text: jsonText.metrics_national_json.text }, + { href: reverseRouter.json.archivedGmCollection(), text: jsonText.metrics_archived_gm_collection_json.text }, + ], }} pageLinks={content.links} pageInformationHeader={getPageInformationHeaderContent({ diff --git a/packages/app/src/pages/landelijk/positieve-testen.tsx b/packages/app/src/pages/landelijk/positieve-testen.tsx index bc097d3de4..0abd53aad9 100644 --- a/packages/app/src/pages/landelijk/positieve-testen.tsx +++ b/packages/app/src/pages/landelijk/positieve-testen.tsx @@ -131,7 +131,10 @@ function PositivelyTestedPeople(props: StaticProps) { dateOrRange: archivedDataOverallLastValue.date_unix, dateOfInsertionUnix: lastInsertionDateOfPage, dataSources: [textNl.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, diff --git a/packages/app/src/pages/landelijk/reproductiegetal.tsx b/packages/app/src/pages/landelijk/reproductiegetal.tsx index e20e304ed3..465687f737 100644 --- a/packages/app/src/pages/landelijk/reproductiegetal.tsx +++ b/packages/app/src/pages/landelijk/reproductiegetal.tsx @@ -23,6 +23,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 { useReverseRouter } from '~/utils'; import { WarningTile } from '~/components/warning-tile'; const pageMetrics = ['reproduction_archived_20230711']; @@ -65,6 +66,8 @@ export const getStaticProps = createGetStaticProps( const ReproductionIndex = (props: StaticProps) => { const { pageText, selectedArchivedNlData: data, content, lastGenerated } = props; + const reverseRouter = useReverseRouter(); + const reproductionLastValue = getLastFilledValue(data.reproduction_archived_20230711); const reproductionValues = data.reproduction_archived_20230711; @@ -96,7 +99,7 @@ const ReproductionIndex = (props: StaticProps) => { dateOrRange: reproductionLastValue.date_unix, 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, diff --git a/packages/app/src/pages/landelijk/rioolwater.tsx b/packages/app/src/pages/landelijk/rioolwater.tsx index c9b7213b79..90df74d347 100644 --- a/packages/app/src/pages/landelijk/rioolwater.tsx +++ b/packages/app/src/pages/landelijk/rioolwater.tsx @@ -103,7 +103,10 @@ const SewerWater = (props: StaticProps) => { dateOrRange: sewerAverages.last_value.date_unix, dateOfInsertionUnix: lastInsertionDateOfPage, dataSources: [textNl.bronnen.rivm], - jsonSources: [jsonText.metrics_national_json, jsonText.metrics_gm_collection_json], + jsonSources: [ + { href: reverseRouter.json.national(), text: jsonText.metrics_national_json.text }, + { href: reverseRouter.json.gmCollection(), text: jsonText.metrics_gm_collection_json.text }, + ], }} pageInformationHeader={getPageInformationHeaderContent({ dataExplained: content.dataExplained, diff --git a/packages/app/src/pages/landelijk/sterfte.tsx b/packages/app/src/pages/landelijk/sterfte.tsx index 7667f67be5..c5710ae040 100644 --- a/packages/app/src/pages/landelijk/sterfte.tsx +++ b/packages/app/src/pages/landelijk/sterfte.tsx @@ -27,6 +27,7 @@ import { TimeSeriesChart } from '~/components/time-series-chart'; import { TwoKpiSection } from '~/components/two-kpi-section'; 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'; @@ -75,6 +76,8 @@ const DeceasedNationalPage = (props: StaticProps) => { const [deceasedOverTimeTimeframe, setDeceasedOverTimeTimeframe] = useState(TimeframeOption.ALL); const [isArchivedContentShown, setIsArchivedContentShown] = useState(false); + const reverseRouter = useReverseRouter(); + const dataCbs = currentData.deceased_cbs; const dataRivm = archivedData.deceased_rivm_archived_20221231; const dataDeceasedPerAgeGroup = archivedData.deceased_rivm_per_age_group_archived_20221231; @@ -110,7 +113,10 @@ const DeceasedNationalPage = (props: StaticProps) => { }, dateOfInsertionUnix: dataCbs.last_value.date_of_insertion_unix, dataSources: [textNl.section_sterftemonitor.bronnen.cbs], - jsonSources: [jsonText.metrics_national_json, jsonText.metrics_archived_national_json], + jsonSources: [ + { href: reverseRouter.json.national(), text: jsonText.metrics_national_json.text }, + { href: reverseRouter.json.archivedNational(), text: jsonText.metrics_archived_national_json.text }, + ], }} pageInformationHeader={getPageInformationHeaderContent({ dataExplained: content.dataExplained, diff --git a/packages/app/src/pages/landelijk/thuiswonende-70-plussers.tsx b/packages/app/src/pages/landelijk/thuiswonende-70-plussers.tsx index 0a957cc02d..a128b8ad06 100644 --- a/packages/app/src/pages/landelijk/thuiswonende-70-plussers.tsx +++ b/packages/app/src/pages/landelijk/thuiswonende-70-plussers.tsx @@ -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'; @@ -69,6 +70,7 @@ export const getStaticProps = createGetStaticProps( ); function ElderlyAtHomeNationalPage(props: StaticProps) { + const reverseRouter = useReverseRouter(); const { pageText, selectedArchivedNlData: data, archivedChoropleth, lastGenerated, content } = props; const [elderlyAtHomeConfirmedCasesTimeframe, setElderlyAtHomeConfirmedCasesTimeframe] = useState(TimeframeOption.ALL); @@ -108,7 +110,10 @@ function ElderlyAtHomeNationalPage(props: StaticProps) { dateOrRange: elderlyAtHomeData.last_value.date_unix, dateOfInsertionUnix: lastInsertionDateOfPage, dataSources: [textNl.section_positive_tested.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, diff --git a/packages/app/src/pages/landelijk/varianten.tsx b/packages/app/src/pages/landelijk/varianten.tsx index b65edf5fe4..26fe1b944a 100644 --- a/packages/app/src/pages/landelijk/varianten.tsx +++ b/packages/app/src/pages/landelijk/varianten.tsx @@ -18,6 +18,7 @@ import { StaticProps, createGetStaticProps } from '~/static-props/create-get-sta import { TileList } from '~/components/tile-list'; import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts'; import { useIntl } from '~/intl'; +import { useReverseRouter } from '~/utils'; import { useState } from 'react'; import { VariantDynamicLabels } from '~/domain/variants/data-selection/types'; import { Varianten } from '@corona-dashboard/icons'; @@ -91,6 +92,8 @@ export default function CovidVariantenPage(props: StaticProps(pageText, selectLokalizeTexts); const [isArchivedContentShown, setIsArchivedContentShown] = useState(false); @@ -139,7 +142,10 @@ export default function CovidVariantenPage(props: StaticProps) => { const { pageText, selectedNlData: data, content, lastGenerated } = props; const { metadataTexts, textNl, jsonText } = useDynamicLokalizeTexts(pageText, selectLokalizeTexts); const { commonTexts } = useIntl(); + const reverseRouter = useReverseRouter(); const [selectedBedsOccupiedOverTimeChart, setSelectedBedsOccupiedOverTimeChart] = useState('beds_occupied_covid_hospital'); const [hospitalBedsOccupiedOverTimeTimeframe, setHospitalBedsOccupiedOverTimeTimeframe] = useState(TimeframeOption.THIRTY_DAYS); @@ -130,7 +132,7 @@ const HospitalsAndCarePage = (props: StaticProps) => { dateOrRange: hospitalLastValue.date_unix, dateOfInsertionUnix: lastInsertionDateOfPage, dataSources: [textNl.sources.lnaz], - jsonSources: [jsonText.metrics_national_json], + jsonSources: [{ href: reverseRouter.json.national(), text: jsonText.metrics_national_json.text }], }} pageLinks={content.links} pageInformationHeader={getPageInformationHeaderContent({ diff --git a/packages/app/src/utils/get-json-links.ts b/packages/app/src/utils/get-json-links.ts index e0b13413d1..91d2834874 100644 --- a/packages/app/src/utils/get-json-links.ts +++ b/packages/app/src/utils/get-json-links.ts @@ -1,14 +1,8 @@ -import { replaceVariablesInText } from './replace-variables-in-text'; - interface DataSource { href: string; text: string; } -export const getMunicipalityJsonLink = (code: string, dataSource: DataSource): DataSource => { - if (code) { - dataSource.href = replaceVariablesInText(dataSource.href, { code: code }); - } - - return dataSource; +export const getMunicipalityJsonLink = (dataSourceHref: string, dataSourceText: string): DataSource => { + return { href: dataSourceHref, text: dataSourceText }; }; diff --git a/packages/cms/src/lokalize/key-mutations.csv b/packages/cms/src/lokalize/key-mutations.csv index ace26655a5..cb25a2a073 100644 --- a/packages/cms/src/lokalize/key-mutations.csv +++ b/packages/cms/src/lokalize/key-mutations.csv @@ -21,3 +21,9 @@ timestamp,action,key,document_id,move_to 2024-02-22T14:51:00.317Z,add,common.common.metadata.metrics_json_links.metrics_gm_collection_json.text,LEQIG0OTDngFQu9E9HHLOA,__ 2024-02-22T14:51:01.330Z,add,common.common.metadata.metrics_json_links.metrics_archived_gm_collection_json.href,VWkwBKrnqfeEle0Dvjc5hg,__ 2024-02-22T14:51:02.347Z,add,common.common.metadata.metrics_json_links.metrics_archived_gm_collection_json.text,CEYjXN3lO3X17pY2n57mro,__ +2024-03-05T12:31:49.299Z,delete,common.common.metadata.metrics_json_links.metrics_archived_gm_collection_json.href,VWkwBKrnqfeEle0Dvjc5hg,__ +2024-03-05T12:31:49.300Z,delete,common.common.metadata.metrics_json_links.metrics_archived_municipality_json.href,aFg4DQ8VnKtfWX3L7ofdtJ,__ +2024-03-05T12:31:49.300Z,delete,common.common.metadata.metrics_json_links.metrics_archived_national_json.href,BDRHgHFora2UCq5UG30sKP,__ +2024-03-05T12:31:49.301Z,delete,common.common.metadata.metrics_json_links.metrics_gm_collection_json.href,UTNNzvANEIshqW3hB5Uu1r,__ +2024-03-05T12:31:49.301Z,delete,common.common.metadata.metrics_json_links.metrics_municipality_json.href,CEYjXN3lO3X17pY2n57knM,__ +2024-03-05T12:31:49.301Z,delete,common.common.metadata.metrics_json_links.metrics_national_json.href,2z0g0X7Nweo2izzuiKMmnu,__ diff --git a/packages/common/src/data/reverse-router.ts b/packages/common/src/data/reverse-router.ts index 43524c907f..ed4a34068e 100644 --- a/packages/common/src/data/reverse-router.ts +++ b/packages/common/src/data/reverse-router.ts @@ -46,6 +46,15 @@ export function getReverseRouter(isMobile: boolean) { deCoronaprik: (code: string) => `/gemeente/${code}/de-coronaprik`, lijstweergave: () => '/gemeente/lijstweergave', }, + + json: { + national: () => `/json/NL.json`, + archivedNational: () => `/json/archived/NL.json`, + municipality: (code: string) => `/json/${code}.json`, + archivedMunicipality: (code: string) => `/json/archived/${code}.json`, + gmCollection: () => `/json/GM_COLLECTION.json`, + archivedGmCollection: () => `/json/archived/GM_COLLECTION.json`, + }, } as const; return reverseRouter;