Skip to content

Commit 77bac2c

Browse files
committed
Fix price bug
1 parent 5bb4648 commit 77bac2c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/components/Product/ProductCard.component.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ interface ProductCardProps {
55
databaseId: number;
66
name: string;
77
price: string;
8+
regularPrice: string;
9+
salePrice?: string;
10+
onSale: boolean;
811
slug: string;
912
image?: {
1013
sourceUrl?: string;
@@ -15,6 +18,9 @@ const ProductCard = ({
1518
databaseId,
1619
name,
1720
price,
21+
regularPrice,
22+
salePrice,
23+
onSale,
1824
slug,
1925
image,
2026
}: ProductCardProps) => {
@@ -47,7 +53,14 @@ const ProductCard = ({
4753
</div>
4854
</Link>
4955
<div className="mt-2 text-center">
50-
<span className="text-gray-900">{price}</span>
56+
{onSale ? (
57+
<div className="flex justify-center items-center space-x-2">
58+
<span className="text-red-600">{salePrice}</span>
59+
<span className="text-gray-500 text-sm line-through">{regularPrice}</span>
60+
</div>
61+
) : (
62+
<span className="text-gray-900">{price}</span>
63+
)}
5164
</div>
5265
</div>
5366
);

src/components/Product/ProductList.component.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ const ProductList = ({ products, title }: ProductListProps) => {
7171
databaseId={product.databaseId}
7272
name={product.name}
7373
price={product.price}
74+
regularPrice={product.regularPrice}
75+
salePrice={product.salePrice}
76+
onSale={product.onSale}
7477
slug={product.slug}
7578
image={product.image}
7679
/>

0 commit comments

Comments
 (0)