import React, { Suspense, useEffect, useState, useRef, lazy } from 'react'; import { Meteor } from 'meteor/meteor'; import { PoblesCollection } from '/imports/api/pobles.js'; import { useSubscribe, useTracker, useFind } from 'meteor/react-meteor-data/suspense'; import { Roles } from 'meteor/roles'; // import { useUserId } from 'meteor/react-meteor-accounts'; import { BarraNav } from "./BarraNav/BarraNav"; export const Usuaris = () => { const [usrSeleccionat, setUsrSeleccionat] = useState(null); useSubscribe('pobles'); const pobles = useTracker("pobles", () => PoblesCollection.find().fetchAsync()); const [esEditor, setEsEditor] = useState(false); const userId = Meteor.userId(); const usuaris = useTracker("usuaris", () => { Meteor.subscribe('usuaris'); return Meteor.users.find().fetch().filter(u => u._id !== Meteor.userId()); }); // console.log("isAdmin: ", isAdmin) ; console.log("usuaris: ", usuaris); // (async () => { useEffect(() => { (async () => { const comprovaAdmin = await Roles.userIsInRoleAsync(userId, ["admin"]); setEsEditor(comprovaAdmin); })(); }, []); // })(); const QuadreInfo_Usuari = () => { return
{usrSeleccionat &&

{usrSeleccionat._id}

}
{ try { Meteor.callAsync('editaOAfigPoble', { ...usrSeleccionat || [], nomPoble: d.get('nomPoble'), cp: d.get('cp') || "", comarca: d.get('comarca') || "", }).then(() => setUsrSeleccionat(null)) .catch(err => console.error(err)); } catch (err) { alert(err); console.error(err); } }} >


; }; return Carregant...} >

Usuaris

{ esEditor && }
; };