All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m41s
19 lines
1.1 KiB
TypeScript
19 lines
1.1 KiB
TypeScript
import { notFound } from "next/navigation";
|
|
import { randomUUID } from "node:crypto";
|
|
import { ARCADE_RENDERERS } from "@/components/arcade/rendererRegistry";
|
|
import { getArcadePack } from "@/services/arcadeService";
|
|
|
|
export default async function ConnectionsPlayPage(
|
|
props: PageProps<"/[classSlug]/arcade/connections/[packId]/play">
|
|
) {
|
|
const [{ classSlug, packId }, query] = await Promise.all([props.params, props.searchParams]);
|
|
const pack = await getArcadePack(packId);
|
|
if (!pack || pack.class.slug !== classSlug || pack.gameType !== "connections" || pack.normalized.type !== "connections") notFound();
|
|
const normalized = pack.normalized;
|
|
const mistakesValue = Number(query.mistakes);
|
|
const allowedMistakes = Number.isInteger(mistakesValue) && mistakesValue >= 1 && mistakesValue <= 8
|
|
? mistakesValue
|
|
: normalized.settings.allowedMistakes;
|
|
const Renderer = ARCADE_RENDERERS.connections;
|
|
return <Renderer seed={randomUUID()} packId={pack.id} packName={pack.name} classSlug={classSlug} pack={normalized} settings={{ allowedMistakes, oneAwayFeedback: query.oneAway !== "0" }} />;
|
|
}
|