Semblen estabilitzats els elements condicionals privilegiats
This commit is contained in:
parent
261e23e7a0
commit
be572b07a4
@ -15,16 +15,14 @@ import { Usuaris } from './Usuaris';
|
|||||||
const Loguejat = lazy(async () => await import('/imports/ui/Loguejat.jsx'));
|
const Loguejat = lazy(async () => await import('/imports/ui/Loguejat.jsx'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
|
|
||||||
const user = useTracker("user", async () => await Meteor.userAsync());
|
const user = useTracker("user", async () => await Meteor.userAsync());
|
||||||
|
const userId = Meteor.userId();
|
||||||
|
|
||||||
const [esAdministrador, setEsAdministrador] = useState(false);
|
const [esAdministrador, setEsAdministrador] = useState(false);
|
||||||
|
|
||||||
const u = useTracker("user", async () => await Meteor.userAsync());
|
// const u = useTracker("user", async () => await Meteor.userAsync());
|
||||||
const userId = Meteor.userId();
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -32,13 +30,13 @@ export const App = () => {
|
|||||||
const comprovaAdmin = await Roles.userIsInRoleAsync(userId, ["admin"]);
|
const comprovaAdmin = await Roles.userIsInRoleAsync(userId, ["admin"]);
|
||||||
setEsAdministrador(comprovaAdmin);
|
setEsAdministrador(comprovaAdmin);
|
||||||
})();
|
})();
|
||||||
}, []);
|
}, [user]);
|
||||||
// const userId = await Meteor.userAsync();
|
// const userId = await Meteor.userAsync();
|
||||||
|
|
||||||
return <BrowserRouter>
|
return <BrowserRouter>
|
||||||
<UserStat />
|
{Meteor.userId() && <UserStat esAdministrador={esAdministrador} setEsAdministrador={setEsAdministrador} />}
|
||||||
|
|
||||||
<BarraNav />
|
<BarraNav esAdministrador={esAdministrador} setEsAdministrador={setEsAdministrador} />
|
||||||
|
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={ <Suspense fallback={<>Carregant...</>}>{user ? <Loguejat /> : <Login/>}</Suspense> } />
|
<Route path="/" element={ <Suspense fallback={<>Carregant...</>}>{user ? <Loguejat /> : <Login/>}</Suspense> } />
|
||||||
|
|||||||
@ -3,21 +3,34 @@ import { Link } from 'react-router-dom';
|
|||||||
import { Roles } from 'meteor/roles';
|
import { Roles } from 'meteor/roles';
|
||||||
import { PanellSeccions } from "./PanellSeccions/PanellSeccions";
|
import { PanellSeccions } from "./PanellSeccions/PanellSeccions";
|
||||||
|
|
||||||
const SeccióPobles = lazy(async () => await import('/imports/ui/BarraNav/PanellSeccions/PanellSeccions.jsx'));
|
const SeccióPobles = lazy(async () => {
|
||||||
const SeccióNecessitats = lazy(async () => await import('/imports/ui/BarraNav/PanellSeccions/PanellSeccions.jsx'));
|
const module = await import('/imports/ui/BarraNav/PanellSeccions/PanellSeccions.jsx');
|
||||||
const SeccióTipus = lazy(async () => await import('/imports/ui/BarraNav/PanellSeccions/PanellSeccions.jsx'));
|
return ({ default: module.SeccióPobles });
|
||||||
|
});
|
||||||
|
const SeccióNecessitats = lazy(async () => {
|
||||||
|
const module = await import('/imports/ui/BarraNav/PanellSeccions/PanellSeccions.jsx');
|
||||||
|
return ({ default: module.SeccióNecessitats });
|
||||||
|
});
|
||||||
|
const SeccióTipus = lazy(async () => {
|
||||||
|
const module = await import('/imports/ui/BarraNav/PanellSeccions/PanellSeccions.jsx');
|
||||||
|
return ({ default: module.SeccióTipus });
|
||||||
|
});
|
||||||
|
const SeccióUsuaris = lazy(async () => {
|
||||||
|
const module = await import('/imports/ui/BarraNav/PanellSeccions/PanellSeccions.jsx');
|
||||||
|
return ({ default: module.SeccióUsuaris });
|
||||||
|
});
|
||||||
|
|
||||||
const BarraNav = () => {
|
const BarraNav = ({esAdministrador, setEsAdministrador}) => {
|
||||||
const [esAdministrador, setEsAdministrador] = useState(false);
|
const userId = Meteor.userId();
|
||||||
const userId = Meteor.userId();
|
// const [esAdministrador, setEsAdministrador] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
(async () => {
|
// (async () => {
|
||||||
const comprovaAdmin = await Roles.userIsInRoleAsync(userId, ["admin"]);
|
// const comprovaAdmin = await Roles.userIsInRoleAsync(userId, ["admin"]);
|
||||||
setEsAdministrador(comprovaAdmin);
|
// setEsAdministrador(comprovaAdmin);
|
||||||
})();
|
// })();
|
||||||
}, []);
|
// }, [esAdministrador]);
|
||||||
|
|
||||||
|
|
||||||
return <PanellSeccions >
|
return <PanellSeccions >
|
||||||
|
|||||||
@ -27,20 +27,20 @@ const IndicadorMissatges = ({notif}) => {
|
|||||||
</span>;
|
</span>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const UserStat = ({setEditaPerfil}) => {
|
const UserStat = ({esAdministrador, setEsAdministrador}) => {
|
||||||
|
|
||||||
const [esAdministrador, setEsAdministrador] = useState(false);
|
// const [esAdministrador, setEsAdministrador] = useState(false);
|
||||||
|
|
||||||
const u = useTracker("user", async () => await Meteor.userAsync());
|
const u = useTracker("user", async () => await Meteor.userAsync());
|
||||||
const userId = Meteor.userId();
|
const userId = Meteor.userId();
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
// (async () => {
|
// (async () => {
|
||||||
const comprovaAdmin = Roles.userIsInRole(userId, ["admin"]);
|
// const comprovaAdmin = await Roles.userIsInRoleAsync(userId, ["admin"]);
|
||||||
setEsAdministrador(comprovaAdmin);
|
// setEsAdministrador(comprovaAdmin);
|
||||||
// })()1
|
// })();
|
||||||
}, []);
|
// }, [Meteor.userId()]);
|
||||||
|
|
||||||
// const u = useUserContext();
|
// const u = useUserContext();
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ const UserStat = ({setEditaPerfil}) => {
|
|||||||
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{ u && esAdministrador && <div style={{
|
{ (u && esAdministrador) && <div style={{
|
||||||
color: `red`,
|
color: `red`,
|
||||||
fontSize: `xx-small`,
|
fontSize: `xx-small`,
|
||||||
// textAlign: `right`
|
// textAlign: `right`
|
||||||
@ -119,8 +119,6 @@ const UserStat = ({setEditaPerfil}) => {
|
|||||||
margin: `0.3em 0.3em 0.3em auto`
|
margin: `0.3em 0.3em 0.3em auto`
|
||||||
}}>{u?.username}</span>
|
}}>{u?.username}</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
verticalAlign: `middle`,
|
verticalAlign: `middle`,
|
||||||
|
|||||||
35
package-lock.json
generated
35
package-lock.json
generated
@ -8,12 +8,11 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.20.7",
|
"@babel/runtime": "^7.20.7",
|
||||||
"meteor-node-stubs": "^1.2.5",
|
"meteor-node-stubs": "^1.2.5",
|
||||||
"react": "19.0.0-rc.1",
|
"react": "19",
|
||||||
"react-dom": "19.0.0-rc.1",
|
"react-dom": "19",
|
||||||
"react-router-dom": "^6.28.0",
|
"react-router-dom": "^6.28.0",
|
||||||
"react-select": "^5.8.3",
|
"react-select": "^5.8.3",
|
||||||
"styled-components": "^6.1.13",
|
"styled-components": "^6.1.13"
|
||||||
"tailwindcss": "^4.0.0-beta.4"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@babel/code-frame": {
|
"node_modules/@babel/code-frame": {
|
||||||
@ -1952,24 +1951,24 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react": {
|
"node_modules/react": {
|
||||||
"version": "19.0.0-rc.1",
|
"version": "19.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/react/-/react-19.0.0-rc.1.tgz",
|
"resolved": "https://registry.npmjs.org/react/-/react-19.0.0.tgz",
|
||||||
"integrity": "sha512-NZKln+uyPuyHchzP07I6GGYFxdAoaKhehgpCa3ltJGzwE31OYumLeshGaitA1R/fS5d9D2qpZVwTFAr6zCLM9w==",
|
"integrity": "sha512-V8AVnmPIICiWpGfm6GLzCR/W5FXLchHop40W4nXBmdlEceh16rCN8O8LNWm5bh5XUX91fh7KpA+W0TgMKmgTpQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-dom": {
|
"node_modules/react-dom": {
|
||||||
"version": "19.0.0-rc.1",
|
"version": "19.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.0.0-rc.1.tgz",
|
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.0.0.tgz",
|
||||||
"integrity": "sha512-k8MfDX+4G+eaa1cXXI9QF4d+pQtYol3nx8vauqRWUEOPqC7NQn2qmEqUsLoSd28rrZUL+R3T2VC+kZ2Hyx1geQ==",
|
"integrity": "sha512-4GV5sHFG0e/0AD4X+ySy6UJd3jVl1iNsNHdpad0qhABJ11twS3TTBnseqsKurKcsNqCEFeGL3uLpVChpIO3QfQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"scheduler": "0.25.0-rc.1"
|
"scheduler": "^0.25.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "19.0.0-rc.1"
|
"react": "^19.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-is": {
|
"node_modules/react-is": {
|
||||||
@ -2127,9 +2126,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/scheduler": {
|
"node_modules/scheduler": {
|
||||||
"version": "0.25.0-rc.1",
|
"version": "0.25.0",
|
||||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.25.0-rc.1.tgz",
|
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.25.0.tgz",
|
||||||
"integrity": "sha512-fVinv2lXqYpKConAMdergOl5owd0rY1O4P/QTe0aWKCqGtu7VsCt1iqQFxSJtqK4Lci/upVSBpGwVC7eWcuS9Q==",
|
"integrity": "sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/shallowequal": {
|
"node_modules/shallowequal": {
|
||||||
@ -2202,12 +2201,6 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tailwindcss": {
|
|
||||||
"version": "4.0.0-beta.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.0.0-beta.4.tgz",
|
|
||||||
"integrity": "sha512-mkjpwMyaHCa3L5HmRjYyY8w8D+7brxwbM7YQxH8QeEFtCURd5fvdHIC9TEpIaL1X49vhl8cuOFY6Nhi6sCsI5w==",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/tslib": {
|
"node_modules/tslib": {
|
||||||
"version": "2.6.2",
|
"version": "2.6.2",
|
||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||||
|
|||||||
@ -10,12 +10,11 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.20.7",
|
"@babel/runtime": "^7.20.7",
|
||||||
"meteor-node-stubs": "^1.2.5",
|
"meteor-node-stubs": "^1.2.5",
|
||||||
"react": "19.0.0-rc.1",
|
"react": "19",
|
||||||
"react-dom": "19.0.0-rc.1",
|
"react-dom": "19",
|
||||||
"react-router-dom": "^6.28.0",
|
"react-router-dom": "^6.28.0",
|
||||||
"react-select": "^5.8.3",
|
"react-select": "^5.8.3",
|
||||||
"styled-components": "^6.1.13",
|
"styled-components": "^6.1.13"
|
||||||
"tailwindcss": "^4.0.0-beta.4"
|
|
||||||
},
|
},
|
||||||
"meteor": {
|
"meteor": {
|
||||||
"mainModule": {
|
"mainModule": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user