diff --git a/src/components/Modal.jsx b/src/components/Modal.jsx index 247719a6..32356799 100644 --- a/src/components/Modal.jsx +++ b/src/components/Modal.jsx @@ -47,6 +47,7 @@ const ItemModal = () => { const { activeItem, openModal, closeModal } = useContext(ModalsContext); const [secondaryImageSrc, setSecondaryImageSrc] = useState(""); const minIncrease = 1; + const maxIncrease = 10; const [bid, setBid] = useState(); const [valid, setValid] = useState(""); const [isSubmitting, setIsSubmitting] = useState(""); @@ -114,6 +115,13 @@ const ItemModal = () => { setIsSubmitting(false); return; } + // Ensure input is small enough + if (amount > status.amount + maxIncrease) { + setFeedback(`For the demo you can only increase the price up to ${activeItem.currency}${maxIncrease} per bid.`); + setValid("is-invalid"); + setIsSubmitting(false); + return; + } // Finally, place bid updateDoc(doc(db, "auction", "items"), { [formatField(activeItem.id, status.bids + 1)]: {