From 9ffc7cdb229c46eedfcc30224a812470f4b6e51c Mon Sep 17 00:00:00 2001
From: Atiwit Pattanapukdee <65160394@go.buu.ac.th>
Date: Thu, 20 Mar 2025 21:47:38 +0700
Subject: [PATCH] Project Round 9

---
 controllers/tourController.js              | 4 ++--
 routes/tourRoutes.js                       | 2 +-
 views/{my-bookings.ejs => bookinglist.ejs} | 6 ++----
 views/index.ejs                            | 2 +-
 4 files changed, 6 insertions(+), 8 deletions(-)
 rename views/{my-bookings.ejs => bookinglist.ejs} (67%)

diff --git a/controllers/tourController.js b/controllers/tourController.js
index 05e4fc6..e46c6dc 100644
--- a/controllers/tourController.js
+++ b/controllers/tourController.js
@@ -303,7 +303,7 @@ exports.getUserBookings = async (req, res) => {
     const [bookings] = await pool.query(query, [userId]);
 
     // ส่งข้อมูลการจองกลับไปยังผู้ใช้
-    res.render('my-bookings', { bookings });
+    res.render('bookinglist', { bookings });
   } catch (error) {
     console.error('Error fetching user bookings:', error.message);
     res.status(500).send('เกิดข้อผิดพลาดในการดึงข้อมูลการจอง');
@@ -335,7 +335,7 @@ exports.createBooking = async (req, res) => {
     await pool.execute(bookingQuery, [userId, tourId]);
 
     // หลังจากบันทึกการจองสำเร็จแล้ว, ส่งผู้ใช้กลับไปที่หน้ารายการจอง
-    res.redirect('/my-bookings');
+    res.redirect('/bookinglist');
   } catch (error) {
     console.error('Error creating booking:', error.message);
     res.status(500).send('เกิดข้อผิดพลาดในการจองทัวร์');
diff --git a/routes/tourRoutes.js b/routes/tourRoutes.js
index 1007191..5f5d208 100644
--- a/routes/tourRoutes.js
+++ b/routes/tourRoutes.js
@@ -33,7 +33,7 @@ router.get('/edit-profile', tourController.getEditProfilePage);// อัปเ
 router.post('/edit-profile', tourController.updateProfile);// อัปเดตข้อมูลโปรไฟล์
 
 //จองทัวร์
-router.get('/my-bookings', tourController.getUserBookings);
+router.get('/bookinglist', tourController.getUserBookings);
 router.get('/create-booking', tourController.getAllTours);
 router.post('/create-booking', tourController.createBooking);
 router.post('/cancel/:id', tourController.cancelBooking);
diff --git a/views/my-bookings.ejs b/views/bookinglist.ejs
similarity index 67%
rename from views/my-bookings.ejs
rename to views/bookinglist.ejs
index 091350f..e03ac49 100644
--- a/views/my-bookings.ejs
+++ b/views/bookinglist.ejs
@@ -12,16 +12,14 @@
       <tr>
         <th>Booking ID</th>
         <th>Tour Title</th>
-        <th>Booking Date</th>
         <th>Status</th>
       </tr>
     </thead>
     <tbody>
       <% bookings.forEach(booking => { %>
         <tr>
-          <td><%= booking.id %></td> <!-- booking_id --> (ตรวจสอบว่าเป็น id หรือไม่)
-          <td><%= booking.tour_name %></td> <!-- tour_title --> (ตรวจสอบว่าเป็น tour_name หรือไม่)
-          <td><%= booking.booking_date %></td>
+          <td><%= booking.id %></td> <!-- booking_id --> 
+          <td><%= booking.tour_name %></td> <!-- tour_title --> 
           <td><%= booking.status %></td>
         </tr>
       <% }) %>
diff --git a/views/index.ejs b/views/index.ejs
index 64930c6..5725d21 100644
--- a/views/index.ejs
+++ b/views/index.ejs
@@ -21,7 +21,7 @@
       </form>
       
       <% if (session && session.userId) { %>  <!-- ตรวจสอบ session -->
-        <a href="/my-bookings">My-Booking</a>
+        <a href="/bookinglist">My-Booking</a>
         <a href="/logout">Logout</a>
       <% } else { %>
         <a href="/login" class="login-btn">Login</a> <!-- ถ้ายังไม่ได้ login -->
-- 
GitLab