{% if grant %}
  {% extends "deliver_grant_funding/grant_base.html" %}
  {% set active_item_identifier = "details" %}
{% else %}
  {% extends "deliver_grant_funding/base.html" %}
  {% set active_item_identifier = "grants" %}
{% endif %}
{% from "govuk_frontend_jinja/components/back-link/macro.html" import govukBackLink %}

{% set page_title = form.description.label.text %}

{% block beforeContent %}
  {% if not grant %}
    {{
      govukBackLink({
          "text": "Back",
          "href": back_link_href
      })
    }}
  {% endif %}
{% endblock beforeContent %}

{% block content %}
  <div class="govuk-grid-row">
    <div class="govuk-grid-column-two-thirds">
      <span class="govuk-caption-l">{% if grant %}{{ grant.name }}{% else %}Set up the grant{% endif %}</span>
      <h1 class="govuk-heading-l">What is the main purpose of this grant?</h1>
      <p class="govuk-body">Provide a brief description of the main purpose of the grant. This information will be seen by potential grant recipients.</p>

      <form method="post" novalidate>
        {{ form.csrf_token }}

        {{
          form.description(params={
            "label": {
              "classes": "govuk-visually-hidden"
            },
            "maxwords": form.DESCRIPTION_MAX_WORDS
          })
        }}

        <div class="govuk-button-group">
          {% set submit_label = 'Update main purpose' if grant else 'Save and continue' %}
          {{ form.submit(params={"text": submit_label}) }}

          {% if grant %}
            <a class="govuk-link govuk-link--no-visited-state" href="{{ back_link_href }}">Cancel</a>
          {% endif %}
        </div>
      </form>
    </div>
  </div>
{% endblock content %}
