Created
June 8, 2020 11:54
-
-
Save hariomkushwaha/a06249755ece3b59f544796f9c47fa75 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; |
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 firebase from 'firebase/app'; | |
import 'firebase/firestore'; | |
const firebaseConfig = { | |
apiKey: "AIzaSyAuHwK2sMNsHdKa610pJtz6_qzxeTiAQdo", | |
authDomain: "barber-db-8a2d0.firebaseapp.com", | |
databaseURL: "https://barber-db-8a2d0.firebaseio.com", | |
projectId: "barber-db-8a2d0", | |
storageBucket: "barber-db-8a2d0.appspot.com", | |
messagingSenderId: "292629629913", | |
appId: "1:292629629913:web:1d35eaec518efd06e667c8", | |
measurementId: "G-BM5T419CPM" | |
}; | |
firebase.initializeApp(firebaseConfig); | |
export default firebase; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment