import { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { api } from '../lib/api.js'; import { FORMAT_LABEL } from '../lib/labels.js'; import { setAccess } from '../lib/session.js'; export default function CreateMatch({ config }) { const navigate = useNavigate(); const [form, setForm] = useState({ teamA: '', teamB: '', mode: 'competitive', format: 'bo3', vetoStart: 'coin', password: '' }); const [error, setError] = useState(null); const [busy, setBusy] = useState(false); const pool = config?.pools.find((p) => p.mode === form.mode); const set = (key) => (e) => setForm((f) => ({ ...f, [key]: e.target.value })); // Wird ein Format für den neuen Modus nicht unterstützt, auf das erste unterstützte wechseln. useEffect(() => { if (pool && !pool.formats[form.format]?.supported) { const first = Object.keys(pool.formats).find((f) => pool.formats[f].supported); if (first) setForm((f) => ({ ...f, format: first })); } }, [pool, form.format]); const submit = async (e) => { e.preventDefault(); setBusy(true); setError(null); try { const res = await api('/matches', { method: 'POST', body: form }); setAccess(res.id, { token: res.organizerToken, kind: 'organizer' }); navigate(`/m/${res.id}`); } catch (err) { setError(err.message); setBusy(false); } }; if (!config) return

Lade Einstellungen …

; return (

Match erstellen

Mit dem Erstellen der Lobby wird sofort ein Server angefordert, damit er während des Vetos hochfahren kann.

vs.
Spielmodus
{config.pools.map((p) => ( ))}
Serie
{Object.entries(pool.formats).map(([f, info]) => ( ))}
{pool.formats[form.format]?.flow && }
{config.createRequiresPassword && ( )} {error &&
{error}
}
); } const STEP_TEXT = { ban: 'Ban', pick: 'Pick', side: 'Seite', decider: 'Entscheidungsmap' }; function FlowPreview({ flow }) { return (
    {flow.map((raw, i) => { const [type, actor] = raw.split(':'); return (
  1. {STEP_TEXT[type]} {actor && {actor === 'X' ? 'Erstes Team' : 'Zweites Team'}}
  2. ); })}
); }