import { notFound } from "next/navigation"; import { getGameById, incrementPlayCount } from "@/lib/games/service"; import { getCurrentSession } from "@/lib/auth/session"; import { TEMPLATE_LABELS } from "@/lib/games/types"; import { PlaySession } from "@/components/play-session"; const TEMPLATE_HINTS: Record = { quiz: "Выбирайте вариант ответа мышкой.", clicker: "Кликайте по кругу и покупайте улучшения.", maze: "Управление — стрелки на клавиатуре.", }; export default async function PlayPage({ params }: { params: Promise<{ gameId: string }> }) { const { gameId } = await params; const game = await getGameById(gameId); if (!game) notFound(); if (game.status === "draft") { const session = await getCurrentSession(); if (!session || session.user.id !== game.ownerId) notFound(); } else { await incrementPlayCount(gameId); } return (
{TEMPLATE_LABELS[game.templateType]} {game.status === "draft" && Черновик}

{game.title}

{game.description &&

{game.description}

}

{TEMPLATE_HINTS[game.templateType]}

); }