{% load i18n static sekizai_tags cms_tags sass_tags %}{% spaceless %}

{% include "shop/djng-form.html" %}

{% page_url "shop-order" as shop_order_url %}
{% page_attribute "menu_title" "shop-order" as shop_order_title %}
{% page_url "shop-customer-details" as customer_details_url %}
{% page_attribute "menu_title" "shop-customer-details" as customer_details_title %}
{% page_url "shop-password-change" as password_change_url %}
{% page_attribute "menu_title" "shop-password-change" as password_change_title %}
{% page_url "password-reset-request" as password_reset_url %}
{% page_url "shop-register-customer" as register_customer_url %}

<li uib-dropdown class="nav-item dropdown {{ item_class }}"{% if customer.is_anonymous %} auto-close="outsideClick"{% endif %}>
	<a uib-dropdown-toggle class="nav-link dropdown-toggle" role="button" aria-haspopup="true">
	{% if customer.is_authenticated %}
		<i class="fa fa-user"></i>&nbsp;{{ customer.first_name|default:customer }}
	{% else %}
		<i class="fa fa-sign-in"></i>&nbsp;{% trans "Sign in" %}
	{% endif %}
	</a>
	<div uib-dropdown-menu class="dropdown-menu" role="menu">
	{% if customer.is_authenticated %}
		<div class="px-3 py-0" role="dialog" aria-label="logout">
			<form name="logout_form" djng-endpoint="{% url 'shop:logout' %}" role="form">
				<button class="btn btn-primary btn-block" type="button" ng-click="do(create()).then(reloadPage())">
				{% trans "Logout" %}
				&emsp;<i class="fa fa-sign-out"></i>
				</button>
			</form>
		</div>
		{% if shop_order_url or customer_details_url or password_change_url %}
		<div class="dropdown-divider" role="separator"></div>
			{% if shop_order_url %}
		<a class="dropdown-item" href="{{ shop_order_url }}">{{ shop_order_title }}</a>
			{% endif %}
			{% if customer_details_url %}
		<a class="dropdown-item" href="{{ customer_details_url }}">{{ customer_details_title }}</a>
			{% endif %}
			{% if password_change_url %}
		<a class="dropdown-item" href="{{ password_change_url }}">{{ password_change_title }}</a>
			{% endif %}
		{% endif %}
	{% else %}
		<div class="px-3 py-0" role="dialog" aria-label="login">
			<form name="login_form" djng-endpoint="{% url 'shop:login' %}" accept-charset="UTF-8" role="form">
				<div class="alert alert-danger" ng-show="rejectMessageIsVisible()" ng-cloak>
					<a class="close" ng-click="dismissSubmitMessage()">×</a>
					<p ng-bind="getSubmitMessage()"></p>
				</div>
				<div class="form-group">
					<label for="username">{% trans 'E-Mail' %}</label>
					<div class="input-group input-group-sm">
						<div class="input-group-prepend"><i class="input-group-text fa fa-user"></i></div>
						<input class="form-control input-sm" type="text" placeholder="{% trans 'E-Mail' %}" name="username" ng-model="form_data.username" ng-required="true">
					</div>
				</div>
				<div class="form-group">
					<label for="password">{% trans 'Password' %}</label>
					<div class="input-group input-group-sm">
						<div class="input-group-prepend"><i class="input-group-text fa fa-unlock-alt"></i></div>
						<input class="form-control input-sm" type="password" placeholder="{% trans 'Password' %}" name="password" ng-model="form_data.password" ng-required="true">
					</div>
				</div>
		{% if ALLOW_SHORT_SESSIONS %}
				<div class="form-group">
					<div class="form-check">
						<input class="form-check-input" type="checkbox" name="stay_logged_in" ng-model="form_data.stay_logged_in">
						<label class="form-check-label" for="stay_logged_in">{% trans 'Stay logged in' %}</label>
					</div>
				</div>
		{% endif %}
				<button class="btn btn-primary btn-block" type="button" ng-click="do(disable()).then(create()).then(showOK()).then(delay(500)).then(reloadPage()).catch(showFail()).then(delay(500)).finally(restore())" ng-disabled="isDisabled()">
					{% trans "Login" %}
					&emsp;<i class="fa fa-sign-in"></i>
				</button>
			</form>
		</div>
		{% if password_reset_url or register_customer_url %}
		<div class="dropdown-divider" role="separator"></div>
			{% if password_reset_url %}
		<a class="dropdown-item" href="{{ password_reset_url }}">{% trans "Password Forgotten?" %}</a>
			{% endif %}
			{% if register_customer_url %}
		<a class="dropdown-item" href="{{ register_customer_url }}">{% trans "Register Yourself" %}</a>
			{% endif %}
		{% endif %}
	{% endif %}
	</div>

</li>
{% endspaceless %}
