{% extends 'ddm_core/page_with_form.html' %}
{% load static %}

{% block page_title %}Download Donations{% endblock %}

{% block main_heading %}Download Donations for {{ participant_id }} {% endblock %}

{% block main_top %}
  Please provide your secret to decrypt the donation. You defined this secret when you created your project.
{% endblock %}

{% block main_form %}
  <form method="post" id="secret-input-form" enctype="multipart/form-data">
    {% csrf_token %}
    {{ form.media }}

    <div>
      {% if form.errors %}
        <p class="error-disclaimer"><i class="bi bi-exclamation-square-fill"></i> The form could not be processed. Please check the issues highlighted below.</p>
      {% endif %}

      {{ form.non_field_errors }}

      <div id="message-placeholder"></div>

      {% for field in form %}
        <p>
          {{ field.label_tag }}
          <span class="helptext">{{ field.help_text|safe }}</span>
          {{ field.errors }}
          {{ field }}
        </p>
      {% endfor %}
      <input class="ddm-btn" type="submit" value="Download Donations">
      {% block cancel %}
        <p>
          <a href="{% url 'ddm_projects:detail' project.url_id %}">&#129040; Cancel</a>
        </p>
      {% endblock %}
    </div>
  </form>
{% endblock %}

{% block main_bottom %}

  {% include "ddm_core/components/info_modal.html" with modal_id="modal-download-success" body="<p><i class='bi bi-check-circle-fill text-success pe-2'></i><b>Download Successful.</b></p>" %}

  {% include "ddm_core/components/info_modal.html" with modal_id="modal-download-error" body="<p><i class='bi bi-x-octagon-fill text-danger pe-2'></i><b>Download Failed</b></p><span id='download-error-message'></span>" %}

{% endblock %}

{% block breadcrumbs %}
{% endblock %}

{% block scripts %}
  {{ block.super }}
  <script src="{% static 'ddm_datadonation/js/download-with-secret.js' %}"></script>
{% endblock %}
