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

Commit

Permalink
COR-972 Apply Sanity keys logic to VR & GM pages (#4352)
Browse files Browse the repository at this point in the history
* feat: apply sanity keys logic to nl pages

* fix: restore sanity debug setting

* feat: apply sanity keys logic to vr pages

* feat: apply sanity keys logic to gm pages

* feat: apply sanity keys logic to actueel pages

* feat: apply sanity keys logic to artikelen

* fix: resolve pr feedback

Co-authored-by: VWSCoronaDashboard24 <[email protected]>
  • Loading branch information
VWSCoronaDashboard24 and VWSCoronaDashboard24 authored Aug 18, 2022
1 parent 6dc9797 commit fd0bf3c
Show file tree
Hide file tree
Showing 22 changed files with 308 additions and 217 deletions.
27 changes: 15 additions & 12 deletions packages/app/src/pages/actueel/gemeente/[code].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { useAgegroupLabels } from '~/domain/vaccine/logic/use-agegroup-labels';
import { useIntl } from '~/intl';
import { getWarning } from '~/queries/get-elements-query';
import { getTopicalPageData } from '~/queries/get-topical-page-data';
import { Languages } from '~/locale';
import { Languages, SiteText } from '~/locale';
import {
createGetStaticProps,
StaticProps,
Expand All @@ -62,21 +62,23 @@ import {
replaceComponentsInText,
getAverageSplitPoints,
} from '~/utils';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';

export { getStaticPaths } from '~/static-paths/gm';

const selectLokalizeTexts = (siteText: SiteText) => ({
hospitalText: siteText.pages.hospital_page.nl,
positiveTestsText: siteText.pages.positive_tests_page.shared,
textGm: siteText.pages.topical_page.gm,
textShared: siteText.pages.topical_page.shared,
sewerText: siteText.pages.sewer_page.shared,
});

type LokalizeTexts = ReturnType<typeof selectLokalizeTexts>;

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
getLokalizeTexts(
(siteText) => ({
hospitalText: siteText.pages.hospital_page.nl,
positiveTestsText: siteText.pages.positive_tests_page.shared,
textGm: siteText.pages.topical_page.gm,
textShared: siteText.pages.topical_page.shared,
sewerText: siteText.pages.sewer_page.shared,
}),
locale
),
getLokalizeTexts(selectLokalizeTexts, locale),
getLastGeneratedDate,
(context) => {
const data = selectGmData(
Expand Down Expand Up @@ -158,7 +160,8 @@ const TopicalMunicipality = (props: StaticProps<typeof getStaticProps>) => {
const router = useRouter();
const reverseRouter = useReverseRouter();
const { commonTexts, ...formatters } = useIntl();
const { hospitalText, textGm, sewerText, textShared } = pageText;
const { hospitalText, textGm, sewerText, textShared } =
useDynamicLokalizeTexts<LokalizeTexts>(pageText, selectLokalizeTexts);

const gmCode = router.query.code as string;

Expand Down
21 changes: 13 additions & 8 deletions packages/app/src/pages/actueel/gemeente/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Heading } from '~/components/typography';
import { GmComboBox } from '~/domain/layout/components/gm-combo-box';
import { GmLayout } from '~/domain/layout/gm-layout';
import { Layout } from '~/domain/layout/layout';
import { Languages } from '~/locale';
import { Languages, SiteText } from '~/locale';
import {
createGetStaticProps,
StaticProps,
Expand All @@ -25,15 +25,17 @@ import {
} from '~/static-props/get-data';
import { useBreakpoints } from '~/utils/use-breakpoints';
import { useReverseRouter } from '~/utils/use-reverse-router';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';

const selectLokalizeTexts = (siteText: SiteText) => ({
textGm: siteText.pages.topical_page.gm,
});

type LokalizeTexts = ReturnType<typeof selectLokalizeTexts>;

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
getLokalizeTexts(
(siteText) => ({
textGm: siteText.pages.topical_page.gm,
}),
locale
),
getLokalizeTexts(selectLokalizeTexts, locale),
getLastGeneratedDate
);

Expand All @@ -45,7 +47,10 @@ const Municipality = (props: StaticProps<typeof getStaticProps>) => {

const breakpoints = useBreakpoints();

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

const metadata = {
...textGm.index.metadata,
Expand Down
27 changes: 15 additions & 12 deletions packages/app/src/pages/actueel/veiligheidsregio/[code].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { useAgegroupLabels } from '~/domain/vaccine/logic/use-agegroup-labels';
import { useIntl } from '~/intl';
import { getWarning } from '~/queries/get-elements-query';
import { getTopicalPageData } from '~/queries/get-topical-page-data';
import { Languages } from '~/locale';
import { Languages, SiteText } from '~/locale';
import {
createGetStaticProps,
StaticProps,
Expand All @@ -60,21 +60,23 @@ import {
trimNullValues,
getAverageSplitPoints,
} from '~/utils';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';

export { getStaticPaths } from '~/static-paths/vr';

const selectLokalizeTexts = (siteText: SiteText) => ({
hospitalText: siteText.pages.hospital_page.nl,
positiveTestsText: siteText.pages.positive_tests_page.shared,
textVr: siteText.pages.topical_page.vr,
textShared: siteText.pages.topical_page.shared,
sewerText: siteText.pages.sewer_page.shared,
});

type LokalizeTexts = ReturnType<typeof selectLokalizeTexts>;

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
getLokalizeTexts(
(siteText) => ({
hospitalText: siteText.pages.hospital_page.nl,
positiveTestsText: siteText.pages.positive_tests_page.shared,
textVr: siteText.pages.topical_page.vr,
textShared: siteText.pages.topical_page.shared,
sewerText: siteText.pages.sewer_page.shared,
}),
locale
),
getLokalizeTexts(selectLokalizeTexts, locale),
getLastGeneratedDate,
(context) => {
const data = selectVrData(
Expand Down Expand Up @@ -171,7 +173,8 @@ const TopicalVr = (props: StaticProps<typeof getStaticProps>) => {
const reverseRouter = useReverseRouter();
const vrCode = router.query.code as string;
const { commonTexts, ...formatters } = useIntl();
const { hospitalText, textVr, sewerText, textShared } = pageText;
const { hospitalText, textVr, sewerText, textShared } =
useDynamicLokalizeTexts<LokalizeTexts>(pageText, selectLokalizeTexts);

const dataHospitalIntake = data.hospital_nice;
const dataSewerTotal = data.sewer;
Expand Down
21 changes: 13 additions & 8 deletions packages/app/src/pages/actueel/veiligheidsregio/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { VrComboBox } from '~/domain/layout/components/vr-combo-box';
import { Layout } from '~/domain/layout/layout';
import { VrLayout } from '~/domain/layout/vr-layout';
import { useIntl } from '~/intl';
import { Languages } from '~/locale';
import { Languages, SiteText } from '~/locale';
import {
createGetStaticProps,
StaticProps,
Expand All @@ -27,15 +27,17 @@ import {
} from '~/static-props/get-data';
import { useBreakpoints } from '~/utils/use-breakpoints';
import { useReverseRouter } from '~/utils/use-reverse-router';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';

const selectLokalizeTexts = (siteText: SiteText) => ({
textVr: siteText.pages.topical_page.vr,
});

type LokalizeTexts = ReturnType<typeof selectLokalizeTexts>;

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
getLokalizeTexts(
(siteText) => ({
textVr: siteText.pages.topical_page.vr,
}),
locale
),
getLokalizeTexts(selectLokalizeTexts, locale),
getLastGeneratedDate
);

Expand All @@ -47,7 +49,10 @@ const VrIndexPage = (props: StaticProps<typeof getStaticProps>) => {

const { pageText, lastGenerated } = props;

const { textVr } = pageText;
const { textVr } = useDynamicLokalizeTexts<LokalizeTexts>(
pageText,
selectLokalizeTexts
);
const code = router.query.code as string;

const metadata = {
Expand Down
28 changes: 16 additions & 12 deletions packages/app/src/pages/artikelen/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ArticleDetail } from '~/components/article-detail';
import { Box } from '~/components/base';
import { Layout } from '~/domain/layout/layout';
import { getClient, getImageSrc } from '~/lib/sanity';
import { Languages } from '~/locale';
import { Languages, SiteText } from '~/locale';
import {
createGetStaticProps,
StaticProps,
Expand All @@ -16,6 +16,13 @@ import {
} from '~/static-props/get-data';
import { Article, Block, RichContentBlock } from '~/types/cms';
import { assert } from '~/utils/assert';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';

const selectLokalizeTexts = (siteText: SiteText) => ({
textTopicalPageShared: siteText.pages.topical_page.shared,
});

type LokalizeTexts = ReturnType<typeof selectLokalizeTexts>;

const articlesQuery = `*[_type == 'article'] {"slug":slug.current}`;

Expand All @@ -42,12 +49,7 @@ export async function getStaticPaths() {

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
getLokalizeTexts(
(siteText) => ({
textTopicalPgaeShared: siteText.pages.topical_page.shared,
}),
locale
),
getLokalizeTexts(selectLokalizeTexts, locale),
getLastGeneratedDate,
createGetContent<Article>((context) => {
const { locale } = context;
Expand Down Expand Up @@ -83,9 +85,14 @@ export const getStaticProps = createGetStaticProps(
);

const ArticleDetailPage = (props: StaticProps<typeof getStaticProps>) => {
const { pageText, content, lastGenerated } = props;
const { content, lastGenerated, pageText } = props;
const { locale = 'nl' } = useRouter();

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

const { cover } = content;
const { asset } = cover;

Expand All @@ -110,10 +117,7 @@ const ArticleDetailPage = (props: StaticProps<typeof getStaticProps>) => {
{...metadata}
>
<Box backgroundColor="white">
<ArticleDetail
article={content}
text={pageText.textTopicalPgaeShared}
/>
<ArticleDetail article={content} text={textTopicalPageShared} />
</Box>
</Layout>
);
Expand Down
21 changes: 13 additions & 8 deletions packages/app/src/pages/artikelen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
ArticleCategoryType,
} from '~/domain/topical/common/categories';
import { useIntl } from '~/intl';
import { Languages } from '~/locale';
import { Languages, SiteText } from '~/locale';
import {
createGetStaticProps,
StaticProps,
Expand All @@ -27,15 +27,17 @@ import {
} from '~/static-props/get-data';
import { asResponsiveArray } from '~/style/utils';
import { useBreakpoints } from '~/utils/use-breakpoints';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';

const selectLokalizeTexts = (siteText: SiteText) => ({
textShared: siteText.pages.topical_page.shared,
});

type LokalizeTexts = ReturnType<typeof selectLokalizeTexts>;

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
getLokalizeTexts(
(siteText) => ({
textShared: siteText.pages.topical_page.shared,
}),
locale
),
getLokalizeTexts(selectLokalizeTexts, locale),
getLastGeneratedDate,
createGetContent<ArticleSummary[]>((context) => {
const { locale } = context;
Expand All @@ -59,7 +61,10 @@ const ArticlesOverview = (props: StaticProps<typeof getStaticProps>) => {
const router = useRouter();
const breakpoints = useBreakpoints();

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

const articleCategories = useMemo(() => {
/**
Expand Down
25 changes: 15 additions & 10 deletions packages/app/src/pages/gemeente/[code]/positief-geteste-mensen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
import { thresholds } from '~/components/choropleth/logic/thresholds';
import { Layout, GmLayout } from '~/domain/layout';
import { useIntl } from '~/intl';
import { Languages } from '~/locale';
import { Languages, SiteText } from '~/locale';
import {
ElementsQueryResult,
getElementsQuery,
Expand Down Expand Up @@ -49,21 +49,23 @@ import {
getVrForMunicipalityCode,
useReverseRouter,
} from '~/utils';
import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';

export { getStaticPaths } from '~/static-paths/gm';

import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';
const selectLokalizeTexts = (siteText: SiteText) => ({
textGm: siteText.pages.positive_tests_page.gm,
textShared: siteText.pages.positive_tests_page.shared,
});

type LokalizeTexts = ReturnType<typeof selectLokalizeTexts>;

const pageMetrics = ['tested_overall'];

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
getLokalizeTexts(
(siteText) => ({
textGm: siteText.pages.positive_tests_page.gm,
textShared: siteText.pages.positive_tests_page.shared,
}),
locale
),
getLokalizeTexts(selectLokalizeTexts, locale),
getLastGeneratedDate,
selectGmData(
'code',
Expand Down Expand Up @@ -113,7 +115,10 @@ const PositivelyTestedPeople = (props: StaticProps<typeof getStaticProps>) => {

const { commonTexts, formatNumber, formatDateFromSeconds } = useIntl();
const reverseRouter = useReverseRouter();
const { textGm, textShared } = pageText;
const { textGm, textShared } = useDynamicLokalizeTexts<LokalizeTexts>(
pageText,
selectLokalizeTexts
);

const lastValue = data.tested_overall.last_value;
const populationCount = data.static_values.population_count;
Expand Down
Loading

0 comments on commit fd0bf3c

Please sign in to comment.