nomadro/app/admin/users/page.tsx
eric 9f8fec1723 Ship portal PC/H5 acceptance, VIP ScrollReader, admin analytics and ops anchors.
Adds /api/health, ntfy notify on config save, /admin/analytics charts, and deploy smoke for miniprogram config/API.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 23:52:00 -05:00

72 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import { useEffect, useState } from "react";
import styles from "../admin.module.css";
type UserRow = {
id?: string;
email?: string;
username?: string;
name?: string;
created?: string;
};
export default function AdminUsersPage() {
const [items, setItems] = useState<UserRow[]>([]);
const [source, setSource] = useState("");
const [message, setMessage] = useState("");
const [error, setError] = useState("");
useEffect(() => {
fetch("/api/admin/users", { cache: "no-store" })
.then(async (r) => {
const j = await r.json();
if (!r.ok) throw new Error(j.error || r.statusText);
setItems(j.items || []);
setSource(j.source || "");
setMessage(j.message || "");
})
.catch((e) => setError(e instanceof Error ? e.message : String(e)));
}, []);
return (
<>
<h1 className={styles.pageTitle}>👥 用户</h1>
<p className={styles.pageLead}>
来源:{source || "…"}。配置 <code>PB_ADMIN_TOKEN</code> 后拉取 PocketBase users 集合。
</p>
{error ? <p className={styles.error}>{error}</p> : null}
{message ? <p className={styles.muted}>{message}</p> : null}
<div className={styles.panel} style={{ overflowX: "auto" }}>
<table className={styles.table}>
<thead>
<tr>
<th>ID</th>
<th>邮箱 / 用户名</th>
<th>创建时间</th>
</tr>
</thead>
<tbody>
{items.length === 0 ? (
<tr>
<td colSpan={3} className={styles.muted}>
暂无记录
</td>
</tr>
) : (
items.map((u) => (
<tr key={u.id}>
<td>{u.id}</td>
<td>{u.email || u.username || u.name || "—"}</td>
<td>{u.created || "—"}</td>
</tr>
))
)}
</tbody>
</table>
</div>
</>
);
}