<!-- RSK World - Free Programming Resources & Source Code -->
<!-- Founder: Molla Samser | Designer & Tester: Rima Khatun -->
<!-- Website: https://rskworld.in/contact.php | Year: 2026 -->
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Admin - Travel Assistant Bot</title>
    <link rel="stylesheet" href="/static/css/style.css">
  </head>
  <body>
    <header>
      <h1>Admin Dashboard</h1>
      <p>Manage itineraries and monitor status.</p>
    </header>
    <main>
      <section class="tools">
        <div class="tool">
          <h3>Itineraries</h3>
          <div class="auth">
            <input id="admin-token" type="text" placeholder="Bearer token">
            <button id="admin-load">Load</button>
          </div>
          <ul id="admin-itineraries"></ul>
        </div>
      </section>
    </main>
    <script>
      async function loadItineraries() {
        const token = document.getElementById("admin-token").value.trim();
        const r = await fetch("/api/itineraries", {
          headers: token ? { Authorization: `Bearer ${token}` } : {},
        });
        const res = await r.json();
        const ul = document.getElementById("admin-itineraries");
        ul.innerHTML = "";
        (res.itineraries || []).forEach((i) => {
          const li = document.createElement("li");
          li.textContent = `#${i.id} ${i.user} ${i.created_at}`;
          const btn = document.createElement("button");
          btn.textContent = "Delete";
          btn.onclick = async () => {
            const r2 = await fetch(`/api/itineraries/${i.id}`, {
              method: "DELETE",
              headers: { Authorization: `Bearer ${token}` },
            });
            const j2 = await r2.json();
            if (j2.deleted) loadItineraries();
          };
          li.appendChild(btn);
          ul.appendChild(li);
        });
      }
      document.getElementById("admin-load").addEventListener("click", loadItineraries);
    </script>
  </body>
  </html>

