From ce8e16e13571920daddf1f24e84ff4c11b6595f7 Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 2 Aug 2022 22:38:54 -0600 Subject: [PATCH 1/8] agregar filtros para comunidades eliminadas --- web-ui/web-react/src/components/Inquilinos.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/web-ui/web-react/src/components/Inquilinos.js b/web-ui/web-react/src/components/Inquilinos.js index 78fa76df..879c2cba 100644 --- a/web-ui/web-react/src/components/Inquilinos.js +++ b/web-ui/web-react/src/components/Inquilinos.js @@ -34,7 +34,8 @@ const Inquilinos = () => { number_house: 'Sin número de vivienda', user_type: '4', date_entry: new Date(), - status: '1' + status: '1', + status_text: '', }; const [tenants, setTenants] = useState([]); @@ -50,6 +51,7 @@ const Inquilinos = () => { const dt = useRef(null); const [cookies, setCookie] = useCookies(); + const [changeStatusTenantDialog, setChangeStatusTenantDialog] = useState(false); async function tenantsList() { @@ -72,7 +74,9 @@ const Inquilinos = () => { let response = await fetch('http://localhost:4000/community/allCommunities', { method: 'GET' }); let resList = await response.json(); let list = await resList.message; - + list = await list.filter( + (val) => val.status != -1, + ) setCommunitiesList(await list); } From 8428463a9ed2875636a357f70f0f815ed7edd342 Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 2 Aug 2022 22:46:15 -0600 Subject: [PATCH 2/8] Funcionalidad cambiar estado de inquilino --- web-ui/web-react/src/components/Inquilinos.js | 127 +++++++++++++++++- 1 file changed, 122 insertions(+), 5 deletions(-) diff --git a/web-ui/web-react/src/components/Inquilinos.js b/web-ui/web-react/src/components/Inquilinos.js index 879c2cba..f693cb8d 100644 --- a/web-ui/web-react/src/components/Inquilinos.js +++ b/web-ui/web-react/src/components/Inquilinos.js @@ -59,9 +59,18 @@ const Inquilinos = () => { .then((response) => response.json()) .then(data => data.message) .then(data => { - + data = data.filter( + (val) => val.status != -1, + ) data.map((item) => { - if(item.number_house ==""){ + if (item.status == '1') { + item.status_text = 'Activo'; + } else if (item.status == '0') { + item.status_text = 'Inactivo'; + } + + + if (item.number_house == "") { item.number_house = "Sin vivienda asignada"; } }) @@ -193,6 +202,50 @@ const Inquilinos = () => { }); }; + const cambiarStatusUser = () => { + if (tenant.status == '1') { + tenant.status = '0'; + tenant.status_text = 'Inactivo'; + + } else if (tenant.status == '0') { + tenant.status = '1'; + tenant.status_text = 'Activo'; + } + var data = { + id: tenant._id, + status: tenant.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) { + setChangeStatusTenantDialog(false); + toast.current.show({ + severity: 'success', + summary: 'Éxito', + detail: 'Inquilino Actualizado', + life: 3000, + }); + } + ) + .catch( + err => console.log('Ocurrió un error con el fetch', err) + ); + } const hideDeleteTenantDialog = () => { setDeleteTenantDialog(false); @@ -211,11 +264,37 @@ const Inquilinos = () => { setDeleteTenantsDialog(true); }; + const hideChangeStatusTenantDialog = () => { + setChangeStatusTenantDialog(false); + }; + + const confirmChangeStatusTenant = (tenant) => { + setTenant(tenant); + setChangeStatusTenantDialog(true); + }; const actionsTenant = (rowData) => { + let icono = ''; + let text = ''; + if (rowData.status == '0') { + icono = "pi pi-eye"; + text = "Activar Inquilino" + } else if (rowData.status == '1') { + icono = "pi pi-eye-slash"; + text = "Inactivar Inquilino" + + } return (
-
); } @@ -262,6 +341,24 @@ const Inquilinos = () => { ); + + const changeStatusTenantDialogFooter = ( + <> + diff --git a/web-ui/web-react/src/components/Inquilinos.js b/web-ui/web-react/src/components/Inquilinos.js index 8f461bb5..26971e1f 100644 --- a/web-ui/web-react/src/components/Inquilinos.js +++ b/web-ui/web-react/src/components/Inquilinos.js @@ -491,7 +491,7 @@ const Inquilinos = () => {
- +
From f2e019361d8e28f8c76271bd7e4866e5771f0913 Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 2 Aug 2022 23:58:45 -0600 Subject: [PATCH 7/8] mostrar informacion del guarda --- .../src/components/GuardasSeguridad.js | 136 +++++++++++++++--- 1 file changed, 119 insertions(+), 17 deletions(-) diff --git a/web-ui/web-react/src/components/GuardasSeguridad.js b/web-ui/web-react/src/components/GuardasSeguridad.js index d09b09fc..f9c7054e 100644 --- a/web-ui/web-react/src/components/GuardasSeguridad.js +++ b/web-ui/web-react/src/components/GuardasSeguridad.js @@ -15,8 +15,23 @@ import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons'; import { useCookies } from "react-cookie"; const GuardasSeguridad = () => { + + let emptyGuarda = { + _id: null, + dni: '', + name: '', + last_name: '', + email: '', + phone: '', + password: '', + user_type: '1', + status: '1', + status_text: '', + }; + + const [listaGuardas, setListaGuardas] = useState([]); - const [urlFetch, setUrlFetch] = useState('http://localhost:4000/user/findGuards/62be68215692582bbfd77134'); + const [urlFetch, setUrlFetch] = useState('http://localhost:4000/user/findGuards/'); const [guarda, setGuarda] = useState(emptyGuarda); const [selectedGuardas, setSelectedGuardas] = useState(null); const [globalFilter, setGlobalFilter] = useState(null); @@ -28,23 +43,12 @@ const GuardasSeguridad = () => { const [cookies, setCookie] = useCookies(); const [changeStatusGuardDialog, setChangeStatusGuardDialog] = useState(false); - let emptyGuarda = { - _id: null, - dni: '', - name: '', - last_name: '', - email: '', - phone: '', - password: '', - user_type: '1', - status: '', - status_text: '', - }; - + const [guardDialog, setGuardDialog] = useState(false); + const [submitted, setSubmitted] = useState(false); async function listaGuardasF() { - let nombres = await fetch(urlFetch, { method: 'GET' }); + let nombres = await fetch((urlFetch + cookies.community_id), { method: 'GET' }); let listaGuardasRes = await nombres.json(); let data = await listaGuardasRes.message.filter( (val) => val.status != -1, @@ -58,6 +62,7 @@ const GuardasSeguridad = () => { }) setListaGuardas(await data); } + useEffect(() => { listaGuardasF(); }, []) @@ -236,8 +241,18 @@ const GuardasSeguridad = () => { setChangeStatusGuardDialog(true); }; + const hideGuardDialog = () => { + setSubmitted(false); + setGuardDialog(false); + }; - const actionsAdmin = (rowData) => { + const infoGuard = (guard) => { + setGuarda(guard); + setGuardDialog(true); + }; + + + const actionsGuard = (rowData) => { let icono = ''; let text = ''; if (rowData.status == '0') { @@ -250,6 +265,11 @@ const GuardasSeguridad = () => { } return (
+