|
|
@ -38,7 +38,7 @@ import ConfirmationModal from "../components/ConfirmationModal"; |
|
|
|
import PasswordFormField from "../components/forms/PasswordFormField"; |
|
|
|
import constants from "../config/constants"; |
|
|
|
import CheckBox from "../components/forms/CheckBox"; |
|
|
|
import defaultStyles from "../config/styles" |
|
|
|
import defaultStyles from "../config/styles"; |
|
|
|
|
|
|
|
const phoneRegex = RegExp( |
|
|
|
/^\(?[\(]?([0-9]{2})?\)?[)\b]?([0-9]{4,5})[-. ]?([0-9]{4})$/ |
|
|
@ -319,15 +319,23 @@ export default function RegisterScreen(props) { |
|
|
|
}; |
|
|
|
|
|
|
|
const handleSubmit = async (form) => { |
|
|
|
console.log(form); |
|
|
|
const formDate = |
|
|
|
date.format("DD/MM/yyyy") === moment().format("DD/MM/yyyy") ? "" : date; |
|
|
|
|
|
|
|
const result = await signup({ ...form, dateofborn: formDate }); |
|
|
|
// console.log(JSON.stringify(result))
|
|
|
|
|
|
|
|
switch (result.status) { |
|
|
|
case 200: |
|
|
|
automaticLogin(form); |
|
|
|
break; |
|
|
|
case 422: |
|
|
|
setShowLog({ |
|
|
|
show: true, |
|
|
|
message: "Campo obrigatório não informado", |
|
|
|
}); |
|
|
|
break; |
|
|
|
default: |
|
|
|
setShowLog({ |
|
|
|
show: true, |
|
|
@ -342,13 +350,13 @@ export default function RegisterScreen(props) { |
|
|
|
|
|
|
|
if (ru.data) { |
|
|
|
actions.setFieldError("number", "Este número de telefone já está em uso"); |
|
|
|
inUse = false; |
|
|
|
inUse = true; |
|
|
|
} |
|
|
|
|
|
|
|
const rn = await existNickname(form.name); |
|
|
|
if (rn.data) { |
|
|
|
actions.setFieldError("name", "Este apelido de usuário já está em uso"); |
|
|
|
inUse = false; |
|
|
|
inUse = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (!ru.ok || !rn.ok) |
|
|
@ -394,13 +402,11 @@ export default function RegisterScreen(props) { |
|
|
|
comparePassword(form.password, form.confirmPassword); |
|
|
|
|
|
|
|
fieldsAreNotInUse(form, actions).then((isNotUsed) => { |
|
|
|
isNotUsed && handleSubmit(form); |
|
|
|
// NOTE: this woud be nice, but does not work...
|
|
|
|
// : scroll.scrollTo({
|
|
|
|
// x: 0,
|
|
|
|
// y: 0,
|
|
|
|
// animated: true,
|
|
|
|
// });
|
|
|
|
if (isNotUsed) { |
|
|
|
handleSubmit(form); |
|
|
|
} else { |
|
|
|
scroll.scrollTo({ x: 0, y: 0, animated: true }); |
|
|
|
} |
|
|
|
}); |
|
|
|
}} |
|
|
|
validationSchema={validationSchema} |
|
|
@ -535,7 +541,6 @@ export default function RegisterScreen(props) { |
|
|
|
/> |
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
|
|
<Text style={styles.labelStyle}>Termos de uso*</Text> |
|
|
|
<View |
|
|
|
flexDirection={"column"} |
|
|
@ -555,7 +560,6 @@ export default function RegisterScreen(props) { |
|
|
|
backgroundColor={colors.primary} |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<TouchableNativeFeedback |
|
|
|
onPress={() => { |
|
|
|
props.navigation.goBack(); |
|
|
|