Skip to content

Commit

Permalink
refactor(meta): use renamed pageMeta
Browse files Browse the repository at this point in the history
Co-Authored-By: Khallad Sharafeldin <32259466+khallad2@users.noreply.github.com>
  • Loading branch information
chohner and khallad2 committed Jan 10, 2025
1 parent aab4f6b commit a9243dd
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 33 deletions.
4 changes: 2 additions & 2 deletions app/routes/$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { strapiPageFromRequest } from "~/services/cms/index.server";

export const loader = async ({ request }: LoaderFunctionArgs) => {
try {
const { content, meta } = await strapiPageFromRequest({ request });
return json({ content, meta });
const { content, pageMeta } = await strapiPageFromRequest({ request });
return json({ content, meta: pageMeta });
} catch (error) {
if ((error as Error).name === "StrapiPageNotFound") {
throw new Response(null, { status: 404 });
Expand Down
4 changes: 2 additions & 2 deletions app/routes/beratungshilfe.zustaendiges-gericht.ergebnis.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
}

const slug = "/beratungshilfe/zustaendiges-gericht/ergebnis";
const [common, { content, meta }] = await Promise.all([
const [common, { content, pageMeta }] = await Promise.all([
fetchTranslations("amtsgericht"),
fetchPage(slug),
]);

return json({ court, content, meta, common });
return json({ court, content, meta: pageMeta, common });
};

export const Component = () => {
Expand Down
9 changes: 4 additions & 5 deletions app/routes/beratungshilfe.zustaendiges-gericht.suche.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,22 @@ const validatorServer = withZod(serverSchema);
export async function loader({ request }: LoaderFunctionArgs) {
const sessionManager = getSessionManager("/beratungshilfe/vorabcheck");

const [common, { pre_form, form, meta, nextButtonLabel }] = await Promise.all(
[
const [common, { pre_form, form, pageMeta, nextButtonLabel }] =
await Promise.all([
fetchTranslations("amtsgericht"),
fetchFlowPage(
"vorab-check-pages",
"/beratungshilfe/zustaendiges-gericht" as FlowId,
"/suche",
),
],
);
]);
const { url: backURL, session } = getReturnToURL({
request,
session: await sessionManager.getSession(request.headers.get("Cookie")),
});
const headers = { "Set-Cookie": await sessionManager.commitSession(session) };
return json(
{ common, pre_form, form, meta, backURL, nextButtonLabel },
{ common, pre_form, form, meta: pageMeta, backURL, nextButtonLabel },
{ headers },
);
}
Expand Down
4 changes: 2 additions & 2 deletions app/routes/cookie-einstellungen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
import { strapiPageFromRequest } from "~/services/cms/index.server";

export async function loader({ request }: LoaderFunctionArgs) {
const { content, meta } = await strapiPageFromRequest({ request });
const { content, pageMeta } = await strapiPageFromRequest({ request });
const trackingConsent = await trackingCookieValue({ request });
return { meta, content, trackingConsent, acceptCookiesFieldName };
return { meta: pageMeta, content, trackingConsent, acceptCookiesFieldName };
}

export async function action({ request }: ActionFunctionArgs) {
Expand Down
4 changes: 2 additions & 2 deletions app/routes/feedback.erfolgreich.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { strapiPageFromRequest } from "~/services/cms/index.server";
export const loader = async ({ request }: LoaderFunctionArgs) => {
const { searchParams } = new URL(request.url);
const url = searchParams.get("url") ?? "";
const { content, meta } = await strapiPageFromRequest({ request });
return json({ content, meta, url });
const { content, pageMeta } = await strapiPageFromRequest({ request });
return json({ content, meta: pageMeta, url });
};

export default function Index() {
Expand Down
20 changes: 15 additions & 5 deletions app/routes/geld-einklagen.vorabcheck.partnergericht.ergebnis.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,22 @@ export const loader = async ({
}
});

const [common, { heading, freeZone, hintText, meta }] = await Promise.all([
fetchTranslations("amtsgericht"),
fetchFlowPage("result-pages", flowId, stepId),
]);
const [common, { heading, freeZone, hintText, pageMeta }] = await Promise.all(
[
fetchTranslations("amtsgericht"),
fetchFlowPage("result-pages", flowId, stepId),
],
);

return json({ courts, freeZone, heading, hintText, pageType, meta, common });
return json({
courts,
freeZone,
heading,
hintText,
pageType,
meta: pageMeta,
common,
});
};

const iconCSS = "inline-block mr-8 !h-[36px] !w-[36px]";
Expand Down
4 changes: 2 additions & 2 deletions app/routes/kitchensink._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { throw404OnProduction } from "~/services/errorPages/throw404";

export const loader = async ({ request }: LoaderFunctionArgs) => {
throw404OnProduction();
const { content, meta } = await strapiPageFromRequest({ request });
return json({ content, meta });
const { content, pageMeta } = await strapiPageFromRequest({ request });
return json({ content, meta: pageMeta });
};

export default function Kitchensink() {
Expand Down
4 changes: 2 additions & 2 deletions app/routes/opensource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { dependencies } from "~/services/openSourceLicenses/dependencies.server"
import LicenseList from "~/services/openSourceLicenses/LicenseList";

export const loader = async ({ request }: LoaderFunctionArgs) => {
const { content, meta } = await strapiPageFromRequest({ request });
const { content, pageMeta } = await strapiPageFromRequest({ request });
return json({
meta,
meta: pageMeta,
content,
dependencies,
});
Expand Down
9 changes: 7 additions & 2 deletions app/routes/persoenliche-daten-loeschen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
origin,
});

const { content, meta } = await strapiPageFromRequest({ request });
const { content, pageMeta } = await strapiPageFromRequest({ request });
const translations = await fetchTranslations("delete-data");
return { meta, content, translations, backButton: sanitizedReferrer };
return {
meta: pageMeta,
content,
translations,
backButton: sanitizedReferrer,
};
}

export default function PersoenlicheDatenLoeschen() {
Expand Down
2 changes: 1 addition & 1 deletion app/routes/shared/formular.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const loader = async ({
return strapiFormElement;
});

const meta = stepMeta(formPageContent.meta, parentMeta);
const meta = stepMeta(formPageContent.pageMeta, parentMeta);

// Retrieve user data for current step
const fieldNames = formPageContent.form.map((entry) => entry.name);
Expand Down
2 changes: 1 addition & 1 deletion app/routes/shared/result.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const loader = async ({ request, context }: LoaderFunctionArgs) => {
flowId,
common: defaultStrings,
cmsData,
meta: { ...cmsContent.meta, breadcrumb: parentMeta?.breadcrumb },
meta: { ...cmsContent.pageMeta, breadcrumb: parentMeta?.breadcrumb },
backButton,
},
{ headers },
Expand Down
2 changes: 1 addition & 1 deletion app/routes/shared/vorabcheck.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const loader = async ({
return strapiFormElement;
});

const meta = stepMeta(vorabcheckPage.meta, parentMeta);
const meta = stepMeta(vorabcheckPage.pageMeta, parentMeta);

// filter user data for current step
const fieldNames = formElements.map((entry) => entry.name);
Expand Down
4 changes: 2 additions & 2 deletions app/services/cms/__test__/getStrapiEntryFromFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("services/cms", () => {
const impressum = {
slug: impressumPath,
locale: StrapiLocaleSchema.Values.de,
meta: {
pageMeta: {
title: "Impressum",
description: "description",
ogTitle: null,
Expand All @@ -38,7 +38,7 @@ describe("services/cms", () => {
nextButtonLabel: null,
backButtonLabel: null,
stepId: "/stepId",
meta: {
pageMeta: {
title: "",
description: null,
ogTitle: null,
Expand Down
4 changes: 2 additions & 2 deletions app/services/cms/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { Translations } from "../translations/getTranslationByKey";
export async function fetchMeta(
opts: Omit<GetStrapiEntryOpts, "apiId" | "filter"> & { filterValue: string },
) {
const populate = "meta";
const populate = "pageMeta";
const filters = [{ value: opts.filterValue, field: "slug" }];
const apiId = "pages";
const pageEntry = await getStrapiEntry({
Expand All @@ -32,7 +32,7 @@ export async function fetchMeta(
deep: false,
});
const parsedEntry = HasStrapiMetaSchema.safeParse(pageEntry[0]);
return parsedEntry.success ? parsedEntry.data.meta : null;
return parsedEntry.success ? parsedEntry.data.pageMeta : null;
}

export async function fetchSingleEntry<T extends SingleEntryId>(
Expand Down
2 changes: 1 addition & 1 deletion app/services/cms/models/HasStrapiMeta.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { z } from "zod";
import { StrapiMetaSchema } from "./StrapiMeta";

export const HasStrapiMetaSchema = z.object({ meta: StrapiMetaSchema });
export const HasStrapiMetaSchema = z.object({ pageMeta: StrapiMetaSchema });
2 changes: 1 addition & 1 deletion tests/factories/cmsModels/strapiFlowPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getStrapiFlowPage(
pre_form: [],
post_form: [],
locale: params.locale ?? "de",
meta: {
pageMeta: {
title: faker.lorem.word(),
breadcrumb: faker.lorem.word(),
description: null,
Expand Down

0 comments on commit a9243dd

Please sign in to comment.