Search and paging on lists, Settings in tabs, pinned sidebar (1.3.0)

- Installs, Customers, Alerts and the audit log get a search box and
  25-per-page paging (Installs also a health filter); install History pages too.
- Settings is split into Releases and alerts / Email / Login and security /
  Audit log tabs, remembered in the URL hash.
- The side navigation is sticky at window height, so Sign out no longer
  scrolls off long pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 07:51:32 +02:00
co-authored by Claude Opus 5.5
parent e22fa5369b
commit d235ae6c95
13 changed files with 271 additions and 92 deletions
+13 -3
View File
@@ -1,13 +1,14 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useEffect, useMemo, useState } from "react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { Plus } from "lucide-react";
import { api, errorText } from "@/lib/api";
import { ago } from "@/lib/format";
import { matches, usePaged } from "@/lib/paging";
import type { Customer } from "@/lib/types";
import { Badge, Loading, Message, PageTitle } from "@/components/ui";
import { Badge, Loading, Message, PageTitle, Pager, SearchInput } from "@/components/ui";
export default function CustomersPage() {
const router = useRouter();
@@ -16,6 +17,10 @@ export default function CustomersPage() {
const [form, setForm] = useState({ name: "", contactName: "", email: "", phone: "" });
const [msg, setMsg] = useState<{ type: "ok" | "err"; text: string } | null>(null);
const [query, setQuery] = useState("");
const shown = useMemo(() => (list || []).filter(c => matches(query, c.name, c.contactName, c.email, c.phone, ...c.installs.map(i => i.url))), [list, query]);
const paged = usePaged(shown, query);
const load = useCallback(() => api<Customer[]>("/api/admin/customers").then(setList).catch(e => setMsg({ type: "err", text: errorText(e) })), []);
useEffect(() => { load(); }, [load]);
@@ -41,11 +46,14 @@ export default function CustomersPage() {
)}
<Message msg={msg} />
{!list ? <Loading /> : list.length === 0 ? <p className="text-sm text-slate-500">No customers yet.</p> : (
<>
<SearchInput className="mb-3 w-full sm:w-72" value={query} onChange={setQuery} placeholder="Search name, contact or site" />
<div className="card overflow-x-auto p-0">
<table className="w-full text-sm">
<thead className="bg-slate-50 text-left text-xs text-slate-500"><tr><th className="p-3">Customer</th><th className="p-3">Licences</th><th className="p-3">Site</th></tr></thead>
<tbody>
{list.map(c => (
{paged.rows.length === 0 && <tr><td colSpan={3} className="p-3 text-slate-500">No customers match.</td></tr>}
{paged.rows.map(c => (
<tr key={c.id} className="border-t hover:bg-slate-50">
<td className="p-3"><Link href={`/customers/${c.id}`} className="font-medium text-indigo-700 hover:underline">{c.name}</Link><div className="text-xs text-slate-500">{[c.contactName, c.email].filter(Boolean).join(" · ")}</div></td>
<td className="p-3">{c.licences.length ? c.licences.map(l => <span key={l.id} className="mr-1"><Badge value={l.status} /></span>) : <span className="text-xs text-slate-400">none</span>}</td>
@@ -54,7 +62,9 @@ export default function CustomersPage() {
))}
</tbody>
</table>
<Pager {...paged} />
</div>
</>
)}
</>
);