mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 14:40:52 +00:00
fix(bugreport): admin toggle now actually blocks feedback submissions
The "Bug reports" admin toggle had no effect. The form on `/bugreport` posts to `/api/feedback`, which was the wrong endpoint for the gate — it lived only on the legacy `/api/bugreport` route the form does not call. Users still submitted into the local feedback inbox after the admin disabled the feature, and the prior commit message claimed "the report button gracefully disappears" was untrue. - `/api/bugreport/status` now also returns `enabled` (defaults true when the column has never been written) so the page can decide whether to render the form at all. - `/api/feedback` POST checks `bugReportEnabled` and returns 503 with a readable error when the admin has switched the feature off, so a scripted client cannot bypass the UI by hitting the endpoint directly. - `/bugreport` page now hides the form and shows the disabled-banner copy when `enabled === false`. - New i18n keys for the disabled state in DE + EN. - Vitest covers the gate: blocked when off, allowed when on, allowed when row absent. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
4aeb8c904e
commit
31959e436e
6 files changed
+162
-5
No files matched your search
@@ -25,6 +25,7 @@ import { queryKeys } from "@/lib/query-keys";
|
||||
|
||||
interface BugReportStatus {
|
||||
configured: boolean;
|
||||
enabled: boolean;
|
||||
isAdmin: boolean;
|
||||
}
|
||||
|
||||
@@ -115,6 +116,32 @@ export default function BugReportPage() {
|
||||
);
|
||||
}
|
||||
|
||||
if (status && status.enabled === false) {
|
||||
return (
|
||||
<div className="mx-auto w-full max-w-6xl space-y-6">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold tracking-tight">
|
||||
{t("bugreport.title")}
|
||||
</h1>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{t("bugreport.subtitle")}
|
||||
</p>
|
||||
</div>
|
||||
<div className="bg-card border-border border-l-dracula-orange flex gap-2 rounded-lg border-l-4 p-3 text-sm">
|
||||
<Info className="text-dracula-orange mt-0.5 h-4 w-4 shrink-0" />
|
||||
<div>
|
||||
<p className="text-foreground font-medium">
|
||||
{t("bugreport.disabledTitle")}
|
||||
</p>
|
||||
<p className="text-muted-foreground mt-1">
|
||||
{t("bugreport.disabledBody")}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mx-auto w-full max-w-6xl space-y-6">
|
||||
<div>
|
||||
|
||||
Reference in new issue
Block a user