<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
      rel="stylesheet"
      integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
      crossorigin="anonymous"
    />
    <script defer
      src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
      integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
      crossorigin="anonymous"
    ></script>

    <link rel="stylesheet" href="..\..\stylesheets\orders.css">
    <script src="..\..\scripts\orders.js"></script>

    <link rel="stylesheet" href="..\..\stylesheets\index.css">
    <script src="..\..\scripts\index.js"></script>

    <title>Orders</title>
</head>

<body>
  <div class="container-fluid" style="height: 100vh;">
    <div class="row h-100">
      <%- include('navbar') %>

      <!-- Content -->
      <div class="col-9 scrollable-column p-5" style="background-color: aqua;">

        <!-- Order Items and Page Navigation -->
        <div class="row">
          <div class="col">
            <div class="dropdown show">
              <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                Order Items
              </a>
              <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
                <a class="dropdown-item" href="#">Action</a>
                <a class="dropdown-item" href="#">Another action</a>
                <a class="dropdown-item" href="#">Something else here</a>
              </div>
            </div>
          </div>
          <div class="col">
            <nav aria-label="...">
              <ul class="pagination">
                <li class="page-item disabled">
                  <a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
                </li>
                <li class="page-item"><a class="page-link" href="#">1</a></li>
                <li class="page-item active" aria-current="page">
                  <a class="page-link" href="#">2</a>
                </li>
                <li class="page-item"><a class="page-link" href="#">3</a></li>
                <li class="page-item">
                  <a class="page-link" href="#">Next</a>
                </li>
              </ul>
            </nav>
          </div>
        </div>

        <% for(order of parsed_orders) { %> 
        <div class="row mb-4">
          <div class="col-1"></div>
          <div class="col-6">
            <div class="card m-0" style="background-color: lightcoral;">
              <div class="card-body">
                <div class="card-title">
                  <h5><%= "Order #: " + order.orderid %></h5>
                  <h5><%= "Date Ordered: " + order.dateOrdered.toDateString() %></h5>
                </div>
              </div>
            </div>
          </div>
          <div class="col-5"></div>
          <div class="card">
            <div class="card-body">
              <div class="row">
                <div class="col-4">
                  <p>Delivery Status: <span style="font-weight: bold;"><%= order.status %></span></p>
                </div>
                <div class="col-8">
                  <div class="row">
                    <%
                    total = 0
                    for (product of order_dictionary[order.orderid]) {
                     total += product.productprice
                    } %>
                    <h5>Total Cost: $<%= total.toFixed(2) %></h5>
                  </div>
                  <div class="row">
                    <h6><%= "Payment Option: Card ending in " + order.paymentOption %></h6>
                  </div>
                </div>
              </div>
              
              <% for (product of order_dictionary[order.orderid]) { %>
              <!-- Product -->
              <div class="row">
                <div class="card m2">
                  <div class="row">
                    <div class="col-4">
                      <div style="height: 190px; width: 140px; background-color: red;">
                        <img style="height: 100%; width: 100%;" src=<%= "../../images/products/" + product.productimage %>>
                      </div>
                    </div>
                    <div class="col-sm-8 my-auto">
                      <div class="row">
                        <div class="col-8">
                          <h5><a href=<%= "/store/product/" + product.productid %>>
                            <%= product.productname %>
                          </a>
                        </h5>
                        </div>
                        <div class="col-4">
                          <h3><%= "$" + product.productprice %></h3>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <% } %>
            </div>
          </div>
        </div>
        <% } %>

        
      </div>
    </div>
  </div>
  </div>


  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
    integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
    crossorigin="anonymous"></script>
</body>

</html>