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' }) @MessagePattern({ cmd: 'updateAdminCommunity' })
updateAdminCommunity(@Payload() user: UserDocument) { updateAdminCommunity(@Payload() user: UserDocument) {
return this.userService.update(user._id, user); console.log(user)
return this.userService.updateAdminCommunity(user['_id'], user);
} }
@MessagePattern({ cmd: 'updateTenant' }) @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) { async updateTenant(id: string, user: UserDocument) {
await this.saveTenant(user.community_id, user.number_house, user.id); 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 }); toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador de Comunidad de vivienda Creada', life: 3000 });
setListaAdmins(_administrators); setListaAdmins(_administrators);
setAdminDialog(false)
setAdminCommunity(emptyAdminCommunity); setAdminCommunity(emptyAdminCommunity);
@ -296,7 +297,6 @@ const AdministradoresComunidad = () => {
} else { } else {
console.log(`Actualizando admnistrador de comunidad: ${_admin}`) console.log(`Actualizando admnistrador de comunidad: ${_admin}`)
_admin.community_id = communityId; _admin.community_id = communityId;
console.log(`Actualizando admnistrador de comunidad: ${_admin}`)
fetch(`http://localhost:4000/user/updateAdminCommunity/${_admin._id}`, { fetch(`http://localhost:4000/user/updateAdminCommunity/${_admin._id}`, {
cache: 'no-cache', cache: 'no-cache',
@ -320,7 +320,7 @@ const AdministradoresComunidad = () => {
listaAdmin(); listaAdmin();
setCommunityId(''); setCommunityId('');
setAdminDialog(false)
setAdminCommunity(emptyAdminCommunity); setAdminCommunity(emptyAdminCommunity);
}) })
} }

View File

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

View File

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

View File

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

View File

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

View File

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