Skip to content
Snippets Groups Projects
Commit 2da6dfaf authored by meskio's avatar meskio :tent:
Browse files

Don't allow to shop over stock

parent 24291e76
Branches
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ function Panel(props) {
<div>
<BrowserRouter>
<Head onLogout={props.onLogout} />
<Container fluid="lg">
<Container>
<Switch>
<Route path="/members/add">
<MemberAdder />
......
......@@ -45,12 +45,20 @@ class ProductPicker extends React.Component {
code: product.code,
name: product.name,
price: product.price,
stock: product.stock,
amount: 1,
});
this.props.setPicks(picks);
this.setState({ code: "" });
}
setProducts(products) {
if (this.props.amount) {
products = products.filter((p) => p.stock > 0);
}
this.setState({ products });
}
render() {
const rows = this.props.picks.map((p, i) => {
return (
......@@ -67,6 +75,7 @@ class ProductPicker extends React.Component {
<Form.Control
type="number"
min="1"
max={p.stock}
placeholder="cantidad"
value={p.amount}
onChange={(e) => this.setAmount(i, e.target.value)}
......@@ -83,10 +92,7 @@ class ProductPicker extends React.Component {
});
return (
<Fetcher
url="/api/product"
onFetch={(products) => this.setState({ products })}
>
<Fetcher url="/api/product" onFetch={(p) => this.setProducts(p)}>
<Row>
<Col>
<h6>Código</h6>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment