Created
June 8, 2020 11:46
-
-
Save hariomkushwaha/d30d1d9f205b11f2e4345a7189aacc14 to your computer and use it in GitHub Desktop.
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
import React from 'react'; | |
import '../form-input/form-input.component'; | |
import FormInput from '../form-input/form-input.component'; | |
import './reservation.style.scss' | |
import '../firebase/firebase'; | |
import firebase from '../firebase/firebase'; | |
class Reservation extends React.Component{ | |
constructor(){ | |
super(); | |
this.state={ | |
name:'', | |
email:'', | |
mobile:'', | |
address:'', | |
phone:'' | |
}; | |
} | |
handleChange=(event)=>{ | |
this.setState({[event.target.name]:event.target.value}) | |
} | |
handleSubmit=(event)=>{ | |
this.preventDefault(); | |
firebase.database() | |
.ref('coustomer') | |
.push({ | |
name:this.state.name, | |
email:this.state.email, | |
mobile:this.state.mobile, | |
address:this.state.address, | |
phone:this.state.phone | |
}) | |
} | |
render(){ | |
return( | |
<div className='reservation'> | |
<h2>BOOK NOW </h2> | |
<form onSubmit={this.handleSubmit}> | |
<FormInput type='text' label='Name' name='name' value={this.state.name} onChange={this.handleChange}/> | |
<FormInput type='email' label='Email' name='email' value={this.state.email} onChange={this.handleChange}/> | |
<FormInput type='number' label='Mobile No' name='mobile' value={this.state.mobile} onChange={this.handleChange}/> | |
<FormInput type='text' label='Adderss' name='address' value={this.state.address} onChange={this.handleChange}/> | |
<FormInput type='number' label='Phone No' name='phone' value={this.state.phone} onChange={this.handleChange}/> | |
<button type='submit'> Book </button> | |
</form> | |
</div> | |
) | |
} | |
} | |
export default Reservation; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment