feat: display food declarations on menu page

main
RaviAnand Mohabir 4 months ago
parent 1c420d9db8
commit 48a5cc5a76

@ -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<Options<"food-declaration">, "collection" | "pagination">,
) => {
const payload = await getPayload();
return await payload.find({
collection: "food-declaration",
pagination: false,
...opts,
});
};

@ -7,3 +7,4 @@ export * from "./home";
export * from "./menu";
export * from "./settings";
export * from "./vacations";
export * from "./foodDeclarations";

@ -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 (
<Stack p={6} align="center">
@ -40,6 +42,21 @@ export default async function Menu({ params: { locale } }: { params: Params }) {
))}
</Tabs.Root>
</Box>
{foodDeclarations.docs.length > 0 && (
<>
<Heading as="h2" size="xl" maxW="3xl" w="100%">
{t("menu.foodDeclarations")}
</Heading>
<Stack maxW="3xl" w="100%">
{foodDeclarations.docs.map((fd) => (
<Stack key={fd.id}>
<Heading size="lg">{fd.title}</Heading>
{fd.description && <RichText content={fd.description} />}
</Stack>
))}
</Stack>
</>
)}
</Stack>
);
}

@ -50,4 +50,5 @@ export default {
contactSubject: "Kontaktanfrage von {name}",
contactTitle: "Sie haben eine Kontaktanfrage von {name} erhalten:",
},
menu: { foodDeclarations: "Lebensmitteldeklaration" },
} as const;

@ -41,4 +41,5 @@ export default {
reservation: {
guests: "Guests",
},
menu: { foodDeclarations: "Food declarations" },
} as const;

Loading…
Cancel
Save