feat(SW-392): Added book a table link click
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
"use client"
|
||||
|
||||
import NextLink from "next/link"
|
||||
|
||||
import Button from "@/components/TempDesignSystem/Button"
|
||||
import { trackClick } from "@/utils/tracking"
|
||||
|
||||
import type { ButtonLinkProps } from "@/types/components/buttonLink"
|
||||
|
||||
export default function ButtonLink({
|
||||
children,
|
||||
href,
|
||||
target,
|
||||
trackingId,
|
||||
trackingParams,
|
||||
onClick,
|
||||
...buttonProps
|
||||
}: ButtonLinkProps) {
|
||||
return (
|
||||
<Button {...buttonProps} asChild>
|
||||
<NextLink
|
||||
href={href}
|
||||
target={target}
|
||||
onClick={(e) => {
|
||||
if (onClick) {
|
||||
onClick(e)
|
||||
}
|
||||
if (trackingId) {
|
||||
trackClick(trackingId, trackingParams)
|
||||
}
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</NextLink>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
+16
-14
@@ -1,8 +1,6 @@
|
||||
import NextLink from "next/link"
|
||||
|
||||
import ButtonLink from "@/components/ButtonLink"
|
||||
import { OpenInNewSmallIcon } from "@/components/Icons"
|
||||
import Image from "@/components/Image"
|
||||
import Button from "@/components/TempDesignSystem/Button"
|
||||
import Link from "@/components/TempDesignSystem/Link"
|
||||
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
||||
import { getIntl } from "@/i18n"
|
||||
@@ -18,7 +16,7 @@ export default async function RestaurantBarItem({
|
||||
}: RestaurantBarItemProps) {
|
||||
const intl = await getIntl()
|
||||
const { name, openingDetails, menus } = restaurant
|
||||
const { images, bookTableUrl } = restaurant.content
|
||||
const { bookTableUrl, images } = restaurant.content
|
||||
const visibleImages = restaurant.content.images.slice(0, 2)
|
||||
const imageWidth = images.length === 2 ? 240 : 496
|
||||
|
||||
@@ -86,18 +84,22 @@ export default async function RestaurantBarItem({
|
||||
{bookTableUrl || ctaUrl ? (
|
||||
<div className={styles.ctaWrapper}>
|
||||
{bookTableUrl ? (
|
||||
<Button fullWidth theme="base" intent="primary" asChild>
|
||||
<NextLink href={bookTableUrl} target="_blank">
|
||||
{intl.formatMessage({ id: "Book a table online" })}
|
||||
</NextLink>
|
||||
</Button>
|
||||
<ButtonLink
|
||||
fullWidth
|
||||
theme="base"
|
||||
intent="primary"
|
||||
href={bookTableUrl}
|
||||
target="_blank"
|
||||
trackingId="book a table"
|
||||
trackingParams={{ restaurantName: name }}
|
||||
>
|
||||
{intl.formatMessage({ id: "Book a table online" })}
|
||||
</ButtonLink>
|
||||
) : null}
|
||||
{ctaUrl ? (
|
||||
<Button fullWidth theme="base" intent="secondary" asChild>
|
||||
<NextLink href={ctaUrl}>
|
||||
{`${intl.formatMessage({ id: "Discover" })} ${name}`}
|
||||
</NextLink>
|
||||
</Button>
|
||||
<ButtonLink fullWidth theme="base" intent="secondary" href={ctaUrl}>
|
||||
{`${intl.formatMessage({ id: "Discover" })} ${name}`}
|
||||
</ButtonLink>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -23,6 +23,7 @@ export default function Link({
|
||||
variant,
|
||||
weight,
|
||||
trackingId,
|
||||
trackingParams,
|
||||
onClick,
|
||||
/**
|
||||
* Decides if the link should include the current search params in the URL
|
||||
@@ -60,9 +61,9 @@ export default function Link({
|
||||
|
||||
const trackClickById = useCallback(() => {
|
||||
if (trackingId) {
|
||||
trackClick(trackingId)
|
||||
trackClick(trackingId, trackingParams)
|
||||
}
|
||||
}, [trackingId])
|
||||
}, [trackingId, trackingParams])
|
||||
|
||||
const linkProps = {
|
||||
href: fullUrl,
|
||||
|
||||
@@ -10,5 +10,6 @@ export interface LinkProps
|
||||
partialMatch?: boolean
|
||||
prefetch?: boolean
|
||||
trackingId?: string
|
||||
trackingParams?: Record<string, string>
|
||||
keepSearchParams?: boolean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user