{% if menuItems is not defined %}
	{% set menuItems = getMenuItemsFromAlias('main') %}
{% endif %}



<nav class="menu navbar navbar-expand-md navbar-light bg-light">
	<a class="navbar-brand" href="{{ url('index') }}">
		<img src="/images/logo.png" height="45" class="d-inline-block align-top" alt="{{ parameter('mlc_name') }}">
	</a>
	<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
		<span class="navbar-toggler-icon"></span>
	</button>

	{% if menuItems is not null and menuItems|length > 0 %}
		{% import 'common/menu_tree_macro.html.twig' as tree %}
		{% set currentPath = app.request.requestUri %}
		<div class="collapse navbar-collapse" id="navbarSupportedContent">
			<ul class="navbar-nav ml-auto">
				{% if app.user is null %}
					<li class="nav-item dropdownmenu-item has-child dropdown" role="menu-item">
	                    <a href="#" id="navbarDropdown1" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link parent dropdown-toggle ">Adhérer</a>
	                	<div class="dropdown-menu" aria-labelledby="navbarDropdown1">
							<a href="/adherer" class="dropdown-item ">Adhérer à la MLC</a>
	                	</div>
	                </li>
	            {% endif %}
				{{ tree.menu(menuItems, currentPath) }}
				{# MENU UTILISATEUR AYANT ACCES A L'ADMIN CONNECTE #}
				{% if app.user and (is_granted('ROLE_ADMIN_SIEGE') or
									is_granted('ROLE_SUPER_ADMIN') or
									is_granted('ROLE_TRESORIER') or
									is_granted('ROLE_CONTACT') or
									is_granted('ROLE_GESTION_GROUPE') or
									is_granted('ROLE_COMPTOIR') or
									is_granted('ROLE_CONTROLEUR')
									) %}
					<li class="nav-item ml-auto" role="menu-item">
						<a href="{{ path('sonata_admin_dashboard') }}" class="nav-link" data-toggle="tooltip" data-placement="bottom" title="{{ 'Administration'|trans }}">
							{# {{ 'Administration'|trans }} #}
							<i class="fas fa-cog"></i>
						</a>
					</li>
				{% endif %}
				{# MENU UTILISATEUR CONNECTE #}
				{% if app.user %}
					<li class="nav-item dropdown" role="menu-item">
						<a href="#" id="navbarDropdownUC" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link parent dropdown-toggle" alt='{{ app.user.name }}'>
							<span style="{# font-size: 1em; color: grey; #}">
								<i class="fas fa-user"></i>
							</span>
						</a>
	                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownUC">

	                    	{# MENU ADHERENT CONNECTE #}
	                    	{% if is_granted('ROLE_ADHERENT') %}
	                    		{# <a href="{{ path('adherent_infos') }}" class="dropdown-item">{{ 'Mes infos'|trans }}</a>
	                    		<a href="{{ path('transactionAdherentPrestataire') }}" class="dropdown-item">{{ 'Transaction vers presta'|trans }}</a>
	                    		<a href="{{ path('transactionAdherentAdherent') }}" class="dropdown-item">{{ 'Transaction vers adherent'|trans }}</a> #}
	                    	{% endif %}

	                    	{# MENU PRESTATAIRE CONNECTE #}
	                    	{% if is_granted('ROLE_PRESTATAIRE') %}
	                    		{# <a href="{{ path('prestataire_infos') }}" class="dropdown-item">{{ 'Mes infos'|trans }}</a>
	                    		<a href="{{ path('transactionPrestataireAdherent') }}" class="dropdown-item">{{ 'Transaction vers adherent'|trans }}</a>
	                    		<a href="{{ path('transactionPrestatairePrestataire') }}" class="dropdown-item">{{ 'Transaction vers presta'|trans }}</a> #}
	                    	{% endif %}

	                    	{# MENU TRESORIER CONNECTE #}
	                    	{% if is_granted('ROLE_TRESORIER') %}
	                    	{% endif %}

	                    	{% if app.user.groups|length > 1 %}
		                    	<a href="#" class="viewChoiceGroup dropdown-item">{{ 'Choix du rôle'|trans }}</a>
		                    {% endif %}
		                    {% if is_granted('ROLE_PREVIOUS_ADMIN') %}
							    <a href="{{path('index')}}?_switch_user=_exit" class="dropdown-item">{{ 'Exit impersonate'|trans }}</a>
							{% endif %}
		                    <a href="{{ path('fos_user_security_logout') }}" class="dropdown-item">{{ 'Déconnexion'|trans }}</a>
	                    </div>
					</li>
				{% endif %}
			</ul>
		</div>
	{% endif %}

</nav>
