{% extends "atlas/base.html" %}

{% block content %}
<h2>Research Studies</h2>
<p class="text-muted">Create and manage study packets that randomise participants to Atlas collections.</p>

<div class="mb-3">
    <a class="btn btn-primary" href="{% url 'atlas:research_study_create' %}">Create Study</a>
</div>

{% if studies %}
<table class="table table-dark table-striped table-hover table-sm">
    <thead>
        <tr>
            <th>Name</th>
            <th>Slug</th>
            <th>Status</th>
            <th>Randomisation</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        {% for study in studies %}
        <tr>
            <td>{{ study.name }}</td>
            <td>{{ study.slug }}</td>
            <td>
                {% if study.active %}
                    <span class="badge bg-success">Active</span>
                {% else %}
                    <span class="badge bg-secondary">Inactive</span>
                {% endif %}
            </td>
            <td>{{ study.get_randomisation_mode_display }}</td>
            <td><a class="btn btn-sm btn-outline-primary" href="{% url 'atlas:research_study_detail' study.pk %}">Open</a></td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% else %}
<div class="alert alert-info">No studies have been created yet.</div>
{% endif %}
{% endblock %}
