Browse Source

feat: transform data model to includes city indicator

feat/institutions_data_from_api
bobmw 7 months ago
parent
commit
d4a1811af6
  1. 16
      src/app/api/fetchInstutions.js

16
src/app/api/fetchInstutions.js

@ -8,21 +8,29 @@ function transformData(institutions) {
const transformedData = {};
institutions.forEach((institution) => {
let { uf, type, name } = institution;
let { uf, type, name, cidade } = institution;
if (!uf) {
uf = "DF";
}
if (!cidade) {
cidade = "Brasília";
}
if (!transformedData[uf]) {
transformedData[uf] = {};
}
if (!transformedData[uf][type]) {
transformedData[uf][type] = [];
if (!transformedData[uf][cidade]) {
transformedData[uf][cidade] = {};
}
if (!transformedData[uf][cidade][type]) {
transformedData[uf][cidade][type] = [];
}
transformedData[uf][type].push({ value: name, label: name });
transformedData[uf][cidade][type].push({ value: name, label: name });
});
return transformedData;

Loading…
Cancel
Save