diff --git a/src/components/PreviewPanel.jsx b/src/components/PreviewPanel.jsx index 3e66bd7..09c70af 100644 --- a/src/components/PreviewPanel.jsx +++ b/src/components/PreviewPanel.jsx @@ -1,28 +1,19 @@ import React, { useState } from 'react'; -export default function PreviewPanel({ code }) { - const [gameUrl, setGameUrl] = useState(''); - const [settings, setSettings] = useState(null); - const [loadingSetup, setLoadingSetup] = useState(false); +const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; - const fetchBoard = async () => { - if (!gameUrl.trim()) return; - setLoadingSetup(true); - try { - const res = await fetch( - `/api/fetch-board?url=${encodeURIComponent(gameUrl.trim())}` - ); - if (!res.ok) throw new Error('Fetch board failed'); - setSettings(await res.json()); - } catch (err) { - console.error(err); - } finally { - setLoadingSetup(false); +export default function PreviewPanel({ code }) { + const [gameId, setGameId] = useState(''); + const [submitted, setSubmitted] = useState(false); + + const isValid = uuidRegex.test(gameId); + + const handleClick = () => { + if (isValid) { + setSubmitted(true); } }; - const gameId = gameUrl.trim().split('/').pop(); - return (
+ Invalid Game ID format. +
+ )}