Added stock status to ItemCard

This commit is contained in:
FlorianSpeicher
2025-05-22 12:10:21 +02:00
parent a7856b9e88
commit cabc3753e3
2 changed files with 15 additions and 1 deletions

View File

@@ -39,6 +39,20 @@ export default function ItemCard({ item }: { item: Item }) {
<AddShoppingCart />
</IconButton>
</Typography>
{item.stock > 10 ? (
<Typography variant="body2">
In Stock
</Typography>
) : item.stock > 0 ?(
<Typography variant="body2" sx={{ color: 'orange' }}>
Almost Sold Out
</Typography>
) : (
<Typography variant="body2" sx={{ color: 'red' }}>
Out of Stock
</Typography>
)}
</CardContent>
</CardActionArea>
</Card>

View File

@@ -156,7 +156,7 @@ export default function Product() {
size="large"
startIcon={<ShoppingCartIcon />}
onClick={handleAddToCart}
disabled={item.stock === 0}
disabled={item.stock <= 0}
fullWidth
>
Add to Cart