diff --git a/servicio-usuarios/src/users/users.controller.ts b/servicio-usuarios/src/users/users.controller.ts index 0bf8f960..71173308 100644 --- a/servicio-usuarios/src/users/users.controller.ts +++ b/servicio-usuarios/src/users/users.controller.ts @@ -82,7 +82,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' }) diff --git a/servicio-usuarios/src/users/users.service.ts b/servicio-usuarios/src/users/users.service.ts index 0e5a3dff..6e59353f 100644 --- a/servicio-usuarios/src/users/users.service.ts +++ b/servicio-usuarios/src/users/users.service.ts @@ -134,6 +134,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); diff --git a/web-ui/web-react/src/components/AdministradoresComunidad.js b/web-ui/web-react/src/components/AdministradoresComunidad.js index 42b24186..ef8cdd92 100644 --- a/web-ui/web-react/src/components/AdministradoresComunidad.js +++ b/web-ui/web-react/src/components/AdministradoresComunidad.js @@ -50,6 +50,7 @@ const AdministradoresComunidad = () => { const [changeStatusAdminCommunityDialog, setChangeStatusAdminCommunityDialog] = useState(false); const [saveButtonTitle, setSaveButtonTitle] = useState("Registrar"); + const [adminDialog, setAdminDialog] = useState(false); async function listaAdmin() { @@ -280,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); @@ -295,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', @@ -319,7 +320,7 @@ const AdministradoresComunidad = () => { listaAdmin(); setCommunityId(''); - + setAdminDialog(false) setAdminCommunity(emptyAdminCommunity); }) } @@ -356,6 +357,8 @@ const AdministradoresComunidad = () => { setAdminCommunity(admin); setSaveButtonTitle('Actualizar'); setCommunityId(admin.community_id) + setAdminDialog(true) + } @@ -365,6 +368,20 @@ const AdministradoresComunidad = () => { setCommunityId(''); } + const openNewAdmin = () => { + setAdminCommunity(emptyAdminCommunity); + setAdminDialog(true) + setSubmitted(false); + }; + + const hideAdminDialog = () => { + setSubmitted(false); + setAdminDialog(false) + setAdminCommunity(emptyAdminCommunity); + setSaveButtonTitle('Registrar'); + + }; + const actionsAdminCommunity = (rowData) => { let icono = ''; let text = ''; @@ -431,10 +448,33 @@ const AdministradoresComunidad = () => { ); + const adminDialogFooter = ( + <> +