{% extends "deliver_grant_funding/grant_base.html" %}
{% from "govuk_frontend_jinja/components/back-link/macro.html" import govukBackLink %}
{% from "govuk_frontend_jinja/components/warning-text/macro.html" import govukWarningText %}
{% from "deliver_grant_funding/macros/data_sets.html" import render_data_set_data_with_missing_data_grant_recipients with context %}

{% set type_constants = collection.type.constants %}
{% set active_item_identifier = type_constants.active_nav %}

{% set page_title = "Review missing data in " ~ session_data.name ~ " data set" %}

{% block beforeContent %}
  {% if session_data.has_grant_recipient_mismatches %}
    {% set back_link = url_for("deliver_grant_funding.confirm_data_set_grant_recipients", grant_id=grant.id, collection_type=collection.type, collection_id=collection.id, data_source_id=session_data.data_source_id if session_data.is_replace == True else None) %}
  {% else %}
    {% if session_data.is_replace %}
      {% set back_link = url_for("deliver_grant_funding.replace_data_set", grant_id=grant.id, collection_type=collection.type, collection_id=collection.id, data_source_id=session_data.data_source_id) %}
    {% else %}
      {% set back_link = url_for("deliver_grant_funding.upload_data_set", grant_id=grant.id, collection_type=collection.type, collection_id=collection.id) %}
    {% endif %}
  {% endif %}
  {{ govukBackLink({ "text": "Back", "href": back_link }) }}
{% endblock beforeContent %}

{% block content %}
  <div class="govuk-grid-row">
    <div class="govuk-grid-column-two-thirds">
      <h1 class="govuk-heading-l">
        <span class="govuk-caption-l">{{ collection.name }}</span>
        Review missing data in {{ session_data.name }} data set
      </h1>
      {{ govukWarningText({"text": ("Grant recipients will not be able to complete the " ~ type_constants.singular ~ " until their missing data is uploaded. You can replace the data set file to update it later.")}) }}
    </div>
  </div>
  <div class="govuk-grid-row">
    <div class="govuk-grid-column-full">
      {{ render_data_set_data_with_missing_data_grant_recipients(session_data.data_columns,missing_data_rows,all_rows) }}

      <form method="POST" novalidate>
        <div class="govuk-button-group">
          {{ form.csrf_token }}
          {{ form.submit(params={"text": "Continue" }) }}
          <a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('deliver_grant_funding.list_collection_data_sets', grant_id=grant.id, collection_type=collection.type, collection_id=collection.id) }}">Cancel</a>
        </div>
      </form>
    </div>
  </div>
{% endblock content %}
