{% from "govuk_frontend_jinja/components/panel/macro.html" import govukPanel %}
{% extends "access_grant_funding/base.html" %}

{% set constants = submission_helper.collection.type.constants %}
{% set title_text = (constants.singular | uppercase_first) ~ " signed off and submitted" if submission_helper.collection.requires_certification else (constants.singular | uppercase_first) ~ " submitted" %}

{# todo: move the suffix to the base template and call super #}
{% set page_title = title_text ~ " - " ~ submission_helper.long_collection_name ~ " - " ~ grant_recipient.grant.name %}

{% set active_item_identifier = constants.active_nav %}

{% block content %}
  <div class="govuk-grid-row">
    <div class="govuk-grid-column-two-thirds">
      {% set reference_html %}
        {{ constants.singular | uppercase_first }}
        <br />
        <strong>{{ submission_helper.long_collection_name }} for {{ submission_helper.collection.grant.name }}</strong>
        <br />
        <br />Your reference number
        <br />
        <strong data-testid="submission-reference">{{ submission_helper.reference }}</strong>
      {% endset %}
      {{
        govukPanel({
          "titleText": title_text,
          "html": reference_html
        })
      }}
      {% set download_pdf_href = url_for('access_grant_funding.export_submission_pdf', organisation_id=grant_recipient.organisation.id, grant_id=grant_recipient.grant.id, collection_type=submission_helper.collection.type, submission_id=submission_helper.id) %}

      <p class="govuk-body">We have sent a confirmation email to you and anyone else who has access to this {{ constants.singular }}.</p>
      <p class="govuk-body">
        You can
        <a class="govuk-link govuk-link--no-visited-state" download href="{{ download_pdf_href }}">download the {{ constants.singular }} as a PDF</a>.
      </p>
      <h2 class="govuk-heading-m">What happens next</h2>

      <p class="govuk-body">Your {{ submission_helper.long_collection_name }} {{ constants.singular }} for {{ grant_recipient.grant.name }} has been submitted to the {{ submission_helper.collection.grant.organisation.name }}.</p>

      <p class="govuk-body">
        {% set feedback_link = config.GRANT_RECIPIENT_CERTIFIER_FEEDBACK_URL if submission_helper.collection.requires_certification else config.GRANT_RECIPIENT_GENERAL_FEEDBACK_URL %}
        <a class="govuk-link govuk-link--no-visited-state app-!-no-wrap" href="{{ feedback_link }}" target="_blank" rel="noopener noreferrer">Tell us what you think of this service (opens in new tab)</a>
      </p>

      <p class="govuk-body">
        {%
          set back_link = (
          url_for("access_grant_funding.list_collections", organisation_id=grant_recipient.organisation.id, grant_id=grant_recipient.grant.id)
           if not submission_helper.collection.allow_multiple_submissions else
           url_for("access_grant_funding.list_collection_submissions", organisation_id=grant_recipient.organisation.id, grant_id=grant_recipient.grant.id, collection_id=submission_helper.collection.id)
           )
        %}
        <a class="govuk-link govuk-link--no-visited-state" href="{{ back_link }}">Return to {{ constants.plural }}</a>
      </p>
    </div>
  </div>
{% endblock content %}
