Merge remote-tracking branch 'origin/dev' into US-listarInquilinos

This commit is contained in:
Mariela 2022-07-24 17:40:02 -06:00
commit 90c329a806
3 changed files with 132 additions and 10 deletions

View File

@ -50,6 +50,7 @@ import './assets/demo/Demos.scss';
import './assets/layout/layout.scss';
import './App.scss';
import LogIn from './components/LogIn';
import {PrimeIcons} from 'primereact/api';
const App = () => {
const [layoutMode, setLayoutMode] = useState('static');
@ -166,11 +167,11 @@ const App = () => {
label: 'Home',
items: [
{label: 'Dashboard', icon: 'pi pi-fw pi-home', to: '/'},
{label: 'Administradores del sistema', icon: 'pi pi-fw pi-id-card', to: '/administradoresSistema'},
{label: 'Administradores de comunidad', icon: 'pi pi-fw pi-id-card', to: '/administradoresComunidad'},
{label: 'Guardas de seguridad', icon: 'pi pi-fw pi-id-card', to: '/guardasSeguridad'},
{label: 'Comunidadades', icon: 'pi pi-fw pi-id-card', to: '/comunidadesViviendas'},
{label: 'Inquilinos', icon: 'pi pi-fw pi-id-card', to: '/inquilinos'},
{label: 'Administradores del sistema', icon: PrimeIcons.USERS, to: '/administradoresSistema'},
{label: 'Administradores de comunidad', icon: PrimeIcons.USERS, to: '/administradoresComunidad'},
{label: 'Guardas de seguridad', icon: PrimeIcons.LOCK, to: '/guardasSeguridad'},
{label: 'Comunidadades', icon: PrimeIcons.BUILDING, to: '/comunidadesViviendas'},
{label: 'Inquilinos', icon: PrimeIcons.USER, to: '/inquilinos'},
{label: 'Log in', icon: 'pi pi-fw pi-id-card', to: '/logIn'}
]
},

View File

@ -249,6 +249,129 @@ const AdministradoresComunidad = () => {
</>
)
const hideDeleteAdminSystemDialog = () => {
setDeleteAdminSystemDialog(false);
}
const hideDeleteAdminsSystemsDialog = () => {
setDeleteAdminsSystemDialog(false);
}
const confirmDeleteAdminSystem = (sysAdmin) => {
setSysAdmin(sysAdmin);
setDeleteAdminSystemDialog(true);
}
const confirmDeleteSelected = () => {
setDeleteAdminsSystemDialog(true);
}
const deleteSysAdmin = () => {
fetch('http://localhost:4000/user/deleteAdminSystem/' + sysadmin._id, {
cache: 'no-cache',
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
}
})
.then(
function (response) {
if (response.status != 201)
console.log('Ocurrió un error con el servicio: ' + response.status);
else
return response.json();
}
)
.then(
function (response) {
let _sysadmin = listaAdmins.filter(val => val._id !== sysadmin._id);
setListaAdmins(_sysadmin);
setDeleteAdminSystemDialog(false);
setSysAdmin(emptySysAdmin);
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador del Sistema Eliminado', life: 3000 });
}
)
.catch(
err => {
console.log('Ocurrió un error con el fetch', err)
toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Administrador del Sistema no se pudo eliminar', life: 3000 });
}
);
}
const deleteSelectedAdminsSystem = () => {
let _administrators = listaAdmins.filter(val => !selectedAdministrators.includes(val));
selectedAdministrators.map((item) => {
fetch('http://localhost:4000/user/deleteAdminSystem/' + item._id, {
cache: 'no-cache',
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
}
})
})
setListaAdmins(_administrators);
setDeleteAdminsSystemDialog(false);
setSelectedAdministrators(null);
toast.current.show({ severity: 'success', summary: 'Successful', detail: 'Products Deleted', life: 3000 });
}
const actionsAdmin = (rowData) => {
return (
<div className="actions">
<Button icon="pi pi-trash" className="p-button-rounded p-button-danger mt-2" onClick={() => confirmDeleteAdminSystem(rowData)} />
</div>
);
}
const leftToolbarTemplate = () => {
return (
<React.Fragment>
<div className="my-2">
<Button label="Eliminar" icon="pi pi-trash" className="p-button-danger" onClick={confirmDeleteSelected} disabled={!selectedAdministrators || !selectedAdministrators.length} />
</div>
</React.Fragment>
)
}
const rightToolbarTemplate = () => {
return (
<React.Fragment>
<Button label="Exportar" icon="pi pi-upload" className="p-button-help" />
</React.Fragment>
)
}
const header = (
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
<h5 className="m-0">Administradores del sistema <i class="fal fa-user"></i></h5>
<span className="block mt-2 md:mt-0 p-input-icon-left">
<i className="pi pi-search" />
<InputText type="search" onInput={(e) => setGlobalFilter(e.target.value)} placeholder="Buscar..." />
</span>
</div>
);
const deleteAdminSystemDialogFooter = (
<>
<Button label="No" icon="pi pi-times" className="p-button-text" onClick={hideDeleteAdminSystemDialog} />
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteSysAdmin} />
</>
);
const deleteAdminsSystemDialogFooter = (
<>
<Button label="No" icon="pi pi-times" className="p-button-text" onClick={hideDeleteAdminsSystemsDialog} />
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteSelectedAdminsSystem} />
</>
);
return (
<div className="grid">
<div className="col-12">
@ -286,8 +409,6 @@ const AdministradoresComunidad = () => {
</div>
</div>
</div>
)
}

View File

@ -187,7 +187,7 @@ const AdministradoresSistema = () => {
const header = (
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
<h5 className="m-0">Administradores del sistema</h5>
<h5 className="m-0">Administradores del sistema <i class="fal fa-user"></i></h5>
<span className="block mt-2 md:mt-0 p-input-icon-left">
<i className="pi pi-search" />
<InputText type="search" onInput={(e) => setGlobalFilter(e.target.value)} placeholder="Buscar..." />