Refactored stock count on Product page

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

View File

@@ -21,7 +21,7 @@ export default function Home() {
name: "Item 2",
description: "Description 2",
price: 20,
stock: 200,
stock: 9,
category: "Category 2",
rating: 4.0,
discount: 20,
@@ -31,7 +31,7 @@ export default function Home() {
name: "Item 3",
description: "Description 3",
price: 30,
stock: 300,
stock: 10,
category: "Category 3",
rating: 4.8,
discount: 15,
@@ -41,7 +41,7 @@ export default function Home() {
name: "Item 3",
description: "Description 3",
price: 30,
stock: 300,
stock: 0,
category: "Category 3",
rating: 4.8,
discount: 15,

View File

@@ -130,17 +130,15 @@ export default function Product() {
<Divider />
<Typography variant="body1">
{item.description}
</Typography>
<Box>
{item.stock > 0 ? (
<Alert severity="success">
{item.stock > 10 ? (
<Alert severity="success" variant='outlined'>
In Stock ({item.stock} available)
</Alert>
) : item.stock > 0 ? (
<Alert severity="warning" variant='outlined'>Almost sold out ({item.stock} available)</Alert>
) : (
<Alert severity="error">Out of Stock</Alert>
<Alert severity="error" variant='filled'>Out of Stock</Alert>
)}
</Box>
@@ -171,9 +169,16 @@ export default function Product() {
Free shipping on orders over €50
</Typography>
</Box>
</Stack>
</Grid>
<div className='contact-divider-box'>
<Divider className='contact-divider'/>
</div>
<Typography variant="body1">
{item.description}
</Typography>
</Container>
</div>
);