<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Supprimer des produits</title>

    <link href="/css/main.css" rel="stylesheet"/>

    <style>
        table {
            margin: auto;
            text-align: left;
        }

        td {
            min-width: 100px;
        }
    </style>
</head>
<body>

<section>
    <p class="error" th:text="${error}"></p>
    <p class="success" th:if="${materialCode != null}"
       th:text="'Le produit \'' + ${materialCode} + '\' a bien été supprimée.'"></b>
    </p>
    <h1>Supprimer des produits</h1>

    <form action="/material/remover/" class="requireAuth-remover" method="POST">
        <th:block th:if="${!materials.empty}">
            <table id="materialsList">
                <tr>
                    <th>Produit</th>
                    <th>Type</th>
                </tr>
                <th:block th:each="material : ${materials}">
                    <tr>
                        <td class="materialCode" th:data-materialID="${material.materialID}"
                            th:text="${material.materialCode}"></td>
                        <td th:text="${material.materialType.materialTypeName}"></td>
                        <td>
                            <button class="remover" th:data-code="${material.materialCode}"
                                    th:data-recipeID="${material.materialID}"
                                    type="button">Supprimer
                            </button>
                        </td>
                    </tr>
                </th:block>
            </table>
        </th:block>
    </form>
    <th:block th:if="${materials.empty}">
        <b class="error">Aucun produit n'a été trouvé.</b>
    </th:block>
</section>

<script src="/js/main.js"></script>
</body>
</html>