diff --git a/web-ui/web-react/src/components/AdministradoresSistema.js b/web-ui/web-react/src/components/AdministradoresSistema.js index 7cc7688a..92fdf59f 100644 --- a/web-ui/web-react/src/components/AdministradoresSistema.js +++ b/web-ui/web-react/src/components/AdministradoresSistema.js @@ -5,16 +5,19 @@ import { DataTable } from 'primereact/datatable'; import { Column } from 'primereact/column'; import { Toast } from 'primereact/toast'; import { Dialog } from 'primereact/dialog'; +import { Toolbar } from 'primereact/toolbar'; const AdministradoresSistema = () => { const [administrators, setAdministrators] = useState([]); const [urlFetch, setUrlFetch] = useState('http://localhost:4000/user/findAdminSistema/'); const [sysadmin, setSysAdmin] = useState(emptySysAdmin); - + const [selectedAdministrators, setSelectedAdministrators] = useState(null); + const [globalFilter, setGlobalFilter] = useState(null); const [deleteAdminSystemDialog, setDeleteAdminSystemDialog] = useState(false); const [deleteAdminsSystemDialog, setDeleteAdminsSystemDialog] = useState(false); const toast = useRef(null); + const dt = useRef(null); let emptySysAdmin = { @@ -95,11 +98,12 @@ const AdministradoresSistema = () => { setDeleteAdminSystemDialog(true); } + const confirmDeleteSelected = () => { + setDeleteAdminsSystemDialog(true); + } + const deleteSysAdmin = () => { - var data = { - id: sysadmin._id - } fetch('http://localhost:4000/user/deleteAdminSystem/' + sysadmin._id, { cache: 'no-cache', method: 'DELETE', @@ -109,7 +113,7 @@ const AdministradoresSistema = () => { }) .then( function (response) { - if (response.status != 201 ) + if (response.status != 201) console.log('Ocurrió un error con el servicio: ' + response.status); else return response.json(); @@ -120,10 +124,10 @@ const AdministradoresSistema = () => { let _sysadmin = administrators.filter(val => val._id !== sysadmin._id); setAdministrators(_sysadmin); - setDeleteAdminSystemDialog(false); - setSysAdmin(emptySysAdmin); - - toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador del Sistema Eliminado', life: 3000 }); + setDeleteAdminSystemDialog(false); + setSysAdmin(emptySysAdmin); + + toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador del Sistema Eliminado', life: 3000 }); } ) .catch( @@ -132,19 +136,62 @@ const AdministradoresSistema = () => { toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Administrador del Sistema no se pudo eliminar', life: 3000 }); } ); - - - } + const deleteSelectedAdminsSystem = () => { + let _administrators = administrators.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' + } + }) + }) + setAdministrators(_administrators); + setDeleteAdminsSystemDialog(false); + setSelectedAdministrators(null); + toast.current.show({ severity: 'success', summary: 'Successful', detail: 'Products Deleted', life: 3000 }); + } + + const actionsAdmin = (rowData) => { return (
-
); } + const leftToolbarTemplate = () => { + return ( + +
+
+
+ ) + } + + const rightToolbarTemplate = () => { + return ( + +