<!DOCTYPE html>
<html lang="it">
<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 href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>
    <link rel="stylesheet" type="text/css" href="/static/style.css">
    <title>Libreria di <%= utente.Nome %></title>
    <div class="title" id="titlecenter" style="padding-top: 20px;">
         <h2>Libreria di <%= utente.Nome %></h2>
    </div>
</head>
<body>
<div class="container">
    <div class="row" style="padding-top: 30px; padding-left: 10px; padding-right: 10px;">
        <% if(libri.length > 0) { %>
            <% libri.forEach(libro => { %>
                <div class="col">
                    <div class="card" style="width: 18rem;">
                        <img class="card-img-top" src="<%= libro.urlCopertina %>" alt="Card image cap" width="230" height="450">
                        <div class="card-body">
                            <h5 class="card-title">
                                <%= libro.Titolo %>
                            </h5>
                            <h6 class="card-subtitle mb-2 text-muted">
                                <%= libro.Autore %>
                            </h6>

                            <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="<%= '#n' + libro.Isbn %>">
                                Dettagli
                            </button>
                            
                            <div class="modal fade" id="<%= 'n' + libro.Isbn %>" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
                                aria-labelledby="staticBackdropLabel" aria-hidden="true">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <h5 class="modal-title" id="staticBackdropLabel">
                                                <%= libro.Titolo %>
                                            </h5>
                                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                        </div>
                                        <div class="modal-body">
                                            <p>
                                                <%= libro.Descrizione %>
                                            </p>
                                            <br>
                                            <dl class="row">
                                                <dt class="col-sm-3">Pagine Lette</dt>
                                                <dd class="col-sm-9"><%= libro.PagineLette %> di <%= libro.Pagine %></dd>
                                            
                                                <dt class="col-sm-3">Completato</dt>
                                                <dd class="col-sm-9">
                                                    <% if(libro.Completato){%> <p>Si</p> <% }else{ %> <p>No</p> <% } %>
                                                </dd>
                                            
                                                <dt class="col-sm-3">Impressioni</dt>
                                                <dd class="col-sm-9"><% if(libro.Impressioni === ''){%> <p>Ancora niente...</p> <% }else{ %> <%= libro.Impressioni %> <% } %></dd>
                                            
                                                <dt class="col-sm-3">Valutazione</dt>
                                                <dd class="col-sm-9">
                                                    <% if(libro.Valutazione == 0){ %>

                                                        <%= libro.Valutazione %> (Non ancora valutato)
                                                    <% }else if(libro.Valutazione == 5){ %>
                                                        <%= libro.Valutazione %> (Mi e' piaciuto molto)
                                                    <% }else if(libro.Valutazione == 1){ %>
                                                        <%= libro.Valutazione %> (non mi Ã¨ piaciuto)
                                                    <% }else{ %>
                                                        <%= libro.Valutazione %>
                                                    <% } %>
                                                </dd>
                                            </dl>
                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Chiudi</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            <% }) %>
        <% }else{ %>
            <div class="subtitle" id="titlecenter">
                <h2>Ancora nessun libro inserito</h2>
            </div>
        <% } %>
    </div>
</div>
</body>
</html>