Skip to content

Commit

Permalink
fix Bestsellers product type link
Browse files Browse the repository at this point in the history
  • Loading branch information
tvikito committed Jan 15, 2024
1 parent 422d371 commit 6c00915
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export const ProductListItem = forwardRef<HTMLLIElement, ProductItemProps>(
) => {
const { url } = useDomainConfig();
const { t } = useTranslation();
const isMainVariant = product.isMainVariant;

return (
<li
Expand All @@ -71,7 +70,7 @@ export const ProductListItem = forwardRef<HTMLLIElement, ProductItemProps>(
<ExtendedNextLink
className="flex h-full flex-col gap-3 no-underline hover:no-underline"
href={product.slug}
type={isMainVariant ? 'productMainVariant' : 'product'}
type={product.isMainVariant ? 'productMainVariant' : 'product'}
onClick={() => onGtmProductClickEventHandler(product, gtmProductListName, listIndex, url)}
>
<div className="relative">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ export const CategoryBestsellersListItem: FC<CategoryBestsellersListItemProps> =
const formatPrice = useFormatPrice();
const { url } = useDomainConfig();

const productUrl = (product.__typename === 'Variant' && product.mainVariant?.slug) || product.slug;

return (
<div className="flex flex-wrap items-center gap-y-4 border-t border-greyLight py-4 first-of-type:border-0 lg:flex-nowrap lg:gap-5">
<ExtendedNextLink
className="flex items-center gap-5 font-bold no-underline lg:flex-1"
href={product.slug}
type="product"
href={productUrl}
type={product.__typename === 'RegularProduct' ? 'product' : 'productMainVariant'}
onClick={() => onGtmProductClickEventHandler(product, gtmProductListName, listIndex, url)}
>
<div className="flex w-20 shrink-0 items-center justify-center">
Expand Down

0 comments on commit 6c00915

Please sign in to comment.