Local Build and Deploy / deploy (push) Successful in 56s
Replace leftover requireStaff gates with module PERMS, drop hardcoded room rank thresholds, and expand contract tests so admin mutations cannot regress to dashboard-only checks. Co-authored-by: Cursor <[email protected]>
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
"use server";
|
|
|
|
import { revalidatePath } from "next/cache";
|
|
import { requirePermission } from "@/lib/admin/guard";
|
|
import { PERMS } from "@/lib/permissions";
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
export async function getBadgeData({ code }: { code: string }) {
|
|
await requirePermission(PERMS.CATALOG_EDIT);
|
|
const badge = await prisma.websiteBadges.findUnique({
|
|
where: { badgeKey: code },
|
|
select: { badgeName: true, badgeDescription: true },
|
|
});
|
|
if (!badge) return { ok: false as const, data: null };
|
|
return {
|
|
ok: true as const,
|
|
data: { name: badge.badgeName, desc: badge.badgeDescription },
|
|
};
|
|
}
|
|
|
|
export async function updateBadge({
|
|
code,
|
|
name,
|
|
desc,
|
|
}: {
|
|
code: string;
|
|
name: string;
|
|
desc: string;
|
|
}) {
|
|
await requirePermission(PERMS.CATALOG_EDIT);
|
|
await prisma.websiteBadges.upsert({
|
|
where: { badgeKey: code },
|
|
update: { badgeName: name, badgeDescription: desc, updatedAt: new Date() },
|
|
create: {
|
|
badgeKey: code,
|
|
badgeName: name,
|
|
badgeDescription: desc,
|
|
createdAt: new Date(),
|
|
updatedAt: new Date(),
|
|
},
|
|
});
|
|
revalidatePath("/admin/import/badges");
|
|
}
|