<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{default}">
<head>
    <link rel="stylesheet" href="/css/style.css"/>
    <link rel="stylesheet" href="/css/nation.css"/>
    <script type="text/javascript" src="/webjars/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<div layout:fragment="content">
    <div class="Group_create_level">
        <h1>Генератор наций</h1>
        <h2>
            <a class="add-level-button text-dark" type="button"
               th:href="@{/nation/edit/}"
               sec:authorize="hasRole('ROLE_ADMIN')"
            >
                Создать нацию
            </a>
        </h2>
        <h2
                sec:authorize="hasRole('ROLE_USER')"
        >
            Режим просмотра
        </h2>
    </div>
    <div>
        <h1 style="text-align: center; font-family: courier, monospace; background: #FF652F; border-radius: 10px">
            Список существующих наций:
        </h1>
    </div>
    <div th:each="nation, iterator: ${nations}">
        <div class="nation-card">
            <p class="nation-attribute" th:text="'Номер: ' + ${nation.id}"/>
            <p class="nation-attribute" th:text="'Нация: ' + ${nation.nation}"/>
            <div class='nation-button-group'>
                <form th:action="@{/nation/edit/{id}(id=${nation.id})}" method="get">
                    <button class="nation-button" type="submit"
                            th:id="'edit-' + ${nation.id}"
                            sec:authorize="hasRole('ROLE_ADMIN')"
                    >
                        Редактировать
                    </button>
                </form>
                <form th:action="@{/nation/delete/{id}(id=${nation.id})}" method="post">
                    <button th:id="'remove-' + ${nation.id}" class="nation-button" type="submit"
                            sec:authorize="hasRole('ROLE_ADMIN')">
                        Удалить
                    </button>
                </form>
                <form th:action="@{/nation/editTank/{id}(id=${nation.id})}" method="get">
                    <button th:id="'edit-tank-' + ${nation.id}" class="nation-button" type="submit">
                        Список танков
                    </button>
                </form>
            </div>
        </div>
    </div>
</div>
</body>
<th:block layout:fragment="scripts">
</th:block>
</html>