2022-08-04 04:34:16 +00:00
|
|
|
import { Button } from 'primereact/button'
|
2022-08-04 02:43:41 +00:00
|
|
|
import { InputText } from 'primereact/inputtext'
|
2022-08-04 04:40:21 +00:00
|
|
|
import React, { useState } from 'react'
|
2022-08-04 02:43:41 +00:00
|
|
|
|
2022-08-04 04:34:16 +00:00
|
|
|
import { useCookies } from 'react-cookie'
|
2022-08-04 02:43:41 +00:00
|
|
|
|
|
|
|
const Inquilinos = () => {
|
|
|
|
let emptyTenant = {
|
|
|
|
_id: null,
|
|
|
|
dni: '',
|
|
|
|
name: '',
|
|
|
|
last_name: '',
|
|
|
|
email: '',
|
|
|
|
phone: '',
|
|
|
|
password: '',
|
|
|
|
community_id: '',
|
|
|
|
community_name: '',
|
|
|
|
number_house: 'Sin número de vivienda',
|
|
|
|
user_type: '4',
|
|
|
|
date_entry: new Date(),
|
|
|
|
status: '1',
|
|
|
|
status_text: '',
|
2022-08-04 04:34:16 +00:00
|
|
|
}
|
2022-08-04 02:43:41 +00:00
|
|
|
|
2022-08-04 04:34:16 +00:00
|
|
|
const [tenant, setTenant] = useState(emptyTenant)
|
|
|
|
const [selectedTentants, setSelectedTenants] = useState(null)
|
|
|
|
const [globalFilter, setGlobalFilter] = useState(null)
|
|
|
|
const [deleteTenantDialog, setDeleteTenantDialog] = useState(false)
|
|
|
|
const [deleteTenantsDialog, setDeleteTenantsDialog] = useState(false)
|
|
|
|
const [communitiesList, setCommunitiesList] = useState([])
|
|
|
|
const [communityId, setCommunityId] = useState(null)
|
|
|
|
const [submitted, setSubmitted] = useState(false)
|
|
|
|
const [cookies, setCookie] = useCookies()
|
|
|
|
const [changeStatusTenantDialog, setChangeStatusTenantDialog] =
|
|
|
|
useState(false)
|
2022-08-04 02:43:41 +00:00
|
|
|
|
2022-08-04 04:26:07 +00:00
|
|
|
function finalizarRegistro() {
|
2022-08-04 02:43:41 +00:00
|
|
|
let data = {
|
|
|
|
dni: document.getElementById('identificacion').value,
|
|
|
|
name: document.getElementById('nombre').value,
|
|
|
|
last_name: document.getElementById('apellidos').value,
|
|
|
|
phone: document.getElementById('telefono').value,
|
|
|
|
email: document.getElementById('correo_electronico').value,
|
|
|
|
community_id: document.getElementById('numero_vivienda').value,
|
|
|
|
password: document.getElementById('password').value,
|
|
|
|
user_type: '3',
|
|
|
|
status: '1',
|
2022-08-04 04:34:16 +00:00
|
|
|
}
|
2022-08-04 02:43:41 +00:00
|
|
|
|
|
|
|
fetch('http://localhost:3000/api/createUser', {
|
2022-08-04 04:44:52 +00:00
|
|
|
method: 'PUT',
|
2022-08-04 02:43:41 +00:00
|
|
|
cache: 'no-cache',
|
|
|
|
body: JSON.stringify(data),
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
},
|
|
|
|
}).then((response) => {
|
|
|
|
if (response.ok) {
|
2022-08-04 04:34:16 +00:00
|
|
|
alert('Inquilino registrado correctamente')
|
2022-08-04 02:43:41 +00:00
|
|
|
} else {
|
2022-08-04 04:34:16 +00:00
|
|
|
alert('Error al registrar inquilino')
|
2022-08-04 02:43:41 +00:00
|
|
|
}
|
2022-08-04 04:34:16 +00:00
|
|
|
})
|
2022-08-04 02:43:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-08-04 04:34:16 +00:00
|
|
|
<div className='grid'>
|
|
|
|
<div className='col-12'>
|
|
|
|
<div className='card'>
|
2022-08-04 04:39:24 +00:00
|
|
|
<h5 className='card-header'>Finalizar Registro</h5>
|
2022-08-04 04:34:16 +00:00
|
|
|
<div className='p-fluid formgrid grid'>
|
|
|
|
<div className='field col-12 md:col-6'>
|
|
|
|
<label htmlFor='nombre'>Nombre</label>
|
2022-08-04 06:54:36 +00:00
|
|
|
<InputText
|
|
|
|
required
|
|
|
|
type='text'
|
|
|
|
className='form-control'
|
|
|
|
id='nombre'
|
|
|
|
/>
|
2022-08-04 02:43:41 +00:00
|
|
|
</div>
|
2022-08-04 04:34:16 +00:00
|
|
|
<div className='field col-12 md:col-6'>
|
|
|
|
<label htmlFor='apellidos'>Apellido(s)</label>
|
2022-08-04 06:54:36 +00:00
|
|
|
<InputText
|
|
|
|
required
|
|
|
|
type='text'
|
|
|
|
className='form-control'
|
|
|
|
id='apellidos'
|
|
|
|
/>
|
2022-08-04 02:43:41 +00:00
|
|
|
</div>
|
2022-08-04 04:34:16 +00:00
|
|
|
<div className='field col-12 md:col-6'>
|
|
|
|
<label htmlFor='identificacion'>Identificación</label>
|
2022-08-04 02:43:41 +00:00
|
|
|
<InputText
|
2022-08-04 06:54:36 +00:00
|
|
|
required
|
2022-08-04 04:34:16 +00:00
|
|
|
type='text'
|
|
|
|
className='form-control'
|
|
|
|
id='identificacion'
|
2022-08-04 02:43:41 +00:00
|
|
|
/>
|
|
|
|
</div>
|
2022-08-04 04:34:16 +00:00
|
|
|
<div className='field col-12 md:col-6'>
|
|
|
|
<label htmlFor='correo_electronico'>Correo electrónico</label>
|
2022-08-04 02:43:41 +00:00
|
|
|
<InputText
|
2022-08-04 06:54:36 +00:00
|
|
|
required
|
2022-08-04 04:34:16 +00:00
|
|
|
type='email'
|
|
|
|
className='form-control'
|
|
|
|
id='correo_electronico'
|
2022-08-04 02:43:41 +00:00
|
|
|
/>
|
|
|
|
</div>
|
2022-08-04 04:34:16 +00:00
|
|
|
<div className='field col-12 md:col-6'>
|
2022-08-04 04:37:24 +00:00
|
|
|
<label htmlFor='password'>Password</label>
|
2022-08-04 02:43:41 +00:00
|
|
|
<InputText
|
2022-08-04 06:54:36 +00:00
|
|
|
required
|
2022-08-04 04:34:16 +00:00
|
|
|
type='password'
|
|
|
|
className='form-control'
|
2022-08-04 04:37:24 +00:00
|
|
|
id='password'
|
2022-08-04 02:43:41 +00:00
|
|
|
/>
|
|
|
|
</div>
|
2022-08-04 04:34:16 +00:00
|
|
|
<Button label='Registrar' onClick={finalizarRegistro} />
|
2022-08-04 02:43:41 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-04 04:34:16 +00:00
|
|
|
)
|
|
|
|
}
|
2022-08-04 02:43:41 +00:00
|
|
|
|
2022-08-07 11:44:38 +00:00
|
|
|
export default React.memo(InquilinosCompletar)
|