From cabc3753e3aa54ea6fdc542cb02b97c5d5f3a4f8 Mon Sep 17 00:00:00 2001 From: FlorianSpeicher Date: Thu, 22 May 2025 12:10:21 +0200 Subject: [PATCH] Added stock status to ItemCard --- 01-frontend/src/helper/ItemCard.tsx | 14 ++++++++++++++ 01-frontend/src/pages/Product.tsx | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/01-frontend/src/helper/ItemCard.tsx b/01-frontend/src/helper/ItemCard.tsx index f693019..03511d7 100644 --- a/01-frontend/src/helper/ItemCard.tsx +++ b/01-frontend/src/helper/ItemCard.tsx @@ -39,6 +39,20 @@ export default function ItemCard({ item }: { item: Item }) { + + {item.stock > 10 ? ( + + In Stock + + ) : item.stock > 0 ?( + + Almost Sold Out + + ) : ( + + Out of Stock + + )} diff --git a/01-frontend/src/pages/Product.tsx b/01-frontend/src/pages/Product.tsx index ded5bf3..2021e8a 100644 --- a/01-frontend/src/pages/Product.tsx +++ b/01-frontend/src/pages/Product.tsx @@ -156,7 +156,7 @@ export default function Product() { size="large" startIcon={} onClick={handleAddToCart} - disabled={item.stock === 0} + disabled={item.stock <= 0} fullWidth > Add to Cart