{% from "components/table.html" import list_table, field, right_aligned_field_heading, row_heading %}

<div class='dashboard-table ajax-block-container'>
  {% call(item, row_number) list_table(
    jobs,
    caption="Recent files uploaded",
    caption_visible=False,
    empty_message=(
      'You have not uploaded any files yet.'
    ),
    field_headings=[
      'File',
      'Status'
    ],
    field_headings_visible=False
  ) %}
    {% call row_heading() %}
      <div class="file-list">
        <a class="file-list-filename-large usa-link" href="{{ url_for('.view_job', service_id=current_service.id, job_id=item.id) }}">{{ item.original_file_name }}</a>
        {% if item.scheduled %}
          <span class="file-list-hint-large">
            Sending {{
              item.scheduled_for|format_datetime_relative
            }}
          </span>
        {% else %}
          <span class="file-list-hint-large">
            Sent {{
              (item.scheduled_for or item.created_at)|format_datetime_relative
            }}
          </span>
        {% endif %}

      </div>
    {% endcall %}
    {% call field() %}
      {% if item.scheduled %}
        {% if link %}
          <a class="usa-link display-flex" href="{{ link }}">
        {% endif %}
            <span class="big-number-smallest">
              <span class="big-number-number">
                {% if item.notification_count is number %}
                  {% if currency %}
                    {{ "{}{:,.2f}".format(currency, item.notification_count) }}
                  {% else %}
                    {{ "{:,}".format(item.notification_count) }}
                  {% endif %}
                {% else %}
                  {{ item.notification_count }}
                {% endif %}
              </span>
              {% if item.notification_count %}
                <span class="big-number-label">{{ item.notification_count|message_count_label(item.template_type,suffix='waiting to send') }}</span>
              {% endif %}
            </span>
        {% if link %}
          </a>
        {% endif %}
      {% else %}
        <div class="grid-row">
          <div class="grid-col-4">
            {% if link %}
              <a class="usa-link display-flex" href="{{ link }}">
            {% endif %}
              <span class="big-number-smallest">
                <span class="big-number-number">
                  {{ "{:,}".format(item.notifications_sending) }}
                </span>
                <span class="big-number-label">pending</span>
              </span>
            {% if link %}
              </a>
            {% endif %}
          </div>
          <div class="grid-col-4">
          <span class="big-number-smallest">
            <span class="big-number-number">
              {% if item.notifications_delivered is number %}
                {{ "{:,}".format(item.notifications_delivered) }}
              {% else %}
                {{ item.notifications_delivered }}
              {% endif %}
            </span>
            <span class="big-number-label">delivered</span>
          </span>
      </div>
      <div class="grid-col-4">
        {% if link %}
          <a class="usa-link display-flex" href="{{ link }}">
        {% endif %}
            <span class="big-number-smallest">
              <span class="big-number-number">
                {% if item.notifications_failed is number %}
                  {% if currency %}
                    {{ "{}{:,.2f}".format(currency, item.notifications_failed) }}
                  {% else %}
                    {{ "{:,}".format(item.notifications_failed) }}
                  {% endif %}
                {% else %}
                  {{ item.notifications_failed }}
                {% endif %}
              </span>
              <span class="big-number-label">failed</span>
            </span>
        {% if link %}
          </a>
        {% endif %}

      </div></div>

      {% endif %}
    {% endcall %}
  {% endcall %}
</div>
