/* eslint-disable @next/next/no-img-element -- Artwork/symbols come from the MinIO CDN; next/image is out of scope for the designer canvas. */ import { useEffect, useState } from 'react'; import { useRouter } from 'next/router'; import Layout from '../../../components/Layout'; import CardPreview from '../../../components/designer/CardFrame'; import { Button } from '../../../components/ui'; import { useAuth } from '../../../lib/use-auth'; /** Read-only public view of a community-shared custom game. */ export default function PublicGameSpace() { const router = useRouter(); const { id } = router.query; const { user } = useAuth(); const [game, setGame] = useState(null); const [designs, setDesigns] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { if (!id) return undefined; const loadGame = async () => { setLoading(true); try { const response = await fetch(`/api/public/games/${id}`); const data = await response.json(); if (response.ok) { setGame(data.game); setDesigns(data.designs); } else { setError(data.error || 'Game not found.'); } } catch { setError('Failed to load the game.'); } finally { setLoading(false); } }; loadGame(); return undefined; }, [id]); const symbolsMap = {}; // Symbol icons render from per-user libraries; public views fall back // to text pips unless codes are embedded later. if (loading) { return (
); } if (error && !game) { return (

{error}

); } return (

{game.name}

{game.description || 'Custom game system'} · by {game.author} · {designs.length} card{designs.length === 1 ? '' : 's'}

{designs.length === 0 ? (

No cards in this game yet

) : (
{designs.map((design) => (

{design.name}

{design.card_type || 'No type'} {design.mana_cost ? `· ${design.mana_cost}` : ''}

))}
)}
); }