import { Button } from 'primereact/button'; import { InputText } from 'primereact/inputtext' import React, { useEffect, useState, useRef } from 'react' import { DataTable } from 'primereact/datatable'; import { Column } from 'primereact/column'; import { Dropdown } from 'primereact/dropdown'; import { InputText } from 'primereact/inputtext'; import React, { useEffect, useState } from 'react'; import { Toast } from 'primereact/toast'; import { Dialog } from 'primereact/dialog'; import { Toolbar } from 'primereact/toolbar'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faHome } from '@fortawesome/free-solid-svg-icons'; 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 { faHashtag } from '@fortawesome/free-solid-svg-icons'; const Inquilinos = () => { const [communitiesList, setCommunitiesList] = useState([]); const communityIdList = communitiesList.map((community) => community.id); async function getCommunites() { let response = await fetch( 'http://localhost:4000/community/allCommunities', { method: 'GET' }, ); let list = await response.json(); setCommunitiesList(await list); } useEffect(() => { getCommunites(); }, []) function registrarInquilino() { 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', }; 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'); } }); } const cList = communitiesList.map((item) => ({ label: item.name, value: item.id, })) const actionsAdmin = (rowData) => { return (
); } const leftToolbarTemplate = () => { return (
) } const rightToolbarTemplate = () => { return (