<!DOCTYPE html>
<html lang="en"
      th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>Gruppe Beitreten</title>
    <th:block th:fragment="headcontent">
        <!-- Links, Skripts, Styles hier einfügen! -->
    </th:block>
</head>
<body>

<header>
    <nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation">
        <ul>
            <li>
                <a th:href="@{/gruppen2}">Gruppen</a>
            </li>
            <li>
                <a th:href="@{/gruppen2/create}">Erstellen</a>
            </li>
            <li class="active">
                <a th:href="@{/gruppen2/search}">Suche</a>
            </li>
        </ul>
    </nav>
</header>

<main th:fragment="bodycontent">
    <div class="container-fluid">
        <div class="shadow-sm p-4"
             style="border: 1px solid aliceblue; border-radius: 5px; background: aliceblue;">
            <h1 style="color: black; font-weight: bold; font-optical-sizing: auto; overflow-wrap: break-word;"
                th:text="${group.getTitle()}"></h1>
            <div class="shadow-sm p-4" style="background: white;">
                <p style="overflow-wrap: break-word; font-optical-sizing: auto;"
                   th:text="${group.getDescription()}"></p>
            </div>
            <div class="form-group mt-2" th:if="${group.getMembers().size() < group.getUserLimit()}">
                <h3>Möchtest du dieser privaten Gruppe beitreten?</h3>
                <div class="text-right">
                    <form method="post" th:action="@{/gruppen2/details/{id}/join(id = ${group.getId()})}">
                        <input name="id" th:value="${group.getId()}" type="hidden"/>
                        <button class="btn btn-primary"
                                style="background: #52a1eb; border-style: none;"
                                type="submit">Ja, Gruppe beitreten
                        </button>
                        <a class="btn btn-primary"
                           href="/gruppen2"
                           style="background: #52a1eb; border-style: none;"
                           type="submit">Ich will das nicht.
                        </a>
                    </form>
                </div>
            </div>
            <h3 class="mt-2" th:if="${group.getMembers().size() >= group.getUserLimit()}">Gruppe ist
                                                                                          voll und
                                                                                          kann nicht
                                                                                          beigetreten
                                                                                          werden.</h3>
        </div>
    </div>
</main>
</body>
</html>
