fix: improve error handling in admin pages to show user-friendly error messages

- Add error display to help questions new/edit pages
- Improve error visibility in admin-badges, admin-applications, admin-logs, admin-users pages
- Update createHelpQuestion action to properly handle and display unique name collisions and database errors
- Add user-friendly error messages to admin error handling
- Enhances admin page error reporting for better user experience
This commit is contained in:
remco committed 2026-07-01 21:25:30 +02:00
1 parent d775e893f4
commit 0323c3fcaa
13 files changed
+222 -221

No files matched your search

+6 -6
View File
@@ -8,13 +8,13 @@ import { logStaffActivity } from "@/lib/services/staff-activity";
import { CurrencyType } from "@/lib/services/currency";
const giveCurrency = async ({
rcon,
rconClient,
db,
userId,
type,
amount,
}: {
rcon: typeof rcon;
rconClient: typeof rcon;
db: typeof prisma;
userId: number;
type: string;
@@ -101,7 +101,7 @@ export async function POST(request: Request) {
{ status: 400 }
);
}
await giveCurrency({ rcon, db: prisma, userId, type: "credits", amount: credits });
await giveCurrency({ rconClient: rcon, db: prisma, userId, type: "credits", amount: credits });
return NextResponse.json(
{ success: true, message: `Gave ${credits} credits to user #${userId}` },
{ status: 200 }
@@ -116,7 +116,7 @@ export async function POST(request: Request) {
{ status: 400 }
);
}
await giveCurrency({ rcon, db: prisma, userId, type: "duckets", amount });
await giveCurrency({ rconClient: rcon, db: prisma, userId, type: "duckets", amount });
return NextResponse.json(
{ success: true, message: `Gave ${amount} duckets to user #${userId}` },
{ status: 200 }
@@ -131,7 +131,7 @@ export async function POST(request: Request) {
{ status: 400 }
);
}
await giveCurrency({ rcon, db: prisma, userId, type: "diamonds", amount });
await giveCurrency({ rconClient: rcon, db: prisma, userId, type: "diamonds", amount });
return NextResponse.json(
{ success: true, message: `Gave ${amount} diamonds to user #${userId}` },
{ status: 200 }
@@ -146,7 +146,7 @@ export async function POST(request: Request) {
{ status: 400 }
);
}
await giveCurrency({ rcon, db: prisma, userId, type: "points", amount });
await giveCurrency({ rconClient: rcon, db: prisma, userId, type: "points", amount });
return NextResponse.json(
{ success: true, message: `Gave ${amount} points to user #${userId}` },
{ status: 200 }