import { asc, desc, eq, gte } from "drizzle-orm"; import { getTranslations } from "next-intl/server"; import Link from "@/components/link"; import { ContentCard, EmptyState } from "@/components/public/ui"; import { db, User, WebsiteTeams } from "@/lib/db"; import { siteSettings } from "@/lib/services/site-settings"; export const metadata = { title: "Staff" }; type StaffMember = { username: string; look: string; rank: number; motto: string; }; type Team = { id: string; rankName: string; badge: string | null; jobDescription: string | null; staffColor: string; }; export default async function StaffPage() { const t = await getTranslations("pages.staff"); const minStaffRank = Number(await siteSettings.get("min_staff_rank", "7")) || 7; // Independent queries — staff members and teams load concurrently. const [staff, teams] = await Promise.all([ db .select({ username: User.username, look: User.look, rank: User.rank, motto: User.motto, }) .from(User) .where(gte(User.rank, minStaffRank)) .orderBy(desc(User.rank), asc(User.username)) .limit(100) .catch((): StaffMember[] => []), db .select({ id: WebsiteTeams.id, rankName: WebsiteTeams.rankName, badge: WebsiteTeams.badge, jobDescription: WebsiteTeams.jobDescription, staffColor: WebsiteTeams.staffColor, }) .from(WebsiteTeams) .where(eq(WebsiteTeams.hiddenRank, false)) .orderBy(asc(WebsiteTeams.id)) .then((rows) => rows.map((row) => ({ ...row, id: String(row.id) }))) .catch((): Team[] => []), ]); return (
{teams.length > 0 ? (
{teams.map((team) => (

{team.rankName}

{team.jobDescription ? (

{team.jobDescription}

) : null}
))}
) : null} {staff.length === 0 ? ( {t("emptyState")} ) : ( {staff.map((u) => ( ))}
{t("colUsername")} {t("colRank")} {t("colMotto")}
{u.username} {u.rank} {u.motto || "—"}
)}
); }