diff --git a/src/app/components/SearchablePicker.js b/src/app/components/SearchablePicker.js
index e2013f3..65c6131 100644
--- a/src/app/components/SearchablePicker.js
+++ b/src/app/components/SearchablePicker.js
@@ -1,9 +1,11 @@
-import React, { useState } from "react";
+import React, { useState, useEffect } from "react";
import { StyleSheet, View } from "react-native";
import colors from "../config/colors";
import DropDownPicker from "react-native-dropdown-picker";
import { Shadow } from "react-native-shadow-2";
+import { useFormikContext } from "formik";
+import { ErrorMessage } from "./forms";
function DropDown({
value,
@@ -54,16 +56,29 @@ function DropDown({
}
function SearchablePicker({
- value,
- setValue,
items,
setItems,
formPlaceholder,
searchPlaceholder,
+ name,
nothingToShow = "Não encontramos nada com esse termo",
+ marginRight = 2,
+ marginLeft = 16,
}) {
+ const { values, setFieldValue, errors, touched } = useFormikContext();
+ const [value, setValue] = useState(values[name]);
+
+ useEffect(() => {
+ setFieldValue(name, value, true);
+ }, [value]);
+
return (
-
+
+
+
);
}
@@ -89,8 +106,6 @@ const styles = StyleSheet.create({
location: {
flex: 1,
alignSelf: "flex-start",
- marginRight: 2,
- marginLeft: 16,
},
});
diff --git a/src/app/components/forms/FormField.js b/src/app/components/forms/FormField.js
index a5583cb..b17f26a 100644
--- a/src/app/components/forms/FormField.js
+++ b/src/app/components/forms/FormField.js
@@ -59,18 +59,19 @@ function RenderPluviometerInput({
return (
-
- setFieldTouched(name)}
- onChangeText={(val) => {
- setFieldVal(val);
- }}
- width={width}
- value={fieldVal.toString()}
- {...otherProps}/>
+
+ setFieldTouched(name)}
+ onChangeText={(val) => {
+ setFieldVal(val);
+ }}
+ width={width}
+ value={fieldVal.toString()}
+ {...otherProps}
+ />
- {name != "pluviometer" ? (
- setFieldTouched(name)}
- onChangeText={handleChange(name)}
- width={width}
- {...otherProps}
- />
- ) : (
-
- )}
+ {name != "pluviometer" ? (
+ setFieldTouched(name)}
+ onChangeText={handleChange(name)}
+ width={width}
+ {...otherProps}
+ />
+ ) : (
+
+ )}
-
-
-
+
+
+
);
}
diff --git a/src/app/screens/RegisterScreen.js b/src/app/screens/RegisterScreen.js
index 4cba4c6..ecff241 100644
--- a/src/app/screens/RegisterScreen.js
+++ b/src/app/screens/RegisterScreen.js
@@ -17,6 +17,7 @@ import moment from "moment";
import { Shadow } from "react-native-shadow-2";
import SearchablePicker from "../components/SearchablePicker";
import { states, statesToCities } from "../assets/cities_states";
+import { useFormikContext } from "formik";
const phoneRegex = RegExp(
/^\(?[\(]?([0-9]{2})?\)?[)\b]?([0-9]{4,5})[-. ]?([0-9]{4})$/
@@ -38,6 +39,10 @@ const validationSchema = Yup.object().shape({
.min(8, "Senha muito curta, minimo 8 caracteres")
.matches(/[a-zA-Z]/, "A senha só pode conter letras"),
state: Yup.string().required("O estado é obrigatório"),
+ institutionName: Yup.string(),
+ secQuestionAns: Yup.string()
+ .required("A resposta da pergunta de segurança é obrigatória")
+ .max(255),
});
function LocalDatePicker({ date, setDate, _moment }) {
@@ -89,7 +94,7 @@ function LocalDatePicker({ date, setDate, _moment }) {
);
}
-function GenderPicker({ value, setValue }) {
+function GenderPicker({ name }) {
const [items, setItems] = useState([
{ value: "Feminino", label: "Feminino" },
{ value: "Masculino", label: "Masculino" },
@@ -97,8 +102,7 @@ function GenderPicker({ value, setValue }) {
]);
return (
{
state && setItems(statesToCities[state].cities);
}, [state]);
const [items, setItems] = useState([]);
+
return (
+ );
+}
+
+export default function RegisterScreen(props) {
const _moment = moment();
const [date, setDate] = useState(_moment);
const [singUpFailed, setSingUpFailed] = useState(false);
@@ -191,13 +214,19 @@ export default function RegisterScreen(props) {
number: "",
password: "",
confirmPassword: "",
- state: "",
gender: "",
institutionName: "",
+ secQuestionAns: "",
+ gender: "",
+ state: "",
+ city: "",
+ institution: "",
+ secQuestion: "",
}}
- onSubmit={({ name, number, password, confirmPassword }) => {
- comparePassword(password, confirmPassword);
+ onSubmit={(form) => {
+ comparePassword(form.password, form.confirmPassword);
console.log("cadastro ainda não implementado");
+ console.log("Forms values: \n" + JSON.stringify(form));
}}
validationSchema={validationSchema}
>
@@ -301,7 +330,7 @@ export default function RegisterScreen(props) {
size={25}
color={colors.primary}
/>
-
+
Estado*:
@@ -311,7 +340,7 @@ export default function RegisterScreen(props) {
size={25}
color={colors.primary}
/>
-
+
Cidade*:
@@ -321,7 +350,7 @@ export default function RegisterScreen(props) {
size={25}
color={colors.primary}
/>
-
+
Tipo de instituição:
@@ -331,10 +360,7 @@ export default function RegisterScreen(props) {
size={25}
color={colors.primary}
/>
-
+
Nome da instituição
@@ -355,6 +381,30 @@ export default function RegisterScreen(props) {
/>
+ Pergunta de segurança*:
+
+
+
+
+ Resposta*:
+
+
+
+