|
@ -20,7 +20,6 @@ import FormDatePicker from "../components/forms/FormDatePicker"; |
|
|
import moment from "moment"; |
|
|
import moment from "moment"; |
|
|
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 { useFormikContext } from "formik"; |
|
|
import { useFormikContext } from "formik"; |
|
|
import { |
|
|
import { |
|
|
signup, |
|
|
signup, |
|
@ -38,6 +37,7 @@ 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"; |
|
|
import { unMask, mask } from "react-native-mask-text"; |
|
|
|
|
|
import { getInstitutions } from "../api/fetchInstutions"; |
|
|
|
|
|
|
|
|
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})$/ |
|
@ -130,10 +130,10 @@ function GenderPicker({ name }) { |
|
|
|
|
|
|
|
|
function InstitutionPicker({ name }) { |
|
|
function InstitutionPicker({ name }) { |
|
|
const [items, setItems] = useState([ |
|
|
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" }, |
|
|
{ value: "X", label: "Nenhuma" }, |
|
|
]); |
|
|
]); |
|
|
return ( |
|
|
return ( |
|
@ -192,12 +192,21 @@ function InstitutionNamePicker({ name }) { |
|
|
const state = values["state"]; |
|
|
const state = values["state"]; |
|
|
const instType = values["institution"]; |
|
|
const instType = values["institution"]; |
|
|
const [items, setItems] = useState([]); |
|
|
const [items, setItems] = useState([]); |
|
|
|
|
|
const [institutions, setInstitutions] = useState([]); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
getInstitutions().then((data) => { |
|
|
|
|
|
setInstitutions(data); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((error) => { |
|
|
|
|
|
console.error(error); |
|
|
|
|
|
}); |
|
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
try { |
|
|
try { |
|
|
if (state && instType) { |
|
|
if (state && instType) { |
|
|
const insts = institutions[state] && institutions[state][instType]; |
|
|
const insts = institutions[state] && institutions[state][instType]; |
|
|
console.log(insts); |
|
|
|
|
|
insts ? setItems(insts) : setItems([]); |
|
|
insts ? setItems(insts) : setItems([]); |
|
|
} |
|
|
} |
|
|
} catch (e) { |
|
|
} catch (e) { |
|
|