diff --git a/web-ui/web-react/src/components/AdministradoresSistema.js b/web-ui/web-react/src/components/AdministradoresSistema.js index b2eca848..c2761b49 100644 --- a/web-ui/web-react/src/components/AdministradoresSistema.js +++ b/web-ui/web-react/src/components/AdministradoresSistema.js @@ -11,7 +11,7 @@ import { faUserAlt } from '@fortawesome/free-solid-svg-icons'; import { faPhoneAlt } from '@fortawesome/free-solid-svg-icons'; import { faAt } from '@fortawesome/free-solid-svg-icons'; import { faIdCardAlt } from '@fortawesome/free-solid-svg-icons'; -import { faEllipsis } from '@fortawesome/free-solid-svg-icons'; +import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons'; const AdministradoresSistema = () => { const [administrators, setAdministrators] = useState([]); @@ -98,6 +98,51 @@ const AdministradoresSistema = () => { ); } + const cambiarStatusUser = () => { + if (sysadmin.status == '1') { + sysadmin.status = '0'; + sysadmin.status_text = 'Inactivo'; + + } else if (sysadmin.status == '0') { + sysadmin.status = '1'; + sysadmin.status_text = 'Activo'; + } + var data = { + id: sysadmin._id, + status: sysadmin.status, + }; + fetch('http://localhost:4000/user/changeStatus', { + cache: 'no-cache', + method: 'POST', + body: JSON.stringify(data), + 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) { + setChangeStatusAdminSystemDialog(false); + toast.current.show({ + severity: 'success', + summary: 'Éxito', + detail: 'Administrador del Sistema Actualizado', + life: 3000, + }); + } + ) + .catch( + err => console.log('Ocurrió un error con el fetch', err) + ); + } + const confirmDeleteAdminSystem = (sysAdmin) => { setSysAdmin(sysAdmin); setDeleteAdminSystemDialog(true); @@ -115,13 +160,13 @@ const AdministradoresSistema = () => { setDeleteAdminsSystemDialog(false); }; - const confirmChangeStatusAdminSystem = (sysAdmin) => { - setSysAdmin(sysAdmin); - setDeleteAdminSystemDialog(true); + const hideChangeStatusAdminDialog = () => { + setChangeStatusAdminSystemDialog(false); }; - const hideChangeStatusAdminSystemDialog = () => { - setChangeStatusAdminSystemDialog(false); + const confirmChangeStatusAdminSystem = (sysAdmin) => { + setSysAdmin(sysAdmin); + setChangeStatusAdminSystemDialog(true); }; const deleteSysAdmin = () => { @@ -165,7 +210,7 @@ const AdministradoresSistema = () => { const deleteSelectedAdminsSystem = () => { let _administrators = administrators.filter( - (val) => (!selectedAdministrators.includes(val) || val.status != -1), + (val) => (!selectedAdministrators.includes(val)), ); selectedAdministrators.map((item) => { fetch('http://localhost:4000/user/deleteAdminSystem/' + item._id, { @@ -176,7 +221,9 @@ const AdministradoresSistema = () => { }, }); }); - + _administrators = _administrators.filter( + (val) => val.status != -1, + ) setAdministrators(_administrators); setDeleteAdminsSystemDialog(false); setSelectedAdministrators(null); @@ -188,53 +235,21 @@ const AdministradoresSistema = () => { }); }; - const changeStatusAdminSystm = () => { - fetch('http://localhost:4000/user/statusAdminSystem/' + sysadmin._id, { - cache: 'no-cache', - method: 'POST', - 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 = administrators.filter( - (val) => (val._id !== sysadmin._id || val.status != -1), - ); - - setAdministrators(_sysadmin); - setDeleteAdminSystemDialog(false); - setSysAdmin(emptySysAdmin); - toast.current.show({ - severity: 'success', - summary: 'Éxito', - 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 actionsAdmin = (rowData) => { + let icono = ''; + if (rowData.status == '0') { + icono = "pi pi-eye"; + } else if (rowData.status == '1') { + icono = "pi pi-eye-slash"; + } + return (
diff --git a/web-ui/web-react/src/components/ComunidadViviendas.js b/web-ui/web-react/src/components/ComunidadViviendas.js index e220c777..5b607e5e 100644 --- a/web-ui/web-react/src/components/ComunidadViviendas.js +++ b/web-ui/web-react/src/components/ComunidadViviendas.js @@ -12,9 +12,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faHome, faUserAlt } from '@fortawesome/free-solid-svg-icons'; import { faMapLocationDot } from '@fortawesome/free-solid-svg-icons'; import { faPhoneAlt } from '@fortawesome/free-solid-svg-icons'; -import { faEllipsis } from '@fortawesome/free-solid-svg-icons'; import { faHashtag } from '@fortawesome/free-solid-svg-icons'; -import { icon } from '@fortawesome/fontawesome-svg-core'; import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons'; const Communities = () => {