Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit 7ab8d658 authored by 65160394's avatar 65160394
Browse files

Project Round 3

parent ede526b0
No related branches found
No related tags found
No related merge requests found
...@@ -127,7 +127,7 @@ exports.postCreateTour = async (req, res) => { ...@@ -127,7 +127,7 @@ exports.postCreateTour = async (req, res) => {
try { try {
const tour = await Tour.getTourById(req.params.id); const tour = await Tour.getTourById(req.params.id);
if (!tour) return res.status(404).send('ไม่พบข้อมูลทัวร์'); if (!tour) return res.status(404).send('ไม่พบข้อมูลทัวร์');
res.render('edit-tour', { tour }); res.render('edittour', { tour });
} catch (error) { } catch (error) {
res.status(500).send('เกิดข้อผิดพลาด'); res.status(500).send('เกิดข้อผิดพลาด');
} }
......
...@@ -18,6 +18,6 @@ router.get('/create', tourController.getCreateTour); // หน้าสร้า ...@@ -18,6 +18,6 @@ router.get('/create', tourController.getCreateTour); // หน้าสร้า
router.post('/create', tourController.createTour); // บันทึกทัวร์ลงฐานข้อมูล router.post('/create', tourController.createTour); // บันทึกทัวร์ลงฐานข้อมูล
//แก้ไขทัวร์ //แก้ไขทัวร์
router.get('/edit/:id', tourController.getTourDetails); // หน้ารายละเอียดของทัวร์ router.get('/edit/:id', tourController.getEditTour); // หน้ารายละเอียดของทัวร์
module.exports = router; module.exports = router;
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</head> </head>
<body> <body>
<h1>Edit Tour</h1> <h1>Edit Tour</h1>
<form action="/tour/edit/<%= tour.id %>" method="POST"> <form action="/edit/<%= tour.id %>" method="POST">
<div> <div>
<label for="tourName">Tour Name:</label> <label for="tourName">Tour Name:</label>
<input type="text" id="tourName" name="name" value="<%= tour.name %>" required> <input type="text" id="tourName" name="name" value="<%= tour.name %>" required>
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<% if (session.userId) { %> <!-- ตรวจสอบว่าเป็นผู้ใช้ที่ล็อกอินแล้วหรือไม่ --> <% if (session.userId) { %> <!-- ตรวจสอบว่าเป็นผู้ใช้ที่ล็อกอินแล้วหรือไม่ -->
<a href="/edit/<%= tour.id %>" class="btn-edit">Edit</a> <!-- ปุ่มสำหรับแก้ไขทัวร์ --> <a href="/edit/<%= tour.id %>" class="btn-edit">Edit</a> <!-- ปุ่มสำหรับแก้ไขทัวร์ -->
<a href="/delete/<%= tour.id %>" class="btn-delete">Delete</a> <a href="/delete/<%= tour.id %>" class="btn-delete">Delete</a> <!-- ปุ่มสำหรับลบทัวร์ -->
<% } %> <% } %>
</li> </li>
<% }) %> <% }) %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment