diff --git a/src/app/screens/RegisterScreen.js b/src/app/screens/RegisterScreen.js index 99f74f6..cb9d233 100644 --- a/src/app/screens/RegisterScreen.js +++ b/src/app/screens/RegisterScreen.js @@ -20,7 +20,6 @@ import FormDatePicker from "../components/forms/FormDatePicker"; import moment from "moment"; import SearchablePicker from "../components/SearchablePicker"; import { states, statesToCities } from "../assets/cities_states"; -import institutions from "../assets/institutions"; import { useFormikContext } from "formik"; import { signup, @@ -38,6 +37,7 @@ import CheckBox from "../components/forms/CheckBox"; import defaultStyles from "../config/styles"; import PhoneNumberFormField from "../components/forms/PhoneNumberFormField"; import { unMask, mask } from "react-native-mask-text"; +import { getInstitutions } from "../api/fetchInstutions"; const phoneRegex = RegExp( /^\(?[\(]?([0-9]{2})?\)?[)\b]?([0-9]{4,5})[-. ]?([0-9]{4})$/ @@ -130,10 +130,10 @@ function GenderPicker({ name }) { function InstitutionPicker({ name }) { const [items, setItems] = useState([ - { value: "E", label: "Escola" }, - { value: "D", label: "Defesa civil" }, - { value: "N", label: "Não governamental" }, - { value: "O", label: "Outra" }, + { value: "SCHOOL", label: "Escola" }, + { value: "CIVIL_DEFENSE", label: "Defesa civil" }, + { value: "NGO", label: "Não governamental" }, + { value: "OTHER", label: "Outra" }, { value: "X", label: "Nenhuma" }, ]); return ( @@ -192,12 +192,21 @@ function InstitutionNamePicker({ name }) { const state = values["state"]; const instType = values["institution"]; const [items, setItems] = useState([]); + const [institutions, setInstitutions] = useState([]); + + useEffect(() => { + getInstitutions().then((data) => { + setInstitutions(data); + }) + .catch((error) => { + console.error(error); + }); + }, []); useEffect(() => { try { if (state && instType) { const insts = institutions[state] && institutions[state][instType]; - console.log(insts); insts ? setItems(insts) : setItems([]); } } catch (e) {