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 = (
+ <>
+
+
+ >
+ );
+
const leftToolbarTemplate = () => {
return (
+
@@ -562,9 +602,9 @@ const AdministradoresComunidad = () => {
-
setSelectedAdminsCommunities(e.value)}
- scrollable scrollHeight="400px" scrollDirection="both" header={header}
- rowsPerPageOptions={[5, 10, 25]} className="datatable-responsive mt-3"
+ setSelectedAdminsCommunities(e.value)}
+ scrollable scrollHeight="800px" scrollDirection="both" header={header}
+ rowsPerPageOptions={[10, 20, 30]} className="datatable-responsive mt-3"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords} administradores de comunidades de viviendas"
globalFilter={globalFilter} emptyMessage="No hay administradores de comunidades registrados.">
@@ -577,7 +617,7 @@ const AdministradoresComunidad = () => {
-
+
-
-
-
-
-
Registro de un administrador de una comunidad de viviendas
-
-
-
-
-
-
-
-
-
onInputChange(e, 'name')} required autoFocus className={classNames({ 'p-invalid': submitted && adminCommunity.name === '' })} />
+
-
-
-
-
-
-
-
-
onInputChange(e, 'last_name')} required autoFocus className={classNames({ 'p-invalid': submitted && adminCommunity.last_name === '' })} />
+
+
+
+
+
+
+
+ onInputChange(e, 'last_name')} required autoFocus className={classNames({ 'p-invalid': submitted && adminCommunity.last_name === '' })} />
+
+ {submitted && adminCommunity.last_name === '' &&
Apellidos es requirido.}
+
- {submitted && adminCommunity.last_name === '' && Apellidos es requirido.}
-
-
-
-
-
-
-
-
-
-
onInputChange(e, 'email')} required autoFocus
- className={classNames({ 'p-invalid': submitted &&
- (adminCommunity.email === '' || findRepeated('email', adminCommunity.email) > 0) })} />
+
+
+
+
+
+
+
+ onInputChange(e, 'email')} required autoFocus
+ className={classNames({
+ 'p-invalid': submitted &&
+ (adminCommunity.email === '' || findRepeated('email', adminCommunity.email) > 0)
+ })} />
+
+ {submitted && adminCommunity.email === '' &&
Correo electrónico
+ es requirido.}
+ {submitted && findRepeated('email', adminCommunity.email) > 0 &&
+
Correo electrónico se encuentra repetido.
+ }
+
- {submitted && adminCommunity.email === '' && Correo electrónico
- es requirido.}
- {submitted && findRepeated('email', adminCommunity.email) > 0 &&
- Correo electrónico se encuentra repetido.
- }
-
-
-
-
-
-
-
-
-
-
onInputChange(e, 'dni')} required autoFocus
- className={classNames({ 'p-invalid': submitted
- && (adminCommunity.dni === '' || findRepeated('dni', adminCommunity.dni) > 0)})} />
+
+
+
+
+
+
+
+ onInputChange(e, 'dni')} required autoFocus
+ className={classNames({
+ 'p-invalid': submitted
+ && (adminCommunity.dni === '' || findRepeated('dni', adminCommunity.dni) > 0)
+ })} />
+
+ {submitted && adminCommunity.dni === '' &&
Identificación es requirida.}
+ {submitted && findRepeated('dni', adminCommunity.dni) > 0 &&
+
Identificación se encuentra repetida.
+ }
+
- {submitted && adminCommunity.dni === '' && Identificación es requirida.}
- {submitted && findRepeated('dni', adminCommunity.dni) > 0 &&
- Identificación se encuentra repetida.
- }
-
-
-
-
-
-
-
-
-
-
onInputChange(e, 'phone')} required autoFocus className={classNames({ 'p-invalid': submitted && adminCommunity.phone === '' })} />
+
+
+
+
+
+
+
+ onInputChange(e, 'phone')} required autoFocus className={classNames({ 'p-invalid': submitted && adminCommunity.phone === '' })} />
+
+ {submitted && adminCommunity.phone === '' &&
Número de teléfono es requirida.}
+
- {submitted && adminCommunity.phone === '' && Número de teléfono es requirida.}
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ {submitted && !communityId &&
Comunidad es requirida.}
+
- {submitted && !communityId &&
Comunidad es requirida.}
-
-
-
-
- {saveButtonTitle === 'Actualizar' && (
- )}
-
+
-
+
+ )}
+
diff --git a/web-ui/web-react/src/components/AdministradoresSistema.js b/web-ui/web-react/src/components/AdministradoresSistema.js
index a3f47866..319d9ec3 100644
--- a/web-ui/web-react/src/components/AdministradoresSistema.js
+++ b/web-ui/web-react/src/components/AdministradoresSistema.js
@@ -50,7 +50,7 @@ const AdministradoresSistema = () => {
const [adminDialog, setAdminDialog] = useState(false);
const [submitted, setSubmitted] = useState(false);
- const [editAdminDialog, setEditAdminDialog] = useState(false);
+ const [formAdminDialog, setFormAdminDialog] = useState(false);
const [saveButtonTitle, setSaveButtonTitle] = useState("Registrar")
@@ -136,7 +136,7 @@ const AdministradoresSistema = () => {
life: 3000,
});
setAdministrators(_administrators)
- setEditAdminDialog(false);
+ setFormAdminDialog(false);
setSysAdmin(emptySysAdmin);
}
)
@@ -164,6 +164,8 @@ const AdministradoresSistema = () => {
function (response) {
_administrators.push(_admin);
setAdministrators(_administrators)
+ setFormAdminDialog(false)
+
}
)
.catch(
@@ -267,7 +269,23 @@ const AdministradoresSistema = () => {
const editAdmin = (sysadmin) => {
setSysAdmin({ ...sysadmin });
setSaveButtonTitle('Actualizar');
+ setFormAdminDialog(true)
+
};
+ const openNewAdmin = () => {
+ setSysAdmin(emptySysAdmin);
+ setFormAdminDialog(true)
+ setSubmitted(false);
+ };
+
+ const hideFormAdminDialog = () => {
+ setSubmitted(false);
+ setFormAdminDialog(false)
+ setSysAdmin(emptySysAdmin);
+ setSaveButtonTitle('Registrar');
+
+ };
+
const deleteSysAdmin = () => {
fetch('http://localhost:4000/user/deleteAdminSystem/' + sysadmin._id, {
@@ -386,6 +404,12 @@ const AdministradoresSistema = () => {
return (
+
-
-
-
-
-
-
Mantenimiento Administrador del Sistema
-
+
+
-
+
);
};
diff --git a/web-ui/web-react/src/components/AreasComunes.js b/web-ui/web-react/src/components/AreasComunes.js
index b8c2b0f9..c74e2e3a 100644
--- a/web-ui/web-react/src/components/AreasComunes.js
+++ b/web-ui/web-react/src/components/AreasComunes.js
@@ -608,7 +608,6 @@ const AreasComunes = () => {
);
};
-
function compareTimesMinRequired(hour1, hour2) {
var timeFormat1 = Number(hour1.replace(/[:]/g, ''));
var timeFormat2 = Number(hour2.replace(/[:]/g, ''));
@@ -619,10 +618,6 @@ const AreasComunes = () => {
}
}
-
-
-
-
return (
@@ -641,7 +636,7 @@ const AreasComunes = () => {
-
+