|
@@ -166,7 +166,7 @@ const ProductDetails = () => {
|
166
|
166
|
}
|
167
|
167
|
|
168
|
168
|
const handleIncrement = () => {
|
169
|
|
- setQuantity((prevQuantity) => prevQuantity + 1);
|
|
169
|
+ setQuantity((prevQuantity) => (prevQuantity >= variantSelection.quantityAvailable ? variantSelection.quantityAvailable : prevQuantity + 1));
|
170
|
170
|
};
|
171
|
171
|
|
172
|
172
|
const handleDecrement = () => {
|
|
@@ -195,7 +195,7 @@ const ProductDetails = () => {
|
195
|
195
|
<Typography
|
196
|
196
|
variant="body1"
|
197
|
197
|
>
|
198
|
|
- IN STOCK: {`${variantSelection?.quantityAvailable}`}
|
|
198
|
+ {(variantSelection?.quantityAvailable == 0) ? <span style={{color:"red", fontWeight:"bolder"}}>{`OUT OF STOCK`}</span> : `IN STOCK: ${variantSelection?.quantityAvailable}`}
|
199
|
199
|
</Typography>
|
200
|
200
|
</Box>
|
201
|
201
|
|
|
@@ -241,7 +241,7 @@ const ProductDetails = () => {
|
241
|
241
|
variant="contained"
|
242
|
242
|
color="primary"
|
243
|
243
|
sx={{ width: "35px" }}
|
244
|
|
- disabled={variantSelection?.quantityAvailable == 0}
|
|
244
|
+ disabled={variantSelection?.quantityAvailable == 0 || quantity == 1}
|
245
|
245
|
onClick={handleDecrement}
|
246
|
246
|
>
|
247
|
247
|
<RemoveIcon />
|
|
@@ -259,7 +259,7 @@ const ProductDetails = () => {
|
259
|
259
|
variant="contained"
|
260
|
260
|
color="primary"
|
261
|
261
|
sx={{ width: "35px" }}
|
262
|
|
- disabled={variantSelection?.quantityAvailable == 0}
|
|
262
|
+ disabled={variantSelection?.quantityAvailable == 0 || quantity == variantSelection?.quantityAvailable}
|
263
|
263
|
onClick={handleIncrement}
|
264
|
264
|
>
|
265
|
265
|
<AddIcon />
|