Intent ESlint

This commit is contained in:
Pasq G 2025-01-03 10:19:28 +01:00
parent c566cad6e7
commit 5f83dc17fd
6 changed files with 1596 additions and 34 deletions

12
eslint.config.mjs Normal file
View File

@ -0,0 +1,12 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import pluginReact from "eslint-plugin-react";
/** @type {import('eslint').Linter.Config[]} */
export default [
{files: ["**/*.{js,mjs,cjs,jsx}"]},
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
pluginReact.configs.flat.recommended,
];

View File

@ -30,10 +30,10 @@ export const Poble = () => {
const userId = Meteor.userId(); const userId = Meteor.userId();
let pob; let pob;
console.log("ambitPoble: ", ambitPoble); // console.log("ambitPoble: ", ambitPoble);
console.log("pobles: ", pobles); // console.log("pobles: ", pobles);
pob = pobles.find(p => p.ambitAssociat === ambitPoble); pob = pobles.find(p => p.ambitAssociat === ambitPoble);
console.log("pob: ", pob); // console.log("pob: ", pob);
// console.log("isAdmin: ", isAdmin) ; // console.log("isAdmin: ", isAdmin) ;
@ -121,7 +121,7 @@ export const Poble = () => {
{ {
(async () => { (async () => {
const monitors = await Roles.getUsersInRoleAsync("monitor_de_poble", pob?.ambitAssociat); const monitors = await Roles.getUsersInRoleAsync("monitor_de_poble", pob?.ambitAssociat);
console.log("monitors: ", monitors); // console.log("monitors: ", monitors);
return monitors?.map( (u) => <li style={{ return monitors?.map( (u) => <li style={{
display: `block`, display: `block`,
border: `1px solid #6666`, border: `1px solid #6666`,
@ -139,7 +139,7 @@ export const Poble = () => {
{ {
(async () => { (async () => {
const encarregats = await Roles.getUsersInRoleAsync("encarregat_de_tasques", pob?.ambitAssociat); const encarregats = await Roles.getUsersInRoleAsync("encarregat_de_tasques", pob?.ambitAssociat);
console.log("encarregats: ", encarregats); // console.log("encarregats: ", encarregats);
return encarregats?.map( (u) => <li style={{ return encarregats?.map( (u) => <li style={{
display: `block`, display: `block`,
border: `1px solid #6666`, border: `1px solid #6666`,
@ -157,7 +157,7 @@ export const Poble = () => {
{ {
(async () => { (async () => {
const voluntaris = await Roles.getUsersInRoleAsync("voluntari_de_poble", pob?.ambitAssociat); const voluntaris = await Roles.getUsersInRoleAsync("voluntari_de_poble", pob?.ambitAssociat);
console.log("voluntaris: ", voluntaris); // console.log("voluntaris: ", voluntaris);
return voluntaris?.map( (u) => <li style={{ return voluntaris?.map( (u) => <li style={{
display: `block`, display: `block`,
border: `1px solid #6666`, border: `1px solid #6666`,

View File

@ -17,6 +17,8 @@ export const Pobles = () => {
const [pobleSeleccionat, setPobleSeleccionat] = useState(null); const [pobleSeleccionat, setPobleSeleccionat] = useState(null);
const [creantPoble, setCreantPoble] = useState(false); const [creantPoble, setCreantPoble] = useState(false);
useSubscribe('pobles'); useSubscribe('pobles');
useSubscribe('usuaris');
// const pobles = useTracker("pobles", () => PoblesCollection.find().fetchAsync()); // const pobles = useTracker("pobles", () => PoblesCollection.find().fetchAsync());
const pobles = useFind(PoblesCollection, [{}, {sort: {nomPoble: 1}}]); const pobles = useFind(PoblesCollection, [{}, {sort: {nomPoble: 1}}]);
@ -38,17 +40,24 @@ export const Pobles = () => {
useSubscribe('necessitats', pob.ambitAssociat); useSubscribe('necessitats', pob.ambitAssociat);
const necessitats = useFind(NecessitatsCollection, [{"poble.ambitAssociat": pob.ambitAssociat}]); const necessitats = useFind(NecessitatsCollection, [{"poble.ambitAssociat": pob.ambitAssociat}]);
const [monitors, setMonitors] = useState(false); const [monitors, setMonitors] = useState(false);
const [encarregats, setEncarregats] = useState(false);
const [voluntaris, setVoluntaris] = useState(false);
// let mon, mons, enc, encs, vol, vols;
useEffect(() => { (async () => {
(async () => { const mons = await Roles.getUsersInRoleAsync("monitor_de_poble", pob?.ambitAssociat);
const mon = await Roles.getUsersInRoleAsync('monitor_de_poble', pob.ambitAssociat); // console.log("monitors: ", monitors);
setMonitors(mon.map(m => m).length); setMonitors(mons?.fetch().length || false);
})();
}, [pob]); const encs = await Roles.getUsersInRoleAsync("encarregat_de_tasques", pob?.ambitAssociat);
// console.log("monitors: ", monitors);
setEncarregats(encs?.fetch().length || false);
// console.log("mon: ", monitors);
const vols = await Roles.getUsersInRoleAsync("voluntari_de_poble", pob?.ambitAssociat);
// console.log("monitors: ", monitors);
setVoluntaris(vols?.fetch().length || false);
})();
return <li return <li
key={`pob_${pob._id}`} key={`pob_${pob._id}`}
@ -67,14 +76,16 @@ export const Pobles = () => {
<div style={{ <div style={{
position: `absolute`, position: `absolute`,
// display: `inline-block`, // display: `inline-block`,
display: `flex`, display: `grid`,
gridTemplateAreas: `"mons encs vols"`,
justifyContent: `space-around`, justifyContent: `space-around`,
left: `0`, left: `0`,
top: `-.8em`, top: `-.8em`,
width: `100%`, width: `100%`,
fontSize: `60%`, fontSize: `60%`,
textAlign: `center`, textAlign: `center`,
pointerEvents: `none` pointerEvents: `none`,
alignItems: `center`
}}> }}>
{ {
monitors monitors
@ -82,22 +93,34 @@ export const Pobles = () => {
border: `1px solid #6666`, border: `1px solid #6666`,
borderRadius: `50%`, borderRadius: `50%`,
minWidth: `1rem`, minWidth: `1rem`,
backgroundColor: `#ff0a` minHeight: `1rem`,
backgroundColor: `#f006`,
gridArea: `mons`
}}>{monitors}</span> }}>{monitors}</span>
: false : false
} }
<span style={{ { encarregats
border: `1px solid #6666`, ? <span style={{
borderRadius: `50%`, border: `1px solid #6666`,
minWidth: `1rem`, borderRadius: `50%`,
backgroundColor: `#fffa` minWidth: `1rem`,
}}>2</span> minHeight: `1rem`,
<span style={{ backgroundColor: `#fa0a`,
border: `1px solid #6666`, gridArea: `encs`
borderRadius: `50%`, }}>{encarregats}</span>
minWidth: `1rem`, : false
backgroundColor: `#fffa` }
}}>3</span> { voluntaris
? <span style={{
border: `1px solid #6666`,
borderRadius: `50%`,
minWidth: `1rem`,
minHeight: `1rem`,
backgroundColor: `#ff06`,
gridArea: `vols`
}}>{voluntaris}</span>
: false
}
</div> </div>
} }
@ -123,7 +146,7 @@ export const Pobles = () => {
border: `1px solid #6666`, border: `1px solid #6666`,
borderRadius: `50%`, borderRadius: `50%`,
minWidth: `1rem`, minWidth: `1rem`,
backgroundColor: `#f006` backgroundColor: `#00a6`
}}>{necessitats.length }</span> }}>{necessitats.length }</span>
: false : false
} }
@ -229,7 +252,7 @@ export const Pobles = () => {
pobles pobles
.sort((a,b) => a.nomPoble?.toLowerCase() > b.nomPoble?.toLowerCase()) .sort((a,b) => a.nomPoble?.toLowerCase() > b.nomPoble?.toLowerCase())
.map(pob => { .map(pob => {
return <BotoPobleAmbIndicadors pob={pob} /> return <BotoPobleAmbIndicadors pob={pob} key={`pob_${pob.ambitAssociat}`} />
}) })
}</ul> }</ul>

View File

@ -169,10 +169,10 @@ export const Usuaris = () => {
return await Roles.getRolesForUserAsync(usrSeleccionat?._id); return await Roles.getRolesForUserAsync(usrSeleccionat?._id);
}); });
console.log("rols: ", rols); // console.log("rols: ", rols);
// console.log("isAdmin: ", isAdmin) ; // console.log("isAdmin: ", isAdmin) ;
console.log("usuaris: ", usuaris); // console.log("usuaris: ", usuaris);
// (async () => { // (async () => {
useEffect(() => { useEffect(() => {
(async () => { (async () => {

1523
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -23,5 +23,9 @@
"server": "server/main.js" "server": "server/main.js"
}, },
"testModule": "tests/main.js" "testModule": "tests/main.js"
},
"devDependencies": {
"babel-plugin-react-compiler": "^19.0.0-beta-55955c9-20241229",
"eslint-plugin-react-compiler": "^19.0.0-beta-55955c9-20241229"
} }
} }