Skip to content
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.

add product hyperlink in cart page #745

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/@next/components/organisms/CartRow/CartRow.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React, { useEffect, useState } from "react";
import { Link } from "react-router-dom";

import { Icon, IconButton } from "@components/atoms";
import { CachedImage, TextField } from "@components/molecules";

import { generateProductUrl } from "../../../../core/utils";

import * as S from "./styles";
import { IProps } from "./types";

Expand Down Expand Up @@ -39,6 +42,7 @@ export const CartRow: React.FC<IProps> = ({
thumbnail,
attributes = [],
onRemove,
id,
}: IProps) => {
const [tempQuantity, setTempQuantity] = useState<string>(quantity.toString());
const [isTooMuch, setIsTooMuch] = useState(false);
Expand Down Expand Up @@ -92,13 +96,19 @@ export const CartRow: React.FC<IProps> = ({
]
: undefined;

const productUrl = generateProductUrl(id, name);

return (
<S.Wrapper>
<S.Photo>
<CachedImage data-cy={`cartPageItem${index}Image`} {...thumbnail} />
<Link to={productUrl}>
<CachedImage data-cy={`cartPageItem${index}Image`} {...thumbnail} />
</Link>
</S.Photo>
<S.Description>
<S.Name data-cy={`cartPageItem${index}Name`}>{name}</S.Name>
<Link to={productUrl}>
<S.Name data-cy={`cartPageItem${index}Name`}>{name}</S.Name>
</Link>
<S.Sku>
<S.LightFont>
SKU:{" "}
Expand Down
1 change: 1 addition & 0 deletions src/@next/components/organisms/CartRow/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const DEFAULT_PROPS = {
],
},
],
id: "2",
maxQuantity: 5,
name: "The Great Square Table",
quantity: 3,
Expand Down
4 changes: 4 additions & 0 deletions src/@next/components/organisms/CartRow/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export interface IProps {
* Item index
*/
index?: number;
/**
* Id of the product
*/
id: string;
/**
* Price for single unit
*/
Expand Down
1 change: 1 addition & 0 deletions src/@next/pages/CartPage/CartPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const generateCart = (
<CartRow
key={id ? `id-${id}` : `idx-${index}`}
index={index}
id={variant?.product?.id || ""}
name={variant?.product?.name || ""}
maxQuantity={variant.quantityAvailable || quantity}
quantity={quantity}
Expand Down