<!--

    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/>.

-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
    <!--@thymesVar id="#authenticatedP" type="nl.tudelft.labracore.lib.security.user.Person"-->

    <!--@thymesVar id="qSession" type="nl.tudelft.queue.dto.view.QueueSessionViewDTO"-->

    <!--@thymesVar id="current" type="nl.tudelft.queue.dto.view.RequestViewDTO"-->

    <body>
        <th:block th:fragment="current-request">
            <div th:if="${current != null}">
                <div class="surface p-0">
                    <h3 class="surface__header" th:unless="${current.eventInfo.status.isRejected()}">You are currently enqueued</h3>
                    <h3 class="surface__header" th:if="${current.eventInfo.status.isRejected()}">You have been rejected for this lab</h3>

                    <div class="surface__content">
                        <th:block th:if="${qSession.type == T(nl.tudelft.queue.model.enums.QueueSessionType).CAPACITY}">
                            <!--@thymesVar id="qSession" type="nl.tudelft.queue.dto.view.labs.CapacitySessionViewDTO"-->
                            <p
                                th:if="${qSession.capacitySessionConfig.procedure == T(nl.tudelft.queue.model.enums.SelectionProcedure).FCFS && !current.eventInfo.status.isSelected()}">
                                You are currently in the Queue to enter
                                <th:block th:text="|${current.room.building.name} - ${current.room.name}|"></th:block>
                                .
                            </p>
                            <p
                                th:unless="${qSession.capacitySessionConfig.procedure == T(nl.tudelft.queue.model.enums.SelectionProcedure).FCFS or current.eventInfo.status.isHandled()}">
                                Selection will happen automatically, please return to this page after
                                <th:block th:text="${#temporals.format(qSession.capacitySessionConfig.selectionAt, 'dd MMMM yyyy HH:mm')}"></th:block>
                            </p>
                            <p th:if="${current.eventInfo.status.isRejected()}">
                                You were manually removed from this lab. See request info for a more detailed reason.
                            </p>
                        </th:block>

                        <th:block th:unless="${qSession.type == T(nl.tudelft.queue.model.enums.QueueSessionType).CAPACITY}">
                            <div th:unless="${qSession.type == T(nl.tudelft.queue.model.enums.QueueSessionType).REGULAR}">
                                <p class="lead">Your time slot is:</p>
                                <p class="lead" th:text="${current.timeSlot.slot.toSentence()}"></p>
                            </div>
                            <div th:if="${qSession.type == T(nl.tudelft.queue.model.enums.QueueSessionType).REGULAR}">
                                <p>Current position in the Queue:</p>
                                <p id="position" class="font-500" th:text="${qSession.data.position(#authenticatedP.id)}"></p>
                            </div>
                            <p class="mt-3">
                                Once your request has been processed, you can
                                <a class="link" th:href="@{/history}">leave feedback.</a>
                            </p>
                        </th:block>

                        <th:block th:if="${@permissionService.canRevokeRequest(current.data)}">
                            <form th:action="@{/request/{id}/revoke(id=${current.id})}" method="POST" class="mt-3">
                                <button class="button" data-style="outlined" data-type="error">Revoke request</button>
                            </form>
                        </th:block>
                    </div>
                </div>
            </div>
        </th:block>
    </body>
</html>
