From c564a9db1c6526a067294d16aad708e02526574a Mon Sep 17 00:00:00 2001
From: Atiwit Pattanapukdee <65160394@go.buu.ac.th>
Date: Thu, 20 Mar 2025 19:16:22 +0700
Subject: [PATCH] Project Round 8

---
 controllers/tourController.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/controllers/tourController.js b/controllers/tourController.js
index c6fa09c..becdf95 100644
--- a/controllers/tourController.js
+++ b/controllers/tourController.js
@@ -211,10 +211,14 @@ exports.postEditTour = async (req, res) => {
   }
 
   const tourData = { name, description, price, duration };
+  const tourId = req.params.userId;  
+  if (!tourId) {
+    return res.status(400).send('ไม่พบข้อมูลทัวร์');
+  }
 
   try {
-    await Tour.updateTour(id, tourData); 
-    res.redirect('/tour/' + req.params.id); // ไปที่หน้ารายละเอียดทัวร์
+    await Tour.updateTour(tourId, tourData); 
+    res.redirect('/tour/' + tourId); // ไปที่หน้ารายละเอียดทัวร์
   } catch (error) {
     console.error('Error updating tour:', error);  // ข้อผิดพลาด
     res.status(500).send('เกิดข้อผิดพลาดในการแก้ไขทัวร์');
-- 
GitLab