Added stock status to ItemCard
This commit is contained in:
@@ -39,6 +39,20 @@ export default function ItemCard({ item }: { item: Item }) {
|
|||||||
<AddShoppingCart />
|
<AddShoppingCart />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Typography>
|
</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>
|
</CardContent>
|
||||||
</CardActionArea>
|
</CardActionArea>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ export default function Product() {
|
|||||||
size="large"
|
size="large"
|
||||||
startIcon={<ShoppingCartIcon />}
|
startIcon={<ShoppingCartIcon />}
|
||||||
onClick={handleAddToCart}
|
onClick={handleAddToCart}
|
||||||
disabled={item.stock === 0}
|
disabled={item.stock <= 0}
|
||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
Add to Cart
|
Add to Cart
|
||||||
|
|||||||
Reference in New Issue
Block a user