From e0996b3464fbf9ad9411b1963059fb12996ef444 Mon Sep 17 00:00:00 2001 From: Fredrik Thorsson Date: Tue, 11 Feb 2025 12:05:49 +0000 Subject: [PATCH] Merged in feat/SW-1064-restaurant-and-bar-subpage (pull request #1299) feat/SW-1064 restaurant and bar subpage * feat(SW-1064): add appendToPath to buttonlink * feat(SW-1064): add sidebar template * feat(SW-1064): render pages from nameInUrl * feat(SW-1064): add content to restaurant sidebar * feat(SW-1064): change icon size * feat(SW-1064): move opening hours component * feat(SW-1064): update switch statement * feat(SW-1064): fix typo * feat(SW-1064): rebase * feat(SW-1064): remove accidentally added file * feat(SW-1064): undefined check for restaurant subpage Approved-by: Erik Tiekstra --- components/ButtonLink/index.tsx | 16 +++- .../AccordionAmenities/Breakfast/index.tsx | 3 +- .../RestaurantBar/RestaurantBarItem/index.tsx | 23 +++-- .../RestaurantSidebar/RestaurantSidebar.tsx | 93 +++++++++++++++++++ .../restaurantSiderbar.module.css | 15 +++ .../HotelSubpage/Sidebar/index.tsx | 13 ++- components/ContentType/HotelSubpage/index.tsx | 11 ++- components/ContentType/HotelSubpage/utils.ts | 20 ++++ .../SidePeeks => }/OpeningHours/index.tsx | 0 .../OpeningHours/openingHours.module.css | 0 i18n/dictionaries/da.json | 1 + i18n/dictionaries/de.json | 1 + i18n/dictionaries/en.json | 1 + i18n/dictionaries/fi.json | 1 + i18n/dictionaries/no.json | 1 + i18n/dictionaries/sv.json | 1 + .../schemas/hotel/include/restaurants.ts | 3 + types/components/buttonLink.ts | 1 + 18 files changed, 186 insertions(+), 18 deletions(-) create mode 100644 components/ContentType/HotelSubpage/Sidebar/RestaurantSidebar/RestaurantSidebar.tsx create mode 100644 components/ContentType/HotelSubpage/Sidebar/RestaurantSidebar/restaurantSiderbar.module.css rename components/{ContentType/HotelPage/SidePeeks => }/OpeningHours/index.tsx (100%) rename components/{ContentType/HotelPage/SidePeeks => }/OpeningHours/openingHours.module.css (100%) diff --git a/components/ButtonLink/index.tsx b/components/ButtonLink/index.tsx index 1b5c89359..bbc26e90b 100644 --- a/components/ButtonLink/index.tsx +++ b/components/ButtonLink/index.tsx @@ -1,6 +1,8 @@ "use client" import NextLink from "next/link" +import { usePathname } from "next/navigation" +import { useMemo } from "react" import Button from "@/components/TempDesignSystem/Button" import { trackClick } from "@/utils/tracking" @@ -14,12 +16,24 @@ export default function ButtonLink({ trackingId, trackingParams, onClick = () => {}, + appendToCurrentPath, ...buttonProps }: ButtonLinkProps) { + const currentPageSlug = usePathname() + + const fullUrl = useMemo(() => { + let newPath = href + if (appendToCurrentPath) { + newPath = `${currentPageSlug}${newPath}` + } + + return newPath + }, [href, appendToCurrentPath, currentPageSlug]) + return ( + )} +
+ + {intl.formatMessage({ id: "Menus" })} + + +
+
+ + {intl.formatMessage({ id: "Address" })} + +
+ {address.streetAddress} + {`${address.zipCode} ${address.city}`} +
+
+ {(phoneNumber || email) && ( +
+ + {intl.formatMessage({ id: "Contact us" })} + +
+ {phoneNumber && ( + {phoneNumber} + )} + {email && {email}} +
+
+ )} + + ) +} diff --git a/components/ContentType/HotelSubpage/Sidebar/RestaurantSidebar/restaurantSiderbar.module.css b/components/ContentType/HotelSubpage/Sidebar/RestaurantSidebar/restaurantSiderbar.module.css new file mode 100644 index 000000000..f3c2165cc --- /dev/null +++ b/components/ContentType/HotelSubpage/Sidebar/RestaurantSidebar/restaurantSiderbar.module.css @@ -0,0 +1,15 @@ +.sidebar { + display: grid; + gap: var(--Spacing-x3); +} + +.content { + display: grid; + gap: var(--Spacing-x-one-and-half); +} + +.menuList { + display: grid; + gap: var(--Spacing-x-half); + list-style-type: none; +} diff --git a/components/ContentType/HotelSubpage/Sidebar/index.tsx b/components/ContentType/HotelSubpage/Sidebar/index.tsx index 724fbaa1f..00a0de03b 100644 --- a/components/ContentType/HotelSubpage/Sidebar/index.tsx +++ b/components/ContentType/HotelSubpage/Sidebar/index.tsx @@ -1,19 +1,30 @@ +import RestaurantSidebar from "./RestaurantSidebar/RestaurantSidebar" import ParkingSidebar from "./ParkingSidebar" import WellnessSidebar from "./WellnessSidebar" -import type { AdditionalData, Hotel } from "@/types/hotel" +import type { AdditionalData, Hotel, Restaurant } from "@/types/hotel" interface HotelSubpageSidebarProps { subpage: string hotel: Hotel additionalData: AdditionalData + restaurants: Restaurant[] } export default function HotelSubpageSidebar({ subpage, hotel, additionalData, + restaurants, }: HotelSubpageSidebarProps) { + const restaurantSubPage = restaurants.find( + (restaurant) => restaurant.nameInUrl === subpage + ) + + if (restaurantSubPage) { + return + } + switch (subpage) { case additionalData.hotelParking.nameInUrl: return diff --git a/components/ContentType/HotelSubpage/index.tsx b/components/ContentType/HotelSubpage/index.tsx index 163962c01..bd336e7b9 100644 --- a/components/ContentType/HotelSubpage/index.tsx +++ b/components/ContentType/HotelSubpage/index.tsx @@ -43,6 +43,8 @@ export default async function HotelSubpage({ notFound() } + const { hotel, restaurants, additionalData } = hotelData + return ( <>
@@ -73,15 +75,16 @@ export default async function HotelSubpage({
diff --git a/components/ContentType/HotelSubpage/utils.ts b/components/ContentType/HotelSubpage/utils.ts index 9d54045e6..70ba735e5 100644 --- a/components/ContentType/HotelSubpage/utils.ts +++ b/components/ContentType/HotelSubpage/utils.ts @@ -9,6 +9,26 @@ export function getSubpageData( ) { const additionalData = hotelData.additionalData const hotel = hotelData.hotel + const restaurants = hotelData.restaurants + const restaurantSubPage = restaurants.find( + (restaurant) => restaurant.nameInUrl === subpage + ) + + if (restaurantSubPage) { + const restaurantImage = restaurantSubPage.content.images[0] + + return { + mainBody: restaurantSubPage.mainBody, + elevatorPitch: restaurantSubPage.elevatorPitch, + heading: restaurantSubPage.name, + heroImage: restaurantImage + ? { + src: restaurantSubPage.content.images[0].imageSizes.medium, + alt: restaurantSubPage.content.images[0].metaData.altText || "", + } + : null, + } + } switch (subpage) { case additionalData.hotelParking.nameInUrl: diff --git a/components/ContentType/HotelPage/SidePeeks/OpeningHours/index.tsx b/components/OpeningHours/index.tsx similarity index 100% rename from components/ContentType/HotelPage/SidePeeks/OpeningHours/index.tsx rename to components/OpeningHours/index.tsx diff --git a/components/ContentType/HotelPage/SidePeeks/OpeningHours/openingHours.module.css b/components/OpeningHours/openingHours.module.css similarity index 100% rename from components/ContentType/HotelPage/SidePeeks/OpeningHours/openingHours.module.css rename to components/OpeningHours/openingHours.module.css diff --git a/i18n/dictionaries/da.json b/i18n/dictionaries/da.json index 4171c9493..f0cf470da 100644 --- a/i18n/dictionaries/da.json +++ b/i18n/dictionaries/da.json @@ -155,6 +155,7 @@ "Discard unsaved changes?": "Slette ændringer, der ikke er gemt?", "Discover": "Opdag", "Discover the little extra touches to make your upcoming stay even more unforgettable.": "Discover the little extra touches to make your upcoming stay even more unforgettable.", + "Discover {name}": "Opdag {name}", "Distance to city center": "Afstand til centrum", "Distance to hotel: {distanceInM} m": "Afstand til hotel: {distance} m", "Do you want to start the day with Scandics famous breakfast buffé?": "Vil du starte dagen med Scandics berømte morgenbuffet?", diff --git a/i18n/dictionaries/de.json b/i18n/dictionaries/de.json index 7bbe4067e..f636e4265 100644 --- a/i18n/dictionaries/de.json +++ b/i18n/dictionaries/de.json @@ -156,6 +156,7 @@ "Discard unsaved changes?": "Nicht gespeicherte Änderungen verwerfen?", "Discover": "Entdecken", "Discover the little extra touches to make your upcoming stay even more unforgettable.": "Discover the little extra touches to make your upcoming stay even more unforgettable.", + "Discover {name}": "Entdecken Sie {name}", "Distance to city center": "Entfernung zum Stadtzentrum", "Distance to hotel: {distanceInM} m": "Entfernung zum Hotel: {distance} m", "Do you want to start the day with Scandics famous breakfast buffé?": "Möchten Sie den Tag mit Scandics berühmtem Frühstücksbuffet beginnen?", diff --git a/i18n/dictionaries/en.json b/i18n/dictionaries/en.json index f0f5882c8..1f212895f 100644 --- a/i18n/dictionaries/en.json +++ b/i18n/dictionaries/en.json @@ -158,6 +158,7 @@ "Discard unsaved changes?": "Discard unsaved changes?", "Discover": "Discover", "Discover the little extra touches to make your upcoming stay even more unforgettable.": "Discover the little extra touches to make your upcoming stay even more unforgettable.", + "Discover {name}": "Discover {name}", "Distance to city center": "Distance to city center", "Distance to hotel: {distanceInM} m": "Distance to hotel: {distanceInM} m", "Do you want to start the day with Scandics famous breakfast buffé?": "Do you want to start the day with Scandics famous breakfast buffé?", diff --git a/i18n/dictionaries/fi.json b/i18n/dictionaries/fi.json index a9abc47e0..d7089b7c7 100644 --- a/i18n/dictionaries/fi.json +++ b/i18n/dictionaries/fi.json @@ -155,6 +155,7 @@ "Discard unsaved changes?": "Hylkäätkö tallentamattomat muutokset?", "Discover": "Löydä", "Discover the little extra touches to make your upcoming stay even more unforgettable.": "Discover the little extra touches to make your upcoming stay even more unforgettable.", + "Discover {name}": "Tutustu {name}", "Distance to city center": "Etäisyys kaupungin keskustaan", "Distance to hotel: {distanceInM} m": "Etäisyys hotelliin: {distance} m", "Do you want to start the day with Scandics famous breakfast buffé?": "Haluatko aloittaa päiväsi Scandicsin kuuluisalla aamiaisbuffella?", diff --git a/i18n/dictionaries/no.json b/i18n/dictionaries/no.json index 07bbbd8bc..a076c74d8 100644 --- a/i18n/dictionaries/no.json +++ b/i18n/dictionaries/no.json @@ -154,6 +154,7 @@ "Discard unsaved changes?": "Forkaste endringer som ikke er lagret?", "Discover": "Oppdag", "Discover the little extra touches to make your upcoming stay even more unforgettable.": "Discover the little extra touches to make your upcoming stay even more unforgettable.", + "Discover {name}": "Oppdag {name}", "Distance to city center": "Avstand til sentrum", "Distance to hotel: {distanceInM} m": "Avstand til hotell: {distance} m", "Do you want to start the day with Scandics famous breakfast buffé?": "Vil du starte dagen med Scandics berømte frokostbuffé?", diff --git a/i18n/dictionaries/sv.json b/i18n/dictionaries/sv.json index 58c6baf27..6dab1ccf4 100644 --- a/i18n/dictionaries/sv.json +++ b/i18n/dictionaries/sv.json @@ -154,6 +154,7 @@ "Discard unsaved changes?": "Vill du ignorera ändringar som inte har sparats?", "Discover": "Upptäck", "Discover the little extra touches to make your upcoming stay even more unforgettable.": "Discover the little extra touches to make your upcoming stay even more unforgettable.", + "Discover {name}": "Upptäck {name}", "Distance to city center": "Avstånd till centrum", "Distance to hotel: {distanceInM} m": "Avstånd till hotell: {distance} m", "Do you want to start the day with Scandics famous breakfast buffé?": "Vill du starta dagen med Scandics berömda frukostbuffé?", diff --git a/server/routers/hotels/schemas/hotel/include/restaurants.ts b/server/routers/hotels/schemas/hotel/include/restaurants.ts index b55365bd1..0fe973620 100644 --- a/server/routers/hotels/schemas/hotel/include/restaurants.ts +++ b/server/routers/hotels/schemas/hotel/include/restaurants.ts @@ -87,6 +87,9 @@ export const restaurantsSchema = z.object({ openingDetails: z.array(openingDetailsSchema).default([]), phoneNumber: z.string().optional(), restaurantPage: z.boolean().default(false), + elevatorPitch: z.string().optional(), + nameInUrl: z.string().optional(), + mainBody: z.string().optional(), specialAlerts: specialAlertsSchema, }), id: z.string(), diff --git a/types/components/buttonLink.ts b/types/components/buttonLink.ts index 89c824dbe..118247a88 100644 --- a/types/components/buttonLink.ts +++ b/types/components/buttonLink.ts @@ -6,4 +6,5 @@ export type ButtonLinkProps = React.PropsWithChildren & href: string trackingId?: string trackingParams?: Record + appendToCurrentPath?: boolean }