From 683481a5277915a700dc5b3e589f4a73fea88c33 Mon Sep 17 00:00:00 2001 From: Anton Gunnarsson Date: Tue, 12 Aug 2025 11:55:16 +0000 Subject: [PATCH] Merged in fix/add-use-client-to-buttonlink-usage (pull request #2624) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: Add RestaurantBarItemLinks component with 'use client' * Add RestaurantBarItemLinks component with 'use client' Approved-by: Joakim Jäderberg --- .../RestaurantBarItemLinks.tsx | 64 +++++++++++++++++++ .../RestaurantBar/RestaurantBarItem/index.tsx | 50 ++------------- 2 files changed, 71 insertions(+), 43 deletions(-) create mode 100644 apps/scandic-web/components/ContentType/HotelPage/SidePeeks/RestaurantBar/RestaurantBarItem/RestaurantBarItemLinks.tsx diff --git a/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/RestaurantBar/RestaurantBarItem/RestaurantBarItemLinks.tsx b/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/RestaurantBar/RestaurantBarItem/RestaurantBarItemLinks.tsx new file mode 100644 index 000000000..95f7a2d37 --- /dev/null +++ b/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/RestaurantBar/RestaurantBarItem/RestaurantBarItemLinks.tsx @@ -0,0 +1,64 @@ +"use client" + +import { useIntl } from "react-intl" + +import ButtonLink from "@scandic-hotels/design-system/ButtonLink" + +import { trackClick } from "@/utils/tracking" + +import styles from "./restaurantBarItem.module.css" + +export function RestaurantBarItemLinks({ + bookTableUrl, + restaurantPageHref, + restaurantName, + showDetailsLink, +}: { + bookTableUrl: string | null + restaurantPageHref: string | null + restaurantName: string + showDetailsLink: boolean +}) { + const intl = useIntl() + if (!bookTableUrl && !restaurantPageHref) return null + + return ( +
+ {bookTableUrl ? ( + trackClick("book a table", { restaurantName })} + > + {showDetailsLink + ? intl.formatMessage({ + defaultMessage: "Read more", + }) + : intl.formatMessage({ + defaultMessage: "Book a table", + })} + + ) : null} + {restaurantPageHref && showDetailsLink ? ( + + {intl.formatMessage( + { + defaultMessage: "Discover {name}", + }, + { name: restaurantName } + )} + + ) : null} +
+ ) +} diff --git a/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/RestaurantBar/RestaurantBarItem/index.tsx b/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/RestaurantBar/RestaurantBarItem/index.tsx index ea974461d..128887cb9 100644 --- a/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/RestaurantBar/RestaurantBarItem/index.tsx +++ b/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/RestaurantBar/RestaurantBarItem/index.tsx @@ -1,4 +1,3 @@ -import ButtonLink from "@scandic-hotels/design-system/ButtonLink" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" @@ -6,9 +5,9 @@ import OpeningHours from "@/components/OpeningHours" import Link from "@/components/TempDesignSystem/Link" import { getIntl } from "@/i18n" import { appendSlugToPathname } from "@/utils/appendSlugToPathname" -import { trackClick } from "@/utils/tracking" import SidePeekImages from "../../Images" +import { RestaurantBarItemLinks } from "./RestaurantBarItemLinks" import { getRestaurantIconName } from "./utils" import styles from "./restaurantBarItem.module.css" @@ -97,47 +96,12 @@ export default async function RestaurantBarItem({ ) : null} {/* If (restaurantPageHref && bookTableUrl && mainBody==empty), link to external restaurant page. */} - {bookTableUrl || restaurantPageHref ? ( -
- {bookTableUrl ? ( - - trackClick("book a table", { restaurantName: name }) - } - > - {restaurantPageHref && !mainBody?.length - ? intl.formatMessage({ - defaultMessage: "Read more", - }) - : intl.formatMessage({ - defaultMessage: "Book a table", - })} - - ) : null} - {restaurantPageHref && mainBody?.length ? ( - - {intl.formatMessage( - { - defaultMessage: "Discover {name}", - }, - { name: name } - )} - - ) : null} -
- ) : null} + ) }