Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit 9ffc7cdb authored by 65160394's avatar 65160394
Browse files

Project Round 9

parent aaf60ea4
Branches
No related tags found
No related merge requests found
......@@ -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('เกิดข้อผิดพลาดในการจองทัวร์');
......
......@@ -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);
......
......@@ -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>
<% }) %>
......
......@@ -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 -->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment