From 52cdf9f8996477dd5718d0a227fb552548e6db9d Mon Sep 17 00:00:00 2001 From: Mariela Date: Thu, 1 Sep 2022 01:55:41 -0600 Subject: [PATCH] informacion en inquilinos --- .../web-react/src/components/AreasComunes.js | 5 - web-ui/web-react/src/components/Inquilinos.js | 356 ++++++++++-------- 2 files changed, 207 insertions(+), 154 deletions(-) diff --git a/web-ui/web-react/src/components/AreasComunes.js b/web-ui/web-react/src/components/AreasComunes.js index b8c2b0f9..ce40ffdc 100644 --- a/web-ui/web-react/src/components/AreasComunes.js +++ b/web-ui/web-react/src/components/AreasComunes.js @@ -608,7 +608,6 @@ const AreasComunes = () => { ); }; - function compareTimesMinRequired(hour1, hour2) { var timeFormat1 = Number(hour1.replace(/[:]/g, '')); var timeFormat2 = Number(hour2.replace(/[:]/g, '')); @@ -619,10 +618,6 @@ const AreasComunes = () => { } } - - - - return (
diff --git a/web-ui/web-react/src/components/Inquilinos.js b/web-ui/web-react/src/components/Inquilinos.js index 2fc7413d..5bc8801e 100644 --- a/web-ui/web-react/src/components/Inquilinos.js +++ b/web-ui/web-react/src/components/Inquilinos.js @@ -51,6 +51,8 @@ const Inquilinos = () => { const dt = useRef(null) const [cookies] = useCookies() const [changeStatusTenantDialog, setChangeStatusTenantDialog] = useState(false) + const [tenantDialog, setTenantDialog] = useState(false) + async function tenantsList() { await fetch( @@ -74,7 +76,7 @@ const Inquilinos = () => { }) data = data.filter( (val) => val.status != -1, - ); + ); setTenants(data) }) } @@ -175,14 +177,14 @@ const Inquilinos = () => { }).then(() => { fetch('http://localhost:4000/community/saveTenant', - { - cache: 'no-cache', - method: 'POST', - body: JSON.stringify(_tenant), - headers: { - 'Content-Type': 'application/json', - } - }); + { + cache: 'no-cache', + method: 'POST', + body: JSON.stringify(_tenant), + headers: { + 'Content-Type': 'application/json', + } + }); toast.current.show({ severity: 'success', @@ -352,17 +354,34 @@ const Inquilinos = () => { const editTenant = (tenant) => { setTenant(tenant); - console.log(tenant); setSaveButtonTitle('Actualizar'); setHouseNumber(tenant.number_house); + setTenantDialog(true) + } const cancelEdit = () => { setTenant(emptyTenant); setSaveButtonTitle('Registrar'); setHouseNumber(''); + setTenantDialog(false) + } + const openNewTenant = () => { + setTenant(emptyTenant); + setTenantDialog(true) + setSubmitted(false); + }; + + const hideTenantDialog = () => { + setSubmitted(false); + setTenantDialog(false) + setTenant(emptyTenant); + setSaveButtonTitle('Registrar'); + + }; + const actionsTenant = (rowData) => { let icono = '' let text = '' @@ -407,6 +426,12 @@ const Inquilinos = () => { return (
+
-
-
-
-
Registro de un Inquilino
-
-
- -
-
- - - - onInputChange(e, 'name')} required autoFocus className={classNames({ 'p-invalid': submitted && tenant.name === '' })} /> -
- {submitted && tenant.name === '' && Nombre es requerido.} -
-
-
- -
-
- - - - onInputChange(e, 'last_name')} required autoFocus className={classNames({ 'p-invalid': submitted && tenant.last_name === '' })} /> -
- {submitted && tenant.last_name === '' && Apellidos son requeridos.} -
-
-
- -
-
- - - - onInputChange(e, 'email')} required autoFocus className={classNames({ 'p-invalid': submitted && tenant.email === '' })} /> -
- {submitted && tenant.email === '' && Correo electrónico es requerido.} -
-
-
- -
-
- - - - onInputChange(e, 'dni')} required autoFocus className={classNames({ 'p-invalid': submitted && tenant.dni === '' })} /> -
- {submitted && tenant.dni === '' && Identificación es requerida.} -
-
-
- -
-
- - - - onInputChange(e, 'phone')} type='tel' required autoFocus className={classNames({ 'p-invalid': submitted && tenant.phone === '' })} /> -
- {submitted - && tenant.phone === '' - && Número de teléfono es requerido.} -
-
-
- -
-
- - - - -
- {submitted - && !houseNumber - && Casa es requerida.} -
-
-
-
-
-
-
- + + + ) }