Skip to content

Commit 9734906

Browse files
committed
compact formatting of races
1 parent c5df17b commit 9734906

3 files changed

Lines changed: 220 additions & 273 deletions

File tree

tiny-racing-vue/src/components/AllTeams.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,22 @@ function getDriverForCar(car: CarDb): DriverDb | undefined {
314314
// Filter races to only show non-started races (REGISTRATION_OPEN or REGISTRATION_CLOSED)
315315
const upcomingRacesForExpandedTeam = computed(() => {
316316
if (!expandedTeamData.value) return [];
317-
return expandedTeamData.value.registeredRaces.filter(
317+
const filtered = expandedTeamData.value.registeredRaces.filter(
318318
(race) =>
319319
race.race_status === 'REGISTRATION_OPEN' || race.race_status === 'REGISTRATION_CLOSED',
320320
);
321+
322+
// Sort chronologically by start_datetime (earliest first)
323+
// Races without start_datetime go to the end
324+
const sorted = filtered.sort((a, b) => {
325+
if (!a.start_datetime && !b.start_datetime) return 0;
326+
if (!a.start_datetime) return 1; // a goes to end
327+
if (!b.start_datetime) return -1; // b goes to end
328+
return new Date(a.start_datetime).getTime() - new Date(b.start_datetime).getTime();
329+
});
330+
331+
// Return only the next 3 upcoming races
332+
return sorted.slice(0, 3);
321333
});
322334
323335
async function loadTeams() {

0 commit comments

Comments
 (0)