index.ejs 1.73 KiB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tour Website</title>
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<header>
<h1>Welcome to JourneyHub</h1>
<nav>
<% if (session && session.id) { %>
<a href="/create" class="btn-create">Create Tour</a>
<a href="/create-booking" class="btn-create">Create Booking</a>
<% } %>
<form action="/search" method="GET" class="search-container">
<input type="text" name="query" placeholder="Search for tours..." required>
<button type="submit">Search</button>
</form>
<% if (session && session.userId) { %> <!-- ตรวจสอบ session -->
<a href="/bookinglist">My-Booking</a>
<a href="/logout">Logout</a>
<% } else { %>
<a href="/login" class="login-btn">Login</a> <!-- ถ้ายังไม่ได้ login -->
<% } %>
</nav>
</header>
<section>
<h2>โปรแกรมทัวร์ที่เปิดให้จองขณะนี้</h2>
<ul>
<% tours.forEach(tour => { %>
<li>
<a href="/tour/<%= tour.id %>"><%= tour.name %></a> - <%= tour.price %> THB
<% if (session && session.id) { %>
<a href="/edit/<%= tour.id %>" class="btn-edit">Edit</a> <!-- ปุ่มสำหรับแก้ไขทัวร์ -->
<a href="/delete/<%= tour.id %>" class="btn-delete">Delete</a> <!-- ปุ่มสำหรับลบทัวร์ -->
<% } %>
</li>
<% }) %>
</ul>
</section>
<footer>
<p>© 2025 Tour Website</p>
</footer>
</body>
</html>