|
1 | 1 | import { html } from "hono/html"; |
2 | 2 | import { formatISO } from "date-fns"; |
3 | 3 |
|
4 | | -// Admin users list component |
5 | 4 | export const UsersList = ({ users, total }) => html` |
6 | | - <div class="form-section"> |
7 | | - <h3>Users (${total} total)</h3> |
| 5 | + <div class="card"> |
| 6 | + <div class="card-header card-header-cb"> |
| 7 | + <h3 class="h5 mb-0">Users (${total} total)</h3> |
| 8 | + </div> |
8 | 9 | ${users && users.length > 0 |
9 | 10 | ? html` |
10 | | - <table> |
11 | | - <thead> |
12 | | - <tr> |
13 | | - <th>Name</th> |
14 | | - <th>Email</th> |
15 | | - <th>Verified</th> |
16 | | - <th>Role</th> |
17 | | - <th>Created</th> |
18 | | - </tr> |
19 | | - </thead> |
20 | | - <tbody> |
21 | | - ${users.map( |
22 | | - (user) => html` |
23 | | - <tr> |
24 | | - <td>${user.name}</td> |
25 | | - <td>${user.email}</td> |
26 | | - <td>${user.emailVerified ? "✅" : "❌"}</td> |
27 | | - <td> |
28 | | - <form method="post" action="/admin/user/role"> |
29 | | - <input type="hidden" name="userId" value="${user.id}" /> |
30 | | - <select name="role" onchange="this.form.submit()"> |
31 | | - <option |
32 | | - value="user" |
33 | | - ${user.role === "user" ? "selected" : ""} |
| 11 | + <div class="table-responsive"> |
| 12 | + <table class="table table-hover mb-0"> |
| 13 | + <thead class="table-light"> |
| 14 | + <tr> |
| 15 | + <th>Name</th> |
| 16 | + <th>Email</th> |
| 17 | + <th>Verified</th> |
| 18 | + <th>Role</th> |
| 19 | + <th>Date</th> |
| 20 | + </tr> |
| 21 | + </thead> |
| 22 | + <tbody> |
| 23 | + ${users.map( |
| 24 | + (user) => html` |
| 25 | + <tr> |
| 26 | + <td>${user.name}</td> |
| 27 | + <td>${user.email}</td> |
| 28 | + <td>${user.emailVerified ? "✅" : "❌"}</td> |
| 29 | + <td> |
| 30 | + <form method="post" action="/admin/user/role"> |
| 31 | + <input |
| 32 | + type="hidden" |
| 33 | + name="userId" |
| 34 | + value="${user.id}" |
| 35 | + /> |
| 36 | + <select |
| 37 | + name="role" |
| 38 | + class="form-select form-select-sm" |
| 39 | + onchange="this.form.submit()" |
34 | 40 | > |
35 | | - User |
36 | | - </option> |
37 | | - <option |
38 | | - value="admin" |
39 | | - ${user.role === "admin" ? "selected" : ""} |
40 | | - > |
41 | | - Admin |
42 | | - </option> |
43 | | - </select> |
44 | | - </form> |
45 | | - </td> |
46 | | - <td> |
47 | | - ${formatISO(new Date(user.createdAt), { |
48 | | - representation: "date", |
49 | | - })} |
50 | | - </td> |
51 | | - </tr> |
52 | | - `, |
53 | | - )} |
54 | | - </tbody> |
55 | | - </table> |
| 41 | + <option |
| 42 | + value="user" |
| 43 | + ${user.role === "user" ? "selected" : ""} |
| 44 | + > |
| 45 | + User |
| 46 | + </option> |
| 47 | + <option |
| 48 | + value="admin" |
| 49 | + ${user.role === "admin" ? "selected" : ""} |
| 50 | + > |
| 51 | + Admin |
| 52 | + </option> |
| 53 | + </select> |
| 54 | + </form> |
| 55 | + </td> |
| 56 | + <td class="text-nowrap"> |
| 57 | + ${formatISO(new Date(user.createdAt), { |
| 58 | + representation: "date", |
| 59 | + })} |
| 60 | + </td> |
| 61 | + </tr> |
| 62 | + `, |
| 63 | + )} |
| 64 | + </tbody> |
| 65 | + </table> |
| 66 | + </div> |
56 | 67 | ` |
57 | | - : html` <p>No users found.</p> `} |
| 68 | + : html`<div class="card-body"> |
| 69 | + <p class="mb-0 text-muted">No users found.</p> |
| 70 | + </div>`} |
58 | 71 | </div> |
59 | 72 | `; |
0 commit comments