fixes en administradores de comunidad
This commit is contained in:
parent
1629edc32a
commit
51d76c9841
|
@ -155,6 +155,10 @@ const AdministradoresComunidad = () => {
|
|||
setDeleteAdminCommunityDialog(true);
|
||||
}
|
||||
|
||||
const confirmDeleteSelected = () => {
|
||||
setDeleteAdminsCommunitiesDialog(true);
|
||||
}
|
||||
|
||||
|
||||
const actionsAdminCommunity = (rowData) => {
|
||||
return (
|
||||
|
@ -178,6 +182,36 @@ const AdministradoresComunidad = () => {
|
|||
</>
|
||||
);
|
||||
|
||||
|
||||
const leftToolbarTemplate = () => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="my-2">
|
||||
<Button label="Eliminar" icon="pi pi-trash" className="p-button-danger" onClick={confirmDeleteSelected} disabled={!selectedAdminsCommunities || !selectedAdminsCommunities.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 de Comunidades</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 headerName = (
|
||||
<>
|
||||
<p> <FontAwesomeIcon icon={faUserAlt} style={{ color: "#C08135" }} /> Nombre</p>
|
||||
|
@ -220,129 +254,6 @@ 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 de Comunidades</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">
|
||||
|
|
Loading…
Reference in New Issue