## mako
<%page expression_filter="h"/>
<%namespace name='static' file='../static_content.html'/>

<%!
import json
from urllib.parse import urljoin

from django.conf import settings
from django.urls import reverse
from django.utils.translation import gettext as _

from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_image_urls_for_user
from openedx.features.enterprise_support.utils import get_enterprise_learner_generic_name, get_enterprise_learner_portal
%>

<%
## This template should not use the target student's details when masquerading, see TNL-4895
self.real_user = getattr(user, 'real_user', user)
profile_image_url = get_profile_image_urls_for_user(self.real_user)['medium']
username = self.real_user.username
displayname = get_enterprise_learner_generic_name(request) or username
enterprise_customer_portal = get_enterprise_learner_portal(request)
## Enterprises with the learner portal enabled should not show order history, as it does
## not apply to the learner's method of purchasing content.
should_show_order_history = not enterprise_customer_portal
%>

<!-- NEW IN INDIGO update user icon -->

<div class="nav-item hidden-mobile nav-item-dropdown" tabindex="-1">
    <div class="toggle-user-dropdown" role="button" aria-label=${_("Options Menu")} aria-expanded="false" tabindex="0" aria-controls="user-menu">
        <span data-hj-suppress class="username">${displayname}</span>
    </div>
    <div class="dropdown-user-menu hidden" aria-label=${_("More Options")} role="menu" id="user-menu" tabindex="-1">
        % if not enterprise_customer_portal:
            <div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${reverse('dashboard')}" role="menuitem">${_("Dashboard")}</a></div>
        % else:
            <div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL}/${enterprise_customer_portal.get('slug')}" role="menuitem">${_("Dashboard")}</a></div>
        % endif

        <div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${urljoin(settings.PROFILE_MICROFRONTEND_URL, f'{user.username}')}" role="menuitem">${_("Profile")}</a></div>
        <div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${settings.ACCOUNT_MICROFRONTEND_URL}" role="menuitem">${_("Account")}</a></div>
        % if should_show_order_history:
            <div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${settings.ORDER_HISTORY_MICROFRONTEND_URL}" role="menuitem">${_("Order History")}</a></div>
        % endif
        <div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${reverse('logout')}" role="menuitem">${_("Sign Out")}</a></div>
    </div>
</div>
