Added stock status to ItemCard
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user