fix: language default, google OAuth cookie issue, add admin tier/usage controls

- ai-generate-dialog: useLocale() returns {locale,setLocale} object, not
  string — was stringifying whole object as default language value
- auth/server: add trustedOrigins so session cookie survives reverse-proxy
  deployments where BETTER_AUTH_URL differs from container's own view
- admin: add tier limit editor (/admin/tiers) and per-user usage reset
  button, both audit-logged

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Arnaud
2026-07-03 19:51:06 +02:00
parent cbba1ec2ff
commit ac9f5c87e9
9 changed files with 244 additions and 2 deletions
@@ -0,0 +1,38 @@
"use client";
import { useState } from "react";
import { useRouter } from "next/navigation";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
export function ResetUsageButton({ userId }: { userId: string }) {
const router = useRouter();
const [resetting, setResetting] = useState(false);
async function handleReset() {
if (!confirm("Reset this user's usage counters for the current month?")) return;
setResetting(true);
try {
const res = await fetch(`/api/v1/admin/users/${userId}/usage`, { method: "PATCH" });
if (!res.ok) throw new Error("Reset failed");
toast.success("Usage reset");
router.refresh();
} catch {
toast.error("Failed to reset usage");
} finally {
setResetting(false);
}
}
return (
<Button
variant="outline"
size="sm"
onClick={() => { void handleReset(); }}
disabled={resetting}
className="text-destructive hover:text-destructive"
>
{resetting ? "Resetting…" : "Reset Usage"}
</Button>
);
}