<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB"
        crossorigin="anonymous">
    <title>Mongo CRUD Operations</title>
    <style>
        p{
            padding: 0px 10px;
        }
        .flex{
            display: flex;
            flex-direction: row;
        }
        a{
            text-decoration: none;
        }
        input{
            margin: 10px;
        }
        .heading{
            margin-top: 30px;
        }
    </style>
</head>

<body>
    <div class="container gap heading">
        <h1>Mongo CRUD Operations</h1>
        <h2>Books list : </h2>
    </div>
    <div class="container gap flex">
        <% var count = 1; %>
        <% message.forEach(function(book){ %>
        <div class="card" style="width: 18rem;margin: 20px 20px 20px 0;">
            <form action="/deletebook" method="POST">
                <h4 style="text-align:center;">Book<%= typeof message == 'undefined'? '' : count %></h4>
                <p>Id : <%= typeof message == 'undefined'? '' : book.id %></p>
                <p>Title : <%= typeof message == 'undefined'? '' : book.title %></p>
                <p>Author : <%= typeof message == 'undefined'? '' : book.author %></p>
                <p>Category : <%= typeof message == 'undefined'? '' : book.category %></p>
                <input type="hidden" name="id" value="<%= typeof message == 'undefined'? '' : book.id %>">
                <input type="submit" value="Delete" class="btn btn-danger">
            </form>
        </div>
        <% count+=1; %>
        <% }); %>

    </div>
    <br>
    <div class="container gap">
        <a href="/newbook">
            <button type="button" class="btn btn-primary">Add New Book</button>
        </a>
    </div>

    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
        crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T"
        crossorigin="anonymous"></script>
</body>

</html>