coreui-free-react-admin-template
coreui-free-react-admin-template copied to clipboard
Showing sidebar items by roles
First i want to say this template is really nice, my thing is i want to show the items on the sidebar deping on redux state for user roles, somthing like if((this.state.user.rol).includes('admin'){ ///... show side var items }
have you got solutions for this ? if yes please post it here
you can create your new navbar item list in src/_nav.js.
const customNav1 = {
items: [
{
name: 'Dashboard',
url: '/dashboard',
icon: 'icon-speedometer',
badge: {
variant: 'info',
text: 'NEW',
},
},
]
};
then import it to src/containers/DefaultLayout/DefaultLayout.js by changing few codes
//from
import navigation from '../../_nav';
//to
import {customNav1, customNav2} from '../../_nav';
then in render method, add some logic before return statement
if (isAdmin)
navigation = customNav1;
else
navigation = customNav2;
thanks so much @anantadwi13 , just need to put export for a variable to be exported in _nav