<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" href="favicon.ico" type="image/x-icon">
    <!-- google fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Cabin:wght@400;500;700&display=swap" rel="stylesheet">
    
    <!-- bootstrap css -->
    <link rel="stylesheet" href="dist/css/bootstrap.min.css" crossorigin="anonymous">
    
    <!-- custom css -->
    <link rel="stylesheet" href="styles.css">

    <!--Font Awesome -->
    <link rel="stylesheet" href="fontawesome-free/css/all.css">
        
    <title>Store-On-The-Go</title>
</head>
<body onload="hide_loading()">
  <div class="load_div">
    <div class="spinner-border text-info p-4 spin-load" role="status">
      <div class="sr-only">Loading...</div>
    </div>
  </div>
  
  <section class="main-background">
    <section id="header">
        <div class="container-fluid">
            <nav class="navbar navbar-expand-lg">
                <a class="navbar-brand" href="/"><img src="shop.png" alt="" style="width: 40px;"> Store-On-The-Go</a>
                <button
                  class="navbar-toggler"
                  type="button"
                  data-toggle="collapse"
                  data-target="#navbarSupportedContent"
                  aria-controls="navbarSupportedContent"
                  aria-expanded="false"
                  aria-label="Toggle navigation"
                >
                <i class="fas fa-ellipsis-v nav-toggler-icon"></i>
                  <!-- <span class="navbar-toggler-icon"></span> -->
                </button>
                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                  <ul class="navbar-nav ml-auto">
                    <li class="nav-item">
                      <a class="nav-link" href="/">Location</a>
                    </li>
                    <li class="nav-item">
                      <a class="nav-link" href="/signup">Sign up</a>
                    </li>
                    <li class="nav-item">
                      <a class="nav-link nav-btn mx-auto" href="/login">Log in</a>
                    </li>
                  </ul>
                </div>
              </nav>
        </div>
    </section>
    <section id="location">
      <div id="stickySearchBar">
      
          <div class="sticky-search-box mx-auto">
              <form method="post" action="/search" id="wordSubmit">
                <input method="" name="input" action="" class="sticky-input-box search-tag" type="text" id="word_input" autocomplete="off" autofocus required
                  placeholder="Search products" />
                  <input type="hidden" name="explorecity" class="explorecity" value="<%= city %>">
                <button class="sticky-button" href="" id="searchbtn">
                  <i class="fas fa-search"></i>
                </button>
              </form>
              <script>
                var input = document.getElementById("word_input");
            
                  input.addEventListener("keyup", function (event) {
                  // Number 13 is the "Enter" key on the keyboard
                  if (event.keyCode === 13) {
                    // Cancel the default action, if needed
                    event.preventDefault();
                    // Trigger the button element with a click
                    document.getElementById("searchbtn").click();
                  }
                });
              </script>
              <div class="suggestions"></div>
              
            </div>
          </div>
      <div class="container-fluid explore-city-header">
        <div class="row">
          <div class="col-lg-6 col-md-6 col-sm-6">
            <img src="explore-city.svg" alt="" class="ml-auto explore-image">
            </div>
          <h1 class="col-lg-6 col-md-6 col-sm-6 my-auto pr-0">Explore <%= city %></h1>
        </div>
      </div>
    </section>
    <section id="products">
        <div class="container-fluid row">
          <% if(products.length === 0) { %>
            <div class="mx-auto col-lg-12"><img class="col-lg-4 col-md-6 col-sm-6" src="no_result.svg" alt=""></div>
            <h3 style="margin-top: 50px; color: #FC5185;" class="mx-auto">No products found</h3>
          <% } %>
          <% products.forEach(element => { %>
            <div class="col-lg-4 col-md-6 cart-item">
              <form action="/consumer/addToCart" method="POST">
                <input type="hidden" name="id" value="<%= element._id %>">
                <input type="hidden" name="quantity" value="<%= element.quantity %>">
              <div class="card mx-auto">
                <a href="/consumer/<%= element._id %>"><img src="data:<%= element.image.mimetype %>;base64,<%= element.image.data.toString('base64') %>" class="card-img-top" alt="..."></a>
                <div class="card-body text-left">
                  <a href="/consumer/<%= element._id %>"><h5 class="card-title"><%= element.name %></h5></a>
                  <p class="card-text custom-height-card-text"><%= element.description.substring(0,60) %>...</p>
                  <span href="#" class="cart-price">₨. <%= element.price %></span>
                  <button class="cart-quantity add-to-cart btn btn-outline-info" type="submit">Add to cart <i class="fas fa-cart-plus card-link"></i></button>
                </div>
              </div>
            </form>
            </div>
          <% }); %> 
        </div>
    </section>
    <section id="footer">
        <div class="container-fluid">
          <p>© Copyright <span id="Copyright"></span> Store-On-The-Go</p>
        </div>
    </section>
  </section>
    <script src="script.js"></script>
    <script src="tagSuggestion.js"></script>
    <script src="dist/jquery.slim.min.js" crossorigin="anonymous"></script>
    <script src="core/dist/umd/popper.min.js" crossorigin="anonymous"></script>
    <script src="dist/js/bootstrap.min.js" crossorigin="anonymous"></script>
</body>
</html>