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

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale-1, shrink-to-fit=no">
    <title>Home</title>
    <!--Bootstrap CSS-->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <!--Font Awesome-->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/checkout-styles.css">
</head>

<body>

    <header class="display-6 p-4">
        <div class="container">
            <div class="row justify-content-between align-items-center">
                <div class="col-md-6 text-md-start">
                    Checkout
                </div>
                <div class="col-md-6 text-md-end">
                    <button type="button" class="btn btn-outline-primary"
                        onclick="location.href='/api/account'">Account</button>
                    <button type="button" class="btn btn-outline-primary"
                        onclick="location.href='/api/logout'">Logout</button>
                </div>
            </div>
        </div>
    </header>


    <div class="main">
        <div class="main-content">

            <% for (let i=0; i < cart.length; i++) { %>
                <% var temp="/img/" + cart[i]['name'] + ".jpg" ;%>

                    <div class="item-container">
                        <div class="item-image-container">
                            <img class="item-image" src="<%= temp %>" alt="<%= cart[i]['name'] %>">
                        </div>
                        <div class="item">
                            <h1>
                                <%= cart[i]['name']%>
                            </h1>
                            <h3>$<%= cart[i]['price']%>
                            </h3>
                            <div class="q">Quantity: <%= cart[i]['quantity']%>
                            </div>
                        </div>
                    </div>

                    <% } %>

                        <div class="checkout-box">
                            <div>Total: $<%= total %>
                            </div>
                            <div>Items in Cart: <%= cart.length %>
                            </div>
                        </div>
        </div>

        <div class="user-info-container">
            <div class="info-form">
                <header>Contact Information</header>
                <form name="update_form" action="/api/confirm_purchase" method="post">

                    <label for="email">Email</label>
                    <input type="text" required name="email">

                    <label for="p">Phone Number</label>
                    <input type="text" required name="phone">


                    <label for="addr">Shipping Address</label>
                    <input type="text" required name="address">

                    <input type="submit" value="Confirm" class="button">
                    <p class="error error--hidden"></p>


                    <input type="hidden" name="total" value="<%= total %>">


                </form>


            </div>
        </div>

    </div>


    <footer class="text-center">
        Retail Experience
    </footer>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
        crossorigin="anonymous"></script>
</body>

</html>