Translate admin panel to all 6 languages

This commit is contained in:
openhands committed 2026-07-04 21:21:15 +02:00
1 parent f381aa987f
commit befa4ec282
63 files changed
+9353 -1443

No files matched your search

+38 -36
View File
@@ -2,6 +2,7 @@ import { Users } from "lucide-react";
import { createTeam, deleteTeam } from "@/actions/admin-teams";
import { StatusCard } from "@/components/admin/dashboard";
import { prisma } from "@/lib/prisma";
import { getTranslations } from "next-intl/server";
export const dynamic = "force-dynamic";
@@ -15,6 +16,7 @@ type TeamRow = {
};
export default async function AdminTeams() {
const t = await getTranslations("pages.admin.teams");
let teams: TeamRow[] = [];
try {
teams = await prisma.websiteTeams.findMany({
@@ -41,80 +43,80 @@ export default async function AdminTeams() {
<Users size={20} className="text-[var(--color-primary)]" />
</div>
<div>
<h1 className="m-0 text-xl font-extrabold text-[var(--color-text)]">Teams</h1>
<p className="m-0 text-xs text-[var(--color-text-muted)] mt-0.5">Staff rank definitions shown on the public team page.</p>
<h1 className="m-0 text-xl font-extrabold text-[var(--color-text)]">{t("title")}</h1>
<p className="m-0 text-xs text-[var(--color-text-muted)] mt-0.5">{t("subtitle")}</p>
</div>
</div>
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
<StatusCard label="Team ranks" value={teams.length} icon="🛡️" />
<StatusCard label={t("teamRanks")} value={teams.length} icon="🛡️" />
<StatusCard
label="Visible"
label={t("visible")}
value={teams.length - hidden}
state={teams.length - hidden > 0 ? "ok" : "neutral"}
icon="👁️"
/>
<StatusCard label="Hidden" value={hidden} icon="🙈" />
<StatusCard label={t("hidden")} value={hidden} icon="🙈" />
</div>
<div className="admin-card" style={{ marginBottom: "1.5rem" }}>
<h3 style={{ marginTop: 0 }}>New team rank</h3>
<h3 style={{ marginTop: 0 }}>{t("newTeamRank")}</h3>
<form action={createTeam} style={{ display: "grid", gap: "0.6rem" }}>
<div className="grid cols-2">
<label style={{ display: "grid", gap: "0.25rem" }}>
<span className="text-sm text-gray-500 dark:text-gray-400">Rank name</span>
<input name="rankName" placeholder="e.g. Moderator" required />
<span className="text-sm text-gray-500 dark:text-gray-400">{t("rankName")}</span>
<input name="rankName" placeholder={t("rankNamePlaceholder")} required />
</label>
<label style={{ display: "grid", gap: "0.25rem" }}>
<span className="text-sm text-gray-500 dark:text-gray-400">Badge code</span>
<input name="badge" placeholder="e.g. ADM" />
<span className="text-sm text-gray-500 dark:text-gray-400">{t("badgeCode")}</span>
<input name="badge" placeholder={t("badgeCodePlaceholder")} />
</label>
<label style={{ display: "grid", gap: "0.25rem" }}>
<span className="text-sm text-gray-500 dark:text-gray-400">Job description</span>
<input name="jobDescription" placeholder="Short description" />
<span className="text-sm text-gray-500 dark:text-gray-400">{t("jobDescription")}</span>
<input name="jobDescription" placeholder={t("jobDescriptionPlaceholder")} />
</label>
<label style={{ display: "grid", gap: "0.25rem" }}>
<span className="text-sm text-gray-500 dark:text-gray-400">Staff color</span>
<input name="staffColor" defaultValue="#327fa8" placeholder="#327fa8" />
<span className="text-sm text-gray-500 dark:text-gray-400">{t("staffColor")}</span>
<input name="staffColor" defaultValue="#327fa8" placeholder={t("staffColorPlaceholder")} />
</label>
</div>
<label style={{ display: "flex", alignItems: "center", gap: "0.4rem" }}>
<input type="checkbox" name="hiddenRank" style={{ width: "auto" }} />
<span className="text-sm text-gray-500 dark:text-gray-400">Hidden rank</span>
<span className="text-sm text-gray-500 dark:text-gray-400">{t("hiddenRank")}</span>
</label>
<div>
<button type="submit" className="btn btn-primary">
Create team
{t("createTeam")}
</button>
</div>
</form>
</div>
<section className="mt-6">
<h2 className="admin-section-title">Ranks ({teams.length})</h2>
<h2 className="admin-section-title">{t("ranksTitle", { count: teams.length })}</h2>
{teams.length === 0 ? (
<div className="admin-empty">No teams yet.</div>
<div className="admin-empty">{t("noTeams")}</div>
) : (
<div className="overflow-x-auto">
<table>
<thead>
<tr>
<th>ID</th>
<th>Rank name</th>
<th>Badge</th>
<th>Job description</th>
<th>Color</th>
<th>Visibility</th>
<th>{t("colId")}</th>
<th>{t("rankName")}</th>
<th>{t("badge")}</th>
<th>{t("jobDescription")}</th>
<th>{t("color")}</th>
<th>{t("visibility")}</th>
<th />
</tr>
</thead>
<tbody>
{teams.map((t) => (
<tr key={String(t.id)}>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{String(t.id)}</td>
<td>{t.rankName}</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{t.badge ?? "—"}</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{t.jobDescription ?? "—"}</td>
{teams.map((team) => (
<tr key={String(team.id)}>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{String(team.id)}</td>
<td>{team.rankName}</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{team.badge ?? "—"}</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{team.jobDescription ?? "—"}</td>
<td>
<span
style={{
@@ -130,22 +132,22 @@ export default async function AdminTeams() {
height: 14,
borderRadius: 4,
border: "1px solid var(--border-color)",
background: t.staffColor,
background: team.staffColor,
}}
/>
{t.staffColor}
{team.staffColor}
</span>
</td>
<td>
<span className={`inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full ${t.hiddenRank ? "bg-[var(--color-primary)]/18 text-[var(--color-text)]" : "bg-green-600/20 text-[var(--color-text)]"}`}>
{t.hiddenRank ? "hidden" : "visible"}
<span className={`inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full ${team.hiddenRank ? "bg-[var(--color-primary)]/18 text-[var(--color-text)]" : "bg-green-600/20 text-[var(--color-text)]"}`}>
{team.hiddenRank ? t("hidden") : t("visible")}
</span>
</td>
<td>
<form action={deleteTeam}>
<input type="hidden" name="id" value={String(t.id)} />
<input type="hidden" name="id" value={String(team.id)} />
<button type="submit" className="btn btn-danger">
Delete
{t("delete")}
</button>
</form>
</td>