This file contains hidden or 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
| state = { | |
| msg: '', | |
| showMsg: false, | |
| isModalOpen: false, | |
| from: this.props.flight.from, | |
| to: this.props.flight.to, | |
| noBooking: this.props.flight.noBooking, | |
| }; |
This file contains hidden or 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
| <button onClick={() => update(flight.noBooking)} > Edit </button> |
This file contains hidden or 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
| <Flights | |
| flights={this.state.flights} | |
| onDeleteFlight={this.onDeleteFlight} | |
| update={this.update} | |
| showMsg={this.state.showMsg} | |
| msg={this.state.msg} | |
| /> |
This file contains hidden or 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
| update = noBooking => { | |
| const flight = this.state.flights.find(flight => flight.noBooking === noBooking) | |
| this.setState({ editModal: !this.state.editModal, flight: flight }); | |
| }; |
This file contains hidden or 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
| onSubmit = e => { | |
| this.onEditFlight(e); | |
| this.setState(() => ({ isModalOpen: !this.state.isModalOpen })); | |
| }; |
This file contains hidden or 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
| <form onSubmit={this.onSubmit}> | |
| <input type="text" name="from" value={from} onChange={this.onChange}/> | |
| <input type="text" name="to" value={to} onChange={this.onChange}/> | |
| <input type="text" name="noBooking" value={noBooking} onChange={this.onChange}/> | |
| <button type="submit">Submit</button> | |
| </form> |
This file contains hidden or 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
| openEditModale = noBooking => { | |
| const flight = this.state.flights.find(flight => flight.noBooking === noBooking) | |
| this.setState({ editModal: !this.state.editModal, flight: flight }); | |
| }; |
This file contains hidden or 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
| app.post('/flights/editFlight/', function(req, res) { | |
| const newItem = req.body.flights; | |
| savedItems = [newItem, ...savedItems]; | |
| updateItems(res); | |
| if (newItem) { | |
| res.send(savedItems); | |
| } | |
| }); |
This file contains hidden or 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
| onEditFlight = e => { | |
| e.preventDefault(); | |
| const { from, to, noBooking } = e.target; | |
| const flights = { | |
| from: from.value, | |
| to: to.value, | |
| noBooking: noBooking.value, | |
| }; |
This file contains hidden or 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
| const updateItems = res => { | |
| fs.writeFile(reqPath, JSON.stringify(savedItems), 'utf8', function(err) { | |
| if (err) { | |
| console.log(err); | |
| } | |
| }); | |
| }; | |
| app.post('/flights/remove', function(req, res) { | |
| savedItems = savedItems.filter(item => item.noBooking !== req.body.noBooking); |
NewerOlder