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 Pobles = () => { const [pobleSeleccionat, setPobleSeleccionat] = useState(null); useSubscribe('pobles'); const pobles = useTracker("pobles", () => PoblesCollection.find().fetchAsync()); const [esEditor, setEsEditor] = useState(false); const userId = Meteor.userId(); // console.log("isAdmin: ", isAdmin) ; // (async () => { useEffect(() => { (async () => { const comprovaAdmin = await Roles.userIsInRoleAsync(userId, ["admin"]); setEsEditor(comprovaAdmin); })(); }, []); // })(); const QuadreInfo_Poble = () => { return
{pobleSeleccionat &&

{pobleSeleccionat._id}

}

Pobles

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


; }; return Carregant...} > { esEditor && } ; };