import React from 'react'; import { withRouter } from 'react-router-dom'; import DatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; class BookingForm extends React.Component { constructor(props) { super(props); this.state = { spot_id: this.props.spot.id, check_in: new Date(), check_out: new Date(), num_guest: 1 } this.handleSubmit = this.handleSubmit.bind(this); this.handleCheckIn = this.handleCheckIn.bind(this); this.handleCheckOut = this.handleCheckOut.bind(this); this.handleGuest = this.handleGuest.bind(this); } handleGuest(event) { let value = Number(event.target.value); this.setState({ num_guest: value }) } handleCheckIn(date) { this.setState({ check_in: date }) // this.setState({ check_in: date, check_out: date }) } handleCheckOut(date) { this.setState({ check_out: date }) } handleSubmit(e) { e.preventDefault(); const booking = Object.assign({},this.state); this.props.processForm(booking) .then(this.props.history.push('/booking')) // .then(this.props.closeModal) } render() { const guests = [1,2,3,4].map(num => ( )) return (
×
${this.props.spot.price}/night

CHECK-IN

CHECK-OUT

GUESTS

{/* */}
) } } export default withRouter(BookingForm); // import React from 'react'; // import DatePicker from "react-datepicker"; // import "react-datepicker/dist/react-datepicker.css"; // class BookingForm extends React.Component { // constructor(props) { // super(props); // this.state = { check_in: new Date(), check_out: new Date(), num_guest: null, listing_id: Number(this.props.listingId[0]), owner_id: this.props.listing.owner_id } // this.handleSubmit = this.handleSubmit.bind(this); // this.handleChange1 = this.handleChange1.bind(this); // this.handleChange2 = this.handleChange2.bind(this); // this.handleSelect = this.handleSelect.bind(this); // } // handleSelect(event) { // let value = Number(event.target.value); // this.setState({ num_guest: value }) // } // handleSubmit(e) { // e.preventDefault(); // this.props.processForm(this.state); // this.props.closeModal(); // } // handleChange1(date) { // this.setState({ check_in: date, check_out: date }) // } // handleChange2(date) { // this.setState({ check_out: date }) // } // render() { // const guests = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(num => ( // // )) // return ( //
//
//
${this.props.listing.price} / day
//
//
// //
//
// //
//
// //
//
//
//
// //
// //
//
//
// //
//
You won't be charged yet
//
// ) // } // } // export default BookingForm;