ultimos fixes

This commit is contained in:
Mariela 2022-09-01 15:12:35 -06:00
parent 065456200b
commit 56cef964f1
8 changed files with 272 additions and 209 deletions

View File

@ -84,7 +84,8 @@ export class UsersController {
@MessagePattern({ cmd: 'updateAdminCommunity' })
updateAdminCommunity(@Payload() user: UserDocument) {
return this.userService.update(user._id, user);
console.log(user)
return this.userService.updateAdminCommunity(user['_id'], user);
}
@MessagePattern({ cmd: 'updateTenant' })

View File

@ -137,6 +137,17 @@ export class UsersService {
});
}
async updateAdminCommunity(id: string, user: UserDocument) {
return this.userModel.findOneAndUpdate({ _id: id }, {
name: user['name'], last_name: user['last_name'],
dni: user['dni'], email: user['email'], phone: user['phone'],
community_id: user['community_id']
}, {
new: true,
});
}
async updateTenant(id: string, user: UserDocument) {
await this.saveTenant(user.community_id, user.number_house, user.id);

View File

@ -281,6 +281,7 @@ const AdministradoresComunidad = () => {
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador de Comunidad de vivienda Creada', life: 3000 });
setListaAdmins(_administrators);
setAdminDialog(false)
setAdminCommunity(emptyAdminCommunity);
@ -296,7 +297,6 @@ const AdministradoresComunidad = () => {
} else {
console.log(`Actualizando admnistrador de comunidad: ${_admin}`)
_admin.community_id = communityId;
console.log(`Actualizando admnistrador de comunidad: ${_admin}`)
fetch(`http://localhost:4000/user/updateAdminCommunity/${_admin._id}`, {
cache: 'no-cache',
@ -320,7 +320,7 @@ const AdministradoresComunidad = () => {
listaAdmin();
setCommunityId('');
setAdminDialog(false)
setAdminCommunity(emptyAdminCommunity);
})
}

View File

@ -164,6 +164,8 @@ const AdministradoresSistema = () => {
function (response) {
_administrators.push(_admin);
setAdministrators(_administrators)
setFormAdminDialog(false)
}
)
.catch(

View File

@ -49,6 +49,7 @@ const Communities = () => {
const [editCommunityDialog, setEditCommunityDialog] = useState(false);
const toast = useRef(null);
const dt = useRef(null);
const [formCommunityDialog, setFormCommunityDialog] = useState(false);
@ -263,6 +264,7 @@ const Communities = () => {
setCantonId('');
setDistrictId('');
setCodeHouses('');
setFormCommunityDialog(false);
setCommunity(emptyCommunity);
})
@ -335,6 +337,16 @@ const Communities = () => {
setEditCommunityDialog(true);
};
const openNewCommunity = () => {
setCommunity({ emptyCommunity });
setFormCommunityDialog(true);
};
const hideFormCommunityDialog = () => {
setCommunity({ emptyCommunity });
setFormCommunityDialog(false);
};
//desactivar o activar una comunidad
const cambiarEstadoCommunity = () => {
if (community.status == '1') {
@ -489,6 +501,12 @@ const Communities = () => {
return (
<React.Fragment>
<div className="my-2">
<Button
label="Agregar Comunidad"
icon="pi pi-plus"
className="p-button-primary mr-2"
onClick={openNewCommunity}
/>
<Button
label="Eliminar"
icon="pi pi-trash"
@ -539,6 +557,25 @@ const Communities = () => {
</>
);
const formCommunityDialogFooter = (
<>
<Button
label={'Registrar'}
icon="pi pi-check"
className="p-button-primary"
onClick={saveCommunity}
/>
<Button
label="Cerrar"
icon="pi pi-times"
className="p-button-text"
onClick={hideFormCommunityDialog}
/>
</>
);
const deleteCommunityDialogFooter = (
<>
<Button
@ -654,7 +691,7 @@ const Communities = () => {
<p>
{' '}
<FontAwesomeIcon icon={faHashtag} style={{ color: '#D7A86E' }} />{' '}
Número de viviendas
Cantidad de viviendas
</p>
</>
);
@ -690,6 +727,16 @@ const Communities = () => {
</>
);
const headerCodeHouses = (
<>
<p>
{' '}
<FontAwesomeIcon icon={faHashtag} style={{ color: '#D7A86E' }} />{' '}
Código de vivienda
</p>
</>
);
const statusBodyTemplate = (rowData) => {
return (
<>
@ -731,14 +778,14 @@ const Communities = () => {
value={communitiesList}
dataKey="_id"
paginator
rows={5}
rows={10}
selection={selectedCommunities}
onSelectionChange={(e) => setSelectedCommunities(e.value)}
scrollable
scrollHeight="400px"
scrollHeight="800px"
scrollDirection="both"
header={header}
rowsPerPageOptions={[5, 10, 25]}
rowsPerPageOptions={[10, 20, 30]}
className="datatable-responsive mt-3"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords} comunidades de viviendas"
@ -773,11 +820,6 @@ const Communities = () => {
header={headerDistrict}
style={{ flexGrow: 1, flexBasis: '160px' }}
></Column>
<Column
field="phone"
header={headerPhone}
style={{ flexGrow: 1, flexBasis: '180px' }}
></Column>
<Column
field="num_houses"
sortable
@ -799,7 +841,7 @@ const Communities = () => {
</Column>
<Column
body={actionsCommunity}
style={{ flexGrow: 1, flexBasis: '100px' }}
style={{ flexGrow: 1, flexBasis: '160px' }}
></Column>
</DataTable>
@ -815,10 +857,11 @@ const Communities = () => {
<div className='container text-center'>
<div className='row my-4'>
<div className=" col-12 md:col-12">
<p>Nombre</p>
<i className="pi pi-home icon-khaki"></i>
<p><strong>Nombre</strong></p>
<div className="p-0 col-2 md:col-2" style={{ margin: '0 auto' }}>
<div className="p-inputgroup align-items-center justify-content-evenly">
<i className="pi pi-home icon-khaki"></i>
<p>{community.name}</p>
</div>
</div>
@ -826,20 +869,22 @@ const Communities = () => {
</div>
<div className='row my-5'>
<div className=" col-6 md:col-6">
<p>Administrador</p>
<i className="pi pi-user icon-khaki"></i>
<p><strong>Administrador</strong></p>
<div className="p-0 col-6 md:col-6" style={{ margin: '0 auto' }}>
<div className="p-inputgroup align-items-center justify-content-evenly">
<i className="pi pi-user icon-khaki"></i>
<p>{community.name_admin}</p>
</div>
</div>
</div>
<div className=" col-6 md:col-6">
<p>Teléfono Administrativo</p>
<i className="pi pi-phone icon-khaki"></i>
<p><strong>Teléfono Administrativo</strong></p>
<div className="p-0 col-6 md:col-6" style={{ margin: '0 auto' }}>
<div className="p-inputgroup align-items-center justify-content-evenly">
<i className="pi pi-phone icon-khaki"></i>
<p>{community.phone}</p>
</div>
@ -849,30 +894,33 @@ const Communities = () => {
<div className='row my-5'>
<div className=" col-4 col-md-4 md:col-4">
<p>Provincia</p>
<div className="p-0 col-10 md:col-10">
<div className="p-inputgroup align-items-center justify-content-evenly">
<i className="pi pi-map-marker icon-khaki"></i>
<p><strong>Provincia</strong></p>
<div className="p-0 col-12 md:col-12">
<div className="p-inputgroup align-items-center justify-content-evenly">
<p>{community.province}</p>
</div>
</div>
</div>
<div className=" col-4 md:col-4">
<p>Cantón</p>
<div className="p-0 col-10 md:col-10">
<div className="p-inputgroup align-items-center justify-content-evenly">
<i className="pi pi-map-marker icon-khaki"></i>
<p><strong>Cantón</strong></p>
<div className="p-0 col-12 md:col-12">
<div className="p-inputgroup align-items-center justify-content-evenly">
<p>{community.canton}</p>
</div>
</div>
</div>
<div className=" col-4 md:col-4">
<p>Distrito</p>
<div className="p-0 col-10 md:col-10">
<div className="p-inputgroup align-items-center justify-content-evenly">
<i className="pi pi-map-marker icon-khaki"></i>
<p><strong>Distrito</strong></p>
<div className="p-0 col-12 md:col-12">
<div className="p-inputgroup align-items-center justify-content-evenly">
<p>{community.district}</p>
</div>
@ -881,10 +929,11 @@ const Communities = () => {
</div>
<div className='row my-5'>
<div className=" col-12 md:col-12">
<p>Número de Viviendas</p>
<i className="pi pi-hashtag icon-khaki"></i>
<p><strong>Cantidad de viviendas</strong></p>
<div className="p-0 col-2 md:col-2" style={{ margin: '0 auto' }}>
<div className="p-inputgroup justify-content-evenly">
<i className="pi pi-hashtag icon-khaki"></i>
<p>{community.num_houses}</p>
</div>
</div>
@ -912,7 +961,7 @@ const Communities = () => {
>
<Column
field="number_house"
header={headerNumberHouses}
header={headerCodeHouses}
style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px' }}
></Column>
<Column
@ -991,11 +1040,14 @@ const Communities = () => {
)}
</div>
</Dialog>
</div>
</div>
<div className="col-12">
<div className="card">
<h5>Registro de comunidad de viviendas</h5>
<Dialog
visible={formCommunityDialog}
style={{ width: '850px' }}
header="Mantenimiento de comunidad de viviendas"
modal
footer={formCommunityDialogFooter}
onHide={hideFormCommunityDialog}
>
<div className="p-fluid formgrid grid">
<div className="field col-12 md:col-12">
<label htmlFor="name">Nombre</label>
@ -1168,14 +1220,9 @@ const Communities = () => {
)}
</div>
</div>
<div className="col-12 md:col-12 py-2">
<Button
label="Registrar"
icon="pi pi-check"
onClick={saveCommunity}
></Button>
</div>
</div>
</Dialog>
</div>
</div>
</div>

View File

@ -99,6 +99,8 @@ const GuardasSeguridad = () => {
return response.json();
}).then(() => {
listaGuardasF();
setFormGuardDialog(false)
setGuarda(emptyGuarda)
}).catch(
err => console.log('Ocurrió un error con el fetch', err)
);
@ -123,6 +125,8 @@ const GuardasSeguridad = () => {
detail: 'Guarda actualizado correctamente'
});
setGuarda(emptyGuarda);
setFormGuardDialog(false)
listaGuardasF();
})
}

View File

@ -157,6 +157,8 @@ const Inquilinos = () => {
setTenants(_tenants)
setTenant(emptyTenant)
setHouseNumber('')
setTenantDialog(false)
})
.catch((error) => console.log(`Ocurrió un error: ${error}`))
} else setSubmitted(true)
@ -195,6 +197,8 @@ const Inquilinos = () => {
tenantsList()
setTenant(emptyTenant)
setHouseNumber('')
setTenantDialog(false)
})
}
}

View File

@ -171,41 +171,35 @@ const InvitadosComunidad = () => {
globalFilter={globalFilter}
emptyMessageTemplate="No se encontraron invitados"
>
<Column field="name" header="Nombre" sortable header={headerName} />
<Column field="name" sortable header={headerName} />
<Column
field="last_name"
header="Apellido"
sortable
header={headerLastName}
/>
<Column field="dni" header="DNI" sortable header={headerDNI} />
<Column field="dni" sortable header={headerDNI} />
<Column
field="number_plate"
header="Placa"
sortable
header={headerPlate}
/>
<Column
field="telefono"
header="Teléfono"
sortable
header={headerPhone}
/>
<Column
field="email"
header="Email"
sortable
header={headerEmail}
/>
<Column
field="date_entry"
header="Fecha de registro"
sortable
header={headerName}
/>
<Column
field="tenant_name"
header="Inquilino"
sortable
header={headerTenant}
/>