{% extends 'core/base.html' %}
{% block title %}Invitations – Admin – Nature In Pots{% endblock %}

{% block content %}
<h1>Invitations</h1>

<p>
  <a href="{{ url_for('auth.send_invite') }}"
     class="btn btn-primary mb-3">
    Create Invitation
  </a>
</p>

<table class="table table-striped">
  <thead>
    <tr>
      <th>Code</th>
      <th>Recipient Email</th>
      <th>Created By</th>
      <th>Created At</th>
      <th>Used By</th>
      <th>Used At</th>
      <th>Active</th>
    </tr>
  </thead>
  <tbody>
    {% for inv in invitations %}
    <tr>
      <td>{{ inv.code }}</td>
      <td>{{ inv.recipient_email }}</td>
      <td>{{ inv.creator.email }}</td>
      <td>{{ inv.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
      <td>{{ inv.user.email if inv.user else '' }}</td>
      <td>{{ inv.used_at.strftime('%Y-%m-%d %H:%M') if inv.used_at else '' }}</td>
      <td>{{ 'Yes' if inv.is_active else 'No' }}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>
{% endblock %}
