<!--

    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.LabViewDTO"-->

    <!--@thymesVar id="rooms" type="java.util.List<nl.tudelft.labracore.api.dto.RoomSummaryDTO>"-->

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

    <body>
        <th:block th:fragment="current-request-edit" th:if="${current.eventInfo.status.isPending()}">
            <div class="surface p-0">
                <h3 class="surface__header" th:if="${current.room != null}">Update your location and question</h3>
                <h3 class="surface__header" th:if="${current.onlineMode != null}">Update your question</h3>

                <div class="surface__content">
                    <form class="form" method="post" th:action="@{/request/{id}/update-request-info(id=${current.id})}" th:object="${currentDto}">
                        <div th:if="${current.room != null}" id="physical-location-info" class="flex vertical gap-3">
                            <div class="flex vertical gap-1 align-start">
                                <span th:text="|Current location: ${current.room?.building?.name} - ${current.room?.name}|"></span>
                                <select class="textfield" th:field="*{room}" data-style="variant">
                                    <option disabled value="">Choose your new room</option>
                                    <option
                                        th:each="room : ${rooms}"
                                        th:value="${room.id}"
                                        th:selected="${current.room == room.id}"
                                        th:text="|${room.building.name} - ${room.name}|"></option>
                                </select>
                            </div>

                            <div class="flex vertical gap-1" id="comment">
                                <label for="inputComment">Where are you located?</label>
                                <textarea
                                    type="text"
                                    class="textfield"
                                    data-style="variant"
                                    id="inputComment"
                                    placeholder="Cubicle 1..."
                                    th:field="*{comment}"></textarea>
                            </div>
                        </div>

                        <div
                            th:if="${current.requestType == T(nl.tudelft.queue.model.enums.RequestType).QUESTION}"
                            class="flex vertical gap-1 mt-3"
                            id="question">
                            <label for="inputQuestion">What is your question?</label>
                            <textarea
                                type="text"
                                class="textfield"
                                data-style="variant"
                                id="inputQuestion"
                                placeholder="How do I..."
                                required
                                minlength="15"
                                th:field="*{question}"></textarea>
                        </div>

                        <div class="mt-3">
                            <button type="submit" class="button" name="updateRequestInfo">Save</button>
                        </div>
                    </form>

                    <div id="image-holder"></div>
                </div>
            </div>
        </th:block>
    </body>
</html>
