From 76fbaba293803e4195bbf37ed3867c2a5793a966 Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Tue, 8 Sep 2026 22:38:38 -0400 Subject: [PATCH] refactor(minigames): derive custom-page unlock state from shared lib predicates Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- src/app/(frontend)/eod/custom/page.tsx | 10 ++++++---- src/app/(frontend)/radio/custom/page.tsx | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/app/(frontend)/eod/custom/page.tsx b/src/app/(frontend)/eod/custom/page.tsx index b7a03d2..b56527a 100644 --- a/src/app/(frontend)/eod/custom/page.tsx +++ b/src/app/(frontend)/eod/custom/page.tsx @@ -4,6 +4,7 @@ import { getPayload } from "payload"; import { headers as nextHeaders } from "next/headers"; import { Bomb } from "lucide-react"; import { CustomMinefieldBrowser } from "@/components/frontend/eod/CustomMinefieldBrowser"; +import { isEodUnlocked } from "@/lib/custom-minigames/eod"; export const metadata: Metadata = { title: "Custom Minefields (Polaris Task Force)", @@ -28,10 +29,11 @@ export default async function CustomMinefieldsPage() { }) ).docs[0]?.progression?.minigames?.eodMinesweeper ?? {} : {}; - const unlocked = - (eod.bestTrainingTime ?? 0) > 0 && - (eod.bestPerimeterTime ?? 0) > 0 && - (eod.bestSupplyRoadTime ?? 0) > 0; + const unlocked = isEodUnlocked({ + bestTrainingTime: eod.bestTrainingTime ?? 0, + bestPerimeterTime: eod.bestPerimeterTime ?? 0, + bestSupplyRoadTime: eod.bestSupplyRoadTime ?? 0, + }); return (
diff --git a/src/app/(frontend)/radio/custom/page.tsx b/src/app/(frontend)/radio/custom/page.tsx index e25fea4..c55dd8e 100644 --- a/src/app/(frontend)/radio/custom/page.tsx +++ b/src/app/(frontend)/radio/custom/page.tsx @@ -4,6 +4,7 @@ import { getPayload } from "payload"; import { headers as nextHeaders } from "next/headers"; import { Radio } from "lucide-react"; import { CustomTestBrowser } from "@/components/frontend/radio/CustomTestBrowser"; +import { isRadioUnlocked } from "@/lib/custom-minigames/radio"; export const metadata: Metadata = { title: "Custom Radio Tests (Polaris Task Force)", @@ -28,8 +29,10 @@ export default async function CustomRadioTestsPage() { }) ).docs[0]?.progression?.minigames?.radioTraffic ?? {} : {}; - const unlocked = - (radio.sprintBestAccuracy ?? 0) >= 0.9 && (radio.watchBestAccuracy ?? 0) >= 0.85; + const unlocked = isRadioUnlocked({ + sprintBestAccuracy: radio.sprintBestAccuracy ?? 0, + watchBestAccuracy: radio.watchBestAccuracy ?? 0, + }); return (