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