File size: 3,717 Bytes
ae6debc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>FriendlyBot — Roster List</title>
  <link rel="icon" href="/logo.png" />
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet" />
  <style>
    :root {
      --bg: #0a0a1a;
      --surface: #12122a;
      --border: rgba(255, 255, 255, 0.06);
      --text: #fff;
      --text-dim: rgba(255, 255, 255, 0.6);
      --accent: #5865F2;
      --radius: 16px;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: "Inter", sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
      padding: 40px 20px;
    }
    header {
      max-width: 1000px;
      margin: 0 auto 40px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    h1 { font-size: 28px; font-weight: 700; }
    .btn {
      display: inline-block;
      padding: 10px 20px;
      background: var(--accent);
      color: #fff;
      text-decoration: none;
      border-radius: 8px;
      font-weight: 600;
      font-size: 14px;
    }
    .container { max-width: 1000px; margin: 0 auto; }
    .team-section {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 24px;
      margin-bottom: 24px;
    }
    .team-title {
      font-size: 20px;
      font-weight: 700;
      margin-bottom: 16px;
      color: var(--accent);
    }
    table { width: 100%; border-collapse: collapse; }
    th, td {
      text-align: left;
      padding: 12px;
      border-bottom: 1px solid var(--border);
    }
    th {
      color: var(--text-dim);
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 1px;
    }
    tr:last-child td { border-bottom: none; }
    .empty {
      text-align: center;
      color: var(--text-dim);
      padding: 40px;
    }
  </style>
</head>
<body>
  <header>
    <h1>📋 Roster List</h1>
    <a href="/" class="btn">Back to Dashboard</a>
  </header>

  <div class="container" id="app">
    <div class="empty">Loading rosters...</div>
  </div>

  <script>
    async function loadRosters() {
      try {
        const res = await fetch("/api/roster");
        const data = await res.json();
        const app = document.getElementById("app");
        
        if (!data || Object.keys(data).length === 0) {
          app.innerHTML = '<div class="empty">No rosters found. Use !roster-add @user Role in Discord to add one.</div>';
          return;
        }

        let html = "";
        Object.entries(data).forEach(([team, members]) => {
          html += `<div class="team-section">
            <div class="team-title">${team}</div>
            <table>
              <thead>
                <tr><th>User</th><th>Role</th><th>Added</th></tr>
              </thead>
              <tbody>
                ${members.map(m => `
                  <tr>
                    <td>${escapeHtml(m.user)}</td>
                    <td>${escapeHtml(m.role)}</td>
                    <td>${escapeHtml(m.addedAt)}</td>
                  </tr>
                `).join("")}
              </tbody>
            </table>
          </div>`;
        });
        app.innerHTML = html;
      } catch (err) {
        document.getElementById("app").innerHTML = '<div class="empty">Failed to load rosters.</div>';
      }
    }

    function escapeHtml(str) {
      if (!str) return "";
      const d = document.createElement("div");
      d.textContent = str;
      return d.innerHTML;
    }

    loadRosters();
  </script>
</body>
</html>