<%- include('header.html', { pageTitle, extraStyles, extraScripts }) %> <% function formatDateLong(date){ if(!date){ date = new Date()} let sdate = date.toLocaleDateString('es-MX', { year: 'numeric', month: 'long', day: 'numeric' }); return sdate } function formatDate(date){ if(!date){ date = new Date()} let sdate = date.toLocaleDateString('es-MX', { year: 'numeric', month: 'short', day: 'numeric' }); return sdate.toUpperCase() } function formatTime(time){ let hh = time.substr(0,2) let mm = time.substr(3,2) let am = parseInt(hh) > 11 ? 'pm' : 'am' let hr = parseInt(hh) hr = hr > 12 ? hr-12 : hr return `${hr.toString().padStart(2,'0')}:${mm} ${am}` } function showSex(sex){ return {male:'Masculino', female:'Femenino', mixed:'Mixto'}[sex?.toLowerCase() || 'male'] } %>
<% if (tournament.status === 'comenzado') { %>Comenzado<% } %> <% if (tournament.status === 'proximo') { %>Próximo<% } %> <% if (tournament.status === 'finalizado') { %>Finalizado<% } %>

<%= tournament.name %>

<% if (tournament.description) { %>

<%= tournament.description %>

<% } %>

Ubicación: <%= tournament.location %>

Fechas: <%= formatDateLong(tournament.start_date) %> - <%= formatDateLong(tournament.end_date) %>

Canchas: <%= tournament.number_of_courts %>

Categorías

<% if (categories.length === 0) { %>

No hay categorías definidas

<% } else { %>
<% categories.forEach(function(cat) { %>

<%= cat.name %>

<%=cat.teams || 0%> <%=cat.teams == 1 ? 'Equipo' : 'Equipos' %>
<% }) %>
<% } %>

Equipos

<% if (teams.length === 0) { %>

No hay equipos registrados

<% } else { %>
<% teams.forEach(function(team) { %>
#<%= team.seed_number %>
<% if (team.group_name) { %> Grupo <%= team.group_name %> <% } %>

<%= team.name %>

<%= team.player1 || '(Por asignar)' %> <%= team.player2 || ' ' %>
G: <%= team.wins %> P: <%= team.losses %>
<% }) %>
<% } %>

Fases y Partidos

<% if (phases.length === 0) { %>

No hay fases definidas

<% } else { %> <% phases.forEach(function(phase) { %>

<%= phase.catname %>

Fase <%= phase.phase_order %>: <%= phase.name %>

<% const phaseMatches = matches.filter(m => m.phase_id === phase.id); %> <% if (phaseMatches.length === 0) { %>

No hay partidos en esta fase

<% } else { %>
<% phaseMatches.forEach(function(match) { %> <% }) %>
Fecha Cancha Equipo 1 Equipo 2 Resultado Estado
<%=formatDate(match.scheduled_date)%>
<%=formatTime(match.scheduled_time || '17:00')%>
<%=match.court_name%> <%= match.team1_name || 'TBD' %>
<%=match.team1_player1%> / <%=match.team1_player2%>
<%= match.team2_name || 'TBD' %>
<%=match.team2_player1%> / <%=match.team2_player2%>
<% if (match.status === 'finalizado') { %> <% if (match.scores && match.scores.length > 0) { %> <% match.scores.forEach(function(s, idx) { %> <%= s.team1_points %>-<%= s.team2_points %> <% }) %> <% } else { %> <%= match.team1_score %>-<%= match.team2_score %> <% } %> <% } else { %> - <% } %> <%= match.status %>
<% } %>
<% }) %> <% } %>

Tabla de Posiciones

<% if (leaderboard.length === 0) { %>

No hay datos en la tabla de posiciones

<% } else { %>
<% leaderboard.forEach(function(entry) { %> <% }) %>
# Equipo Grupo G P SG SP PG PP
<%= entry.rank %> <%= entry.team_name %> <%= entry.group_name || '-' %> <%= entry.wins %> <%= entry.losses %> <%= entry.sets_won %> <%= entry.sets_lost %> <%= entry.points_for %> <%= entry.points_against %>
<% } %>
<%- include('footer.html', { extraScripts }) %>