import { giveBadge } from "@/actions/admin-badges"; import { uploadBadge } from "@/actions/admin-badge-upload"; import { prisma } from "@/lib/prisma"; export const dynamic = "force-dynamic"; export const metadata = { title: "Badges" }; export default async function AdminBadges({ searchParams, }: { searchParams: Promise<{ uploaded?: string; error?: string }>; }) { const { uploaded, error } = await searchParams; let badges: Awaited> = []; try { badges = await prisma.websiteBadges.findMany({ orderBy: { badgeName: "asc" }, take: 500, }); } catch { badges = []; } return (

Badges

Website badge catalogue (website_badges). Granting fires the emulator givebadge RCON command and records the badge in users_badges.

{uploaded ? (

Uploaded Badge image{" "} {uploaded}.gif saved.

) : null} {error ? (

Error {error}

) : null}

Upload badge image

Saves a .gif badge image to the emulator badge directory (BADGE_UPLOAD_DIR). The file is stored as <code>.gif.

Give badge to user

{badges.map((b) => ( ))}

Catalogue ({badges.length})

{badges.length === 0 ? (

No badges in the catalogue.

) : (
{badges.map((b) => ( ))}
Code Name Description
{b.badgeKey} {b.badgeName} {b.badgeDescription}
)}
); }