Separate data requests from website feedback in the admin

Forms now has two queues, Website feedback and Data requests, each
its own card on the admin home and a tab on the page, with what's new
in each. The API takes ?kind=feedback|privacy and counts per queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-29 09:19:06 -05:00
parent 7c1723b0ad
commit 99d83eb090
5 changed files with 69 additions and 12 deletions

View file

@ -18,7 +18,7 @@
═══════════════════════════════════════════════════════════════ */
import { useCallback, useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { Link, useNavigate } from "react-router-dom";
import { del, get, patch, ApiError } from "../../lib/api.ts";
import { isUnauthorized, useAuth } from "../../lib/auth.tsx";
@ -225,9 +225,25 @@ function FeedbackCard({ row, onChange, onRemove, canWrite, canRemove }) {
/* ── The page ────────────────────────────────────────────────── */
export default function AdminFeedback() {
/* The two queues this page shows: the website feedback form, and
data requests from the Privacy page. Same table, same triage. */
const QUEUES = {
feedback: {
to: "/admin/feedback",
title: "Website feedback",
blurb: "Everything submitted through the site's feedback form.",
},
privacy: {
to: "/admin/data-requests",
title: "Data requests",
blurb: "Requests to see, correct or delete someone's information, from the Privacy page. Each has an email to answer.",
},
} as const;
export default function AdminFeedback({ kind = "feedback" }: { kind?: keyof typeof QUEUES }) {
const { user } = useAuth();
const navigate = useNavigate();
const queue = QUEUES[kind];
const [status, setStatus] = useState("new");
const [query, setQuery] = useState("");
@ -235,6 +251,7 @@ export default function AdminFeedback() {
const [rows, setRows] = useState<any[]>([]);
const [counts, setCounts] = useState<any>({});
const [newByKind, setNewByKind] = useState<any>({});
const [cursor, setCursor] = useState<any>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<any>(null);
@ -249,6 +266,7 @@ export default function AdminFeedback() {
setError(null);
const params = new URLSearchParams();
params.set("kind", kind);
if (status !== "all") params.set("status", status);
if (search) params.set("q", search);
if (before) params.set("before", String(before));
@ -257,6 +275,7 @@ export default function AdminFeedback() {
const data = await get(`/admin/feedback?${params}`, { ttl: 0 });
setRows((prev) => (before ? [...prev, ...data.feedback] : data.feedback));
setCounts(data.counts);
setNewByKind(data.newByKind ?? {});
setCursor(data.nextCursor);
} catch (err) {
if (isUnauthorized(err)) {
@ -271,7 +290,7 @@ export default function AdminFeedback() {
setLoading(false);
}
},
[status, search, navigate],
[kind, status, search, navigate],
);
useEffect(() => {
@ -306,11 +325,27 @@ export default function AdminFeedback() {
return (
<div>
<h1 className="text-3xl font-bold text-link">Feedback</h1>
{/* The two queues, each with what's new in it. */}
<nav aria-label="Forms" className="mb-6 flex gap-1 border-b border-brand/15">
{Object.entries(QUEUES).map(([id, q]) => (
<Link
key={id}
to={q.to}
aria-current={id === kind ? "page" : undefined}
className={
"-mb-px border-b-2 px-4 py-2 text-sm font-semibold transition-colors " +
(id === kind ? "border-link text-link" : "border-transparent text-muted hover:text-link")
}
>
{q.title}
{newByKind[id] ? ` (${newByKind[id]} new)` : ""}
</Link>
))}
</nav>
<h1 className="text-3xl font-bold text-link">{queue.title}</h1>
<p className="mt-2 text-sm text-muted">
{canWrite
? "Everything submitted through the site form."
: "Read-only: your account can't change statuses or notes."}
{canWrite ? queue.blurb : "Read-only: your account can't change statuses or notes."}
</p>
{/* Filters */}