fix: resolve critical bugs and improve admin panel reliability
- Fix missing await in pets API route causing empty responses - Fix updateSetting to use upsert pattern instead of update-only - Create missing /api/admin/sounds/upload route (upload was broken) - Wire bulk delete actions in catalog table - Replace native confirm() with useConfirmDialog() across rooms and clone pages - Add error logging to silent catch blocks in radio actions and audit route - Add graceful degradation to devops health endpoint - Add cache eviction to clone icon route to prevent memory leak - Internationalize hardcoded Italian strings to English - Remove placeholder created_at fields from prefix API responses - Remove dead code and fix type errors in translations and import pages - Standardize PERMS import path in analytics export route
This commit is contained in:
1 parent
6f53ca514d
commit
1b817fe434
19 files changed
+255
-89
No files matched your search
@@ -24,6 +24,7 @@ import {
|
||||
deleteRoomItem,
|
||||
roomRconAction,
|
||||
} from "@/actions/rooms";
|
||||
import { useConfirmDialog } from "@/components/admin/confirm-dialog";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
@@ -91,6 +92,7 @@ function isWallType(t: string) {
|
||||
|
||||
export function FurniClient({ room, items = [], canEdit }: Props) {
|
||||
const { run, isPending } = useServerAction();
|
||||
const { confirm, dialog: confirmDialog } = useConfirmDialog();
|
||||
const [search, setSearch] = useState("");
|
||||
const [page, setPage] = useState(1);
|
||||
const [view, setView] = useState<View>("flat");
|
||||
@@ -231,29 +233,44 @@ export function FurniClient({ room, items = [], canEdit }: Props) {
|
||||
setSelected(next);
|
||||
}
|
||||
|
||||
function handleRcon(action: "reload" | "kick") {
|
||||
if (action === "kick" && !confirm("Kick all users from this room?")) return;
|
||||
async function handleRcon(action: "reload" | "kick") {
|
||||
if (action === "kick") {
|
||||
const ok = await confirm({
|
||||
title: "Kick Users",
|
||||
description: "Kick all users from this room?",
|
||||
confirmLabel: "Kick",
|
||||
variant: "danger",
|
||||
});
|
||||
if (!ok) return;
|
||||
}
|
||||
run(() => roomRconAction({ roomId: room.id, action }), {
|
||||
successMessage:
|
||||
action === "reload" ? "Room reloaded" : "All users kicked",
|
||||
});
|
||||
}
|
||||
|
||||
function handleDelete(itemId: number, name: string) {
|
||||
if (!confirm(`Delete "${name}" (#${itemId}) from this room?`)) return;
|
||||
async function handleDelete(itemId: number, name: string) {
|
||||
const ok = await confirm({
|
||||
title: "Delete Item",
|
||||
description: `Delete "${name}" (#${itemId}) from this room?`,
|
||||
confirmLabel: "Delete",
|
||||
variant: "danger",
|
||||
});
|
||||
if (!ok) return;
|
||||
run(() => deleteRoomItem({ roomId: room.id, itemId }), {
|
||||
successMessage: "Item deleted",
|
||||
});
|
||||
}
|
||||
|
||||
function handleBulkDelete() {
|
||||
async function handleBulkDelete() {
|
||||
if (selected.size === 0) return;
|
||||
if (
|
||||
!confirm(
|
||||
`Delete ${selected.size} selected item${selected.size > 1 ? "s" : ""}?`,
|
||||
)
|
||||
)
|
||||
return;
|
||||
const ok = await confirm({
|
||||
title: "Delete Items",
|
||||
description: `Delete ${selected.size} selected item${selected.size > 1 ? "s" : ""}?`,
|
||||
confirmLabel: "Delete",
|
||||
variant: "danger",
|
||||
});
|
||||
if (!ok) return;
|
||||
run(
|
||||
() =>
|
||||
bulkDeleteRoomItems({ roomId: room.id, itemIds: Array.from(selected) }),
|
||||
@@ -264,8 +281,18 @@ export function FurniClient({ room, items = [], canEdit }: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
function handleDeleteGroup(_baseId: number, ids: number[], name: string) {
|
||||
if (!confirm(`Delete all ${ids.length} "${name}" from this room?`)) return;
|
||||
async function handleDeleteGroup(
|
||||
_baseId: number,
|
||||
ids: number[],
|
||||
name: string,
|
||||
) {
|
||||
const ok = await confirm({
|
||||
title: "Delete Items",
|
||||
description: `Delete all ${ids.length} "${name}" from this room?`,
|
||||
confirmLabel: "Delete",
|
||||
variant: "danger",
|
||||
});
|
||||
if (!ok) return;
|
||||
run(() => bulkDeleteRoomItems({ roomId: room.id, itemIds: ids }), {
|
||||
successMessage: `${ids.length} item(s) deleted`,
|
||||
});
|
||||
@@ -276,6 +303,7 @@ export function FurniClient({ room, items = [], canEdit }: Props) {
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{confirmDialog}
|
||||
{/* ── Header ─────────────────────────────────────────── */}
|
||||
<div className="flex flex-wrap items-center justify-between gap-4">
|
||||
<div className="flex items-center gap-4">
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
} from "lucide-react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { deleteRoom, roomRconAction, updateRoom } from "@/actions/rooms";
|
||||
import { useConfirmDialog } from "@/components/admin/confirm-dialog";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
@@ -63,13 +64,17 @@ export function RoomEditForm({ room }: RoomEditFormProps) {
|
||||
});
|
||||
}
|
||||
|
||||
function handleDelete() {
|
||||
if (
|
||||
!confirm(
|
||||
const { confirm, dialog: confirmDialog } = useConfirmDialog();
|
||||
|
||||
async function handleDelete() {
|
||||
const ok = await confirm({
|
||||
title: "Delete Room",
|
||||
description:
|
||||
"Are you sure you want to delete this room? This cannot be undone.",
|
||||
)
|
||||
)
|
||||
return;
|
||||
confirmLabel: "Delete",
|
||||
variant: "danger",
|
||||
});
|
||||
if (!ok) return;
|
||||
run(() => deleteRoom({ id: room.id }), { redirectTo: "/admin/rooms" });
|
||||
}
|
||||
|
||||
@@ -82,6 +87,7 @@ export function RoomEditForm({ room }: RoomEditFormProps) {
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{confirmDialog}
|
||||
<div className="grid gap-6 lg:grid-cols-2">
|
||||
{/* Edit Form */}
|
||||
<Card>
|
||||
|
||||
Reference in new issue
Block a user