{% from "components/banner.html" import banner_wrapper %}

<div class="grid-col-12 template-container margin-bottom-4">
  {{ template|string }}
</div>
<div class="grid-col-12">
  {% if template._template.archived %}
    <p class="hint">
      This template was deleted {{ template._template.updated_at|format_datetime_relative }}.
    </p>
  {% elif not current_user.has_permissions('send_messages', 'manage_api_keys', 'manage_templates', 'manage_service') or not user_has_template_permission %}
    <p class="top-gutter-1-3 {% if template.template_type != 'sms' %}bottom-gutter{% endif %}">
      If you need to send this
      {{ 1|message_count_label(template.template_type, suffix='') }}
      or edit this template, contact your manager.
    </p>
  {% else %}
    <div class="grid-row margin-bottom-5">
      <div class="usa-button-group">
        {% if current_user.has_permissions('send_messages', restrict_admin_usage=True) %}
            <a href="{{ url_for(".set_sender", service_id=current_service.id, template_id=template.id) }}" class="usa-button usa-pill-separate-item">
              Use this template
            </a>
        {% endif %}
        {% if current_user.has_permissions('manage_templates') %}
            <a href="{{ url_for(".edit_service_template", service_id=current_service.id, template_id=template.id) }}" class="usa-button usa-button--outline usa-pill-separate-item">
              Edit
            </a>
        {% endif %}
      </div>
    </div>
  {% endif %}
</div>

