From 99d83eb090424abe84c7b1e3e53298ee22d0ee84 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Tue, 29 Sep 2026 09:19:06 -0500 Subject: [PATCH] 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 --- server/src/routes/admin.js | 24 ++++++++++++--- src/App.tsx | 1 + src/pages/Privacy.tsx | 2 +- src/pages/admin/AdminFeedback.tsx | 49 ++++++++++++++++++++++++++----- src/pages/admin/adminNav.ts | 5 ++++ 5 files changed, 69 insertions(+), 12 deletions(-) diff --git a/server/src/routes/admin.js b/server/src/routes/admin.js index 5914fe2..e14cd1c 100644 --- a/server/src/routes/admin.js +++ b/server/src/routes/admin.js @@ -23,6 +23,8 @@ const NOTE_LIMIT = 2000; /* ── GET /api/admin/feedback ───────────────────────────────────── ?status=new one of STATUSES, or omitted for all + ?kind=feedback website feedback (every type but 'privacy') + ?kind=privacy data requests from the Privacy page ?type=broken feedback_type ?q=retreat substring of the message ?before=41 cursor: rows with a lower id than this @@ -31,11 +33,17 @@ const NOTE_LIMIT = 2000; admin.get("/feedback", (c) => { const db = c.get("db"); - const { status, type, q, before, limit } = c.req.query(); + const { status, type, kind, q, before, limit } = c.req.query(); const where = []; const params = []; + // Data requests and website feedback share the table but are two + // queues in the admin (Forms → Website feedback, Data requests). + const kindWhere = + kind === "privacy" ? "feedback_type = 'privacy'" : kind === "feedback" ? "feedback_type <> 'privacy'" : null; + if (kindWhere) where.push(kindWhere); + if (STATUSES.includes(status)) { where.push("status = ?"); params.push(status); @@ -69,19 +77,27 @@ admin.get("/feedback", (c) => { const hasMore = rows.length > take; const page = hasMore ? rows.slice(0, take) : rows; - // Counts are unfiltered on purpose: the tabs should show what's - // waiting overall, not what's left after the current filter. + // Status counts cover this queue (kind) but ignore the other + // filters: the tabs show what's waiting, not what's left after a + // search. newByKind is what's new in each queue, for the queue tabs. const counts = Object.fromEntries(STATUSES.map((s) => [s, 0])); for (const row of db - .prepare("SELECT status, COUNT(*) AS n FROM feedback GROUP BY status") + .prepare(`SELECT status, COUNT(*) AS n FROM feedback ${kindWhere ? `WHERE ${kindWhere}` : ""} GROUP BY status`) .all()) { counts[row.status] = row.n; } + const newByKind = db + .prepare( + `SELECT SUM(feedback_type <> 'privacy') AS feedback, SUM(feedback_type = 'privacy') AS privacy + FROM feedback WHERE status = 'new'`, + ) + .get(); return c.json( { feedback: page, counts, + newByKind: { feedback: newByKind?.feedback ?? 0, privacy: newByKind?.privacy ?? 0 }, nextCursor: hasMore ? page[page.length - 1].id : null, }, 200, diff --git a/src/App.tsx b/src/App.tsx index 3bd6951..8252b6c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -128,6 +128,7 @@ export default function App() { } /> } /> + } /> } /> }> } /> diff --git a/src/pages/Privacy.tsx b/src/pages/Privacy.tsx index 0e1d1ff..582790c 100644 --- a/src/pages/Privacy.tsx +++ b/src/pages/Privacy.tsx @@ -21,7 +21,7 @@ const PAGE = sitePage("/privacy"); The contact address is Panel → Site settings → Privacy contact email. Requests from the form below are feedback rows of type - 'privacy', in Admin → Feedback. + 'privacy', in Admin → Forms → Data requests. ═══════════════════════════════════════════════════════════════ */ const LAST_UPDATED = "September 28, 2026"; diff --git a/src/pages/admin/AdminFeedback.tsx b/src/pages/admin/AdminFeedback.tsx index 5068d91..b9c6edd 100644 --- a/src/pages/admin/AdminFeedback.tsx +++ b/src/pages/admin/AdminFeedback.tsx @@ -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([]); const [counts, setCounts] = useState({}); + const [newByKind, setNewByKind] = useState({}); const [cursor, setCursor] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(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 (
-

Feedback

+ {/* The two queues, each with what's new in it. */} + + +

{queue.title}

- {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."}

{/* Filters */} diff --git a/src/pages/admin/adminNav.ts b/src/pages/admin/adminNav.ts index 53aab53..3cd9528 100644 --- a/src/pages/admin/adminNav.ts +++ b/src/pages/admin/adminNav.ts @@ -118,6 +118,11 @@ export const FORMS_NAV = { label: "Website feedback", blurb: "The triage queue for the feedback form.", }, + { + to: "/admin/data-requests", + label: "Data requests", + blurb: "Requests to see, correct or delete someone's information, from the Privacy page.", + }, ], };