Needing to check that a users bid is greater than the current bid/price. Currently I'm getting back that the input is always less than the current bid/ price. The test variable is the current price/bid that i passed down from another component.
import React, { Fragment, useState } from "react";
import { connect } from "react-redux";
import { addBid } from "../../actions/listing";
import PropTypes from "prop-types";
const BidForm = ({ test, listingId, addBid }) => {
const [price, setBid] = useState("");
return (
<Fragment>
<h1 className="large text-primary">Bid</h1>
<form
className="form-1"
onSubmit={e => {
addBid(listingId, { price });
}}
>
<div className="form-group pb">
<input
type="text"
placeholder="Price"
name="price"
value={price}
onChange={e =>
setBid(e.target.value) & (parseFloat(price) > parseFloat(test))
? console.log("greater")
: console.log("less than")
}
/>
</div>
<input type="submit" className="btn btn-primary my-1" />
</form>
</Fragment>
);
};
BidForm.propTypes = {
addBid: PropTypes.func.isRequired
};
export default connect(
null,
{ addBid }
)(BidForm);