fix communities UI

This commit is contained in:
Eduardo Quiros 2022-09-01 16:02:50 -06:00
parent a44fe8caa2
commit b704597d54
No known key found for this signature in database
GPG Key ID: B77F36C3F12720B4
1 changed files with 29 additions and 27 deletions

View File

@ -257,6 +257,7 @@ const Communities = () => {
}) })
.catch((err) => console.log('Ocurrió un error con el fetch', err)); .catch((err) => console.log('Ocurrió un error con el fetch', err));
} else { } else {
let _communities = [...communitiesList];
let _community = { ...community }; let _community = { ...community };
_community.province = provinciaId; _community.province = provinciaId;
_community.canton = cantonId; _community.canton = cantonId;
@ -275,36 +276,37 @@ const Communities = () => {
console.log('Ocurrió un error con el servicio: ' + response.status); console.log('Ocurrió un error con el servicio: ' + response.status);
else return response.json(); else return response.json();
}) })
.then(() => { .then(() => {
_community.province = provincesList.find( _community.province = provincesList.find(
(p) => p.code === _community.province, (p) => p.code === _community.province,
).name; ).name;
_community.canton = cantonsList.find( _community.canton = cantonsList.find(
(p) => p.code === _community.canton, (p) => p.code === _community.canton,
).name; ).name;
_community.district = districtsList.find( _community.district = districtsList.find(
(p) => p.code === _community.district, (p) => p.code === _community.district,
).name; ).name;
_communities.push(_community); _communities.push(_community);
toast.current.show({ toast.current.show({
severity: 'success', severity: 'success',
summary: 'Registro exitoso', summary: 'Registro exitoso',
detail: 'Comunidad de vivienda Creada', detail: 'Comunidad de vivienda Creada',
life: 3000, life: 3000,
}); });
setCommunitiesList(_communities); setCommunitiesList(_communities);
setProvinciaId(''); setProvinciaId('');
setCantonId(''); setCantonId('');
setDistrictId(''); setDistrictId('');
setCodeHouses(''); setCodeHouses('');
setFormCommunityDialog(false); setFormCommunityDialog(false);
setCommunity(emptyCommunity); setCommunity(emptyCommunity);
}) })
.catch((err) => console.log('Ocurrió un error con el fetch', err)); .catch((err) => console.log('Ocurrió un error con el fetch', err));
}
} else { } else {
setSubmitted(true); setSubmitted(true);
} }
@ -1271,7 +1273,7 @@ const Communities = () => {
)} )}
</div> </div>
</div> </div>
</div> </div>
</Dialog> </Dialog>
</div> </div>