2022-08-04 03:55:04 +00:00
|
|
|
import { Button } from 'primereact/button'
|
2022-07-20 00:54:20 +00:00
|
|
|
import { InputText } from 'primereact/inputtext'
|
2022-08-04 03:55:04 +00:00
|
|
|
import React, { useEffect, useRef, useState } from 'react'
|
|
|
|
import { DataTable } from 'primereact/datatable'
|
|
|
|
import { Column } from 'primereact/column'
|
|
|
|
import { Dropdown } from 'primereact/dropdown'
|
|
|
|
import { Toast } from 'primereact/toast'
|
|
|
|
import { Dialog } from 'primereact/dialog'
|
|
|
|
import { Toolbar } from 'primereact/toolbar'
|
2022-07-24 23:44:25 +00:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
2022-08-04 03:55:04 +00:00
|
|
|
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 { faHashtag } from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import { useCookies } from 'react-cookie'
|
2022-08-21 02:25:55 +00:00
|
|
|
import classNames from 'classnames';
|
2022-07-16 07:48:36 +00:00
|
|
|
|
|
|
|
const Inquilinos = () => {
|
2022-08-20 09:44:14 +00:00
|
|
|
const emptyTenant = {
|
2022-08-01 00:19:20 +00:00
|
|
|
_id: null,
|
|
|
|
dni: '',
|
|
|
|
name: '',
|
|
|
|
last_name: '',
|
|
|
|
email: '',
|
|
|
|
phone: '',
|
|
|
|
password: '',
|
|
|
|
community_id: '',
|
|
|
|
community_name: '',
|
2022-08-01 02:02:13 +00:00
|
|
|
number_house: 'Sin número de vivienda',
|
2022-08-01 00:19:20 +00:00
|
|
|
user_type: '4',
|
|
|
|
date_entry: new Date(),
|
2022-08-03 04:38:54 +00:00
|
|
|
status: '1',
|
|
|
|
status_text: '',
|
2022-08-04 03:55:04 +00:00
|
|
|
}
|
2022-08-01 00:19:20 +00:00
|
|
|
|
2022-08-04 03:55:04 +00:00
|
|
|
const [tenants, setTenants] = useState([])
|
|
|
|
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)
|
2022-08-21 09:50:27 +00:00
|
|
|
const [community, setCommunity] = useState([])
|
2022-08-22 06:07:33 +00:00
|
|
|
const [saveButtonTitle, setSaveButtonTitle] = useState("Registrar")
|
2022-08-21 09:50:27 +00:00
|
|
|
const [houseNumber, setHouseNumber] = useState([])
|
|
|
|
const [housesList, setHousesList] = useState([])
|
2022-08-04 03:55:04 +00:00
|
|
|
const [submitted, setSubmitted] = useState(false)
|
2022-08-22 02:11:53 +00:00
|
|
|
const [infoDialogVisible, setShowInfoDialog] = useState(false)
|
2022-08-04 03:55:04 +00:00
|
|
|
const toast = useRef(null)
|
|
|
|
const dt = useRef(null)
|
2022-08-21 09:50:27 +00:00
|
|
|
const [cookies] = useCookies()
|
|
|
|
const [changeStatusTenantDialog, setChangeStatusTenantDialog] = useState(false)
|
2022-08-01 00:19:20 +00:00
|
|
|
|
|
|
|
async function tenantsList() {
|
2022-08-04 03:55:04 +00:00
|
|
|
await fetch(
|
|
|
|
`http://localhost:4000/user/findTenants/${cookies.community_id}`,
|
|
|
|
{ method: 'GET' },
|
|
|
|
)
|
2022-08-01 00:19:20 +00:00
|
|
|
.then((response) => response.json())
|
2022-08-04 03:55:04 +00:00
|
|
|
.then((data) => data.message)
|
|
|
|
.then((data) => {
|
2022-08-22 22:43:52 +00:00
|
|
|
data = data.filter((val) => val.status != -1)
|
2022-08-01 02:02:13 +00:00
|
|
|
data.map((item) => {
|
2022-08-04 06:54:52 +00:00
|
|
|
if (item.status === '1') {
|
2022-08-04 03:55:04 +00:00
|
|
|
item.status_text = 'Activo'
|
2022-08-04 06:54:52 +00:00
|
|
|
} else if (item.status === '0') {
|
2022-08-04 03:55:04 +00:00
|
|
|
item.status_text = 'Inactivo'
|
2022-08-03 04:46:15 +00:00
|
|
|
}
|
|
|
|
|
2022-08-04 06:54:52 +00:00
|
|
|
if (item.number_house === '') {
|
2022-08-04 03:55:04 +00:00
|
|
|
item.number_house = 'Sin vivienda asignada'
|
2022-08-01 02:02:13 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
setTenants(data)
|
2022-08-04 03:55:04 +00:00
|
|
|
})
|
2022-08-01 00:19:20 +00:00
|
|
|
}
|
|
|
|
|
2022-08-21 09:50:27 +00:00
|
|
|
async function getCommunity() {
|
2022-08-04 03:55:04 +00:00
|
|
|
let response = await fetch(
|
2022-08-21 09:50:27 +00:00
|
|
|
`http://localhost:4000/community/findCommunityName/${cookies.community_id}`,
|
2022-08-04 03:55:04 +00:00
|
|
|
{ method: 'GET' },
|
2022-08-03 04:38:54 +00:00
|
|
|
)
|
2022-08-21 09:50:27 +00:00
|
|
|
const responseJson = await response.json()
|
|
|
|
const result = await responseJson.message
|
|
|
|
setCommunity(await result)
|
|
|
|
const houses = await result.houses.filter((house) =>
|
|
|
|
house.state === "desocupada"
|
|
|
|
)
|
|
|
|
setHousesList(houses.map((house) => ({
|
|
|
|
label: house.number_house, value: house.number_house
|
|
|
|
}))
|
|
|
|
)
|
2022-07-20 01:22:50 +00:00
|
|
|
}
|
|
|
|
|
2022-08-16 22:36:06 +00:00
|
|
|
|
|
|
|
async function getHouses() {
|
|
|
|
let response = await fetch(
|
|
|
|
`http://localhost:4000/community/findHousesCommunity/${cookies.community_id}`,
|
|
|
|
{ method: 'GET' },
|
|
|
|
)
|
|
|
|
let resList = await response.json()
|
2022-08-16 22:46:20 +00:00
|
|
|
setHousesList(await resList)
|
2022-08-16 22:36:06 +00:00
|
|
|
}
|
|
|
|
|
2022-08-01 00:19:20 +00:00
|
|
|
useEffect(() => {
|
2022-08-04 03:55:04 +00:00
|
|
|
tenantsList()
|
2022-08-22 02:11:53 +00:00
|
|
|
}, [])
|
2022-08-01 00:19:20 +00:00
|
|
|
|
2022-07-20 01:22:50 +00:00
|
|
|
useEffect(() => {
|
2022-08-21 09:50:27 +00:00
|
|
|
getCommunity()
|
2022-07-20 01:22:50 +00:00
|
|
|
}, [])
|
2022-07-24 23:44:25 +00:00
|
|
|
|
2022-08-20 08:42:33 +00:00
|
|
|
const saveTenant = () => {
|
2022-08-22 06:07:33 +00:00
|
|
|
if (tenant._id === null) {
|
|
|
|
if (tenant.email && tenant.number_house && tenant.dni
|
|
|
|
&& tenant.name && tenant.last_name && tenant.phone) {
|
|
|
|
let _tenants = [...tenants]
|
|
|
|
let _tenant = { ...tenant }
|
|
|
|
_tenant.community_id = cookies.community_id;
|
|
|
|
_tenant.number_house = houseNumber;
|
|
|
|
_tenant.password = _tenant.email;
|
2022-08-22 22:43:52 +00:00
|
|
|
console.log(`Registrando nuevo inquilino: ${_tenant}`)
|
2022-08-22 06:07:33 +00:00
|
|
|
|
2022-08-22 18:57:33 +00:00
|
|
|
fetch(`http://localhost:4000/user/createTenant`, {
|
2022-08-22 06:07:33 +00:00
|
|
|
cache: 'no-cache',
|
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify(_tenant),
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then((response) => {
|
|
|
|
if (response.status !== 200)
|
|
|
|
console.log(`Hubo un error en el servicio: ${response.status}`)
|
|
|
|
else return response.json()
|
|
|
|
})
|
2022-08-22 22:43:52 +00:00
|
|
|
.then((data) => {
|
2022-08-22 18:57:33 +00:00
|
|
|
if (_tenant.status === '1') {
|
|
|
|
_tenant.status_text = 'Activo'
|
2022-08-22 20:58:43 +00:00
|
|
|
} else if (_tenant.status === '0') {
|
|
|
|
_tenant.status_text = 'Inactivo'
|
2022-08-22 18:57:33 +00:00
|
|
|
}
|
2022-08-22 06:07:33 +00:00
|
|
|
_tenants.push(_tenant)
|
|
|
|
toast.current.show({
|
|
|
|
severity: 'success',
|
|
|
|
summary: 'Éxito',
|
|
|
|
detail: 'Inquilino creado',
|
|
|
|
life: 3000,
|
|
|
|
})
|
2022-08-22 18:57:33 +00:00
|
|
|
|
2022-08-22 06:07:33 +00:00
|
|
|
setTenants(_tenants)
|
|
|
|
setTenant(emptyTenant)
|
|
|
|
setHouseNumber('')
|
|
|
|
})
|
|
|
|
.catch((error) => console.log(`Ocurrió un error: ${error}`))
|
|
|
|
} else setSubmitted(true)
|
|
|
|
} else {
|
|
|
|
let _tenant = { ..._tenant, number_house: houseNumber };
|
|
|
|
console.log(`Actualizando inquilino: ${_tenant}`)
|
|
|
|
fetch(`http://localhost:4000/user/updateUser/${tenant._id}`, {
|
2022-08-20 08:42:33 +00:00
|
|
|
cache: 'no-cache',
|
2022-08-22 06:07:33 +00:00
|
|
|
method: 'PUT',
|
2022-08-21 03:20:50 +00:00
|
|
|
body: JSON.stringify(_tenant),
|
2022-08-20 08:42:33 +00:00
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
},
|
2022-08-22 06:07:33 +00:00
|
|
|
}).then((response) => {
|
|
|
|
if (response.status !== 200)
|
|
|
|
console.log(`Hubo un error en el servicio: ${response.status}`)
|
|
|
|
else return response.json()
|
|
|
|
}).then(() => {
|
|
|
|
toast.current.show({
|
|
|
|
severity: 'success',
|
|
|
|
summary: 'Éxito',
|
|
|
|
detail: 'Inquilino editado',
|
|
|
|
life: 3000,
|
2022-08-20 08:42:33 +00:00
|
|
|
})
|
2022-08-22 06:07:33 +00:00
|
|
|
tenantsList()
|
|
|
|
setTenant(emptyTenant)
|
|
|
|
setHouseNumber('')
|
|
|
|
})
|
|
|
|
}
|
2022-07-16 07:48:36 +00:00
|
|
|
}
|
2022-07-18 01:20:03 +00:00
|
|
|
|
2022-08-01 00:19:20 +00:00
|
|
|
const deleteTenant = () => {
|
2022-08-22 22:43:52 +00:00
|
|
|
|
2022-08-22 22:39:20 +00:00
|
|
|
let _tenant = {
|
|
|
|
community_id: tenant.community_id,
|
|
|
|
number_house: tenant.number_house
|
|
|
|
};
|
|
|
|
|
|
|
|
fetch('http://localhost:4000/user/deleteTenant/' + tenant._id, {
|
|
|
|
cache: 'no-cache',
|
|
|
|
method: 'PUT',
|
|
|
|
body: JSON.stringify(_tenant),
|
|
|
|
headers: {
|
2022-08-22 22:43:52 +00:00
|
|
|
'Content-Type': 'application/json'
|
2022-08-22 22:39:20 +00:00
|
|
|
}
|
2022-08-22 22:43:52 +00:00
|
|
|
})
|
2022-08-22 22:39:20 +00:00
|
|
|
.then(
|
2022-08-22 22:43:52 +00:00
|
|
|
function (response) {
|
|
|
|
if (response.status != 201)
|
|
|
|
console.log('Ocurrió un error con el servicio: ' + response.status);
|
|
|
|
else
|
|
|
|
return response.json();
|
|
|
|
}
|
2022-08-22 22:39:20 +00:00
|
|
|
)
|
|
|
|
.then(
|
2022-08-22 22:43:52 +00:00
|
|
|
function (response) {
|
|
|
|
|
|
|
|
let _tenants = tenants.filter((val) => val._id !== tenant._id)
|
|
|
|
setTenants(_tenants)
|
|
|
|
setDeleteTenantDialog(false)
|
|
|
|
setTenant(emptyTenant)
|
|
|
|
toast.current.show({
|
|
|
|
severity: 'success',
|
|
|
|
summary: 'Inquilino Eliminado',
|
|
|
|
life: 3000,
|
|
|
|
})
|
|
|
|
}
|
2022-08-22 22:39:20 +00:00
|
|
|
)
|
|
|
|
.catch(
|
2022-08-22 22:43:52 +00:00
|
|
|
err => {
|
|
|
|
console.log('Ocurrió un error con el fetch', err)
|
|
|
|
toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Inquilino no se pudo eliminar', life: 3000 });
|
|
|
|
}
|
2022-08-22 22:39:20 +00:00
|
|
|
);
|
2022-08-22 22:43:52 +00:00
|
|
|
|
|
|
|
|
2022-08-04 03:55:04 +00:00
|
|
|
}
|
2022-08-01 00:19:20 +00:00
|
|
|
|
|
|
|
const deleteSelectedTenants = () => {
|
2022-08-04 03:55:04 +00:00
|
|
|
let _tenants = tenants.filter((val) => !selectedTentants.includes(val))
|
|
|
|
setTenants(_tenants)
|
|
|
|
setDeleteTenantsDialog(false)
|
|
|
|
setSelectedTenants(null)
|
2022-08-01 00:19:20 +00:00
|
|
|
toast.current.show({
|
|
|
|
severity: 'success',
|
|
|
|
summary: 'Éxito',
|
|
|
|
detail: 'Inquilinos Eliminados',
|
|
|
|
life: 3000,
|
2022-08-04 03:55:04 +00:00
|
|
|
})
|
|
|
|
}
|
2022-07-24 23:44:25 +00:00
|
|
|
|
2022-08-03 04:46:15 +00:00
|
|
|
const cambiarStatusUser = () => {
|
2022-08-04 06:54:52 +00:00
|
|
|
if (tenant.status === '1') {
|
2022-08-04 03:55:04 +00:00
|
|
|
tenant.status = '0'
|
|
|
|
tenant.status_text = 'Inactivo'
|
2022-08-04 06:54:52 +00:00
|
|
|
} else if (tenant.status === '0') {
|
2022-08-04 03:55:04 +00:00
|
|
|
tenant.status = '1'
|
|
|
|
tenant.status_text = 'Activo'
|
2022-08-03 04:46:15 +00:00
|
|
|
}
|
|
|
|
var data = {
|
|
|
|
id: tenant._id,
|
|
|
|
status: tenant.status,
|
2022-08-04 03:55:04 +00:00
|
|
|
}
|
2022-08-03 04:46:15 +00:00
|
|
|
fetch('http://localhost:4000/user/changeStatus', {
|
|
|
|
cache: 'no-cache',
|
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify(data),
|
|
|
|
headers: {
|
2022-08-04 03:55:04 +00:00
|
|
|
'Content-Type': 'application/json',
|
|
|
|
},
|
2022-08-03 04:46:15 +00:00
|
|
|
})
|
2022-08-04 03:01:34 +00:00
|
|
|
.then((response) => {
|
2022-08-04 06:54:52 +00:00
|
|
|
if (response.status !== 201) {
|
2022-08-04 03:55:04 +00:00
|
|
|
console.log('Ocurrió un error con el servicio: ' + response.status)
|
|
|
|
} else {
|
|
|
|
return response.json()
|
|
|
|
}
|
2022-08-04 03:01:34 +00:00
|
|
|
})
|
2022-08-04 06:01:39 +00:00
|
|
|
.then(() => {
|
2022-08-04 03:55:04 +00:00
|
|
|
setChangeStatusTenantDialog(false)
|
2022-08-04 03:01:34 +00:00
|
|
|
toast.current.show({
|
|
|
|
severity: 'success',
|
|
|
|
summary: 'Éxito',
|
|
|
|
detail: 'Inquilino Actualizado',
|
|
|
|
life: 3000,
|
2022-08-04 03:55:04 +00:00
|
|
|
})
|
2022-08-04 03:01:34 +00:00
|
|
|
})
|
2022-08-04 03:55:04 +00:00
|
|
|
.catch((err) => console.log('Ocurrió un error con el fetch', err))
|
2022-08-03 04:46:15 +00:00
|
|
|
}
|
2022-07-24 23:44:25 +00:00
|
|
|
|
2022-08-01 00:19:20 +00:00
|
|
|
const hideDeleteTenantDialog = () => {
|
2022-08-04 03:55:04 +00:00
|
|
|
setDeleteTenantDialog(false)
|
2022-08-01 00:19:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const hideDeleteTenantsDialog = () => {
|
2022-08-04 03:55:04 +00:00
|
|
|
setDeleteTenantsDialog(false)
|
2022-08-01 00:19:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const confirmDeleteTenant = (tenant) => {
|
2022-08-04 03:55:04 +00:00
|
|
|
setTenant(tenant)
|
|
|
|
setDeleteTenantDialog(true)
|
2022-08-01 00:19:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const confirmDeleteSelected = () => {
|
2022-08-04 03:55:04 +00:00
|
|
|
setDeleteTenantsDialog(true)
|
|
|
|
}
|
2022-08-01 00:19:20 +00:00
|
|
|
|
2022-08-03 04:46:15 +00:00
|
|
|
const hideChangeStatusTenantDialog = () => {
|
2022-08-04 03:55:04 +00:00
|
|
|
setChangeStatusTenantDialog(false)
|
|
|
|
}
|
2022-08-03 04:46:15 +00:00
|
|
|
|
|
|
|
const confirmChangeStatusTenant = (tenant) => {
|
2022-08-04 03:55:04 +00:00
|
|
|
setTenant(tenant)
|
|
|
|
setChangeStatusTenantDialog(true)
|
|
|
|
}
|
2022-08-01 00:19:20 +00:00
|
|
|
|
2022-08-22 02:11:53 +00:00
|
|
|
const hideInfoDialog = () => {
|
|
|
|
setSubmitted(false);
|
|
|
|
setShowInfoDialog(false);
|
|
|
|
setTenant(emptyTenant);
|
|
|
|
}
|
|
|
|
|
|
|
|
const infoTenant = (tenant) => {
|
|
|
|
setTenant(tenant);
|
|
|
|
setShowInfoDialog(true);
|
|
|
|
}
|
|
|
|
|
2022-08-22 06:07:33 +00:00
|
|
|
const editTenant = (tenant) => {
|
|
|
|
setTenant(tenant);
|
|
|
|
console.log(tenant);
|
|
|
|
setSaveButtonTitle('Actualizar');
|
|
|
|
setHouseNumber(tenant.number_house);
|
|
|
|
}
|
|
|
|
|
|
|
|
const cancelEdit = () => {
|
|
|
|
setTenant(emptyTenant);
|
|
|
|
setSaveButtonTitle('Registrar');
|
|
|
|
setHouseNumber('');
|
|
|
|
}
|
|
|
|
|
2022-08-01 00:19:20 +00:00
|
|
|
const actionsTenant = (rowData) => {
|
2022-08-04 03:55:04 +00:00
|
|
|
let icono = ''
|
|
|
|
let text = ''
|
2022-08-04 06:54:52 +00:00
|
|
|
if (rowData.status === '0') {
|
2022-08-04 03:55:04 +00:00
|
|
|
icono = 'pi pi-eye'
|
|
|
|
text = 'Activar Inquilino'
|
2022-08-04 06:54:52 +00:00
|
|
|
} else if (rowData.status === '1') {
|
2022-08-04 03:55:04 +00:00
|
|
|
icono = 'pi pi-eye-slash'
|
2022-08-22 02:27:04 +00:00
|
|
|
text = 'Desactivar Inquilino'
|
2022-08-03 04:46:15 +00:00
|
|
|
}
|
2022-08-01 00:19:20 +00:00
|
|
|
return (
|
2022-08-04 03:55:04 +00:00
|
|
|
<div className='actions'>
|
2022-08-22 06:07:33 +00:00
|
|
|
<Button
|
|
|
|
icon="pi pi-pencil"
|
|
|
|
className="p-button-rounded p-button-success mt-2 mx-2"
|
|
|
|
onClick={() => editTenant(rowData)}
|
|
|
|
title="Editar"
|
|
|
|
/>
|
2022-08-22 02:11:53 +00:00
|
|
|
<Button
|
|
|
|
icon="pi pi-exclamation-circle"
|
|
|
|
className="p-button-rounded p-button-info mt-2 mx-2"
|
|
|
|
onClick={() => infoTenant(rowData)}
|
2022-08-22 02:27:04 +00:00
|
|
|
title="Ver Información"
|
2022-08-22 02:11:53 +00:00
|
|
|
/>
|
2022-08-04 03:55:04 +00:00
|
|
|
<Button
|
2022-08-03 04:46:15 +00:00
|
|
|
icon={`${icono}`}
|
2022-08-04 03:55:04 +00:00
|
|
|
className='p-button-rounded p-button-warning mt-2 mx-2'
|
2022-08-03 04:46:15 +00:00
|
|
|
onClick={() => confirmChangeStatusTenant(rowData)}
|
|
|
|
title={`${text}`}
|
|
|
|
/>
|
2022-08-04 03:55:04 +00:00
|
|
|
<Button
|
|
|
|
icon='pi pi-trash'
|
|
|
|
className='p-button-rounded p-button-danger mt-2 mx-2'
|
|
|
|
onClick={() => confirmDeleteTenant(rowData)}
|
2022-08-22 02:27:04 +00:00
|
|
|
title='Eliminar Inquilino'
|
2022-08-04 03:55:04 +00:00
|
|
|
/>
|
2022-07-24 23:44:25 +00:00
|
|
|
</div>
|
2022-08-04 03:55:04 +00:00
|
|
|
)
|
2022-08-01 00:19:20 +00:00
|
|
|
}
|
2022-07-24 23:44:25 +00:00
|
|
|
|
2022-08-01 00:19:20 +00:00
|
|
|
const leftToolbarTemplate = () => {
|
|
|
|
return (
|
2022-07-24 23:44:25 +00:00
|
|
|
<React.Fragment>
|
2022-08-04 03:55:04 +00:00
|
|
|
<div className='my-2'>
|
|
|
|
<Button
|
|
|
|
label='Eliminar'
|
|
|
|
icon='pi pi-trash'
|
|
|
|
className='p-button-danger'
|
|
|
|
onClick={confirmDeleteSelected}
|
|
|
|
disabled={!selectedTentants || !selectedTentants.length}
|
|
|
|
/>
|
2022-08-01 00:19:20 +00:00
|
|
|
</div>
|
2022-07-24 23:44:25 +00:00
|
|
|
</React.Fragment>
|
2022-08-01 00:19:20 +00:00
|
|
|
)
|
|
|
|
}
|
2022-07-24 23:44:25 +00:00
|
|
|
|
2022-08-01 00:19:20 +00:00
|
|
|
const rightToolbarTemplate = () => {
|
|
|
|
return (
|
2022-07-24 23:44:25 +00:00
|
|
|
<React.Fragment>
|
2022-08-04 03:55:04 +00:00
|
|
|
<Button
|
|
|
|
label='Exportar'
|
|
|
|
icon='pi pi-upload'
|
|
|
|
className='p-button-help'
|
|
|
|
/>
|
2022-07-24 23:44:25 +00:00
|
|
|
</React.Fragment>
|
2022-08-01 00:19:20 +00:00
|
|
|
)
|
|
|
|
}
|
2022-07-24 23:44:25 +00:00
|
|
|
|
2022-08-01 00:19:20 +00:00
|
|
|
const header = (
|
2022-08-04 03:55:04 +00:00
|
|
|
<div className='flex flex-column md:flex-row md:justify-content-between md:align-items-center'>
|
|
|
|
<h5 className='m-0'>Inquilinos</h5>
|
|
|
|
<span className='block mt-2 md:mt-0 p-input-icon-left'>
|
|
|
|
<i className='pi pi-search' />
|
|
|
|
<InputText
|
|
|
|
type='search'
|
|
|
|
onInput={(e) => setGlobalFilter(e.target.value)}
|
|
|
|
placeholder='Buscar...'
|
|
|
|
/>
|
2022-07-24 23:44:25 +00:00
|
|
|
</span>
|
2022-08-01 00:19:20 +00:00
|
|
|
</div>
|
2022-08-04 03:55:04 +00:00
|
|
|
)
|
2022-08-01 00:19:20 +00:00
|
|
|
|
|
|
|
const deleteTenantDialogFooter = (
|
|
|
|
<>
|
2022-08-04 03:55:04 +00:00
|
|
|
<Button
|
|
|
|
label='No'
|
|
|
|
icon='pi pi-times'
|
|
|
|
className='p-button-text'
|
|
|
|
onClick={hideDeleteTenantDialog}
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
label='Sí'
|
|
|
|
icon='pi pi-check'
|
|
|
|
className='p-button-text'
|
|
|
|
onClick={deleteTenant}
|
|
|
|
/>
|
2022-08-01 00:19:20 +00:00
|
|
|
</>
|
2022-08-04 03:55:04 +00:00
|
|
|
)
|
2022-08-01 00:19:20 +00:00
|
|
|
|
|
|
|
const deleteTenantsDialogFooter = (
|
|
|
|
<>
|
2022-08-04 03:55:04 +00:00
|
|
|
<Button
|
|
|
|
label='No'
|
|
|
|
icon='pi pi-times'
|
|
|
|
className='p-button-text'
|
|
|
|
onClick={hideDeleteTenantsDialog}
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
label='Sí'
|
|
|
|
icon='pi pi-check'
|
|
|
|
className='p-button-text'
|
|
|
|
onClick={deleteSelectedTenants}
|
|
|
|
/>
|
2022-08-01 00:19:20 +00:00
|
|
|
</>
|
2022-08-04 03:55:04 +00:00
|
|
|
)
|
2022-08-03 04:46:15 +00:00
|
|
|
|
|
|
|
const changeStatusTenantDialogFooter = (
|
|
|
|
<>
|
|
|
|
<Button
|
2022-08-04 03:55:04 +00:00
|
|
|
label='No'
|
|
|
|
icon='pi pi-times'
|
|
|
|
className='p-button-text'
|
2022-08-03 04:46:15 +00:00
|
|
|
onClick={hideChangeStatusTenantDialog}
|
|
|
|
/>
|
|
|
|
<Button
|
2022-08-04 03:55:04 +00:00
|
|
|
label='Sí'
|
|
|
|
icon='pi pi-check'
|
|
|
|
className='p-button-text'
|
2022-08-03 04:46:15 +00:00
|
|
|
onClick={cambiarStatusUser}
|
|
|
|
/>
|
|
|
|
</>
|
2022-08-04 03:55:04 +00:00
|
|
|
)
|
|
|
|
|
2022-08-22 02:11:53 +00:00
|
|
|
const infoDialogFooter = (
|
|
|
|
<>
|
|
|
|
<Button
|
|
|
|
label='Cerrar'
|
|
|
|
icon='pi pi-times'
|
|
|
|
className='p-button-text'
|
|
|
|
onClick={hideInfoDialog}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
2022-08-01 00:19:20 +00:00
|
|
|
const headerName = (
|
|
|
|
<>
|
2022-08-04 03:55:04 +00:00
|
|
|
<p>
|
|
|
|
<FontAwesomeIcon icon={faUserAlt} style={{ color: '#C08135' }} /> Nombre
|
|
|
|
</p>
|
2022-08-01 00:19:20 +00:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
|
|
|
|
const headerLastName = (
|
|
|
|
<>
|
2022-08-04 03:55:04 +00:00
|
|
|
<p>
|
|
|
|
<FontAwesomeIcon icon={faUserAlt} style={{ color: '#D7A86E' }} />{' '}
|
|
|
|
Apellidos
|
|
|
|
</p>
|
2022-08-01 00:19:20 +00:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
|
|
|
|
const headerDNI = (
|
|
|
|
<>
|
2022-08-04 03:55:04 +00:00
|
|
|
<p>
|
|
|
|
<FontAwesomeIcon icon={faIdCardAlt} style={{ color: '#C08135' }} />{' '}
|
|
|
|
Identificación
|
|
|
|
</p>
|
2022-08-01 00:19:20 +00:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
|
|
|
|
const headerEmail = (
|
|
|
|
<>
|
2022-08-04 03:55:04 +00:00
|
|
|
<p>
|
|
|
|
<FontAwesomeIcon icon={faAt} style={{ color: '#D7A86E' }} /> Correo
|
|
|
|
Electrónico
|
|
|
|
</p>
|
2022-08-01 00:19:20 +00:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
|
|
|
|
const headerPhone = (
|
|
|
|
<>
|
2022-08-04 03:55:04 +00:00
|
|
|
<p>
|
|
|
|
<FontAwesomeIcon icon={faPhoneAlt} style={{ color: '#C08135' }} />{' '}
|
|
|
|
Teléfono
|
|
|
|
</p>
|
2022-08-01 00:19:20 +00:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
|
|
|
|
const headerNumberHouse = (
|
|
|
|
<>
|
2022-08-04 03:55:04 +00:00
|
|
|
<p>
|
|
|
|
<FontAwesomeIcon icon={faHashtag} style={{ color: '#C08135' }} /> Número
|
|
|
|
de vivienda
|
|
|
|
</p>
|
2022-08-01 00:19:20 +00:00
|
|
|
</>
|
|
|
|
)
|
2022-07-24 23:44:25 +00:00
|
|
|
|
2022-08-03 04:48:36 +00:00
|
|
|
const headerStatus = (
|
|
|
|
<>
|
2022-08-04 03:55:04 +00:00
|
|
|
<p>
|
|
|
|
{' '}
|
|
|
|
<FontAwesomeIcon
|
|
|
|
icon={faCircleQuestion}
|
|
|
|
style={{ color: '#D7A86E' }}
|
|
|
|
/>{' '}
|
2022-08-03 04:48:36 +00:00
|
|
|
Estado
|
|
|
|
</p>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
|
|
|
|
const statusBodyTemplate = (rowData) => {
|
|
|
|
return (
|
|
|
|
<>
|
2022-08-04 03:55:04 +00:00
|
|
|
<span className={`status status-${rowData.status}`}>
|
2022-08-03 04:48:36 +00:00
|
|
|
{rowData.status_text}
|
|
|
|
</span>
|
|
|
|
</>
|
2022-08-04 03:55:04 +00:00
|
|
|
)
|
|
|
|
}
|
2022-08-03 04:46:15 +00:00
|
|
|
|
2022-08-21 01:04:02 +00:00
|
|
|
const onInputChange = (e, name) => {
|
2022-08-20 08:42:33 +00:00
|
|
|
const value = (e.target && e.target.value) || ''
|
|
|
|
let _tenant = { ...tenant }
|
|
|
|
_tenant[`${name}`] = value
|
|
|
|
setTenant(_tenant)
|
|
|
|
}
|
|
|
|
|
2022-08-21 09:50:27 +00:00
|
|
|
const handleHouses = (e) => {
|
|
|
|
const getHouseNumber = e.target.value;
|
|
|
|
setHouseNumber(getHouseNumber);
|
2022-08-16 23:49:10 +00:00
|
|
|
}
|
|
|
|
|
2022-07-18 01:20:03 +00:00
|
|
|
return (
|
2022-08-04 03:55:04 +00:00
|
|
|
<div className='grid'>
|
|
|
|
<div className='col-12'>
|
2022-08-01 00:19:20 +00:00
|
|
|
<Toast ref={toast} />
|
2022-08-04 03:55:04 +00:00
|
|
|
<div className='card'>
|
|
|
|
<Toolbar
|
|
|
|
className='mb-4'
|
|
|
|
left={leftToolbarTemplate}
|
|
|
|
right={rightToolbarTemplate}
|
|
|
|
></Toolbar>
|
|
|
|
<DataTable
|
|
|
|
ref={dt}
|
|
|
|
value={tenants}
|
|
|
|
dataKey='_id'
|
|
|
|
paginator
|
|
|
|
rows={5}
|
|
|
|
selection={selectedTentants}
|
|
|
|
onSelectionChange={(e) => setSelectedTenants(e.value)}
|
|
|
|
scrollable
|
|
|
|
scrollHeight='400px'
|
|
|
|
scrollDirection='both'
|
|
|
|
header={header}
|
|
|
|
rowsPerPageOptions={[5, 10, 25]}
|
|
|
|
className='datatable-responsive mt-3'
|
|
|
|
paginatorTemplate='FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown'
|
|
|
|
currentPageReportTemplate='Mostrando {first} a {last} de {totalRecords} inquilinos'
|
|
|
|
globalFilter={globalFilter}
|
|
|
|
emptyMessage='No hay inquilinos en esta comunidad registrados.'
|
|
|
|
>
|
|
|
|
<Column
|
|
|
|
selectionMode='multiple'
|
|
|
|
headerStyle={{ width: '3rem' }}
|
|
|
|
></Column>
|
|
|
|
<Column
|
|
|
|
field='name'
|
|
|
|
sortable
|
|
|
|
header={headerName}
|
|
|
|
style={{
|
|
|
|
flexGrow: 1,
|
|
|
|
flexBasis: '160px',
|
|
|
|
minWidth: '160px',
|
|
|
|
wordBreak: 'break-word',
|
|
|
|
}}
|
|
|
|
></Column>
|
|
|
|
<Column
|
|
|
|
field='last_name'
|
|
|
|
sortable
|
|
|
|
header={headerLastName}
|
|
|
|
style={{
|
|
|
|
flexGrow: 1,
|
|
|
|
flexBasis: '160px',
|
|
|
|
minWidth: '160px',
|
|
|
|
wordBreak: 'break-word',
|
|
|
|
}}
|
|
|
|
alignFrozen='left'
|
|
|
|
></Column>
|
|
|
|
<Column
|
|
|
|
field='dni'
|
|
|
|
sortable
|
|
|
|
header={headerDNI}
|
|
|
|
style={{
|
|
|
|
flexGrow: 1,
|
|
|
|
flexBasis: '160px',
|
|
|
|
minWidth: '160px',
|
|
|
|
wordBreak: 'break-word',
|
|
|
|
}}
|
|
|
|
></Column>
|
|
|
|
<Column
|
|
|
|
field='email'
|
|
|
|
sortable
|
|
|
|
header={headerEmail}
|
|
|
|
style={{
|
|
|
|
flexGrow: 1,
|
|
|
|
flexBasis: '160px',
|
|
|
|
minWidth: '160px',
|
|
|
|
wordBreak: 'break-word',
|
|
|
|
}}
|
|
|
|
></Column>
|
|
|
|
<Column
|
|
|
|
field='phone'
|
|
|
|
header={headerPhone}
|
|
|
|
style={{
|
|
|
|
flexGrow: 1,
|
|
|
|
flexBasis: '80px',
|
|
|
|
minWidth: '80px',
|
|
|
|
wordBreak: 'break-word',
|
|
|
|
}}
|
|
|
|
></Column>
|
|
|
|
<Column
|
|
|
|
field='number_house'
|
|
|
|
sortable
|
|
|
|
header={headerNumberHouse}
|
|
|
|
style={{
|
|
|
|
flexGrow: 1,
|
|
|
|
flexBasis: '160px',
|
|
|
|
minWidth: '160px',
|
|
|
|
wordBreak: 'break-word',
|
|
|
|
justifyContent: 'center',
|
|
|
|
}}
|
|
|
|
></Column>
|
2022-08-03 04:48:36 +00:00
|
|
|
<Column
|
2022-08-04 03:55:04 +00:00
|
|
|
field='status'
|
2022-08-03 04:48:36 +00:00
|
|
|
sortable
|
|
|
|
header={headerStatus}
|
|
|
|
body={statusBodyTemplate}
|
2022-08-04 03:55:04 +00:00
|
|
|
style={{
|
|
|
|
flexGrow: 1,
|
|
|
|
flexBasis: '160px',
|
|
|
|
minWidth: '160px',
|
|
|
|
wordBreak: 'break-word',
|
|
|
|
}}
|
|
|
|
></Column>
|
2022-08-22 06:07:33 +00:00
|
|
|
<Column style={{ flexGrow: 1, flexBasis: '80px', minWidth: '80px' }} body={actionsTenant}></Column>
|
2022-08-01 00:19:20 +00:00
|
|
|
</DataTable>
|
2022-08-22 02:11:53 +00:00
|
|
|
<Dialog
|
|
|
|
visible={infoDialogVisible}
|
|
|
|
style={{ width: '650px' }}
|
|
|
|
header="Información del Inquilino"
|
|
|
|
modal
|
|
|
|
className="p-fluid"
|
|
|
|
footer={infoDialogFooter}
|
|
|
|
onHide={hideInfoDialog}>
|
|
|
|
<div className='container text-center'>
|
|
|
|
<div className='row my-4'>
|
|
|
|
<div className=" col-4 md:col-4">
|
|
|
|
<p>Nombre</p>
|
|
|
|
<div className="p-0 col-2 md:col-2" style={{ margin: '0 auto' }}>
|
|
|
|
<div className="p-inputgroup align-items-center justify-content-evenly">
|
|
|
|
<i className="pi pi-user icon-khaki"></i>
|
|
|
|
<p>{tenant.name}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className=" col-4 md:col-4">
|
|
|
|
<p>Apellido(s)</p>
|
|
|
|
<div className="p-0 col-6 md:col-6" style={{ margin: '0 auto' }}>
|
|
|
|
<div className="p-inputgroup align-items-center justify-content-evenly">
|
|
|
|
<i className="pi pi-user icon-khaki"></i>
|
|
|
|
<p>{tenant.last_name}</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className=" col-4 col-md-4 md:col-4">
|
|
|
|
<p>Identificación</p>
|
|
|
|
<div className="p-0 col-10 md:col-10" style={{ margin: '0 auto' }}>
|
|
|
|
<div className="p-inputgroup align-items-center justify-content-evenly">
|
|
|
|
<i className="pi pi-id-card icon-khaki"></i>
|
|
|
|
<p>{tenant.dni}</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className='row my-5 justify-content-center'>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div className='row my-5 justify-content-center'>
|
|
|
|
<div className=" col-4 md:col-4">
|
|
|
|
<p>Teléfono</p>
|
|
|
|
<div className="p-0 col-10 md:col-10">
|
|
|
|
<div className="p-inputgroup align-items-center justify-content-evenly">
|
|
|
|
<i className="pi pi-phone icon-khaki"></i>
|
|
|
|
<p>{tenant.phone}</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className=" col-6 md:col-6">
|
|
|
|
<p>Correo Electrónico</p>
|
|
|
|
<div className="p-0 col-10 md:col-10" style={{ margin: '0 auto' }}>
|
|
|
|
<div className="p-inputgroup align-items-center justify-content-evenly">
|
|
|
|
<i className="pi pi-envelope icon-khaki"></i>
|
|
|
|
<p>{tenant.email}</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</Dialog>
|
2022-08-04 03:55:04 +00:00
|
|
|
<Dialog
|
|
|
|
visible={deleteTenantDialog}
|
|
|
|
style={{ width: '450px' }}
|
|
|
|
header='Confirmar'
|
|
|
|
modal
|
|
|
|
footer={deleteTenantDialogFooter}
|
|
|
|
onHide={hideDeleteTenantDialog}
|
|
|
|
>
|
|
|
|
<div className='flex align-items-center justify-content-center'>
|
|
|
|
<i
|
|
|
|
className='pi pi-exclamation-triangle mr-3'
|
|
|
|
style={{ fontSize: '2rem' }}
|
|
|
|
/>
|
|
|
|
{tenant && (
|
|
|
|
<span>
|
|
|
|
¿Estás seguro que desea eliminar a <b>{tenant.name}</b>?
|
|
|
|
</span>
|
|
|
|
)}
|
2022-08-01 00:19:20 +00:00
|
|
|
</div>
|
|
|
|
</Dialog>
|
2022-08-04 03:55:04 +00:00
|
|
|
<Dialog
|
|
|
|
visible={deleteTenantsDialog}
|
|
|
|
style={{ width: '450px' }}
|
|
|
|
header='Confirmar'
|
|
|
|
modal
|
|
|
|
footer={deleteTenantsDialogFooter}
|
|
|
|
onHide={hideDeleteTenantsDialog}
|
|
|
|
>
|
|
|
|
<div className='flex align-items-center justify-content-center'>
|
|
|
|
<i
|
|
|
|
className='pi pi-exclamation-triangle mr-3'
|
|
|
|
style={{ fontSize: '2rem' }}
|
|
|
|
/>
|
|
|
|
{selectedTentants && (
|
|
|
|
<span>¿Está seguro eliminar los inquilinos seleccionados?</span>
|
|
|
|
)}
|
2022-08-01 00:19:20 +00:00
|
|
|
</div>
|
|
|
|
</Dialog>
|
2022-08-03 04:46:15 +00:00
|
|
|
<Dialog
|
|
|
|
visible={changeStatusTenantDialog}
|
|
|
|
style={{ width: '450px' }}
|
2022-08-04 03:55:04 +00:00
|
|
|
header='Confirmar'
|
2022-08-03 04:46:15 +00:00
|
|
|
modal
|
|
|
|
footer={changeStatusTenantDialogFooter}
|
|
|
|
onHide={hideChangeStatusTenantDialog}
|
|
|
|
>
|
2022-08-04 03:55:04 +00:00
|
|
|
<div className='flex align-items-center justify-content-center'>
|
2022-08-03 04:46:15 +00:00
|
|
|
<i
|
2022-08-04 03:55:04 +00:00
|
|
|
className='pi pi-exclamation-triangle mr-3'
|
2022-08-03 04:46:15 +00:00
|
|
|
style={{ fontSize: '2rem' }}
|
|
|
|
/>
|
|
|
|
{tenant && (
|
|
|
|
<span>
|
|
|
|
¿Estás seguro que desea cambiar estado a <b>{tenant.name}</b>?
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</Dialog>
|
2022-08-01 00:19:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-21 02:25:55 +00:00
|
|
|
<div className="col-12">
|
|
|
|
<div className="card">
|
2022-08-22 11:04:54 +00:00
|
|
|
<h5>Registro de un Inquilino</h5>
|
2022-08-21 02:25:55 +00:00
|
|
|
<div className="p-fluid formgrid grid">
|
|
|
|
<div className="field col-12 md:col-6">
|
|
|
|
<label htmlFor="name">Nombre</label>
|
|
|
|
<div className="p-0 col-12 md:col-12">
|
|
|
|
<div className="p-inputgroup">
|
|
|
|
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
|
|
|
<i className="pi pi-home"></i>
|
|
|
|
</span>
|
2022-08-21 02:31:28 +00:00
|
|
|
<InputText type="text" id="name" value={tenant.name} onChange={(e) => onInputChange(e, 'name')} required autoFocus className={classNames({ 'p-invalid': submitted && tenant.name === '' })} />
|
2022-08-21 02:25:55 +00:00
|
|
|
</div>
|
|
|
|
{submitted && tenant.name === '' && <small className="p-invalid">Nombre es requerido.</small>}
|
|
|
|
</div>
|
2022-07-20 01:23:36 +00:00
|
|
|
</div>
|
2022-08-21 02:25:55 +00:00
|
|
|
<div className="field col-12 md:col-6">
|
|
|
|
<label htmlFor="name">Apellido(s)</label>
|
|
|
|
<div className="p-0 col-12 md:col-12">
|
|
|
|
<div className="p-inputgroup">
|
|
|
|
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
|
|
|
<i className="pi pi-home"></i>
|
|
|
|
</span>
|
2022-08-21 02:31:28 +00:00
|
|
|
<InputText type="text" id="last_name" value={tenant.last_name} onChange={(e) => onInputChange(e, 'last_name')} required autoFocus className={classNames({ 'p-invalid': submitted && tenant.last_name === '' })} />
|
2022-08-21 02:25:55 +00:00
|
|
|
</div>
|
2022-08-21 02:31:28 +00:00
|
|
|
{submitted && tenant.last_name === '' && <small className="p-invalid">Apellidos son requeridos.</small>}
|
2022-08-21 02:25:55 +00:00
|
|
|
</div>
|
2022-07-20 00:28:41 +00:00
|
|
|
</div>
|
2022-08-21 02:25:55 +00:00
|
|
|
<div className="field col-12 md:col-6">
|
|
|
|
<label htmlFor="name">Correo Electrónico</label>
|
|
|
|
<div className="p-0 col-12 md:col-12">
|
|
|
|
<div className="p-inputgroup">
|
|
|
|
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
|
|
|
<i className="pi pi-home"></i>
|
|
|
|
</span>
|
2022-08-21 02:31:28 +00:00
|
|
|
<InputText type='email' id="email" value={tenant.email} onChange={(e) => onInputChange(e, 'email')} required autoFocus className={classNames({ 'p-invalid': submitted && tenant.email === '' })} />
|
2022-08-21 02:25:55 +00:00
|
|
|
</div>
|
2022-08-21 02:31:28 +00:00
|
|
|
{submitted && tenant.email === '' && <small className="p-invalid">Correo electrónico es requerido.</small>}
|
2022-08-21 02:25:55 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="field col-12 md:col-6">
|
2022-08-21 02:31:28 +00:00
|
|
|
<label htmlFor="dni">Identificación</label>
|
2022-08-21 02:25:55 +00:00
|
|
|
<div className="p-0 col-12 md:col-12">
|
|
|
|
<div className="p-inputgroup">
|
|
|
|
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
|
|
|
<i className="pi pi-home"></i>
|
|
|
|
</span>
|
|
|
|
<InputText id="dni" value={tenant.dni} onChange={(e) => onInputChange(e, 'dni')} required autoFocus className={classNames({ 'p-invalid': submitted && tenant.dni === '' })} />
|
|
|
|
</div>
|
|
|
|
{submitted && tenant.email === '' && <small className="p-invalid">Identificación es requerida.</small>}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="field col-12 md:col-6">
|
2022-08-21 02:31:28 +00:00
|
|
|
<label htmlFor="phone">Número de teléfono</label>
|
2022-08-21 02:25:55 +00:00
|
|
|
<div className="p-0 col-12 md:col-12">
|
|
|
|
<div className="p-inputgroup">
|
|
|
|
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
|
|
|
<i className="pi pi-phone"></i>
|
|
|
|
</span>
|
2022-08-21 02:31:28 +00:00
|
|
|
<InputText id="phone" value={tenant.phone} onChange={(e) => onInputChange(e, 'phone')} type='tel' required autoFocus className={classNames({ 'p-invalid': submitted && tenant.phone === '' })} />
|
2022-08-21 02:25:55 +00:00
|
|
|
</div>
|
2022-08-21 09:50:27 +00:00
|
|
|
{submitted
|
|
|
|
&& tenant.phone === ''
|
|
|
|
&& <small className="p-invalid">Número de teléfono es requerido.</small>}
|
2022-08-21 02:25:55 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="field col-12 md:col-6">
|
2022-08-21 09:50:27 +00:00
|
|
|
<label htmlFor="number_house">Casa a asignar: </label>
|
2022-08-21 02:25:55 +00:00
|
|
|
<div className="p-0 col-12 md:col-12">
|
|
|
|
<div className="p-inputgroup">
|
|
|
|
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
|
|
|
<i className="pi pi-home"></i>
|
|
|
|
</span>
|
2022-08-21 09:50:27 +00:00
|
|
|
<Dropdown
|
|
|
|
placeholder="--Seleccione la Casa a Asignar--"
|
|
|
|
id="number_house"
|
|
|
|
value={houseNumber}
|
|
|
|
options={housesList}
|
|
|
|
onChange={handleHouses}
|
|
|
|
required autoFocus
|
|
|
|
className={
|
|
|
|
classNames({ 'p-invalid': submitted && !houseNumber })}
|
|
|
|
/>
|
2022-08-21 02:25:55 +00:00
|
|
|
</div>
|
2022-08-21 09:50:27 +00:00
|
|
|
{submitted
|
|
|
|
&& !houseNumber
|
|
|
|
&& <small className="p-invalid">Casa es requerida.</small>}
|
2022-08-21 02:25:55 +00:00
|
|
|
</div>
|
2022-07-20 00:28:41 +00:00
|
|
|
</div>
|
2022-08-22 06:07:33 +00:00
|
|
|
<div style={{
|
|
|
|
display: "flex",
|
|
|
|
justifyContent: "center",
|
|
|
|
gap: "10px",
|
|
|
|
width: "100%"
|
|
|
|
}}>
|
|
|
|
<Button
|
|
|
|
label={`${saveButtonTitle}`}
|
|
|
|
onClick={saveTenant}
|
|
|
|
/>
|
|
|
|
{saveButtonTitle === 'Actualizar' && (
|
|
|
|
<Button
|
|
|
|
label="Cancel"
|
|
|
|
onClick={cancelEdit}
|
|
|
|
className="p-button-danger" />)}
|
|
|
|
</div>
|
2022-07-20 00:28:41 +00:00
|
|
|
</div>
|
2022-07-18 01:20:03 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-04 03:55:04 +00:00
|
|
|
)
|
|
|
|
}
|
2022-07-18 01:30:06 +00:00
|
|
|
|
2022-08-04 03:55:04 +00:00
|
|
|
export default React.memo(Inquilinos)
|