Gitlab@Informatics

Skip to content
Snippets Groups Projects
Select Git revision
  • c863e0611934f6af1f501f67b2c0d95838ee686e
  • main default protected
2 results

product.ejs

Blame
  • product.ejs 1.63 KiB
    <!DOCTYPE html>
    <html lang="en">
    <head>
       <meta charset="UTF-8">
       <meta name="viewport" content="width=device-width, initial-scale=1.0">
       <title>รายละเอียดสินค้า</title>
       <style>
          img {
             width: 300px;
             border-radius: 10px;
             margin-bottom: 20px;
          }
       </style>
    </head>
    <body>
        <h1><%= product.product_name %></h1>
    <img src="<%= product.image %>" alt="<%= product.product_name %>" width="300px">
    <p>ราคา: <strong><%= product.price %> บาท</strong></p>
    <p>รายละเอียด: <%= product.description || "ไม่มีรายละเอียด" %></p>
    <p>สร้างโดย: <%= product.owner %></p>
    
    <% if (currentUserEmail === product.owner) { %>
       <form action="/delete_product/<%= product.product_id %>" method="POST" onsubmit="return confirm('ยืนยันการลบสินค้านี้?');">
          <button type="submit" style="color: red;">ลบสินค้า</button>
       </form>
       <form action="/products/<%= product.product_id %>/edit" method="GET">
          <button type="submit" style="color: yellow;">เเก้ไขสินค้า</button>
       </form>
       <form action="/cart/add" method="POST">
           <input type="hidden" name="product_id" value="<%= product.product_id %>">
           <input type="hidden" name="price" value="<%= product.price %>">
           <label>จำนวน: </label>
           <input type="number" name="quantity" value="1" min="1">
           <button type="submit">เพิ่มลงตะกร้า</button>
       </form>
    <% } %>
    
    
    <a href="/">กลับหน้าหลัก</a>
     
    </body>
    </html>