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 './assets/layout/layout.scss';
import './App.scss'; import './App.scss';
import LogIn from './components/LogIn'; import LogIn from './components/LogIn';
import {PrimeIcons} from 'primereact/api';
const App = () => { const App = () => {
const [layoutMode, setLayoutMode] = useState('static'); const [layoutMode, setLayoutMode] = useState('static');
@ -166,11 +167,11 @@ const App = () => {
label: 'Home', label: 'Home',
items: [ items: [
{label: 'Dashboard', icon: 'pi pi-fw pi-home', to: '/'}, {label: 'Dashboard', icon: 'pi pi-fw pi-home', to: '/'},
{label: 'Administradores del sistema', icon: 'pi pi-fw pi-id-card', to: '/administradoresSistema'}, {label: 'Administradores del sistema', icon: PrimeIcons.USERS, to: '/administradoresSistema'},
{label: 'Administradores de comunidad', icon: 'pi pi-fw pi-id-card', to: '/administradoresComunidad'}, {label: 'Administradores de comunidad', icon: PrimeIcons.USERS, to: '/administradoresComunidad'},
{label: 'Guardas de seguridad', icon: 'pi pi-fw pi-id-card', to: '/guardasSeguridad'}, {label: 'Guardas de seguridad', icon: PrimeIcons.LOCK, to: '/guardasSeguridad'},
{label: 'Comunidadades', icon: 'pi pi-fw pi-id-card', to: '/comunidadesViviendas'}, {label: 'Comunidadades', icon: PrimeIcons.BUILDING, to: '/comunidadesViviendas'},
{label: 'Inquilinos', icon: 'pi pi-fw pi-id-card', to: '/inquilinos'}, {label: 'Inquilinos', icon: PrimeIcons.USER, to: '/inquilinos'},
{label: 'Log in', icon: 'pi pi-fw pi-id-card', to: '/logIn'} {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 ( return (
<div className="grid"> <div className="grid">
<div className="col-12"> <div className="col-12">
@ -286,9 +409,7 @@ const AdministradoresComunidad = () => {
</div> </div>
</div> </div>
</div> </div>
) )
} }
export default React.memo(AdministradoresComunidad); export default React.memo(AdministradoresComunidad);

View File

@ -187,7 +187,7 @@ const AdministradoresSistema = () => {
const header = ( const header = (
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center"> <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"> <span className="block mt-2 md:mt-0 p-input-icon-left">
<i className="pi pi-search" /> <i className="pi pi-search" />
<InputText type="search" onInput={(e) => setGlobalFilter(e.target.value)} placeholder="Buscar..." /> <InputText type="search" onInput={(e) => setGlobalFilter(e.target.value)} placeholder="Buscar..." />
@ -316,4 +316,4 @@ const comparisonFn = function (prevProps, nextProps) {
return prevProps.location.pathname === nextProps.location.pathname; return prevProps.location.pathname === nextProps.location.pathname;
}; };
export default React.memo(AdministradoresSistema, comparisonFn); export default React.memo(AdministradoresSistema, comparisonFn);