{% extends "base.html" %}
{% block title %}杯赛管理{% endblock %}
{% block content %}
<h1>杯赛管理</h1>
<table class="table table-striped">
    <thead>
        <tr>
            <th>ID</th>
            <th>名称</th>
            <th>描述</th>
            <th>状态</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        {% for comp in competitions %}
        <tr>
            <td>{{ comp.id }}</td>
            <td>{{ comp.name }}</td>
            <td>{{ comp.description }}</td>
            <td>
                {% if comp.status == 'active' %}
                    <span class="badge bg-success">进行中</span>
                {% else %}
                    <span class="badge bg-secondary">已停止</span>
                {% endif %}
            </td>
            <td>{{ comp.created_at }}</td>
            <td>
                {% if comp.status == 'active' %}
                <form action="{{ url_for('stop_competition', id=comp.id) }}" method="post" style="display:inline;">
                    <button type="submit" class="btn btn-warning btn-sm" onclick="return confirm('确定停止该比赛吗？')">停止</button>
                </form>
                {% else %}
                <span class="text-muted">无操作</span>
                {% endif %}
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% endblock %}