(function(){ const params = new URLSearchParams(location.search); const id = Number(params.get('id') || '0'); if(!id){ document.getElementById('info').innerHTML = '

Tournoi introuvable (id manquant)

'; return; } async function load(){ const t = await SSAPI.get('/tournaments/'+id).catch(()=>null); if(!t){ document.getElementById('info').innerHTML = '

Tournoi introuvable

'; return; } document.getElementById('info').innerHTML = `

${t.name}

Lieu: ${t.location || '—'}
Dates: ${t.start_date} → ${t.end_date}
Inscrits
${t.enrollment_count}
Équipes
${t.team_count}
Matches
${t.match_count}
${t.next_match ? `
Prochain match
${t.next_match.round || ''} — ${t.next_match.court || ''}
${t.next_match.scheduled_at ? new Date(t.next_match.scheduled_at).toLocaleString() : ''}
` : ''} `; const parts = await SSAPI.get('/enrollments?tournament_id='+id).catch(()=>[]); document.getElementById('participants').innerHTML = parts.map(p=>`
${p.first_name} ${p.last_name} (#${p.ranking || '—'})
`).join('') || '

Aucun inscrit

'; const matches = await SSAPI.get('/matches?tournament_id='+id).catch(()=>[]); document.getElementById('matchlist').innerHTML = matches.map(m=>`
${m.round || 'Match'} — ${m.court || 'Court ?'}
Teams: ${m.team_a_id || '?'} vs ${m.team_b_id || '?'}
Score: ${m.score_a} - ${m.score_b} (${m.status})
${m.scheduled_at ? new Date(m.scheduled_at).toLocaleString() : ''}
`).join('') || '

Aucun match

'; } load(); })();