From a87aee1145f3e6e221e3eb3ee5fdfe9b5e06e2c5 Mon Sep 17 00:00:00 2001
From: Atiwit Pattanapukdee <65160394@go.buu.ac.th>
Date: Wed, 26 Mar 2025 17:52:17 +0700
Subject: [PATCH] Project Round 11

---
 views/index.ejs        | 11 ++++++++++-
 views/tour-details.ejs |  2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/views/index.ejs b/views/index.ejs
index 8816134..fdd0e84 100644
--- a/views/index.ejs
+++ b/views/index.ejs
@@ -36,7 +36,9 @@
           
           <% if (session && session.userId) { %>  
             <a href="/edit/<%= tour.id %>" class="btn-edit">Edit</a> <!-- ปุ่มสำหรับแก้ไขทัวร์ -->
-            <a href="/delete/<%= tour.id %>" class="btn-delete">Delete</a> <!-- ปุ่มสำหรับลบทัวร์ -->
+            <form action="/tour/delete/<%= tour.id %>" method="POST" onsubmit="return confirmDelete()">
+              <button type="submit" class="btn-delete">Delete</button> <!-- ปุ่มสำหรับลบทัวร์ -->
+            </form>
           <% } %>
         </li>
       <% }) %>
@@ -46,5 +48,12 @@
   <footer>
     <p>&copy; 2025 Tour Website</p>
   </footer>
+
+  <script>
+    // ฟังก์ชันยืนยันการลบ
+    function confirmDelete() {
+      return confirm("คุณแน่ใจหรือไม่ว่าต้องการลบทัวร์นี้?");
+    }
+  </script>
 </body>
 </html>
diff --git a/views/tour-details.ejs b/views/tour-details.ejs
index 2a34d11..c53af30 100644
--- a/views/tour-details.ejs
+++ b/views/tour-details.ejs
@@ -16,7 +16,7 @@
     <p><strong>ชื่อทัวร์:</strong> <%= tour.name %></p>
     <p><strong>คำอธิบาย:</strong> <%= tour.description %></p>
     <p><strong>ราคา:</strong> <%= tour.price %></p>
-    <p><strong>ระยะเวลา:</strong> <%= tour.duration %></p>
+    <p><strong>ระยะเวลา:</strong> <%= tour.duration %> วัน</p>
     <p><strong>บริษัท:</strong> <%= tour.cname %></p>
     <a href="/" class="btn-edit">ย้อนกลับ</a>   
   </section>
-- 
GitLab