-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding signup and firebase integration
- Loading branch information
Showing
9 changed files
with
162 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import React from 'react'; | ||
|
||
import FormInput from '../form-input/form-input.component'; | ||
import CustomButton from '../custom-button/custom-button.component'; | ||
|
||
import {auth, createUserProfileDocument } from '../../fireabase/firebase.utils'; | ||
|
||
import './sign-up.styles.scss'; | ||
|
||
class SignUp extends React.Component { | ||
constructor(){ | ||
super(); | ||
this.state = { | ||
displayName: '', | ||
email: '', | ||
password: '', | ||
confirmPassword: '' | ||
}; | ||
} | ||
handleSubmit = async event => { | ||
event.preventDefault(); | ||
const { displayName, email, password, confirmPassword } = this.state; | ||
|
||
if(password !== confirmPassword){ | ||
alert("La contraseña no coincide con la confirmación."); | ||
return; | ||
} | ||
try{ | ||
|
||
const {user} = await auth.createUserWithEmailAndPassword(email, password); | ||
await createUserProfileDocument(user, {displayName}); | ||
this.setState({ | ||
displayName: '', | ||
email: '', | ||
password: '', | ||
confirmPassword: '' | ||
}) | ||
}catch(error){ | ||
console.log(error); | ||
} | ||
} | ||
|
||
handleChange = event => { | ||
|
||
const {name, value} = event.target; | ||
this.setState({[name]:value}); | ||
} | ||
|
||
render(){ | ||
const { displayName, email, password, confirmPassword } = this.state; | ||
return( | ||
<div className='sign-up'> | ||
<h2 className='title'>No tengo una cuenta</h2> | ||
<span>Registrate con tu correo electronico y contraseña</span> | ||
<form className='sign-up-form' onSubmit={this.handleSubmit}> | ||
<FormInput | ||
type='text' | ||
name='displayName' | ||
value={displayName} | ||
handleChange={this.handleChange} | ||
label="Nombre" | ||
required | ||
/> | ||
<FormInput | ||
type='text' | ||
name="email" | ||
value={email} | ||
handleChange={this.handleChange} | ||
label="Correo Electrónico" | ||
required | ||
/> | ||
<FormInput | ||
type='password' | ||
name='password' | ||
value={password} | ||
handleChange={this.handleChange} | ||
label="Contraseña" | ||
required | ||
/> | ||
<FormInput | ||
type='password' | ||
name='confirmPassword' | ||
value={confirmPassword} | ||
handleChange={this.handleChange} | ||
label="Confirmar Contraseña" | ||
required | ||
/> | ||
|
||
<CustomButton type="submit">Registrarse</CustomButton> | ||
</form> | ||
</div> | ||
) | ||
} | ||
} | ||
export default SignUp; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.sign-up { | ||
display: flex; | ||
flex-direction: column; | ||
width: 380px; | ||
|
||
.title { | ||
margin: 10px 0; | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.sign-in-and-sign-up { | ||
width: 850px; | ||
display: flex; | ||
justify-content: space-between; | ||
margin: 30px auto; | ||
} |
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
Empty file.