Merged in fix/add-use-client-to-buttonlink-usage (pull request #2624)

fix: Add RestaurantBarItemLinks component with 'use client'

* Add RestaurantBarItemLinks component with 'use client'


Approved-by: Joakim Jäderberg
This commit is contained in:
Anton Gunnarsson
2025-08-12 11:55:16 +00:00
parent 855f795d50
commit 683481a527
2 changed files with 71 additions and 43 deletions

View File

@@ -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 (
<div className={styles.ctaWrapper}>
{bookTableUrl ? (
<ButtonLink
variant="Primary"
color="Primary"
size="Medium"
typography="Body/Paragraph/mdBold"
href={bookTableUrl}
target="_blank"
onClick={() => trackClick("book a table", { restaurantName })}
>
{showDetailsLink
? intl.formatMessage({
defaultMessage: "Read more",
})
: intl.formatMessage({
defaultMessage: "Book a table",
})}
</ButtonLink>
) : null}
{restaurantPageHref && showDetailsLink ? (
<ButtonLink
variant="Secondary"
color="Primary"
size="Medium"
typography="Body/Paragraph/mdBold"
href={restaurantPageHref}
>
{intl.formatMessage(
{
defaultMessage: "Discover {name}",
},
{ name: restaurantName }
)}
</ButtonLink>
) : null}
</div>
)
}

View File

@@ -1,4 +1,3 @@
import ButtonLink from "@scandic-hotels/design-system/ButtonLink"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import { Typography } from "@scandic-hotels/design-system/Typography" import { Typography } from "@scandic-hotels/design-system/Typography"
@@ -6,9 +5,9 @@ import OpeningHours from "@/components/OpeningHours"
import Link from "@/components/TempDesignSystem/Link" import Link from "@/components/TempDesignSystem/Link"
import { getIntl } from "@/i18n" import { getIntl } from "@/i18n"
import { appendSlugToPathname } from "@/utils/appendSlugToPathname" import { appendSlugToPathname } from "@/utils/appendSlugToPathname"
import { trackClick } from "@/utils/tracking"
import SidePeekImages from "../../Images" import SidePeekImages from "../../Images"
import { RestaurantBarItemLinks } from "./RestaurantBarItemLinks"
import { getRestaurantIconName } from "./utils" import { getRestaurantIconName } from "./utils"
import styles from "./restaurantBarItem.module.css" import styles from "./restaurantBarItem.module.css"
@@ -97,47 +96,12 @@ export default async function RestaurantBarItem({
</div> </div>
) : null} ) : null}
{/* If (restaurantPageHref && bookTableUrl && mainBody==empty), link to external restaurant page. */} {/* If (restaurantPageHref && bookTableUrl && mainBody==empty), link to external restaurant page. */}
{bookTableUrl || restaurantPageHref ? ( <RestaurantBarItemLinks
<div className={styles.ctaWrapper}> bookTableUrl={bookTableUrl}
{bookTableUrl ? ( restaurantPageHref={restaurantPageHref}
<ButtonLink showDetailsLink={Boolean(mainBody?.length)}
variant="Primary" restaurantName={name}
color="Primary" />
size="Medium"
typography="Body/Paragraph/mdBold"
href={bookTableUrl}
target="_blank"
onClick={() =>
trackClick("book a table", { restaurantName: name })
}
>
{restaurantPageHref && !mainBody?.length
? intl.formatMessage({
defaultMessage: "Read more",
})
: intl.formatMessage({
defaultMessage: "Book a table",
})}
</ButtonLink>
) : null}
{restaurantPageHref && mainBody?.length ? (
<ButtonLink
variant="Secondary"
color="Primary"
size="Medium"
typography="Body/Paragraph/mdBold"
href={restaurantPageHref}
>
{intl.formatMessage(
{
defaultMessage: "Discover {name}",
},
{ name: name }
)}
</ButtonLink>
) : null}
</div>
) : null}
</div> </div>
) )
} }