import { useEffect, useState } from 'react' import { Link, Navigate, useParams } from 'react-router-dom' import { api } from '../api' import { useAuth } from '../auth' import { ForestFortuneGame } from '../games/forest-fortune/ForestFortuneGame' import type { GameInfo } from '../types' export function GamePage() { const { slug } = useParams<{ slug: string }>() const { user, loading } = useAuth() const [game, setGame] = useState(null) const [error, setError] = useState(null) useEffect(() => { if (!slug) return void api .getGame(slug) .then(setGame) .catch((err: unknown) => setError(err instanceof Error ? err.message : 'Не найдено')) }, [slug]) if (!loading && user && !user.agreement_accepted) { return } const playable = game?.status === 'available' && game.slug === 'forest-fortune' return (
← Назад {error &&

{error}

} {game && playable && } {game && !playable && (

{game.title}

{game.description}

В разработке

)}
) }