import React, { useEffect, useState } from 'react'; import { InputText } from 'primereact/inputtext'; import { Button } from 'primereact/button'; import { DataTable } from 'primereact/datatable'; import { Column } from 'primereact/column'; const AdministradoresComunidad = () => { const [listaAdmins,setListaAdmins]=useState([]); const [listaAdminComunidad,setListaAdminComunidad]=useState([]); async function listaAdmin(){ let nombres=await fetch('http://localhost:4000/user/findAdminComunidad/', {method:'GET'}); let nombresRes= await nombres.json(); setListaAdmins(nombresRes.message); } async function listaComunidades(nombre){ let nombres=await fetch('http://localhost:4000/community/findCommunityName/'+nombre, {method:'GET'}); let nombresRes= await nombres.json(); setListaAdminComunidad(nombresRes.message); } listaAdmins.map(function(administrador){ listaComunidades(administrador.community_id); administrador.community_id=listaAdminComunidad.name; }) useEffect(()=>{ listaAdmin(); },[]) return (
Administradores de comunidad
) } export default React.memo(AdministradoresComunidad);