<!--

    Queue - A Queueing system that can be used to handle labs in higher education
    Copyright (C) 2016-2024  Delft University of Technology

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

-->
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
    <header class="header" layout:fragment="header">
        <a th:href="@{/}" class="header__title">
            <h1 th:unless="${@thymeleafConfig.isTheDay()}">Queue</h1>
            <h1 th:if="${@thymeleafConfig.isTheDay()}">Stack</h1>
        </a>

        <div class="header__links" th:if="${#authenticatedP != null}">
            <ul>
                <li><a th:href="@{/}">My Courses</a></li>
                <li><a th:href="@{/editions}">Catalog</a></li>
                <li th:if="${@permissionService.canViewRequests()}">
                    <a th:href="@{/requests}">Requests</a>
                </li>
                <li th:if="${@permissionService.isAdmin()}"><a th:href="@{/admin}">Admin</a></li>
            </ul>
        </div>

        <div class="user-menu menu-wrapper" th:if="${#authenticatedP != null}">
            <button aria-controls="user-menu">
                <span th:text="${#authenticatedP.displayName}"></span>
                <span class="fa-solid fa-chevron-down"></span>
            </button>
            <ul id="user-menu" class="menu" aria-expanded="false" role="list">
                <li><a th:href="@{/history}">Request history</a></li>
                <li th:if="${@permissionService.canViewOwnFeedback()}">
                    <a th:href="@{/feedback/{id}(id=${#authenticatedP.id})}">Feedback</a>
                </li>
                <li th:if="${@permissionService.canViewRequests()}" class="flex vertical">
                    <button data-dialog="language-overlay">Languages</button>
                </li>
                <li class="flex vertical">
                    <button data-dialog="theme-overlay">Appearance</button>
                </li>
                <li>
                    <form class="flex vertical" th:action="@{/logout}" method="post">
                        <button>Log out</button>
                    </form>
                </li>
            </ul>
        </div>

        <div class="header__user" th:if="${#authenticatedP == null}">
            <a th:href="@{/login}">Log in</a>
        </div>

        <th:block layout:replace="~{home/language :: overlay}"></th:block>
        <th:block layout:replace="~{home/theme :: overlay}"></th:block>
    </header>
</html>
