holy shit i can score an event properly!!!! this is awesome

This commit is contained in:
2026-06-29 14:40:02 +01:00
parent 7ae5b2fbbc
commit 07692fe0bd
7 changed files with 95 additions and 33 deletions

View File

@@ -41,7 +41,29 @@
'Content-type': 'application/json; charset=UTF-8'
}
});
return response.json();
const data = await response.json();
// Sort the players inside each bracket before returning the data
if (data && data[0] && data[0].registeredPlayers) {
data[0].registeredPlayers.forEach((bracket: any) => {
bracket.items.sort((a: any, b: any) => {
// 1. Both have no placement (placement === 0) -> keep original order
if (a.placement === 0 && b.placement === 0) return 0;
// 2. 'a' has no placement, but 'b' does -> move 'b' to the top
if (a.placement === 0) return 1;
// 3. 'a' has a placement, but 'b' doesn't -> keep 'a' on top
if (b.placement === 0) return -1;
// 4. Both have placements -> sort ascending (1st, 2nd, 3rd, etc.)
return a.placement - b.placement;
});
});
}
return data;
}
let eventDataPromise = getEventData();