ajustes

1 parent 8a899405
{
"expoServerPort": null,
"expoServerNgrokUrl": null,
"packagerNgrokUrl": null,
"ngrokPid": null,
"packagerPort": null,
"packagerPid": null,
"expoServerPort": 19000,
"expoServerNgrokUrl": "https://xz-g8k.evote.rn-evote.exp.direct",
"packagerNgrokUrl": "https://packager.xz-g8k.evote.rn-evote.exp.direct",
"ngrokPid": 6104,
"packagerPort": 19001,
"packagerPid": 6053,
"devToolsPort": 19002
}
\ No newline at end of file
import React, { Component } from 'react';
import {
View,
Text,
StyleSheet,
KeyboardAvoidingView,
View,
StyleSheet,
KeyboardAvoidingView,
AsyncStorage,
TouchableOpacity,
ActivityIndicator } from 'react-native';
import InputTexto from '../components/InputTexto';
import styles from '../styles/estilos';
import DateInput from '../components/DateInput';
import InputEmail from '../components/InputEmail';
import InputSenha from '../components/InputSenha';
import BotaoAnterior from '../components/BotaoAnterior';
import BotaoGrande from '../components/BotaoGrande';
import Aviso from '../components/Aviso';
import { auth, db } from '../config';
export default class TelaCadastro extends Component{
constructor(props) {
super(props)
......@@ -38,36 +34,27 @@ export default class TelaCadastro extends Component{
validate = async () => {
let error = '';
if(this.isNomeValido()==false){
error = 'nome'
}else if(this.isEmailValido()==false){
this.isNomeValido();
this.isEmailValido();
this.isCPFValido();
this.isSenhaValido();
if(this.state.errorNome){
error = 'nome';
this.setState({errorMessage: this.state.errorNome});
}else if(this.state.errorEmail){
this.setState({errorMessage: this.state.errorEmail});
error = 'email'
}else if(this.isCPFValido()==false){
}else if(this.state.errorCPF){
error = 'cpf'
}else if(this.isSenhaValido()==false){
this.setState({errorMessage: this.state.errorCPF});
}else if(this.state.errorSenha){
error = 'senha'
this.setState({errorMessage: this.state.errorSenha});
} else {
await this.handleSignUp();
}
switch(error) {
case 'nome':
await this.setState({errorMessage: this.state.errorNome})
return
case 'email':
await this.setState({errorMessage: this.state.errorEmail})
return
case 'cpf':
await this.setState({errorMessage: this.state.errorCPF})
return
case 'senha':
await this.setState({errorMessage: this.state.errorSenha})
return
default:
await this.handleSignUp();
return
}
return error;
}
......@@ -99,23 +86,23 @@ export default class TelaCadastro extends Component{
size="large"
color="#00DC7B"
/> :
<KeyboardAvoidingView behavior={"padding"} style={styles.container} enabled number="2" >
<KeyboardAvoidingView behavior={"padding"} style={styles.container} enabled number="2">
<View style={{flex: 1} [styles.flowButtonsContainer, { marginTop: 5 }]}>
<InputTexto
label="Nome"
value={this.state.nome}
onChangeText={nome => this.setState({ nome })}/>
onChangeText={nome => this.setState({ nome, errorNome: '', errorMessage: '' })}/>
<InputEmail
autoCorrect={false}
keyboardType='email-address'
returnKeyType="next"
onChangeText={email => this.setState({ email })}
onChangeText={email => this.setState({ email, errorEmail: '', errorMessage: '' })}
value={this.state.email}
label='E-mail' />
<InputTexto
label= "CPF"
value={this.state.cpf}
onChangeText={cpf => this.setState({ cpf })}/>
onChangeText={cpf => this.setState({ cpf, errorCPF: '', errorMessage: '' })}/>
</View>
<View style={{flex: 2, backgroundColor: 'white'} }>
<InputSenha
......@@ -123,7 +110,7 @@ export default class TelaCadastro extends Component{
returnKeyType="go"
ref={(input)=> this.passwordInput = input}
label='Senha'
onChangeText={senha => this.setState({ senha })}
onChangeText={senha => this.setState({ senha, errorSenha: '', errorMessage: '' })}
value={this.state.senha}
/>
<InputSenha
......@@ -131,18 +118,16 @@ export default class TelaCadastro extends Component{
returnKeyType="go"
ref={(input)=> this.passwordInput = input}
label='Confirmar senha'
onChangeText={confirmaSenha => this.setState({ confirmaSenha })}
value={this.state.confirmaSenha}
onChangeText={senhaConfirma => this.setState({ senhaConfirma, errorSenha: '', errorMessage: '' })}
value={this.state.senhaConfirma}
/>
<BotaoGrande
texto="Confirmar"
onPress={() => this.validate()}
onPress={ () => this.validate()}
endereco='Login'
navigation={this.props.navigation}
/>
<Text>
{this.state.errorMessage}
</Text>
<Aviso texto={this.state.errorMessage} />
</View>
</KeyboardAvoidingView>
)
......@@ -150,16 +135,14 @@ export default class TelaCadastro extends Component{
// utilizada classe '../shared/validationUtil.js'
isEmailValido = () => {
const {email} = this.state;
if(email.includes('@'))return true
this.setState({errorEmail : 'Email inválido'});
return false
const { email } = this.state;
if(email.includes('@')) return true
return this.setState({errorEmail : 'Email inválido'});
}
isNomeValido = () => {
const {nome} = this.state;
const { nome } = this.state;
if(nome.length > 0 && nome.length < 100) return true
this.setState({errorNome : 'Nome deve ter de 1 a 100 caracteres'});
return false
return this.setState({errorNome : 'Nome deve ter de 1 a 100 caracteres'});
}
isCPFValido = () => {
......@@ -168,8 +151,7 @@ export default class TelaCadastro extends Component{
let validated = true;
Soma = 0;
if(this.state.cpf.length != 11){
this.setState({errorCPF : 'CPF deve ter 11 numeros'});
return false;
return this.setState({errorCPF : 'CPF deve ter 11 numeros'});
}
if (this.state.cpf == "00000000000") validated = false;
......@@ -199,12 +181,10 @@ export default class TelaCadastro extends Component{
if(senha === senhaConfirma){
return true;
} else {
this.setState({errorSenha : 'As senhas não batem.'})
return false
return this.setState({errorSenha : 'As senhas não batem.'})
}
} else {
this.setState({errorSenha : 'Senha deve ter pelo menos 6 caracteres'});
return false
return this.setState({errorSenha : 'Senha deve ter pelo menos 6 caracteres'});
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!