<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/jobs.css">
    <link rel="icon" href="img/favicon.png" type="image/png" />
    <title>Intranet Saint-James</title>
</head>
<body>
    <!-- EN-TÊTE -->
    <header>
        <!--- Logo du site -->
        <img class="logo" src="img/logo.png">
        <!-- Barre de navigation -->
        <nav>
            <!-- Bouton hamburger pour les appareils mobiles -->
            <label for="toggle">☰</label>
            <input type="checkbox" id="toggle">
            <!-- Liens des pages -->
            <div class="main_pages">
                <a href="/">Accueil</a>
                <a href="/form">Formulaires</a>
                <a href="/list">Liste des téléphones</a>
                <a href="/jobs">Offres d'emploi</a>
            </div>
        </nav>
    </header>

    <div class="user-control">
        <img class="svg-color" src="img/user.svg" />
        <p><%= useremail %></p>
        <a class="logout" href="/logout">Déconnexion</a>
    </div>

    <!-- CONTENU PRINCIPAL -->
    <main>
        <% if (strapiStatus) { %>
            <a class="add-button" href="/newjob"><img src="img/plus.png" />Nouveau</a>
        <% } else { %>
            <a class="add-button" href="/loginjob"><img src="img/user.svg" />Connexion</a>
        <% } %>

        <% for(let i = 0; i < job.data.length; i++) { %>
            <% date = new Date(job.data[i].attributes.createdAt); %>

            <div class="job">
                <h3>#<%= job.data[i].id %></h3>
                <h2 class="job-title"><%= job.data[i].attributes.name %></h2>
                <h3 class="job-time"><%= date.toLocaleDateString("fr-FR") + " " + date.toLocaleTimeString("fr-FR"); %></h3>
                <p class="job-details"><%= job.data[i].attributes.details %></p>
                <a href="/viewjob?id=<%= job.data[i].id %>">Voir</a>
            </div>

            <div class="line"></div>
        <% } %>
    </main>

    <!-- SCRIPTS -->
    <script src="js/spin.js"></script>
</body>
</html>