<%- include('partials/header') %>

<div class="products">
    <% products.forEach(product => { %>
        <div class="product-card">
            <img src="<%= product.image_url %>" alt="<%= product.name %>">
            <h3><%= product.name %></h3>
            <p><%= product.description %></p>
            <p>สินค้าเหลือ <%= product.stock %> ชิ้น</p>
            <p class="price">฿<%= product.price.toLocaleString() %></p>
            <form action="/cart/add" method="POST">
                <input type="hidden" name="productId" value="<%= product.id %>">
                <input type="number" name="quantity" value="1" min="1" max="<%= product.stock %>">
                <button type="submit">Add to Cart</button>
            </form>
        </div>
    <% }); %>
</div>

<%- include('partials/footer') %>