feat(ui): sort matches by date with upcoming matches after played matches

Split match display into played and upcoming sections, sorting played matches in descending order (newest first) and upcoming matches in ascending order (soonest first), then concatenate them for display.
This commit is contained in:
Your Name committed 2026-10-18 17:08:28 +02:00
1 parent 9775295d38
commit 996462716e
1 file changed
+6 -3
+6 -3
View File
@@ -391,10 +391,13 @@
const comps = state.data.club_detail.competitions || [];
const sections = [];
for(const comp of comps){
const matches = (comp.matches || [])
const now = new Date();
const dated = (comp.matches || [])
.map(m=>({ m, dt: parseCZDate(m.date_time) }))
.filter(x=>!!x.dt)
.sort((a,b)=> b.dt - a.dt);
.filter(x=>!!x.dt);
const played = dated.filter(x=> x.dt <= now).sort((a,b)=> b.dt - a.dt);
const upcoming = dated.filter(x=> x.dt > now).sort((a,b)=> a.dt - b.dt);
const matches = played.concat(upcoming);
if(matches.length === 0) continue;
const compName = truncate(escapeHTML(comp.name || comp.code || 'Soutěž'), 40);
const itemsHtml = matches.map(({m})=>{