From e0fe79a1e50d40c0512ca3a120d75ceca3f0e7ba Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 2 Aug 2022 22:22:45 -0600 Subject: [PATCH] agregar columna de estado en la lista --- .../src/components/AdministradoresSistema.js | 52 +++++++++++++++---- .../src/components/ComunidadViviendas.js | 28 +++++----- 2 files changed, 57 insertions(+), 23 deletions(-) diff --git a/web-ui/web-react/src/components/AdministradoresSistema.js b/web-ui/web-react/src/components/AdministradoresSistema.js index c2761b49..40529fc6 100644 --- a/web-ui/web-react/src/components/AdministradoresSistema.js +++ b/web-ui/web-react/src/components/AdministradoresSistema.js @@ -41,14 +41,24 @@ const AdministradoresSistema = () => { password: '', user_type: '1', status: '1', + status_text: '', }; async function fetchP() { let nombres = await fetch(urlFetch, { method: 'GET' }); let adminRes = await nombres.json(); + let data = await adminRes.message.filter( + (val) => val.status != -1, + ) + await data.map((item) => { + if (item.status == '1') { + item.status_text = 'Activo'; + } else if (item.status == '0') { + item.status_text = 'Inactivo'; + } + }) setAdministrators(adminRes.message); - console.log(administrators); } useEffect(() => { fetchP(); @@ -67,7 +77,6 @@ const AdministradoresSistema = () => { status: "1" }; setSysAdmin(data) - // console.log(data); fetch('http://localhost:4000/user/createAdminSystem/', { cache: 'no-cache', @@ -186,7 +195,7 @@ const AdministradoresSistema = () => { let _sysadmin = administrators.filter( (val) => (val._id !== sysadmin._id || val.status != -1), ); - + setAdministrators(_sysadmin); setDeleteAdminSystemDialog(false); setSysAdmin(emptySysAdmin); @@ -235,27 +244,33 @@ const AdministradoresSistema = () => { }); }; - + const actionsAdmin = (rowData) => { - let icono = ''; + let icono = ''; + let text = ''; if (rowData.status == '0') { icono = "pi pi-eye"; + text = "Activar Administrador" } else if (rowData.status == '1') { icono = "pi pi-eye-slash"; + text = "Inactivar Administrador" + } return (
-
); @@ -413,6 +428,18 @@ const AdministradoresSistema = () => { ) + const statusBodyTemplate = (rowData) => { + return ( + <> + + {rowData.status_text} + + + ); + }; + return (
@@ -502,8 +529,15 @@ const AdministradoresSistema = () => { }} > + + diff --git a/web-ui/web-react/src/components/ComunidadViviendas.js b/web-ui/web-react/src/components/ComunidadViviendas.js index 5b607e5e..61c86b41 100644 --- a/web-ui/web-react/src/components/ComunidadViviendas.js +++ b/web-ui/web-react/src/components/ComunidadViviendas.js @@ -696,15 +696,15 @@ const Communities = () => { const statusBodyTemplate = (rowData) => { return ( - <> - - {rowData.status_text} - - + <> + + {rowData.status_text} + + ); -}; + }; const tenantsBodyTemplate = (rowData) => { let tenants = rowData.tenants; @@ -790,12 +790,12 @@ const Communities = () => { header={headerAdministrator} style={{ flexGrow: 1, flexBasis: '180px' }} > - +