|
@ -2,7 +2,6 @@ import { |
|
|
Form, |
|
|
Form, |
|
|
SubmitButton, |
|
|
SubmitButton, |
|
|
FormField, |
|
|
FormField, |
|
|
ErrorMessage, |
|
|
|
|
|
} from "../components/forms"; |
|
|
} from "../components/forms"; |
|
|
import React, { useState, useEffect, useContext } from "react"; |
|
|
import React, { useState, useEffect, useContext } from "react"; |
|
|
import { |
|
|
import { |
|
@ -16,11 +15,9 @@ import Screen from "../components/Screen"; |
|
|
import { dimensions } from "../config/dimensions"; |
|
|
import { dimensions } from "../config/dimensions"; |
|
|
import { MaterialCommunityIcons } from "@expo/vector-icons"; |
|
|
import { MaterialCommunityIcons } from "@expo/vector-icons"; |
|
|
import colors from "../config/colors"; |
|
|
import colors from "../config/colors"; |
|
|
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"; |
|
|
|
|
|
import * as Yup from "yup"; |
|
|
import * as Yup from "yup"; |
|
|
import FormDatePicker from "../components/forms/FormDatePicker"; |
|
|
import FormDatePicker from "../components/forms/FormDatePicker"; |
|
|
import moment from "moment"; |
|
|
import moment from "moment"; |
|
|
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 institutions from "../assets/institutions"; |
|
|
import institutions from "../assets/institutions"; |
|
@ -40,6 +37,7 @@ import constants from "../config/constants"; |
|
|
import CheckBox from "../components/forms/CheckBox"; |
|
|
import CheckBox from "../components/forms/CheckBox"; |
|
|
import defaultStyles from "../config/styles"; |
|
|
import defaultStyles from "../config/styles"; |
|
|
import PhoneNumberFormField from "../components/forms/PhoneNumberFormField"; |
|
|
import PhoneNumberFormField from "../components/forms/PhoneNumberFormField"; |
|
|
|
|
|
import { unMask, mask } from "react-native-mask-text"; |
|
|
|
|
|
|
|
|
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})$/ |
|
@ -300,6 +298,11 @@ export default function RegisterScreen(props) { |
|
|
const [date, setDate] = useState(_moment); |
|
|
const [date, setDate] = useState(_moment); |
|
|
const [scroll, setScroll] = useState(); |
|
|
const [scroll, setScroll] = useState(); |
|
|
const [showLog, setShowLog] = useState({ show: false, message: "" }); |
|
|
const [showLog, setShowLog] = useState({ show: false, message: "" }); |
|
|
|
|
|
const [showModal, setShowModal] = useState({ |
|
|
|
|
|
show: false, |
|
|
|
|
|
message: "", |
|
|
|
|
|
form: null, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
const comparePassword = (password, confirmPassword) => { |
|
|
const comparePassword = (password, confirmPassword) => { |
|
|
return password !== confirmPassword; |
|
|
return password !== confirmPassword; |
|
@ -321,7 +324,6 @@ export default function RegisterScreen(props) { |
|
|
date.format("DD/MM/yyyy") === moment().format("DD/MM/yyyy") ? "" : date; |
|
|
date.format("DD/MM/yyyy") === moment().format("DD/MM/yyyy") ? "" : date; |
|
|
|
|
|
|
|
|
const result = await signup({ ...form, dateofborn: formDate }); |
|
|
const result = await signup({ ...form, dateofborn: formDate }); |
|
|
// console.log(JSON.stringify(result))
|
|
|
|
|
|
|
|
|
|
|
|
switch (result.status) { |
|
|
switch (result.status) { |
|
|
case 200: |
|
|
case 200: |
|
@ -371,6 +373,35 @@ export default function RegisterScreen(props) { |
|
|
return !inUse; |
|
|
return !inUse; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const copnfirmations = (form, actions) => { |
|
|
|
|
|
console.log(form); |
|
|
|
|
|
var current_mask = |
|
|
|
|
|
form.number.length >= 11 ? "(99) 99999-9999" : "(99) 9999-9999"; |
|
|
|
|
|
|
|
|
|
|
|
const psw_match = comparePassword(form.password, form.confirmPassword); |
|
|
|
|
|
if (psw_match) { |
|
|
|
|
|
actions.setFieldError("confirmPassword", "As senhas não correspondem"); |
|
|
|
|
|
scroll.scrollTo({ x: 0, y: 0, animated: true }); |
|
|
|
|
|
} else { |
|
|
|
|
|
fieldsAreNotInUse(form, actions).then((isNotUsed) => { |
|
|
|
|
|
if (isNotUsed) { |
|
|
|
|
|
setShowModal({ |
|
|
|
|
|
show: true, |
|
|
|
|
|
form: form, |
|
|
|
|
|
message: |
|
|
|
|
|
'Você está cadastrando o apelido "' + |
|
|
|
|
|
form.name + |
|
|
|
|
|
'" e o número ' + mask(form.number, current_mask) + |
|
|
|
|
|
'. Deseja continuar o cadastro?', |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
console.log("scrolll"); |
|
|
|
|
|
scroll.scrollTo({ x: 0, y: 0, animated: true }); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<Screen style={styles.containter}> |
|
|
<Screen style={styles.containter}> |
|
|
<ConfirmationModal |
|
|
<ConfirmationModal |
|
@ -379,6 +410,21 @@ export default function RegisterScreen(props) { |
|
|
confirmationLabel="OK" |
|
|
confirmationLabel="OK" |
|
|
onConfirm={() => setShowLog({ ...showLog, show: false })} |
|
|
onConfirm={() => setShowLog({ ...showLog, show: false })} |
|
|
/> |
|
|
/> |
|
|
|
|
|
<ConfirmationModal |
|
|
|
|
|
show={showModal.show} |
|
|
|
|
|
description={showModal.message} |
|
|
|
|
|
isNicknameConfirmation={true} |
|
|
|
|
|
icon="user-check" |
|
|
|
|
|
confirmationLabel="SIM" |
|
|
|
|
|
declineLabel="NÃO" |
|
|
|
|
|
onConfirm={() => { |
|
|
|
|
|
handleSubmit(showModal.form); |
|
|
|
|
|
}} |
|
|
|
|
|
onDecline={() => { |
|
|
|
|
|
setShowModal({ ...showModal, show: false, message: "" }); |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<Form |
|
|
<Form |
|
|
initialValues={{ |
|
|
initialValues={{ |
|
|
name: "", |
|
|
name: "", |
|
@ -396,28 +442,7 @@ export default function RegisterScreen(props) { |
|
|
consent: false, |
|
|
consent: false, |
|
|
}} |
|
|
}} |
|
|
onSubmit={(form, actions) => { |
|
|
onSubmit={(form, actions) => { |
|
|
console.log(form); |
|
|
|
|
|
const psw_match = comparePassword( |
|
|
|
|
|
form.password, |
|
|
|
|
|
form.confirmPassword |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (psw_match) { |
|
|
|
|
|
actions.setFieldError( |
|
|
|
|
|
"confirmPassword", |
|
|
|
|
|
"As senhas não correspondem" |
|
|
|
|
|
); |
|
|
|
|
|
scroll.scrollTo({ x: 0, y: 0, animated: true }); |
|
|
|
|
|
} else { |
|
|
|
|
|
fieldsAreNotInUse(form, actions).then((isNotUsed) => { |
|
|
|
|
|
if (isNotUsed) { |
|
|
|
|
|
handleSubmit(form); |
|
|
|
|
|
} else { |
|
|
|
|
|
console.log("scrolll"); |
|
|
|
|
|
scroll.scrollTo({ x: 0, y: 0, animated: true }); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
copnfirmations(form, actions); |
|
|
}} |
|
|
}} |
|
|
validationSchema={validationSchema} |
|
|
validationSchema={validationSchema} |
|
|
> |
|
|
> |
|
@ -527,11 +552,13 @@ export default function RegisterScreen(props) { |
|
|
</View> |
|
|
</View> |
|
|
<Text style={styles.labelStyle}>Nome da instituição</Text> |
|
|
<Text style={styles.labelStyle}>Nome da instituição</Text> |
|
|
<View style={{ flexDirection: "column", flex: 1 }}> |
|
|
<View style={{ flexDirection: "column", flex: 1 }}> |
|
|
<View style={{...styles.iconField, marginBottom:12}}> |
|
|
|
|
|
|
|
|
<View style={{ ...styles.iconField, marginBottom: 12 }}> |
|
|
<MaterialCommunityIconsCustom name="bank" /> |
|
|
<MaterialCommunityIconsCustom name="bank" /> |
|
|
<InstitutionNamePicker name="institutionName" /> |
|
|
<InstitutionNamePicker name="institutionName" /> |
|
|
</View> |
|
|
</View> |
|
|
<Text style={styles.warningText}>O nome da instituição é fornecido pelo Cemaden Educação</Text> |
|
|
|
|
|
|
|
|
<Text style={styles.warningText}> |
|
|
|
|
|
O nome da instituição é fornecido pelo Cemaden Educação |
|
|
|
|
|
</Text> |
|
|
</View> |
|
|
</View> |
|
|
<Text style={styles.labelStyle}>Vínculo institucional:</Text> |
|
|
<Text style={styles.labelStyle}>Vínculo institucional:</Text> |
|
|
<View style={[styles.iconField]}> |
|
|
<View style={[styles.iconField]}> |
|
@ -633,4 +660,4 @@ const styles = StyleSheet.create({ |
|
|
textAlign: "left", |
|
|
textAlign: "left", |
|
|
marginBottom: 24, |
|
|
marginBottom: 24, |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
|
|
|
|
|
|
}); |