- seeded OPORD generator (grid, azimuth, H-HOUR, phase lines, codewords, callsign, frequency) in pure lib src/lib/opord-recall.ts with per-tier memo windows (25/18/12s) and quiz sizes (4/6/8) - server action submitOpordRecallResult validates input, recomputes score server-side, persists to Profiles progression.minigames.opordRecall, broadcasts XP, emits minigame:opord-recall event - UI at /opord: briefing countdown, one-at-a-time quiz, debrief metres, tier radio group, SSE presence, REST leaderboard per tier - profiles migration 20260908_152021 (7 additive columns) + XP hook wiring - nav entries in command palette and NavUser Exercises submenu - e2e spec plays a full round and asserts debrief + leaderboard row
66 lines
2.1 KiB
TypeScript
66 lines
2.1 KiB
TypeScript
import type { 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 { ScrollText } from "lucide-react";
|
|
import { OpordArena } from "@/components/frontend/opord/OpordArena";
|
|
|
|
export const metadata: Metadata = {
|
|
title: "OPORD Recall (Polaris Task Force)",
|
|
description: "Study a live operations order, then recall the details under pressure.",
|
|
};
|
|
|
|
export default async function OpordPage() {
|
|
const headers = await nextHeaders();
|
|
const payloadConfig = await config;
|
|
const payload = await getPayload({ config: payloadConfig });
|
|
const { user } = await payload.auth({ headers, canSetHeaders: false });
|
|
|
|
if (!user) {
|
|
redirect(`/login?returnTo=${encodeURIComponent("/opord")}`);
|
|
}
|
|
|
|
const profileRes = await payload.find({
|
|
collection: "profiles",
|
|
where: { user: { equals: user.id as number } },
|
|
limit: 1,
|
|
depth: 0,
|
|
overrideAccess: true,
|
|
select: {
|
|
progression: {
|
|
minigames: true,
|
|
},
|
|
},
|
|
});
|
|
|
|
const opordRecall = profileRes.docs[0]?.progression?.minigames?.opordRecall ?? {};
|
|
const stats = {
|
|
gamesPlayed: opordRecall.gamesPlayed ?? 0,
|
|
bestScore: opordRecall.bestScore ?? 0,
|
|
bestAccuracy: opordRecall.bestAccuracy ?? 0,
|
|
recruitBestScore: opordRecall.recruitBestScore ?? 0,
|
|
veteranBestScore: opordRecall.veteranBestScore ?? 0,
|
|
eliteBestScore: opordRecall.eliteBestScore ?? 0,
|
|
opordRecallXp: opordRecall.xpEarned ?? 0,
|
|
xpEarned: 0,
|
|
score: 0,
|
|
accuracy: 0,
|
|
};
|
|
|
|
return (
|
|
<div className="flex min-w-0 flex-col gap-6 p-5">
|
|
<div className="flex flex-col gap-1">
|
|
<div className="flex items-center gap-2">
|
|
<ScrollText className="size-5 text-muted-foreground" />
|
|
<h1 className="text-lg font-semibold">OPORD Recall</h1>
|
|
</div>
|
|
<p className="text-sm text-muted-foreground">
|
|
Study a live operations order, then recall the details under pressure.
|
|
</p>
|
|
</div>
|
|
|
|
<OpordArena initialStats={stats} currentUserId={user.id as number} />
|
|
</div>
|
|
);
|
|
}
|