<!DOCTYPE html>
<html lang="de" dir="ltr" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=0.75, user-scalable=no">

    <title>Angebote</title>
    <link rel="stylesheet" th:href="@{/css/ecom.css}"/>
</head>

<body>
<nav th:replace="fragments/header :: header">Header</nav>
<main>
    <div class='hero'>
        <div class='content-width'>
            <h1>Angebote</h1>
            <script th:src="@{/js/back.js}"></script>
            <div class="back" data-group="shop" data-name="Zurück zur Startseite." data-insert="false"></div>
            <div th:if="${commercialArticles.size() == 0}">
                <h1>Momentan gibt es keine Angebote</h1>
            </div>
            <div class='grid m base shadow' th:if="${commercialArticles.size() != 0}">
                <section th:each="article: ${commercialArticles}">
                    <a th:href="@{/shop/articles/{id}(id=${article.id})}" class="section">

                        <img th:src="@{/shop/articles/{id}/image.jpg(id=${article.id})}"/>
                        <h2 th:text="${article.title}"/>
                        <p class='price'><span
                                th:text="${#numbers.formatDecimal(article.getPriceGross() * 0.01, 1, 'POINT', 2, 'COMMA')}"></span><span> EUR</span>
                        </p>
                        <p th:text="${article.description}"/>
                    </a>
                </section>
                <section class="spacer"></section>
                <section class="spacer"></section>
                <section class="spacer"></section>
                <section class="spacer"></section>
            </div>
        </div>
        <div class="vertical-spacer s"></div>
    </div>
    <div class=''>
        <div class='content-width'>
            <h1>Personalisierte Empfehlungen</h1>

            <!-- if a User is NOT logged in-->
            <div class="grid l" th:if="${isLoggedIn == false}">
                <img th:src="@{/img/undraw_successful_purchase_secondary.svg}"/>
                <div>
                    <h2>Werde jetzt Kunde</h2>
                    <p> Jetzt Kunde werden und viele Vorteile sichern,
                        wie z.B. personalisierte Empfehlungen. </p>
                    <p>
                        <a class="button" th:href="@{/register}">Registieren</a>
                    </p>
                </div>
            </div>

            <!-- If User is logged in but hasn't ordered anything yet-->
            <div th:if="${isLoggedIn == true and hasOrders == false}">
                <h2>Jetzt Shoppen und Empfehlungen erhalten!</h2>
            </div>

            <!-- If User is logged in and has ordered something before-->
            <div th:if="${hasOrders == true}">
                <div class='grid m base shadow'>
                    <section th:each="article: ${suggestedArticles}">
                        <a th:href="@{/shop/articles/{id}(id=${article.id})}" class="section">

                            <img th:src="@{/shop/articles/{id}/image.jpg(id=${article.id})}"/>
                            <h2 th:text="${article.title}"/>
                            <p class='price'><span
                                    th:text="${#numbers.formatDecimal(article.getPriceGross() * 0.01, 1, 'POINT', 2, 'COMMA')}"></span><span> EUR</span>
                            </p>
                            <p th:text="${article.description}"/>
                        </a>
                    </section>
                </div>
            </div>
        </div>
        <div class="vertical-spacer s"></div>
    </div>
</main>
<footer th:replace="fragments/footer :: footer"></footer>
</body>

</html>
