feat: display food declarations on menu page

main
RaviAnand Mohabir 3 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 "./menu";
export * from "./settings"; export * from "./settings";
export * from "./vacations"; export * from "./vacations";
export * from "./foodDeclarations";

@ -1,16 +1,18 @@
import { Box, Stack } from "@styled-system/jsx"; import { Box, Stack } from "@styled-system/jsx";
import { getFoodDeclarations, getMenuCategories } from "@/api";
import { Heading } from "@/components/ui/heading"; import { Heading } from "@/components/ui/heading";
import { MenuCategory } from "@/payload-types"; import { MenuCategory } from "@/payload-types";
import MenuCategoryTabContent from "./menu-category-tab-content"; import MenuCategoryTabContent from "./menu-category-tab-content";
import { Params } from "../shared"; import { Params } from "../shared";
import RichText from "@/components/rich-text";
import { Tabs } from "@/components/ui/tabs"; import { Tabs } from "@/components/ui/tabs";
import { getI18n } from "@/i18n/server"; import { getI18n } from "@/i18n/server";
import { getMenuCategories } from "@/api";
export default async function Menu({ params: { locale } }: { params: Params }) { export default async function Menu({ params: { locale } }: { params: Params }) {
const t = await getI18n(); const t = await getI18n();
const menuCategories = await getMenuCategories({ locale }); const menuCategories = await getMenuCategories({ locale });
const foodDeclarations = await getFoodDeclarations({ locale });
return ( return (
<Stack p={6} align="center"> <Stack p={6} align="center">
@ -40,6 +42,21 @@ export default async function Menu({ params: { locale } }: { params: Params }) {
))} ))}
</Tabs.Root> </Tabs.Root>
</Box> </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> </Stack>
); );
} }

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

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

Loading…
Cancel
Save