|
@ -18,6 +18,8 @@ import { Shadow } from "react-native-shadow-2"; |
|
|
import SearchablePicker from "../components/SearchablePicker"; |
|
|
import SearchablePicker from "../components/SearchablePicker"; |
|
|
import { states, statesToCities } from "../assets/cities_states"; |
|
|
import { states, statesToCities } from "../assets/cities_states"; |
|
|
import { useFormikContext } from "formik"; |
|
|
import { useFormikContext } from "formik"; |
|
|
|
|
|
import Checkbox from "../components/forms/CheckBox"; |
|
|
|
|
|
import { TouchableOpacity } from "react-native-gesture-handler"; |
|
|
|
|
|
|
|
|
const phoneRegex = RegExp( |
|
|
const phoneRegex = RegExp( |
|
|
/^\(?[\(]?([0-9]{2})?\)?[)\b]?([0-9]{4,5})[-. ]?([0-9]{4})$/ |
|
|
/^\(?[\(]?([0-9]{2})?\)?[)\b]?([0-9]{4,5})[-. ]?([0-9]{4})$/ |
|
@ -25,7 +27,7 @@ const phoneRegex = RegExp( |
|
|
|
|
|
|
|
|
const validationSchema = Yup.object().shape({ |
|
|
const validationSchema = Yup.object().shape({ |
|
|
name: Yup.string() |
|
|
name: Yup.string() |
|
|
.required("O nome é obrigatória") |
|
|
|
|
|
|
|
|
.required("O nome é obrigatório") |
|
|
.matches(/[a-zA-Z]/, "O nome e só pode conter letras"), |
|
|
.matches(/[a-zA-Z]/, "O nome e só pode conter letras"), |
|
|
number: Yup.string() |
|
|
number: Yup.string() |
|
|
.matches(phoneRegex, "Número inválido") |
|
|
.matches(phoneRegex, "Número inválido") |
|
@ -39,10 +41,13 @@ const validationSchema = Yup.object().shape({ |
|
|
.min(8, "Senha muito curta, minimo 8 caracteres") |
|
|
.min(8, "Senha muito curta, minimo 8 caracteres") |
|
|
.matches(/[a-zA-Z]/, "A senha só pode conter letras"), |
|
|
.matches(/[a-zA-Z]/, "A senha só pode conter letras"), |
|
|
state: Yup.string().required("O estado é obrigatório"), |
|
|
state: Yup.string().required("O estado é obrigatório"), |
|
|
|
|
|
city: Yup.string().required("A cidade é obrigatória"), |
|
|
institutionName: Yup.string(), |
|
|
institutionName: Yup.string(), |
|
|
|
|
|
secQuestion: Yup.string().required("Escolha a pergunta de segurança"), |
|
|
secQuestionAns: Yup.string() |
|
|
secQuestionAns: Yup.string() |
|
|
.required("A resposta da pergunta de segurança é obrigatória") |
|
|
.required("A resposta da pergunta de segurança é obrigatória") |
|
|
.max(255), |
|
|
.max(255), |
|
|
|
|
|
consent: Yup.bool().equals([true], "Este campo é obrigatório"), |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
function LocalDatePicker({ date, setDate, _moment }) { |
|
|
function LocalDatePicker({ date, setDate, _moment }) { |
|
@ -176,7 +181,6 @@ function SecQuestionPicker({ name }) { |
|
|
{ value: "d", label: "Qual o nome da rua em que você cresceu?" }, |
|
|
{ value: "d", label: "Qual o nome da rua em que você cresceu?" }, |
|
|
{ value: "f", label: "Qual o nome do seu bicho de estimação predileto?" }, |
|
|
{ value: "f", label: "Qual o nome do seu bicho de estimação predileto?" }, |
|
|
{ value: "g", label: "Qual a sua comida predileta?" }, |
|
|
{ value: "g", label: "Qual a sua comida predileta?" }, |
|
|
{ value: "h", label: "Qual cidade você nasceu?" }, |
|
|
|
|
|
{ value: "j", label: "Qual é o seu país preferido?" }, |
|
|
{ value: "j", label: "Qual é o seu país preferido?" }, |
|
|
{ value: "k", label: "Qual é a sua marca de carro predileto?" }, |
|
|
{ value: "k", label: "Qual é a sua marca de carro predileto?" }, |
|
|
]); |
|
|
]); |
|
@ -193,6 +197,17 @@ function SecQuestionPicker({ name }) { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function MaterialCommunityIconsCustom({ |
|
|
|
|
|
name, |
|
|
|
|
|
color = colors.primary, |
|
|
|
|
|
size = 25, |
|
|
|
|
|
}) { |
|
|
|
|
|
return ( |
|
|
|
|
|
<View justifyContent={"center"} height={48}> |
|
|
|
|
|
<MaterialCommunityIcons name={name} size={size} color={color} /> |
|
|
|
|
|
</View> |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
export default function RegisterScreen(props) { |
|
|
export default function RegisterScreen(props) { |
|
|
const _moment = moment(); |
|
|
const _moment = moment(); |
|
|
const [date, setDate] = useState(_moment); |
|
|
const [date, setDate] = useState(_moment); |
|
@ -216,12 +231,13 @@ export default function RegisterScreen(props) { |
|
|
confirmPassword: "", |
|
|
confirmPassword: "", |
|
|
gender: "", |
|
|
gender: "", |
|
|
institutionName: "", |
|
|
institutionName: "", |
|
|
secQuestionAns: "", |
|
|
|
|
|
gender: "", |
|
|
gender: "", |
|
|
state: "", |
|
|
state: "", |
|
|
city: "", |
|
|
city: "", |
|
|
institution: "", |
|
|
institution: "", |
|
|
secQuestion: "", |
|
|
secQuestion: "", |
|
|
|
|
|
secQuestionAns: "", |
|
|
|
|
|
consent: false, |
|
|
}} |
|
|
}} |
|
|
onSubmit={(form) => { |
|
|
onSubmit={(form) => { |
|
|
comparePassword(form.password, form.confirmPassword); |
|
|
comparePassword(form.password, form.confirmPassword); |
|
@ -234,14 +250,20 @@ export default function RegisterScreen(props) { |
|
|
style={{ flexDirection: "column", justifyContent: "center", flex: 1 }} |
|
|
style={{ flexDirection: "column", justifyContent: "center", flex: 1 }} |
|
|
> |
|
|
> |
|
|
<KeyboardAwareScrollView scrollEnabled={true}> |
|
|
<KeyboardAwareScrollView scrollEnabled={true}> |
|
|
|
|
|
<Text |
|
|
|
|
|
style={{ |
|
|
|
|
|
color: colors.primary, |
|
|
|
|
|
fontSize: 20, |
|
|
|
|
|
fontWeight: "bold", |
|
|
|
|
|
alignSelf: "center", |
|
|
|
|
|
marginVertical: 24, |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
Cadastro do usuário |
|
|
|
|
|
</Text> |
|
|
<Text style={styles.labelStyle}>Apelido de usuário*</Text> |
|
|
<Text style={styles.labelStyle}>Apelido de usuário*</Text> |
|
|
|
|
|
|
|
|
<View style={styles.iconField}> |
|
|
<View style={styles.iconField}> |
|
|
<MaterialCommunityIcons |
|
|
|
|
|
name="account" |
|
|
|
|
|
size={25} |
|
|
|
|
|
color={colors.primary} |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<MaterialCommunityIconsCustom name="account" /> |
|
|
<FormField |
|
|
<FormField |
|
|
paddingRight={2} |
|
|
paddingRight={2} |
|
|
flex={1} |
|
|
flex={1} |
|
@ -251,14 +273,9 @@ export default function RegisterScreen(props) { |
|
|
placeholder="Nome Completo" |
|
|
placeholder="Nome Completo" |
|
|
/> |
|
|
/> |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
<Text style={styles.labelStyle}>Número do telefone:*</Text> |
|
|
<Text style={styles.labelStyle}>Número do telefone:*</Text> |
|
|
<View style={styles.iconField}> |
|
|
<View style={styles.iconField}> |
|
|
<MaterialCommunityIcons |
|
|
|
|
|
name="phone" |
|
|
|
|
|
size={25} |
|
|
|
|
|
color={colors.primary} |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<MaterialCommunityIconsCustom name="phone" /> |
|
|
<FormField |
|
|
<FormField |
|
|
flex={1} |
|
|
flex={1} |
|
|
maxLength={12} |
|
|
maxLength={12} |
|
@ -268,14 +285,9 @@ export default function RegisterScreen(props) { |
|
|
paddingRight={2} |
|
|
paddingRight={2} |
|
|
/> |
|
|
/> |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
<Text style={styles.labelStyle}>Senha:*</Text> |
|
|
<Text style={styles.labelStyle}>Senha:*</Text> |
|
|
<View style={styles.iconField}> |
|
|
<View style={styles.iconField}> |
|
|
<MaterialCommunityIcons |
|
|
|
|
|
name="lock" |
|
|
|
|
|
size={25} |
|
|
|
|
|
color={colors.primary} |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<MaterialCommunityIconsCustom name="lock" /> |
|
|
<FormField |
|
|
<FormField |
|
|
flex={1} |
|
|
flex={1} |
|
|
maxLength={12} |
|
|
maxLength={12} |
|
@ -286,14 +298,9 @@ export default function RegisterScreen(props) { |
|
|
paddingRight={2} |
|
|
paddingRight={2} |
|
|
/> |
|
|
/> |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
<Text style={styles.labelStyle}>Confirmar senha:*</Text> |
|
|
<Text style={styles.labelStyle}>Confirmar senha:*</Text> |
|
|
<View style={styles.iconField}> |
|
|
<View style={styles.iconField}> |
|
|
<MaterialCommunityIcons |
|
|
|
|
|
name="lock" |
|
|
|
|
|
size={25} |
|
|
|
|
|
color={colors.primary} |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<MaterialCommunityIconsCustom name="lock" /> |
|
|
<FormField |
|
|
<FormField |
|
|
flex={1} |
|
|
flex={1} |
|
|
maxLength={12} |
|
|
maxLength={12} |
|
@ -308,69 +315,42 @@ export default function RegisterScreen(props) { |
|
|
error="As senhas não correspondem" |
|
|
error="As senhas não correspondem" |
|
|
visible={singUpFailed} |
|
|
visible={singUpFailed} |
|
|
/> |
|
|
/> |
|
|
|
|
|
|
|
|
<Text style={styles.labelStyle}>Data de nascimento:</Text> |
|
|
<Text style={styles.labelStyle}>Data de nascimento:</Text> |
|
|
<View style={styles.iconField}> |
|
|
<View style={styles.iconField}> |
|
|
<MaterialCommunityIcons |
|
|
|
|
|
name="calendar-today" |
|
|
|
|
|
size={25} |
|
|
|
|
|
color={colors.primary} |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<MaterialCommunityIconsCustom name="calendar-today" /> |
|
|
<LocalDatePicker |
|
|
<LocalDatePicker |
|
|
date={date} |
|
|
date={date} |
|
|
setDate={setDate} |
|
|
setDate={setDate} |
|
|
_moment={_moment} |
|
|
_moment={_moment} |
|
|
/> |
|
|
/> |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
<Text style={styles.labelStyle}>Gênero:</Text> |
|
|
<Text style={styles.labelStyle}>Gênero:</Text> |
|
|
<View style={[styles.iconField]}> |
|
|
<View style={[styles.iconField]}> |
|
|
<MaterialCommunityIcons |
|
|
|
|
|
name="account" |
|
|
|
|
|
size={25} |
|
|
|
|
|
color={colors.primary} |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<MaterialCommunityIconsCustom name="account" /> |
|
|
<GenderPicker name="gender" /> |
|
|
<GenderPicker name="gender" /> |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
<Text style={styles.labelStyle}>Estado*:</Text> |
|
|
<Text style={styles.labelStyle}>Estado*:</Text> |
|
|
<View style={[styles.iconField]}> |
|
|
<View style={[styles.iconField]}> |
|
|
<MaterialCommunityIcons |
|
|
|
|
|
name="map-marker" |
|
|
|
|
|
size={25} |
|
|
|
|
|
color={colors.primary} |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<MaterialCommunityIconsCustom name="map-marker" /> |
|
|
<StatePicker name="state" /> |
|
|
<StatePicker name="state" /> |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
<Text style={styles.labelStyle}>Cidade*:</Text> |
|
|
<Text style={styles.labelStyle}>Cidade*:</Text> |
|
|
<View style={[styles.iconField]}> |
|
|
<View style={[styles.iconField]}> |
|
|
<MaterialCommunityIcons |
|
|
|
|
|
name="map-marker" |
|
|
|
|
|
size={25} |
|
|
|
|
|
color={colors.primary} |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<MaterialCommunityIconsCustom name="map-marker" /> |
|
|
<CityPicker name={"city"} /> |
|
|
<CityPicker name={"city"} /> |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
<Text style={styles.labelStyle}>Tipo de instituição:</Text> |
|
|
<Text style={styles.labelStyle}>Tipo de instituição:</Text> |
|
|
<View style={[styles.iconField]}> |
|
|
<View style={[styles.iconField]}> |
|
|
<MaterialCommunityIcons |
|
|
|
|
|
name="bank" |
|
|
|
|
|
size={25} |
|
|
|
|
|
color={colors.primary} |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<MaterialCommunityIconsCustom name="bank" /> |
|
|
<InstitutionPicker name="institution" /> |
|
|
<InstitutionPicker name="institution" /> |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
<Text style={styles.labelStyle}>Nome da instituição</Text> |
|
|
<Text style={styles.labelStyle}>Nome da instituição</Text> |
|
|
|
|
|
|
|
|
<View style={styles.iconField}> |
|
|
<View style={styles.iconField}> |
|
|
<MaterialCommunityIcons |
|
|
|
|
|
name="bank" |
|
|
|
|
|
size={25} |
|
|
|
|
|
color={colors.primary} |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<MaterialCommunityIconsCustom name="bank" /> |
|
|
<FormField |
|
|
<FormField |
|
|
flex={1} |
|
|
flex={1} |
|
|
maxLength={12} |
|
|
maxLength={12} |
|
@ -380,7 +360,6 @@ export default function RegisterScreen(props) { |
|
|
paddingRight={2} |
|
|
paddingRight={2} |
|
|
/> |
|
|
/> |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
<Text style={styles.labelStyle}>Pergunta de segurança*:</Text> |
|
|
<Text style={styles.labelStyle}>Pergunta de segurança*:</Text> |
|
|
<View |
|
|
<View |
|
|
style={{ |
|
|
style={{ |
|
@ -391,7 +370,6 @@ export default function RegisterScreen(props) { |
|
|
> |
|
|
> |
|
|
<SecQuestionPicker name="secQuestion" /> |
|
|
<SecQuestionPicker name="secQuestion" /> |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
<Text style={styles.labelStyle}>Resposta*:</Text> |
|
|
<Text style={styles.labelStyle}>Resposta*:</Text> |
|
|
<View style={styles.iconField}> |
|
|
<View style={styles.iconField}> |
|
|
<FormField |
|
|
<FormField |
|
@ -405,19 +383,29 @@ export default function RegisterScreen(props) { |
|
|
/> |
|
|
/> |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
|
|
|
<Text style={styles.labelStyle}>Termos de uso*</Text> |
|
|
|
|
|
<View flexDirection="column" alignItems={"flex-start"} marginBottom={24} marginTop={12}> |
|
|
|
|
|
<Checkbox name={"consent"} navigate={() => props.navigation.navigate("UserAgreement")}/> |
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
<SubmitButton |
|
|
<SubmitButton |
|
|
flex={1} |
|
|
flex={1} |
|
|
title="cadastrar" |
|
|
title="cadastrar" |
|
|
backgroundColor={colors.primary} |
|
|
backgroundColor={colors.primary} |
|
|
marginTop={10} |
|
|
|
|
|
/> |
|
|
/> |
|
|
|
|
|
|
|
|
<TouchableNativeFeedback |
|
|
<TouchableNativeFeedback |
|
|
onPress={() => { |
|
|
onPress={() => { |
|
|
props.navigation.goBack(); |
|
|
props.navigation.goBack(); |
|
|
}} |
|
|
}} |
|
|
> |
|
|
> |
|
|
<View style={{ flexDirection: "row", alignSelf: "center" }}> |
|
|
|
|
|
|
|
|
<View |
|
|
|
|
|
style={{ |
|
|
|
|
|
flexDirection: "row", |
|
|
|
|
|
alignSelf: "center", |
|
|
|
|
|
paddingBottom: 34, |
|
|
|
|
|
marginTop: 6, |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
<Text>Já tem uma conta? </Text> |
|
|
<Text>Já tem uma conta? </Text> |
|
|
<Text style={{ color: colors.lightBlue }}>Faça Login</Text> |
|
|
<Text style={{ color: colors.lightBlue }}>Faça Login</Text> |
|
|
</View> |
|
|
</View> |
|
@ -441,12 +429,10 @@ const styles = StyleSheet.create({ |
|
|
fontWeight: "bold", |
|
|
fontWeight: "bold", |
|
|
textAlign: "left", |
|
|
textAlign: "left", |
|
|
color: colors.secondary, |
|
|
color: colors.secondary, |
|
|
marginTop: 10, |
|
|
|
|
|
}, |
|
|
}, |
|
|
iconField: { |
|
|
iconField: { |
|
|
width: "100%", |
|
|
width: "100%", |
|
|
flex: 1, |
|
|
flex: 1, |
|
|
alignItems: "center", |
|
|
|
|
|
flexDirection: "row", |
|
|
flexDirection: "row", |
|
|
marginTop: 12, |
|
|
marginTop: 12, |
|
|
marginBottom: 24, |
|
|
marginBottom: 24, |
|
|