diff --git a/src/app/screens/RegisterScreen.js b/src/app/screens/RegisterScreen.js index 3008459..0fc33d6 100644 --- a/src/app/screens/RegisterScreen.js +++ b/src/app/screens/RegisterScreen.js @@ -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})$/ @@ -81,31 +81,31 @@ function LocalDatePicker({ date, setDate, _moment }) { date={date} > - + - - {date != _moment - ? formatDate() - : "Selecione a data de nascimento"} - - + {date != _moment + ? formatDate() + : "Selecione a data de nascimento"} + + @@ -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) { /> - Termos de uso* props.navigation.navigate("UserAgreement")} /> - + - { props.navigation.goBack();