eliminar inquilinos varios

This commit is contained in:
Mariela 2022-08-22 18:23:05 -06:00
parent b9d79c8402
commit ad4d194759
1 changed files with 19 additions and 2 deletions

View File

@ -148,7 +148,7 @@ const Inquilinos = () => {
detail: 'Inquilino creado', detail: 'Inquilino creado',
life: 3000, life: 3000,
}) })
setTenants(_tenants) setTenants(_tenants)
setTenant(emptyTenant) setTenant(emptyTenant)
setHouseNumber('') setHouseNumber('')
@ -231,7 +231,24 @@ const Inquilinos = () => {
} }
const deleteSelectedTenants = () => { const deleteSelectedTenants = () => {
let _tenants = tenants.filter((val) => !selectedTentants.includes(val)) let _tenants = tenants.filter(
(val) => !selectedTentants.includes(val)
);
selectedTentants.map((item) => {
let _tenant = {
community_id: item.community_id,
number_house: item.number_house
};
fetch('http://localhost:4000/user/deleteTenant/' + item._id, {
cache: 'no-cache',
method: 'PUT',
body: JSON.stringify(_tenant),
headers: {
'Content-Type': 'application/json',
},
});
});
setTenants(_tenants) setTenants(_tenants)
setDeleteTenantsDialog(false) setDeleteTenantsDialog(false)
setSelectedTenants(null) setSelectedTenants(null)