Assignació de rol admin

This commit is contained in:
Pasq G 2025-01-08 03:05:30 +01:00
parent 6efa6956d7
commit 8c67900952
2 changed files with 10 additions and 5 deletions

View File

@ -42,7 +42,7 @@ const BarraNav = ({esAdministrador, setEsAdministrador}) => {
<SeccióPobles /> <SeccióPobles />
<SeccióNecessitats /> <SeccióNecessitats />
<SeccióTipus /> <SeccióTipus />
<SeccióCodis /> { esAdministrador && <SeccióCodis />}
</PanellSeccions>; </PanellSeccions>;
}; };

View File

@ -248,8 +248,9 @@ const U = ({u, esAdministrador, setUsrSeleccionat}) => {
const AssignadorDeRols = ({pobles, ambitGeneral, esEditor, rols, usrSeleccionat, ambitsUSel}) => { const AssignadorDeRols = ({pobles, esEditor, rols, usrSeleccionat, ambitsUSel}) => {
const [creantRol, setCreantRol] = useState(false); const [creantRol, setCreantRol] = useState(false);
const [ambitGeneral, setAmbitGeneral] = useState(false);
// const [ambitsUSel, setAmbitsUSel] = useState([]); // const [ambitsUSel, setAmbitsUSel] = useState([]);
// let ambitsUSel; // let ambitsUSel;
// let ambitsUSel = []; // let ambitsUSel = [];
@ -342,16 +343,20 @@ const AssignadorDeRols = ({pobles, ambitGeneral, esEditor, rols, usrSeleccionat,
backgroundColor: `#fffa` backgroundColor: `#fffa`
}}> }}>
<form action={d => { <form action={d => {
Meteor.callAsync('assignaRol', usrSeleccionat._id, d.get('selRol'), d.get('selAmbit')); if (ambitGeneral) {
Meteor.callAsync('assignaRol', usrSeleccionat._id, d.get('selRol'));
} else {
Meteor.callAsync('assignaRol', usrSeleccionat._id, d.get('selRol'), d.get('selAmbit'));
}
}}> }}>
Àmbit: <select name="selAmbit" id="selAmbit" Àmbit: <select name="selAmbit" id="selAmbit"
onChange={ev => setAmbitGeneral(ev.target.value === "general")} onChange={ev => setAmbitGeneral(ev.target.value === "GENERAL")}
> >
{ {
pobles.sort((a,b) => a.ambitAssociat > b.ambitAssociat).map((pob,i) => <option key={`optAmb_${i}`} value={pob.ambitAssociat}>{pob.ambitAssociat}</option>) pobles.sort((a,b) => a.ambitAssociat > b.ambitAssociat).map((pob,i) => <option key={`optAmb_${i}`} value={pob.ambitAssociat}>{pob.ambitAssociat}</option>)
} }
<option value={"general"}>General</option> <option value={"GENERAL"}>General</option>
</select> <br /> </select> <br />
Rol: <select name="selRol" id="selRol"> Rol: <select name="selRol" id="selRol">