agregar registro de inquilino

This commit is contained in:
Eduardo Quiros 2022-07-19 18:28:41 -06:00
parent 358913fe77
commit c4dcbfacd3
No known key found for this signature in database
GPG Key ID: B77F36C3F12720B4
1 changed files with 32 additions and 10 deletions

View File

@ -6,24 +6,46 @@ const Inquilinos = () => {
function registrarInquilino() { function registrarInquilino() {
let data = { let data = {
email: document.getElementById('correo_electronico').value, email: document.getElementById('correo_electronico').value,
user_type: '1', //1 es admin TODO: cambiar a otro valor user_type: '3',
status: '1', status: '1',
} }
fetch('http://localhost:3000/api/createUser', {
method: 'POST',
cache: 'no-cache',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json',
},
}).then((response) => {
if (response.ok) {
alert('Inquilino registrado correctamente')
} else {
alert('Error al registrar inquilino')
}
})
} }
return ( return (
<div className="grid"> <div className="grid">
<div className="col-12"> <div className="col-12">
<div className="card"> <div className="card">
<h5>Inquilinos</h5> <h5 className="card-header">Registrar inquilino</h5>
<DataTable value={listaInquilinos} scrollable scrollHeight="400px" scrollDirection="both" className="mt-3"> <div className="card-body">
<Column field="name" header="Nombre" style={{ flexGrow: 1, flexBasis: '160px' }}></Column> <div className="p-fluid formgrid grid">
<Column field="last_name" header="Apellidos" style={{ flexGrow: 1, flexBasis: '160px' }}></Column> <div className="p-field col-12 md:col-6">
<Column field="dni" header="Identificación" style={{ flexGrow: 1, flexBasis: '160px' }}></Column> <label htmlFor="correo_electronico">Correo electrónico</label>
<Column field="email" header="Correo electrónico" style={{ flexGrow: 1, flexBasis: '160px' }}></Column> <input type="email" className="form-control" id="correo_electronico" />
<Column field="phone" header="Telefóno" style={{ flexGrow: 1, flexBasis: '180px' }}></Column> </div>
<Column field="community_id" header="Comunidad" style={{ flexGrow: 1, flexBasis: '160px' }}></Column> <div className="p-field col-12 md:col-6">
</DataTable> <label htmlFor="numero_vivienda">Número de Vivienda</label>
<input type="text" className="form-control" id="numero_vivienda" />
</div>
</div>
<button type="button" className="btn btn-primary" onClick={registrarInquilino()}>
Registrar
</button>
</div>
</div> </div>
</div> </div>
</div> </div>