actualizar administrador de comunidad

This commit is contained in:
Mariela 2022-08-22 20:08:37 -06:00
parent f8909acc54
commit 01bd394a0d
4 changed files with 25 additions and 5 deletions

View File

@ -243,7 +243,7 @@ export class AppController {
@Put('user/updateAdminCommunity/:id') @Put('user/updateAdminCommunity/:id')
updateAdminCommunity( updateAdminCommunity(
@Param('_id') id: string, @Param('id') id: string,
@Body('dni') dni: string, @Body('dni') dni: string,
@Body('name') name: string, @Body('name') name: string,
@Body('last_name') last_name: string, @Body('last_name') last_name: string,

View File

@ -153,7 +153,7 @@ export class AppService {
.pipe(map((message: string) => ({ message }))); .pipe(map((message: string) => ({ message })));
} }
updateAdminCommunity( updateAdminCommunity(
_id: string, id: string,
dni: string, dni: string,
name: string, name: string,
last_name: string, last_name: string,
@ -163,7 +163,7 @@ export class AppService {
) { ) {
const pattern = { cmd: 'updateAdminCommunity' }; const pattern = { cmd: 'updateAdminCommunity' };
const payload = { const payload = {
id: _id, _id: id,
dni: dni, dni: dni,
name: name, name: name,
last_name: last_name, last_name: last_name,

View File

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

View File

@ -225,6 +225,24 @@ const AdministradoresComunidad = () => {
); );
} }
const findIndexById = (id) => {
let index = -1;
for (let i = 0; i < listaAdmins.length; i++) {
if (listaAdmins[i]._id === id) {
index = i;
break;
}
}
return index;
}
const findRepeated = (name, value) => {
let _administrators = [...listaAdmins];
let value_filtered = _administrators.filter(item => item[`${name}`] === value);
return value_filtered.length
}
const saveAdminCommunity = () => { const saveAdminCommunity = () => {
let _administrators = [...listaAdmins]; let _administrators = [...listaAdmins];
let _admin = { ...adminCommunity }; let _admin = { ...adminCommunity };
@ -289,16 +307,16 @@ const AdministradoresComunidad = () => {
console.log(`Hubo un error en el servicio: ${response.status}`) console.log(`Hubo un error en el servicio: ${response.status}`)
else return response.json() else return response.json()
}).then(() => { }).then(() => {
toast.current.show({ toast.current.show({
severity: 'success', severity: 'success',
summary: 'Éxito', summary: 'Éxito',
detail: 'Administrador de comunidad actualizado', detail: 'Administrador de comunidad actualizado',
life: 3000, life: 3000,
}) })
_administrators.push(_admin);
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador de Comunidad de vivienda Actualizada', life: 3000 }); toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador de Comunidad de vivienda Actualizada', life: 3000 });
setListaAdmins(_administrators); listaAdmin();
setAdminCommunity(emptyAdminCommunity); setAdminCommunity(emptyAdminCommunity);
}) })
@ -343,6 +361,7 @@ const AdministradoresComunidad = () => {
const cancelEdit = () => { const cancelEdit = () => {
setAdminCommunity(emptyAdminCommunity); setAdminCommunity(emptyAdminCommunity);
setSaveButtonTitle('Registrar'); setSaveButtonTitle('Registrar');
setC
} }
const actionsAdminCommunity = (rowData) => { const actionsAdminCommunity = (rowData) => {