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>
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
import styles from "../admin.module.css";
|
|
|
|
type Channel = { id: string; region: string; note: string };
|
|
|
|
export default function AdminOrdersPage() {
|
|
const [channels, setChannels] = useState<Channel[]>([]);
|
|
const [upstream, setUpstream] = useState<{ ok: boolean; detail?: string } | null>(null);
|
|
const [apiBase, setApiBase] = useState("");
|
|
const [note, setNote] = useState("");
|
|
const [error, setError] = useState("");
|
|
|
|
useEffect(() => {
|
|
fetch("/api/admin/orders", { cache: "no-store" })
|
|
.then(async (r) => {
|
|
const j = await r.json();
|
|
if (!r.ok) throw new Error(j.error || r.statusText);
|
|
setChannels(j.channels || []);
|
|
setUpstream(j.upstream || null);
|
|
setApiBase(j.apiBase || "");
|
|
setNote(j.note || "");
|
|
})
|
|
.catch((e) => setError(e instanceof Error ? e.message : String(e)));
|
|
}, []);
|
|
|
|
return (
|
|
<>
|
|
<h1 className={styles.pageTitle}>💳 订单 / 支付</h1>
|
|
<p className={styles.pageLead}>
|
|
网关 {apiBase || "…"}{" "}
|
|
{upstream ? (
|
|
<span className={upstream.ok ? styles.badgeOk : styles.badgeBad}>
|
|
{upstream.ok ? "健康" : "异常"} {upstream.detail}
|
|
</span>
|
|
) : null}
|
|
</p>
|
|
{error ? <p className={styles.error}>{error}</p> : null}
|
|
{note ? <p className={styles.muted}>{note}</p> : null}
|
|
|
|
<div className={styles.grid2}>
|
|
{channels.map((c) => (
|
|
<div key={c.id} className={styles.panel}>
|
|
<h3>{c.id}</h3>
|
|
<span className={styles.badgeMute}>{c.region}</span>
|
|
<p className={styles.muted}>{c.note}</p>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</>
|
|
);
|
|
}
|