Last active
April 16, 2019 20:44
-
-
Save Ledoux/5ade1ce663a9765a70abdd86c77ddfa7 to your computer and use it in GitHub Desktop.
pass-Culture Offer Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Offer extends Component { | |
constructor() { | |
super(); | |
this.state = { | |
available: 0 | |
}; | |
} | |
componentDidMount() { | |
this.props.requestGetOffer(); | |
} | |
render() { | |
const { offer, requestPostStock, stocks } = this.props; | |
const { available } = this.state; | |
if (!offer) { | |
return null; | |
} | |
return ( | |
<Fragment> | |
<h1>{offer.name}</h1> | |
<h2>{stocks.length ? `${stocks.length} dates` : "0 date"}</h2> | |
<input | |
onChange={event => this.setState({ available: event.target.value })} | |
value={available} | |
/> | |
<button onClick={requestPostStock(available)}>Add</button> | |
{stocks.map(stock => ( | |
<div key={stock.id}>{stock.available} places</div> | |
))} | |
</Fragment> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment