<section class="orders light-section">
  <div class="container mx-auto pt-12">
    <h1 class="font-bold lg mb-4">All orders</h1>
    
    <table class="w-full table-auto bg-white">
      <thead>
        <tr>
          <th class="px-4 py-2 text-left"> Orders</th>
          <th class="px-4 py-2 text-left"> Address</th>
          <th class="px-4 py-2 text-left"> Phone</th>
          <th class="px-4 py-2 text-left"> Time</th>
          <th class="px-4 py-2 text-left"> Status</th>
        </tr>
      </thead>
      <tbody>

        <% if(orders){ %>

          <% orders.forEach( (order)=>{ %>
            <tr>
              <td class="border px-4 py-2">
                <a href= '/seller/order/<%= order._id %>  ' class="link">
                  <%= order._id %>
                </a>
              </td>
              <td class="border px-4 py-2">
                <%= order.address %>
              </td>
              <td class="border px-4 py-2">
                <%= order.phone %>
              </td>
              <td class="border px-4 py-2">
                <%= moment(order.createdAt).format('D MMMM YYYY, h:mm A')%>
              </td>
              <td class="border px-4 py-2">
                <%= order.status == -1 ? "Order Canceled" : ''  %>
                <%= order.status == 0 ? "Order Placed" : ''  %>
                <%= order.status == 1 ? "Order Confirmed" : ''  %>
                <%= order.status == 2 ? "Out for delivery" : ''  %>
                <%= order.status == 3 ? "Order Completed" : ''  %>              
              </td>
            </tr>
            <% }) %>


              <% } else { %>
                <tr>
                  <td class="p-4">
                    <span> No orders</span>
                  </td>
                </tr>
                <% } %>
      </tbody>

    </table>
  </div>
</section>