refactor: convert admin pages to Tailwind and improve media uploads; fix TypeScript error in commandocentrum

This commit is contained in:
openhands committed 2026-07-02 17:26:16 +02:00
1 parent 72ef74fc87
commit 518c072491
22 files changed
+488 -430

No files matched your search

+36 -35
View File
@@ -1,6 +1,7 @@
import { giveBadge } from "@/actions/admin-badges";
import { uploadBadge } from "@/actions/admin-badge-upload";
import { prisma } from "@/lib/prisma";
import { Award } from "lucide-react";
export const dynamic = "force-dynamic";
@@ -25,34 +26,34 @@ export default async function AdminBadges({
return (
<main>
<section className="mt-6">
<h2>Badges</h2>
<p className="muted">
Website badge catalogue (<code>website_badges</code>). Granting fires the emulator
<code> givebadge</code> RCON command and records the badge in <code>users_badges</code>.
</p>
<div className="flex items-center gap-3 mb-6">
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-[var(--color-primary)]/20 to-[var(--color-primary)]/5 grid place-items-center">
<Award size={20} className="text-[var(--color-primary)]" />
</div>
<div>
<h1 className="m-0 text-xl font-extrabold text-[var(--color-text)]">Badges</h1>
<p className="m-0 text-xs text-[var(--color-text-muted)] mt-0.5">Website badge catalogue.</p>
</div>
</div>
{uploaded ? (
<p>
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-green-600/20 text-[var(--color-text)]">Uploaded</span> Badge image{" "}
<code>{uploaded}.gif</code> saved.
</p>
) : null}
{error ? (
<p>
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-red-500/22 text-[var(--color-text)]">Error</span> {error}
</p>
) : null}
</section>
{uploaded && (
<div className="mb-4 p-3 rounded-lg bg-green-600/10 text-green-600 dark:text-green-400 text-xs">
Uploaded Badge image <code>{uploaded}.gif</code> saved.
</div>
)}
{error && (
<div className="mb-4 p-3 rounded-lg bg-red-600/10 text-red-600 dark:text-red-400 text-xs">
Error: {error}
</div>
)}
<section className="mt-6">
<h2>Upload badge image</h2>
<p className="muted" style={{ marginTop: "-0.4rem" }}>
Saves a <code>.gif</code> badge image to the emulator badge directory
(<code>BADGE_UPLOAD_DIR</code>). The file is stored as <code>&lt;code&gt;.gif</code>.
<h2 className="admin-section-title">Upload badge image</h2>
<p className="text-xs text-[var(--color-text-muted)] -mt-2 mb-3">
Saves a <code>.gif</code> badge image to the emulator badge directory.
</p>
<form action={uploadBadge} className="card">
<div style={{ display: "flex", gap: "0.5rem", flexWrap: "wrap", alignItems: "center" }}>
<form action={uploadBadge} className="admin-card">
<div className="flex gap-2 flex-wrap items-center">
<input type="file" name="file" accept=".gif,.png" required />
<input
name="code"
@@ -60,7 +61,7 @@ export default async function AdminBadges({
required
maxLength={64}
pattern="[A-Za-z0-9_-]{1,64}"
style={{ flex: 1, minWidth: 160 }}
className="flex-1 min-w-[160px]"
/>
<button type="submit" className="btn btn-primary">
Upload
@@ -70,16 +71,16 @@ export default async function AdminBadges({
</section>
<section className="mt-6">
<h2>Give badge to user</h2>
<form action={giveBadge} className="card">
<div style={{ display: "flex", gap: "0.5rem", flexWrap: "wrap", alignItems: "center" }}>
<h2 className="admin-section-title">Give badge to user</h2>
<form action={giveBadge} className="admin-card">
<div className="flex gap-2 flex-wrap items-center">
<input name="userId" type="number" min={1} placeholder="User ID" required />
<input
name="code"
placeholder="Badge code (e.g. ADM)"
required
maxLength={32}
style={{ flex: 1, minWidth: 160 }}
className="flex-1 min-w-[160px]"
list="badge-codes"
/>
<datalist id="badge-codes">
@@ -97,11 +98,11 @@ export default async function AdminBadges({
</section>
<section className="mt-6">
<h2>Catalogue ({badges.length})</h2>
<h2 className="admin-section-title">Catalogue ({badges.length})</h2>
{badges.length === 0 ? (
<p className="muted">No badges in the catalogue.</p>
<div className="admin-empty">No badges in the catalogue.</div>
) : (
<div style={{ overflowX: "auto" }}>
<div className="overflow-x-auto">
<table>
<thead>
<tr>
@@ -118,11 +119,11 @@ export default async function AdminBadges({
<code>{b.badgeKey}</code>
</td>
<td>{b.badgeName}</td>
<td className="muted">{b.badgeDescription}</td>
<td className="text-sm text-gray-500 dark:text-gray-400">{b.badgeDescription}</td>
<td>
<form
action={giveBadge}
style={{ display: "flex", gap: "0.4rem", alignItems: "center" }}
className="flex gap-2 items-center"
>
<input type="hidden" name="code" value={b.badgeKey} />
<input
@@ -131,7 +132,7 @@ export default async function AdminBadges({
min={1}
placeholder="User ID"
required
style={{ width: 90 }}
className="w-[90px]"
/>
<button type="submit" className="btn btn-outline">
Give