Phase 5 of the minigame periods feature: - Read model (lib/minigames/periods/standings.ts) that shapes period boards from the ledger (rank, placement points, names) and All-Time boards from the untouched profile aggregates into one row type. - GET /api/minigames/leaderboards: ?period=current|<id>|all-time, returning the period, the period list, the boards and the achievements honor roll. - New /minigames/leaderboards page: period selector (current, every past period, All-Time), per-game tabs, and the achievements honor roll. Core-only in period mode; every registered game in All-Time. - Shared client pieces: useLeaderboards hook, StandingsTable, PeriodStandingsCard (period by default, All-Time toggle) and AchievementsHonorRoll. - Each Core game page gains an "Anchored period standings" card so the period board is visible on the game itself; its existing all-time board and mode/difficulty selectors are untouched, and it links to the full page. (Plan said replace the inline board; keeping it preserves the per-mode selectors, so the period board is added instead. Easy to swap if you prefer.) - Ledger fetch helper extracted to lib/minigames/periods/ledger.ts. - Integration test for the period boards, the All-Time path and the honor roll.
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { Metadata } from "next";
|
|
import config from "@payload-config";
|
|
import { getPayload } from "payload";
|
|
import { headers as nextHeaders } from "next/headers";
|
|
import { redirect } from "next/navigation";
|
|
|
|
import { MinigameLeaderboards } from "@/components/frontend/minigames/MinigameLeaderboards";
|
|
import { loadMinigameRegistry } from "@/lib/minigames/loadRegistry";
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Minigame Leaderboards: Polaris Task Force",
|
|
description: "Period standings, all-time bests and achievements for the Polaris minigames.",
|
|
};
|
|
|
|
export default async function MinigameLeaderboardsPage({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<{ game?: string }>;
|
|
}) {
|
|
const { game } = await searchParams;
|
|
const headers = await nextHeaders();
|
|
const payloadConfig = await config;
|
|
const payload = await getPayload({ config });
|
|
const { user } = await payload.auth({ headers, canSetHeaders: false });
|
|
|
|
if (!user) {
|
|
redirect(`/login?returnTo=${encodeURIComponent("/minigames/leaderboards")}`);
|
|
}
|
|
|
|
const games = await loadMinigameRegistry(payload);
|
|
|
|
return (
|
|
<div className="flex flex-col gap-6 p-5">
|
|
<MinigameLeaderboards games={games} currentUserId={user.id as number} initialGame={game} />
|
|
</div>
|
|
);
|
|
}
|