From c8790f1005b481107e86bda1e922127a3f0ed290 Mon Sep 17 00:00:00 2001 From: Pasq G Date: Sat, 4 Jan 2025 23:08:42 +0100 Subject: [PATCH] Rols visibles a Usuaris --- imports/ui/Usuaris.jsx | 92 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 86 insertions(+), 6 deletions(-) diff --git a/imports/ui/Usuaris.jsx b/imports/ui/Usuaris.jsx index 8873b5a..afadf0c 100644 --- a/imports/ui/Usuaris.jsx +++ b/imports/ui/Usuaris.jsx @@ -38,6 +38,30 @@ import { useNavigate, Link } from 'react-router-dom'; const U = ({u, esAdministrador}) => { + const [adm, setAdm] = useState(false); + const [mon, setMon] = useState(false); + const [enc, setEnc] = useState(false); + const [vol, setVol] = useState(false); + + (async () => { + const esAdmin = await Roles.userIsInRoleAsync(u._id, ["admin"]); + setAdm(esAdmin); + const esMonit = await Roles.userIsInRoleAsync(u._id, ["monitor_de_poble"], {anyScope: true}); + setMon(esMonit); + const esEncar = await Roles.userIsInRoleAsync(u._id, ["encarregat_de_tasques"], {anyScope: true}); + setEnc(esEncar); + const esVolun = await Roles.userIsInRoleAsync(u._id, ["voluntari_de_poble"], {anyScope: true}); + setVol(esVolun); + // setEsAdministrador(comprovaAdmin); + })(); + + + // console.log("adm: ", adm); + // console.log("mon: ", mon); + // console.log("enc: ", enc); + // console.log("vol: ", vol); + + // const [esAdministrador, setEsAdministrador] = useState(false); // const u = useTracker("user", async () => await Meteor.userAsync()); @@ -109,11 +133,30 @@ const U = ({u, esAdministrador}) => { }} > - { (u && esAdministrador) &&
ADMIN
} +
+ { (u && adm) &&
ADMIN
} + { (u && mon) &&
mon
} + { (u && enc) &&
enc
} + { (u && vol) &&
vol
} +
{ }, []); // })(); + // const [monitors, setMonitors] = useState(false); + // const [encarregats, setEncarregats] = useState(false); + // const [voluntaris, setVoluntaris] = useState(false); + // const [administradors, setAdministradors] = useState(false); + + // let mon, mons, enc, encs, vol, vols; + // let + // administradors, + // monitors, + // encarregats, + // voluntaris + // ; + + + // (async () => { + // const admins = await Roles.getUsersInRoleAsync("administrador"); + // // console.log("admins: ", admins); + // administradors = await admins?.fetchAsync(); + // console.log("administradors: ", administradors); + + // const mons = await Roles.getUsersInRoleAsync("monitor_de_poble"); + // // console.log("mons: ", mons); + // monitors = await mons?.fetchAsync(); + // console.log("monitors: ", monitors); + + // const encs = await Roles.getUsersInRoleAsync("encarregat_de_tasques"); + // // console.log("encs: ", encs); + // encarregats = await encs?.fetchAsync(); + // console.log("encarregats: ", encarregats); + + // const vols = await Roles.getUsersInRoleAsync("voluntari_de_poble"); + // // console.log("vols: ", vols); + // voluntaris = await vols?.fetchAsync(); + // console.log("voluntaris: ", voluntaris); + // })(); + + const QuadreInfo_Usuari = () => { return
{ }} > {/* {usr.username}{esEditor && } */} - + ) } ;