diff --git a/public/css/editprofile.css b/public/css/editprofile.css new file mode 100644 index 0000000000000000000000000000000000000000..cbb0b8ad929f4d4890d631f440dbf315f8568740 --- /dev/null +++ b/public/css/editprofile.css @@ -0,0 +1,47 @@ +.profile-container { + max-width: 600px; + margin: 30px auto; + padding: 20px; + background: white; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + border-radius: 10px; + } + + h2 { + text-align: center; + color: #0073e6; + margin-bottom: 20px; + } + + .form-group { + margin-bottom: 15px; + } + + .form-group label { + display: block; + font-weight: bold; + } + + .form-group input { + width: 100%; + padding: 10px; + margin-top: 5px; + border-radius: 5px; + border: 1px solid #ccc; + } + + button { + display: block; + width: 100%; + padding: 10px; + background: #007bff; + color: white; + border-radius: 5px; + cursor: pointer; + transition: 0.3s; + } + + button:hover { + background: #0056b3; + } + \ No newline at end of file diff --git a/public/profile.css b/public/profile.css new file mode 100644 index 0000000000000000000000000000000000000000..31b2ce3a46618e57b34a0a488d83134bfcaa9028 --- /dev/null +++ b/public/profile.css @@ -0,0 +1,31 @@ +.profile-container { + max-width: 600px; + margin: 30px auto; + padding: 20px; + background: white; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + border-radius: 10px; + text-align: center; + } + + .profile-card { + padding: 15px; + background: #f8f9fa; + border-radius: 8px; + margin-bottom: 15px; + } + + .btn-edit { + display: inline-block; + padding: 10px 15px; + background: #007bff; + color: white; + border-radius: 5px; + text-decoration: none; + transition: 0.3s; + } + + .btn-edit:hover { + background: #0056b3; + } + \ No newline at end of file diff --git a/routes/tourRoutes.js b/routes/tourRoutes.js index 35f4425b3872c9539259e58a9de1b68249351069..7eb0f54ce8c8c29055fab1b9c1881218086fa20b 100644 --- a/routes/tourRoutes.js +++ b/routes/tourRoutes.js @@ -27,4 +27,8 @@ router.get('/delete/:id', tourController.deleteTour); //ลบทัวร์ //ค้นหา router.get('/search', tourController.searchTours); //หน้าค้นหาทัวร์ +//Profile +router.get('/profile', userController.getProfilePage);//หน้าโปรไฟล์ +router.post('/edit-profile', userController.updateProfile);// อัปเดตข้อมูลโปรไฟล์ + module.exports = router; diff --git a/views/editprofile.ejs b/views/editprofile.ejs new file mode 100644 index 0000000000000000000000000000000000000000..07f948eb2ae0858742c7cc0b10fdaa05da768470 --- /dev/null +++ b/views/editprofile.ejs @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Edit Profile - <%= user.name %></title> + <link rel="stylesheet" href="/css/editprofile.css"> +</head> +<body> + <header> + <h1>Edit Your Profile</h1> + <nav> + <a href="/">Home</a> + <a href="/profile">Back to Profile</a> + <a href="/logout">Logout</a> + </nav> + </header> + + <section class="profile-container"> + <h2>Edit Your Information</h2> + + <form action="/edit-profile" method="POST"> + <div class="form-group"> + <label for="name">Name</label> + <input type="text" id="name" name="name" value="<%= user.name %>" required> + </div> + + <div class="form-group"> + <label for="email">Email</label> + <input type="email" id="email" name="email" value="<%= user.email %>" required> + </div> + + <div class="form-group"> + <label for="password">New Password </label> + <input type="password" id="password" name="password"> + </div> + + <button type="submit" class="btn-edit">Save Changes</button> + </form> + </section> + + <footer> + <p>© 2025 Tour Website</p> + </footer> +</body> +</html> diff --git a/views/profile.ejs b/views/profile.ejs new file mode 100644 index 0000000000000000000000000000000000000000..2ccb35a02067b51fc557d637047db6f2ae69d776 --- /dev/null +++ b/views/profile.ejs @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Profile - <%= user.name %></title> + <link rel="stylesheet" href="/css/profile.css"> +</head> +<body> + <header> + <h1>Welcome, <%= user.name %>!</h1> + <nav> + <a href="/">Home</a> + <a href="/logout">Logout</a> + </nav> + </header> + + <section class="profile-container"> + <h2>Your Profile</h2> + <div class="profile-card"> + <p><strong>Name:</strong> <%= user.name %></p> + <p><strong>Email:</strong> <%= user.email %></p> + </div> + + <a href="/edit-profile" class="btn-edit">Edit Profile</a> + </section> + + <footer> + <p>© 2025 Tour Website</p> + </footer> +</body> +</html> diff --git a/views/tour-details.ejs b/views/tour-details.ejs index d7e2bb2756fc1d31a8e065ef89ffaae2759ef144..07d787bb98d23300af074b28a62fe3c0b9cfaba6 100644 --- a/views/tour-details.ejs +++ b/views/tour-details.ejs @@ -15,7 +15,7 @@ <h2>Description</h2> <p><%= tour.description %></p> <p>Price: <%= tour.price %> THB</p> - <p>ระยะเวลา: <%= tour.duration %></p> + <p>ระยะเวลา: <%= tour.duration %> วัน</p> <a href="/" class="btn-edit">ย้อนกลับ</a> </section>