feat(qualification): add qualification course page
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
282e23edc2
commit
e3e4760f49
1 changed files with 70 additions and 0 deletions
70
src/app/(frontend)/qualification/page.tsx
Normal file
70
src/app/(frontend)/qualification/page.tsx
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
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 { Crosshair } from "lucide-react";
|
||||
|
||||
import type { AimTrainerStats } from "@/app/(frontend)/qualification/actions";
|
||||
import { AimTrainerArena } from "@/components/frontend/qualification/AimTrainerArena";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Qualification Course — Polaris Task Force",
|
||||
description: "Complete a timed qualification course to sharpen your marksmanship and earn XP.",
|
||||
};
|
||||
|
||||
export default async function QualificationPage() {
|
||||
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("/qualification")}`);
|
||||
}
|
||||
|
||||
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 aimTrainer = profileRes.docs[0]?.progression?.minigames?.aimTrainer ?? {};
|
||||
const stats: AimTrainerStats = {
|
||||
gamesPlayed: aimTrainer.gamesPlayed ?? 0,
|
||||
bestScore: aimTrainer.bestScore ?? 0,
|
||||
recruitBestScore: aimTrainer.recruitBestScore ?? 0,
|
||||
veteranBestScore: aimTrainer.veteranBestScore ?? 0,
|
||||
eliteBestScore: aimTrainer.eliteBestScore ?? 0,
|
||||
recruitBestAccuracy: aimTrainer.recruitBestAccuracy ?? 0,
|
||||
veteranBestAccuracy: aimTrainer.veteranBestAccuracy ?? 0,
|
||||
eliteBestAccuracy: aimTrainer.eliteBestAccuracy ?? 0,
|
||||
aimTrainerXp: aimTrainer.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">
|
||||
<Crosshair className="size-5 text-muted-foreground" />
|
||||
<h1 className="text-lg font-semibold">Qualification Course</h1>
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Acquire targets, place your shots, and qualify under pressure.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<AimTrainerArena initialStats={stats} currentUserId={user.id} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue