From ea6a15e99a08df903d03828079517d8c170fa390 Mon Sep 17 00:00:00 2001 From: RaviAnand Mohabir Date: Mon, 26 Aug 2024 19:10:19 +0200 Subject: [PATCH] feat: :sparkles: implement menu and contact pages with opening times, support for iframe embed and menu item images, variants and descriptions --- src/api/index.ts | 2 + src/api/menu.ts | 12 ++ src/api/openingTimes.ts | 6 + src/app/(frontend)/[locale]/contact/page.tsx | 79 +++++++++++++- src/app/(frontend)/[locale]/layout.tsx | 16 +-- .../[locale]/menu/category-tab-content.tsx | 77 +++++++++++++ src/app/(frontend)/[locale]/menu/page.tsx | 37 ++++++- src/app/(frontend)/[locale]/shared.ts | 3 + src/collections/MenuItem.ts | 1 + src/components/layout/footer.tsx | 13 ++- src/components/layout/language-picker.tsx | 34 ++++++ src/components/layout/mobile-nav.tsx | 29 ++++- src/components/layout/navbar.tsx | 5 +- src/components/rich-text/index.tsx | 2 +- src/components/ui/heading.tsx | 1 + src/components/ui/hover-card.tsx | 1 + src/components/ui/menu.tsx | 1 + src/components/ui/styled/heading.tsx | 10 ++ src/components/ui/styled/hover-card.tsx | 45 ++++++++ src/components/ui/styled/menu.tsx | 103 ++++++++++++++++++ src/components/ui/styled/tabs.tsx | 42 +++++++ src/components/ui/styled/text.tsx | 8 ++ src/components/ui/tabs.tsx | 1 + src/components/ui/text.tsx | 1 + src/globals/{Contact.ts => Contact.tsx} | 18 +++ src/i18n/client.ts | 9 +- src/i18n/de.ts | 20 +++- src/i18n/en.ts | 5 + src/payload-types.ts | 3 +- src/utils/formatters.ts | 2 + 30 files changed, 559 insertions(+), 27 deletions(-) create mode 100644 src/api/menu.ts create mode 100644 src/api/openingTimes.ts create mode 100644 src/app/(frontend)/[locale]/menu/category-tab-content.tsx create mode 100644 src/app/(frontend)/[locale]/shared.ts create mode 100644 src/components/layout/language-picker.tsx create mode 100644 src/components/ui/heading.tsx create mode 100644 src/components/ui/hover-card.tsx create mode 100644 src/components/ui/menu.tsx create mode 100644 src/components/ui/styled/heading.tsx create mode 100644 src/components/ui/styled/hover-card.tsx create mode 100644 src/components/ui/styled/menu.tsx create mode 100644 src/components/ui/styled/tabs.tsx create mode 100644 src/components/ui/styled/text.tsx create mode 100644 src/components/ui/tabs.tsx create mode 100644 src/components/ui/text.tsx rename src/globals/{Contact.ts => Contact.tsx} (78%) create mode 100644 src/utils/formatters.ts diff --git a/src/api/index.ts b/src/api/index.ts index 4a11577..c502355 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -2,3 +2,5 @@ export * from "./about"; export * from "./contact"; export * from "./gallery"; export * from "./home"; +export * from "./menu"; + diff --git a/src/api/menu.ts b/src/api/menu.ts new file mode 100644 index 0000000..1039428 --- /dev/null +++ b/src/api/menu.ts @@ -0,0 +1,12 @@ +import { Options } from "node_modules/payload/dist/collections/operations/local/find"; +import { getPayload } from "@/utils/payload"; + +export const getMenuCategories = async () => { + const payload = await getPayload(); + return payload.find({ collection: "menu-category", pagination: false }); +}; + +export const getMenuItems = async (opts: Omit, "collection">) => { + const payload = await getPayload(); + return payload.find({ collection: "menu-item", ...opts }); +}; diff --git a/src/api/openingTimes.ts b/src/api/openingTimes.ts new file mode 100644 index 0000000..3f11ee3 --- /dev/null +++ b/src/api/openingTimes.ts @@ -0,0 +1,6 @@ +import { getPayload } from "@/utils/payload"; + +export const getOpeningTimes = async () => { + const payload = await getPayload(); + return await payload.find({ collection: "opening-time", sort: "from", pagination: false }); +}; diff --git a/src/app/(frontend)/[locale]/contact/page.tsx b/src/app/(frontend)/[locale]/contact/page.tsx index a81e750..ba3c97e 100644 --- a/src/app/(frontend)/[locale]/contact/page.tsx +++ b/src/app/(frontend)/[locale]/contact/page.tsx @@ -1 +1,78 @@ -export default async function Contact() {} +import { Box, HStack, Stack } from "@styled-system/jsx"; +import { getAbout, getContact } from "@/api"; + +import { Heading } from "@/components/ui/heading"; +import { Text } from "@/components/ui/text"; +import { getI18n } from "@/i18n/server"; +import { getOpeningTimes } from "@/api/openingTimes"; +import { styled } from "@styled-system/jsx"; + +export default async function Contact() { + const t = await getI18n(); + const about = await getAbout(); + const contact = await getContact(); + const openingTimes = await getOpeningTimes(); + + return ( + + + {t("general.contact")} + + + + + {t("general.openingTimes")} + + {openingTimes.docs.map((ot) => ( + + + {t(`days.${ot.from}`)} + {ot.to ? `- ${t(`days.${ot.to}`)}` : ""} + + + {new Date(ot.timeOpen).toLocaleTimeString("de-CH", { timeStyle: "short" })} -{" "} + {new Date(ot.timeClose).toLocaleTimeString("de-CH", { timeStyle: "short" })} + + + ))} + + + + + {t("general.address")} + + + {contact.address.embeddedMaps && ( + + )} + + + {about.name} + + {contact.address.street} {contact.address.number} + + + {contact.address.zip} {contact.address.area} + + + {contact.phone && ( + + {t("general.phoneNumber")} + {contact.phone} + + )} + {contact.email && ( + + {t("general.email")} + {contact.email} + + )} + + + + + ); +} diff --git a/src/app/(frontend)/[locale]/layout.tsx b/src/app/(frontend)/[locale]/layout.tsx index 8b22843..59e18d1 100644 --- a/src/app/(frontend)/[locale]/layout.tsx +++ b/src/app/(frontend)/[locale]/layout.tsx @@ -23,13 +23,15 @@ export default async function RootLayout({ }) { return ( - - - - {children}{" "} - -