9 Commits
31bfd66f6b
...
8a0361ee56
Author | SHA1 | Message | Date |
---|---|---|---|
rbantu | 8a0361ee56 |
Merge pull request 'feat/institutions_data_from_api' (#4) from feat/institutions_data_from_api into master
Reviewed-on: https://git.quijaua.com.br/cemaden-educacao/WPD-MobileApp/pulls/4 |
7 months ago |
bobmw | c952d03a2c |
feat(UpdateUserInfoScreen): set institutions filter by UF, City and Type
|
7 months ago |
bobmw | 0bd6188a20 |
feat(RegisterScreen): set institutions filter by UF, City and Type
|
7 months ago |
bobmw | d4a1811af6 |
feat: transform data model to includes city indicator
|
7 months ago |
bobmw | 1c8422c80e |
feat(UpdateUserInfoScreen): set getInstitutions
|
7 months ago |
bobmw | 9bd016c440 |
feat(RegisterScreen): set getInstitutions
|
7 months ago |
bobmw | 6492616471 |
feat: change institutions type constants
|
7 months ago |
bobmw | ada022d73f |
feat: create institutions fetch
|
7 months ago |
bobmw | 8ab07f6e50 |
feat: change apis baseurl auth to authtest
|
7 months ago |
6 changed files with 129 additions and 58 deletions
-
8src/app/api/auth.js
-
51src/app/api/fetchInstutions.js
-
4src/app/auth/authClient.js
-
10src/app/config/constants.js
-
37src/app/screens/RegisterScreen.js
-
77src/app/screens/UpdateUserInfoScreen.js
@ -0,0 +1,51 @@ |
|||||
|
import { create } from "apisauce"; |
||||
|
|
||||
|
const fetchInstitutions = create({ |
||||
|
baseURL: "https://wpd.brazilsouth.cloudapp.azure.com/authtest/organizations/all", |
||||
|
}); |
||||
|
|
||||
|
function transformData(institutions) { |
||||
|
const transformedData = {}; |
||||
|
|
||||
|
institutions.forEach((institution) => { |
||||
|
let { uf, type, name, cidade } = institution; |
||||
|
|
||||
|
if (!uf) { |
||||
|
uf = "DF"; |
||||
|
} |
||||
|
|
||||
|
if (!cidade) { |
||||
|
cidade = "Brasília"; |
||||
|
} |
||||
|
|
||||
|
if (!transformedData[uf]) { |
||||
|
transformedData[uf] = {}; |
||||
|
} |
||||
|
|
||||
|
if (!transformedData[uf][cidade]) { |
||||
|
transformedData[uf][cidade] = {}; |
||||
|
} |
||||
|
|
||||
|
if (!transformedData[uf][cidade][type]) { |
||||
|
transformedData[uf][cidade][type] = []; |
||||
|
} |
||||
|
|
||||
|
transformedData[uf][cidade][type].push({ value: name, label: name }); |
||||
|
}); |
||||
|
|
||||
|
return transformedData; |
||||
|
} |
||||
|
|
||||
|
export function getInstitutions() { |
||||
|
return fetchInstitutions.get() |
||||
|
.then((response) => { |
||||
|
if (response.ok) { |
||||
|
return transformData(response.data); |
||||
|
} else { |
||||
|
throw new Error("Falha ao tentar buscar instituicoes no banco de dados"); |
||||
|
} |
||||
|
}) |
||||
|
.catch((error) => { |
||||
|
throw error; |
||||
|
}); |
||||
|
} |
@ -1,11 +1,11 @@ |
|||||
import { create } from "apisauce"; |
import { create } from "apisauce"; |
||||
|
|
||||
const authClient = create({ |
const authClient = create({ |
||||
baseURL: "https://wpd.brazilsouth.cloudapp.azure.com/auth/users", |
|
||||
|
baseURL: "https://wpd.brazilsouth.cloudapp.azure.com/authtest/users", |
||||
}); |
}); |
||||
|
|
||||
const authChangePswdClient = create({ |
const authChangePswdClient = create({ |
||||
baseURL: "https://wpd.brazilsouth.cloudapp.azure.com/auth/forgotpasswords" |
|
||||
|
baseURL: "https://wpd.brazilsouth.cloudapp.azure.com/authtest/forgotpasswords" |
||||
}) |
}) |
||||
|
|
||||
export { authClient, authChangePswdClient}; |
export { authClient, authChangePswdClient}; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue