{% extends "base.html" %}

{% load crispy_forms_tags %}

{% block content %}
  {% url 'accounts:login' as login_url %}
  {% url 'accounts:edit_profile' as edit_profile_url %}
  {% url 'accounts:password_change' as password_change_url %}
  {% url 'audio:new_feed' as new_feed_url %}
  {% url 'accounts:password_reset' as password_reset_url %}
  {% url 'accounts:register' as register_url %}

  {% if request.path == login_url %}
    {% firstof 'Login' as submit %} 
  {% elif request.path == edit_profile_url %}
    {% firstof 'Update' as submit %} 
  {% elif request.path == password_change_url %}
    {% firstof 'Update' as submit %} 
  {% elif request.path == new_feed_url %}
    {% firstof 'Submit' as submit %} 
  {% elif request.path == password_reset_url %}
    {% firstof 'Reset Password' as submit %} 
  {% elif request.path == register_url %}
    {% firstof 'Register' as submit %}
  {% endif %}

  {% include "base_navbar.html" %}
  {% include "base_heading.html" %}

  <div class="container">
    <div class="d-flex flex-column offset-sm-3 col-sm-6 col-xs-12 px-0">

      {% if request.path == new_feed_url %}
        <form method="POST" enctype="multipart/form-data">
      {% elif form_data == "TRUE" %}
        <form method="POST" enctype="multipart/form-data">
      {% else %}
        <form method="POST">
      {% endif %}
        {% csrf_token %}
        {{ form | crispy }}
        <div class="mt-3 d-flex justify-content-between">
          <input type="submit" class="btn btn-dark btn-lg" value="{{ submit }}">
          {% if edit_feed %}
            <a type="button" class="btn btn-lg btn-dark" href="{% url 'audio:confirm_delete_feed' pk=feed_pk %}">Delete Feed?</a>
          {% elif edit_episode %}
            <a type="button" class="btn btn-lg btn-dark" href="{% url 'audio:confirm_delete_episode' pk=episode_pk %}">Delete Episode?</a>
          {% endif %}
        </div>
      </form><br>
      {% if request.path == edit_profile_url %}
        <div class="container px-0">
          <div class="d-flex flex-column align-items-start">
              {% if user.account.use_totp %}
                <a type="button" class="btn btn-lg btn-dark mb-4" href="{% url 'accounts:disable_totp' %}">Disable 2fa</a>
              {% else %}
                <a type="button" class="btn btn-lg btn-dark mb-4" href="{% url 'accounts:enable_totp' %}">Enable 2fa</a>
              {% endif %}
              <a type="button" class="btn btn-lg btn-dark" href="{% url 'accounts:password_change' %}">Change Password</a>
          </div>
        </div>
      {% endif %}
      {% if request.path == login_url %}
        <p>Forgot Password? <a href="{% url 'accounts:password_reset' %}" class="text-dark" style="text-decoration: underline">Reset Password</a></p>
        <p>Need an account? <a href="{% url 'accounts:register' %}" class="text-dark" style="text-decoration: underline">Register</a></p>
      {% endif %}
    </div>
  </div>
{% endblock %}