bit of a coding noob here lol…
I am having some trouble with one final part of my code. In Mongo, I have a “privileged” document, which is set to false for some users. If a particular user has this privileged field as false, I only want them to access one part of the platform which is the code in my app.js file down below:
<PrivateRoute path = "/training-centre" component = {Training} />
Can I have some sort of if statement in my app.js which checks to see if a user is privileged, and then just have that route inside the if statement? So something like this:
const App = (userData) => {
const {isLoading} = useAuth0();
if (isLoading) {
return <Loading />;
}
return (
<div className="App">
<header className="App-header">
<Router>
<Route exact path = "/" component= {Login} />
{userData.privileged == false && (
<Route exact path="/training-centre" component={Training} />
)}
Not sure on the best way to achieve what I am trying to do…
I tried to use something similar to achieve what I am doing from here but no luck: