1
0
Fork 0
polaris-task-force/src/app/(frontend)/eod/page.tsx

65 lines
2 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 { Bomb } from "lucide-react";
import { EodArena } from "@/components/frontend/eod/EodArena";
export const metadata: Metadata = {
title: "Minefield Clearance (Polaris Task Force)",
description: "Clear simulated minefields across three EOD sectors to earn XP for the task force.",
};
export default async function EodPage() {
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("/eod")}`);
}
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 eod = profileRes.docs[0]?.progression?.minigames?.eodMinesweeper ?? {};
const stats = {
gamesPlayed: eod.gamesPlayed ?? 0,
wins: eod.wins ?? 0,
losses: eod.losses ?? 0,
bestScore: eod.bestScore ?? 0,
eodXp: eod.xpEarned ?? 0,
xpEarned: 0,
bestTrainingTime: eod.bestTrainingTime ?? 0,
bestPerimeterTime: eod.bestPerimeterTime ?? 0,
bestSupplyRoadTime: eod.bestSupplyRoadTime ?? 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">
<Bomb className="size-5 text-muted-foreground" />
<h1 className="text-lg font-semibold">Minefield Clearance</h1>
</div>
<p className="text-sm text-muted-foreground">
Clear the minefield to earn XP. Faster clears score higher.
</p>
</div>
<EodArena initialStats={stats} currentUserId={user.id as number} />
</div>
);
}