Gitlab@Informatics

Skip to content
Snippets Groups Projects
Select Git revision
  • 0d3e953556c32790968eed65021730a880507378
  • main default protected
2 results

index.ejs

Blame
  • index.ejs 1.89 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>
          <a href="/">Home</a>
          <% if (session.userId) { %>
            <a href="/create" class="btn-create">Create Tour</a>
          <% } %>
          <form action="/search" method="GET">
            <input type="text" name="query" placeholder="Search for tours..." required>
            <button type="submit">Search</button>
          </form>
          <% if (session && session.userId) { %>  <!-- ตรวจสอบว่า userId อยู่ใน session หรือไม่ -->
            <a href="/profile"><%= session.userName %></a>  <!-- แสดงชื่อผู้ใช้ -->
            <a href="/logout">Logout</a>
          <% } else { %>
            <a href="/login" class="btn-login">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.userId) { %>  <!-- ตรวจสอบว่าเป็นผู้ใช้ที่ล็อกอินแล้วหรือไม่ -->
                <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>&copy; 2025 Tour Website</p>
      </footer>
    </body>
    </html>