import { asc, desc, eq, gte } from "drizzle-orm"; import type { Metadata } from "next"; import { getTranslations } from "next-intl/server"; import Link from "@/components/link"; import { PublicLoadError } from "@/components/public/load-error"; import { ProfileImage } from "@/components/shared/profile-image"; import { SurfaceCard } from "@/components/surface-card"; import { db, User, WebsiteTeams } from "@/lib/db"; import { avatarImageUrl } from "@/lib/format"; import { publicReadFailure } from "@/lib/services/public-read"; import { siteSettings } from "@/lib/services/site-settings"; import styles from "./staff.module.css"; export async function generateMetadata(): Promise { const t = await getTranslations("pages.staff"); return { title: t("title"), description: t("subtitle"), openGraph: { title: t("title"), description: t("subtitle"), type: "website", }, }; } 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(publicReadFailure("staff.members")), 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(publicReadFailure("staff.teams")), ]); return (

{t("title")}

{t("subtitle")}

{staff && staff.length > 0 && ( {t("membersSubtitle", { count: staff.length })} )}

{t("membersTitle")}

{staff === null ? (

{t("loadError")}

{t("retry")}
) : staff.length === 0 ? (

{t("emptyState")}

) : (
    {staff.map((member) => (
  • {member.username}

    {member.motto || t("noMotto")}

    {t("viewProfile")}
  • ))}
)}
{teams === null ? ( ) : ( teams.length > 0 && (

{t("ranksTitle")}

{t("ranksSubtitle")}

    {teams.map((team) => (
  • ))}
) )}
); }