From fa4dc9f410180a46e2430943d594a76ad954c9bd Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 2 Aug 2022 00:00:55 -0600 Subject: [PATCH 01/10] formulario de registro --- .../web-react/src/components/AreasComunes.js | 171 +++++++++++++++++- 1 file changed, 167 insertions(+), 4 deletions(-) diff --git a/web-ui/web-react/src/components/AreasComunes.js b/web-ui/web-react/src/components/AreasComunes.js index 693467df..6eff36e4 100644 --- a/web-ui/web-react/src/components/AreasComunes.js +++ b/web-ui/web-react/src/components/AreasComunes.js @@ -15,7 +15,7 @@ import { faIdCardAlt } from '@fortawesome/free-solid-svg-icons'; import { faClipboardCheck } from '@fortawesome/free-solid-svg-icons'; import classNames from 'classnames'; import { useCookies } from "react-cookie"; - +import { RadioButton } from 'primereact/radiobutton'; const AreasComunes = () => { @@ -32,6 +32,7 @@ const AreasComunes = () => { status_text: '', }; + const [commonAreaList, setCommonAreaList] = useState([]); const [commonArea, setCommonArea] = useState(emptyCommonArea); const [selectedCommonAreas, setSelectedCommonAreas] = useState(null); @@ -44,6 +45,8 @@ const AreasComunes = () => { const [cookies, setCookie] = useCookies(); + + async function getCommonAreas() { await fetch(`http://localhost:4000/commonArea/findByCommunity/${cookies.community_id}`, { method: 'GET' }) .then((response) => response.json()) @@ -78,6 +81,71 @@ const AreasComunes = () => { getCommonAreas(); }, []); + const saveCommonArea = () => { + if ( + commonArea.name && + commonArea.hourMin && + commonArea.hourMax + ) { + let _common_areas = [...commonAreaList]; + let _common_area = { ...commonArea }; + _common_area.community_id = cookies.community_id; + + // console.log(houses) + fetch('http://localhost:4000/commonArea/createCommonArea', { + cache: 'no-cache', + method: 'POST', + body: JSON.stringify(_common_area), + 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((data) => { + + if (data) { + data.map(item => { + if (item.bookable == '1') { + item.bookable_text = 'Necesaria'; + } else { + item.bookable_text = 'No es necesarioa'; + } + + if (item.status == '1') { + item.status_text = 'Activo'; + } else if (item.status == '0') { + item.status_text = 'Inactivo'; + } else { + item.status_text = 'Eliminado'; + } + }) + } + + _common_area = data.filter( + (val) => val.status != -1, + ) + + _common_areas.push(_common_area); + toast.current.show({ + severity: 'success', + summary: 'Registro exitoso', + detail: 'Área Común Creada', + life: 3000, + }); + + setCommonAreaList(_common_areas); + setCommonArea(emptyCommonArea); + }) + .catch((err) => console.log('Ocurrió un error con el fetch', err)); + } else { + setSubmitted(true); + } + }; + const deleteCommonArea = () => { fetch('http://localhost:4000/commonArea/deleteCommonArea/' + commonArea._id, { @@ -167,8 +235,6 @@ const AreasComunes = () => { setDeleteCommonAreasDialog(true); }; - - const actionsCommonArea = (rowData) => { return (
@@ -181,6 +247,18 @@ const AreasComunes = () => { ); }; + const onBookableChange = (e) => { + let _commonArea = { ...commonArea }; + _commonArea['bookable'] = e.value; + setCommonArea(_commonArea); + }; + + const onInputChange = (e, name) => { + const val = (e.target && e.target.value) || ''; + let _commonArea = { ...commonArea }; + _commonArea[`${name}`] = val; + setCommonArea(_commonArea); + }; const deleteCommonAreaDialogFooter = ( <> @@ -278,7 +356,7 @@ const AreasComunes = () => { const bookableBodyTemplate = (rowData) => { let class_color = ''; - if(rowData.bookable == '1') { + if (rowData.bookable == '1') { class_color = '0'; } else { class_color = '1'; @@ -307,6 +385,8 @@ const AreasComunes = () => { ); }; + + return (
@@ -341,6 +421,89 @@ const AreasComunes = () => {
+
+
+
Registro de área común
+
+
+ + onInputChange(e, 'name')} + value={commonArea.name} + required + autoFocus + className={classNames({ + 'p-invalid': submitted && commonArea.name === '', + })} + /> + {submitted && commonArea.name === '' && ( + Nombre es requirido. + )} +
+
+ + onInputChange(e, 'hourMin')} + value={commonArea.hourMin} + required + autoFocus + className={classNames({ + 'p-invalid': submitted && commonArea.hourMin === '', + })} + /> + {submitted && commonArea.hourMin === '' && ( + Hora de apertura es requirido. + )} +
+
+ + onInputChange(e, 'hourMax')} + value={commonArea.hourMax} + required + autoFocus + className={classNames({ + 'p-invalid': submitted && commonArea.hourMax === '', + })} + /> + {submitted && commonArea.hourMax === '' && ( + Hora de apertura es requirido. + )} +
+
+ +
+
+ + +
+
+ + +
+
+
+ + +
+
+
+
); From ac0984d5af24f5ddb46bf0d61d0f670c86620bf9 Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 2 Aug 2022 00:13:09 -0600 Subject: [PATCH 02/10] fix error de estado despues de registrar --- api-gateway/src/app.service.ts | 1 + .../web-react/src/components/AreasComunes.js | 48 +++++++++---------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 52c79492..1ac8513c 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -261,6 +261,7 @@ export class AppService { hourMax: hourMax, bookable: bookable, community_id: community_id, + status: '1' }; return this.clientCommonAreaApp .send(pattern, payload) diff --git a/web-ui/web-react/src/components/AreasComunes.js b/web-ui/web-react/src/components/AreasComunes.js index 6eff36e4..3b40a941 100644 --- a/web-ui/web-react/src/components/AreasComunes.js +++ b/web-ui/web-react/src/components/AreasComunes.js @@ -21,7 +21,6 @@ const AreasComunes = () => { let emptyCommonArea = { _id: null, - dni: '', name: '', hourMin: '', hourMax: '', @@ -106,41 +105,42 @@ const AreasComunes = () => { else return response.json(); }) .then((data) => { - if (data) { - data.map(item => { - if (item.bookable == '1') { - item.bookable_text = 'Necesaria'; - } else { - item.bookable_text = 'No es necesarioa'; - } - - if (item.status == '1') { - item.status_text = 'Activo'; - } else if (item.status == '0') { - item.status_text = 'Inactivo'; - } else { - item.status_text = 'Eliminado'; - } - }) - } - - _common_area = data.filter( - (val) => val.status != -1, - ) + if (_common_area.bookable == '1') { + _common_area.bookable_text = 'Necesaria'; + } else { + _common_area.bookable_text = 'No es necesaria'; + } + if (_common_area.status == '1') { + _common_area.status_text = 'Activo'; + } else if (_common_area.status == '0') { + _common_area.status_text = 'Inactivo'; + } else { + _common_area.status_text = 'Eliminado'; + } + } _common_areas.push(_common_area); + toast.current.show({ severity: 'success', summary: 'Registro exitoso', detail: 'Área Común Creada', life: 3000, }); - setCommonAreaList(_common_areas); setCommonArea(emptyCommonArea); }) - .catch((err) => console.log('Ocurrió un error con el fetch', err)); + .catch((err) => { + console.log('Ocurrió un error con el fetch', err); + toast.current.show({ + severity: 'danger', + summary: 'Error', + detail: 'No se pudo registrar el área común', + life: 3000 + }); + + }); } else { setSubmitted(true); } From 89134ec7a64d2ff2cf7ab69335bbd0fb20163992 Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 2 Aug 2022 00:41:12 -0600 Subject: [PATCH 03/10] arreglar inputs de tiempos --- web-ui/web-react/src/components/AreasComunes.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web-ui/web-react/src/components/AreasComunes.js b/web-ui/web-react/src/components/AreasComunes.js index 3b40a941..fca6f1e7 100644 --- a/web-ui/web-react/src/components/AreasComunes.js +++ b/web-ui/web-react/src/components/AreasComunes.js @@ -22,8 +22,8 @@ const AreasComunes = () => { let emptyCommonArea = { _id: null, name: '', - hourMin: '', - hourMax: '', + hourMin: '00:00', + hourMax: '01:00', community_id: '', bookable: '1', bookable_text: '', @@ -444,7 +444,9 @@ const AreasComunes = () => {
onInputChange(e, 'hourMin')} value={commonArea.hourMin} required @@ -460,7 +462,9 @@ const AreasComunes = () => {
onInputChange(e, 'hourMax')} value={commonArea.hourMax} required From e449b28e873f0c0a0464d73eb765993b58bdb9dc Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 2 Aug 2022 12:09:00 -0600 Subject: [PATCH 04/10] validaciones de comparacion para las horas que la hora de apertura no sea mayor a la de cierre --- .../web-react/src/components/AreasComunes.js | 46 ++++++++++++------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/web-ui/web-react/src/components/AreasComunes.js b/web-ui/web-react/src/components/AreasComunes.js index fca6f1e7..d539bc40 100644 --- a/web-ui/web-react/src/components/AreasComunes.js +++ b/web-ui/web-react/src/components/AreasComunes.js @@ -83,8 +83,7 @@ const AreasComunes = () => { const saveCommonArea = () => { if ( commonArea.name && - commonArea.hourMin && - commonArea.hourMax + commonArea.hourMin < commonArea.hourMax ) { let _common_areas = [...commonAreaList]; let _common_area = { ...commonArea }; @@ -104,23 +103,26 @@ const AreasComunes = () => { console.log('Ocurrió un error con el servicio: ' + response.status); else return response.json(); }) + .then(function (data) { + return data.message; + }) .then((data) => { if (data) { - if (_common_area.bookable == '1') { - _common_area.bookable_text = 'Necesaria'; + if (data.bookable == '1') { + data.bookable_text = 'Necesaria'; } else { - _common_area.bookable_text = 'No es necesaria'; + data.bookable_text = 'No es necesaria'; } - if (_common_area.status == '1') { - _common_area.status_text = 'Activo'; - } else if (_common_area.status == '0') { - _common_area.status_text = 'Inactivo'; + if (data.status == '1') { + data.status_text = 'Activo'; + } else if (data.status == '0') { + data.status_text = 'Inactivo'; } else { - _common_area.status_text = 'Eliminado'; + data.status_text = 'Eliminado'; } } - _common_areas.push(_common_area); + _common_areas.push(data); toast.current.show({ severity: 'success', @@ -386,6 +388,16 @@ const AreasComunes = () => { }; + function compareTimesMinRequired(hour1, hour2){ + var timeFormat1 = Number(hour1.replace(/[:]/g,'')); + var timeFormat2 = Number(hour2.replace(/[:]/g,'')); + if(timeFormat1 <= timeFormat2){ + return true; + } else { + return false; + } + } + return (
@@ -452,11 +464,11 @@ const AreasComunes = () => { required autoFocus className={classNames({ - 'p-invalid': submitted && commonArea.hourMin === '', + 'p-invalid': submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin), })} /> - {submitted && commonArea.hourMin === '' && ( - Hora de apertura es requirido. + {submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin) && ( + La hora de apertura debe ser menor que la hora de cierre. )}
@@ -470,11 +482,11 @@ const AreasComunes = () => { required autoFocus className={classNames({ - 'p-invalid': submitted && commonArea.hourMax === '', + 'p-invalid': submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin), })} /> - {submitted && commonArea.hourMax === '' && ( - Hora de apertura es requirido. + {submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin) && ( + La hora de cierre debe ser mayor que la hora de apertura )}
From 2499c0ab645dca284775ef2b32e3fbca2d4919c9 Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 2 Aug 2022 12:27:38 -0600 Subject: [PATCH 05/10] =?UTF-8?q?fix=20estilos=20de=20formulario=20de=20ag?= =?UTF-8?q?regar=20=C3=A1rea=20com=C3=BAn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web-react/src/components/AreasComunes.js | 131 +++++++++++------- 1 file changed, 81 insertions(+), 50 deletions(-) diff --git a/web-ui/web-react/src/components/AreasComunes.js b/web-ui/web-react/src/components/AreasComunes.js index d539bc40..0850e31c 100644 --- a/web-ui/web-react/src/components/AreasComunes.js +++ b/web-ui/web-react/src/components/AreasComunes.js @@ -388,10 +388,10 @@ const AreasComunes = () => { }; - function compareTimesMinRequired(hour1, hour2){ - var timeFormat1 = Number(hour1.replace(/[:]/g,'')); - var timeFormat2 = Number(hour2.replace(/[:]/g,'')); - if(timeFormat1 <= timeFormat2){ + function compareTimesMinRequired(hour1, hour2) { + var timeFormat1 = Number(hour1.replace(/[:]/g, '')); + var timeFormat2 = Number(hour2.replace(/[:]/g, '')); + if (timeFormat1 <= timeFormat2) { return true; } else { return false; @@ -439,60 +439,83 @@ const AreasComunes = () => {
- onInputChange(e, 'name')} - value={commonArea.name} - required - autoFocus - className={classNames({ - 'p-invalid': submitted && commonArea.name === '', - })} - /> - {submitted && commonArea.name === '' && ( - Nombre es requirido. - )} +
+ +
+ + + + onInputChange(e, 'name')} + value={commonArea.name} + required + autoFocus + className={classNames({ + 'p-invalid': submitted && commonArea.name === '', + })} + /> +
+ {submitted && commonArea.name === '' && ( + Nombre es requirido. + )} +
- onInputChange(e, 'hourMin')} - value={commonArea.hourMin} - required - autoFocus - className={classNames({ - 'p-invalid': submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin), - })} - /> - {submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin) && ( - La hora de apertura debe ser menor que la hora de cierre. - )} +
+
+ + + + onInputChange(e, 'hourMin')} + value={commonArea.hourMin} + required + autoFocus + className={classNames({ + 'p-invalid': submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin), + })} + /> +
+ {submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin) && ( + La hora de apertura debe ser menor que la hora de cierre. + )} +
- onInputChange(e, 'hourMax')} - value={commonArea.hourMax} - required - autoFocus - className={classNames({ - 'p-invalid': submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin), - })} - /> - {submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin) && ( - La hora de cierre debe ser mayor que la hora de apertura - )} +
+
+ + + + onInputChange(e, 'hourMax')} + value={commonArea.hourMax} + required + autoFocus + className={classNames({ + 'p-invalid': submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin), + })} + /> +
+ {submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin) && ( + La hora de cierre debe ser mayor que la hora de apertura + )} +
-
+
+ { onChange={onBookableChange} checked={commonArea.bookable === '1'} /> - +
{ onChange={onBookableChange} checked={commonArea.bookable === '0'} /> - +
From 52fea9937e9003dda3a91061399219b9b5323e58 Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 2 Aug 2022 23:19:00 -0600 Subject: [PATCH 06/10] funcionalidad desactivar-activar guarda de seguridad --- .../src/components/AdministradoresSistema.js | 2 +- .../src/components/GuardasSeguridad.js | 180 +++++++++++++++--- 2 files changed, 157 insertions(+), 25 deletions(-) diff --git a/web-ui/web-react/src/components/AdministradoresSistema.js b/web-ui/web-react/src/components/AdministradoresSistema.js index 933d0381..3a2b8a97 100644 --- a/web-ui/web-react/src/components/AdministradoresSistema.js +++ b/web-ui/web-react/src/components/AdministradoresSistema.js @@ -58,7 +58,7 @@ const AdministradoresSistema = () => { item.status_text = 'Inactivo'; } }) - setAdministrators(adminRes.message); + setAdministrators(await data); } useEffect(() => { fetchP(); diff --git a/web-ui/web-react/src/components/GuardasSeguridad.js b/web-ui/web-react/src/components/GuardasSeguridad.js index a092910f..79bb2763 100644 --- a/web-ui/web-react/src/components/GuardasSeguridad.js +++ b/web-ui/web-react/src/components/GuardasSeguridad.js @@ -11,7 +11,8 @@ 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'; +import { useCookies } from "react-cookie"; const GuardasSeguridad = () => { const [listaGuardas, setListaGuardas] = useState([]); @@ -23,6 +24,10 @@ const GuardasSeguridad = () => { const [deleteGuardasDialog, setDeleteGuardasDialog] = useState(false); const toast = useRef(null); const dt = useRef(null); + + const [cookies, setCookie] = useCookies(); + const [changeStatusGuardDialog, setChangeStatusGuardDialog] = useState(false); + let emptyGuarda = { _id: null, dni: '', @@ -32,7 +37,8 @@ const GuardasSeguridad = () => { phone: '', password: '', user_type: '1', - status: '' + status: '', + status_text: '', }; @@ -40,7 +46,17 @@ const GuardasSeguridad = () => { async function listaGuardasF() { let nombres = await fetch(urlFetch, { method: 'GET' }); let listaGuardasRes = await nombres.json(); - setListaGuardas(listaGuardasRes.message); + let data = await listaGuardasRes.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'; + } + }) + setListaGuardas(await data); } useEffect(() => { listaGuardasF(); @@ -56,7 +72,7 @@ const GuardasSeguridad = () => { password: document.getElementById('correo_electronico').value, user_type: "4", //4 es guarda status: "1", - community_id: "62be68215692582bbfd77134" + community_id: cookies.community_id }; var data2 = { dni: "11979037", @@ -66,7 +82,7 @@ const GuardasSeguridad = () => { phone: 84664515, password: "1203", user_type: "2", - status: "4", + status: "1", community_id: "62be68215692582bbfd77134" } console.log('ssss'); @@ -74,7 +90,7 @@ const GuardasSeguridad = () => { cache: 'no-cache', method: 'POST', mode: 'cors', - body: JSON.stringify(data2), + body: JSON.stringify(data), headers: { 'Content-Type': 'application/json' } @@ -89,7 +105,6 @@ const GuardasSeguridad = () => { ) .then( function (response) { - console.log('fff'); listaGuardasF(); } ) @@ -98,22 +113,51 @@ const GuardasSeguridad = () => { ); } - const hideDeleteGuardaDialog = () => { - setDeleteGuardaDialog(false); + const cambiarStatusUser = () => { + if (guarda.status == '1') { + guarda.status = '0'; + guarda.status_text = 'Inactivo'; + + } else if (guarda.status == '0') { + guarda.status = '1'; + guarda.status_text = 'Activo'; + } + var data = { + id: guarda._id, + status: guarda.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) { + setChangeStatusGuardDialog(false); + toast.current.show({ + severity: 'success', + summary: 'Éxito', + detail: 'Guarda de Seguridad Actualizado', + life: 3000, + }); + } + ) + .catch( + err => console.log('Ocurrió un error con el fetch', err) + ); } - const hideDeleteGuardasDialog = () => { - setDeleteGuardasDialog(false); - } - - const confirmDeleteGuarda = (guarda) => { - setGuarda(guarda); - setDeleteGuardaDialog(true); - } - - const confirmDeleteSelected = () => { - setDeleteGuardasDialog(true); - } const deleteGuarda = () => { @@ -166,10 +210,55 @@ const GuardasSeguridad = () => { toast.current.show({ severity: 'success', summary: 'Éxito', detail: 'Administradores del Sistema Eliminados', life: 3000 }); } + const hideDeleteGuardaDialog = () => { + setDeleteGuardaDialog(false); + } + + const hideDeleteGuardasDialog = () => { + setDeleteGuardasDialog(false); + } + + const confirmDeleteGuarda = (guarda) => { + setGuarda(guarda); + setDeleteGuardaDialog(true); + } + + const confirmDeleteSelected = () => { + setDeleteGuardasDialog(true); + } + + const hideChangeStatusGuardDialog = () => { + setChangeStatusGuardDialog(false); + }; + + const confirmChangeStatusGuard = (guard) => { + setGuarda(guard); + setChangeStatusGuardDialog(true); + }; + + const actionsAdmin = (rowData) => { + let icono = ''; + let text = ''; + if (rowData.status == '0') { + icono = "pi pi-eye"; + text = "Activar Guarda de Seguridad" + } else if (rowData.status == '1') { + icono = "pi pi-eye-slash"; + text = "Inactivar Guarda de Seguridad" + + } return (
-
); } @@ -178,7 +267,11 @@ const GuardasSeguridad = () => { return (
-
) @@ -187,7 +280,9 @@ const GuardasSeguridad = () => { const rightToolbarTemplate = () => { return ( -
+ +
+ + {guarda && ( + + ¿Estás seguro que desea cambiar estado a {guarda.name}? + + )} +
+
From 3294422e6a7bc2c17b11ff41d90b4e62af563ce0 Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 2 Aug 2022 23:22:51 -0600 Subject: [PATCH 07/10] arreglar textos y estilos --- web-ui/web-react/src/components/GuardasSeguridad.js | 12 ++++++------ web-ui/web-react/src/components/Inquilinos.js | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/web-ui/web-react/src/components/GuardasSeguridad.js b/web-ui/web-react/src/components/GuardasSeguridad.js index 79bb2763..77cbc676 100644 --- a/web-ui/web-react/src/components/GuardasSeguridad.js +++ b/web-ui/web-react/src/components/GuardasSeguridad.js @@ -257,7 +257,7 @@ const GuardasSeguridad = () => { title={`${text}`} />
); @@ -300,14 +300,14 @@ const GuardasSeguridad = () => { const deleteAdminSystemDialogFooter = ( <>
- +
- +
diff --git a/web-ui/web-react/src/components/GuardasSeguridad.js b/web-ui/web-react/src/components/GuardasSeguridad.js index 77cbc676..d09b09fc 100644 --- a/web-ui/web-react/src/components/GuardasSeguridad.js +++ b/web-ui/web-react/src/components/GuardasSeguridad.js @@ -373,6 +373,26 @@ const GuardasSeguridad = () => { ) + const headerStatus = ( + <> +

{' '} + {' '} + Estado +

+ + ) + + const statusBodyTemplate = (rowData) => { + return ( + <> + + {rowData.status_text} + + + ); + }; return (
@@ -393,6 +413,13 @@ const GuardasSeguridad = () => { + + @@ -438,12 +465,12 @@ const GuardasSeguridad = () => {
- +
- +
@@ -451,7 +478,7 @@ const GuardasSeguridad = () => {
- +
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 09/10] 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 (
+