From 996462716e02b59d9f5d916d6ba73a3e56c1e4d8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 18 Oct 2026 17:08:28 +0200 Subject: [PATCH] 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. --- js/facr-frontend.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/js/facr-frontend.js b/js/facr-frontend.js index 29e253d..90d45b2 100644 --- a/js/facr-frontend.js +++ b/js/facr-frontend.js @@ -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})=>{