From 48a5cc5a76f2c8d138bb9bc3956ebc2f1ff9c5ef Mon Sep 17 00:00:00 2001 From: RaviAnand Mohabir Date: Wed, 28 Aug 2024 10:46:09 +0200 Subject: [PATCH] feat: :sparkles: display food declarations on menu page --- src/api/foodDeclarations.ts | 14 ++++++++++++++ src/api/index.ts | 1 + src/app/(frontend)/[locale]/menu/page.tsx | 19 ++++++++++++++++++- src/i18n/de.ts | 1 + src/i18n/en.ts | 1 + 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/api/foodDeclarations.ts diff --git a/src/api/foodDeclarations.ts b/src/api/foodDeclarations.ts new file mode 100644 index 0000000..0682e9c --- /dev/null +++ b/src/api/foodDeclarations.ts @@ -0,0 +1,14 @@ +import type { Options } from "node_modules/payload/dist/collections/operations/local/find"; +import { getPayload } from "@/utils/payload"; + +export const getFoodDeclarations = async ( + opts: Omit, "collection" | "pagination">, +) => { + const payload = await getPayload(); + + return await payload.find({ + collection: "food-declaration", + pagination: false, + ...opts, + }); +}; diff --git a/src/api/index.ts b/src/api/index.ts index 968a009..5c5bcf7 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -7,3 +7,4 @@ export * from "./home"; export * from "./menu"; export * from "./settings"; export * from "./vacations"; +export * from "./foodDeclarations"; diff --git a/src/app/(frontend)/[locale]/menu/page.tsx b/src/app/(frontend)/[locale]/menu/page.tsx index 7904401..6fb811a 100644 --- a/src/app/(frontend)/[locale]/menu/page.tsx +++ b/src/app/(frontend)/[locale]/menu/page.tsx @@ -1,16 +1,18 @@ import { Box, Stack } from "@styled-system/jsx"; +import { getFoodDeclarations, getMenuCategories } from "@/api"; import { Heading } from "@/components/ui/heading"; import { MenuCategory } from "@/payload-types"; import MenuCategoryTabContent from "./menu-category-tab-content"; import { Params } from "../shared"; +import RichText from "@/components/rich-text"; import { Tabs } from "@/components/ui/tabs"; import { getI18n } from "@/i18n/server"; -import { getMenuCategories } from "@/api"; export default async function Menu({ params: { locale } }: { params: Params }) { const t = await getI18n(); const menuCategories = await getMenuCategories({ locale }); + const foodDeclarations = await getFoodDeclarations({ locale }); return ( @@ -40,6 +42,21 @@ export default async function Menu({ params: { locale } }: { params: Params }) { ))} + {foodDeclarations.docs.length > 0 && ( + <> + + {t("menu.foodDeclarations")} + + + {foodDeclarations.docs.map((fd) => ( + + {fd.title} + {fd.description && } + + ))} + + + )} ); } diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 15213cb..3c681a8 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -50,4 +50,5 @@ export default { contactSubject: "Kontaktanfrage von {name}", contactTitle: "Sie haben eine Kontaktanfrage von {name} erhalten:", }, + menu: { foodDeclarations: "Lebensmitteldeklaration" }, } as const; diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 408986d..8b0b530 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -41,4 +41,5 @@ export default { reservation: { guests: "Guests", }, + menu: { foodDeclarations: "Food declarations" }, } as const;