{% extends 'layouts/base.html' %}

{% block title %}Сеты{% endblock %}

{% block content %}
    <div class="card border-0 shadow mb-4">
        <div class="card-body">
            <table>
                <tr>
                    <td>
                        <h1 class="h4">Сеты</h1>
                    </td>
                    {% if user.userinfo.can_create %}
                        <td>
                            <button type="button" class="btn btn-block btn-success mb-3" data-bs-toggle="modal" data-bs-target="#modal-create" style="margin-left: 10px;"><img height="15" width="15" src="/static/assets/img/icons/plus.svg" /></button>
                            <div class="modal fade" id="modal-create" tabindex="-1" aria-labelledby="modal-default" style="display: none;" aria-hidden="true">
                                <div class="modal-dialog modal-dialog-centered" role="document">
                                    <div class="modal-content">
                                        <form method="POST">
                                            {% csrf_token %}
                                            <div class="modal-header">
                                                <h2 class="h6 modal-title">Создать сет</h2>
                                                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                            </div>
                                            <div class="modal-body">
                                                <input type="text" style="width: 100%;" name="name" placeholder="Название сета">
                                            </div>
                                            <div class="modal-footer">
                                                <button type="submit" class="btn btn-secondary">Создать</button>
                                                <button type="button" class="btn btn-link text-gray-600 ms-auto" data-bs-dismiss="modal">Закрыть</button>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </td>
                    {% endif %}
                </tr>
            </table>
            {% for set in user.userinfo.available_sets %}
                <a href="/set?set_id={{ set.id }}">{{ set.name }}</a> {% if set.creator == user or user.username in set.editors %}<a href="/admin/set?set_id={{ set.id }}"><i class="fa fa-pencil"></i> </a><a href="/solutions?set_id={{ set.id }}"><i class="fa fa-stack-overflow"></i> </a>{% endif %}<br>
            {% endfor %}
        </div>
    </div>
{% endblock %}
