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 ( ); } const STEP_TEXT = { ban: 'Ban', pick: 'Pick', side: 'Seite', decider: 'Entscheidungsmap' }; function FlowPreview({ flow }) { return (