diff --git a/src/app/screens/UpdateUserInfoScreen.js b/src/app/screens/UpdateUserInfoScreen.js
index 891f4e7..c5b2d32 100644
--- a/src/app/screens/UpdateUserInfoScreen.js
+++ b/src/app/screens/UpdateUserInfoScreen.js
@@ -25,10 +25,11 @@ import { getInstitutions } from "../api/fetchInstutions";
function InstitutionNamePicker({ name }) {
const { values } = useFormikContext();
const state = values["state"];
+ const city = values["city"];
const instType = values["institution"];
const [items, setItems] = useState([]);
const [institutions, setInstitutions] = useState([]);
-
+
useEffect(() => {
getInstitutions().then((data) => {
setInstitutions(data);
@@ -37,37 +38,37 @@ function InstitutionNamePicker({ name }) {
console.error(error);
});
}, []);
-
+
useEffect(() => {
- try {
- if (state && instType) {
- const insts = institutions[state] && institutions[state][instType];
- insts ? setItems(insts) : setItems([]);
- }
- } catch (e) {
- console.log(e);
+ try {
+ if (state && city && instType) {
+ const insts = institutions[state] && institutions[state][city] && institutions[state][city][instType];
+ insts ? setItems(insts) : setItems([]);
}
- }, [state, instType]);
-
+ } catch (e) {
+ console.log(e);
+ }
+ }, [state,city, instType, institutions]);
+
return (
-
+
);
-}
-
+ }
+
function RolePicker({ name }) {
const [items, setItems] = useState([
{ value: "ROLE_INSTITUTION", label: "Responsável" },