File tree Expand file tree Collapse file tree
tiny-racing-vue/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff 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)
315315const 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
323335async function loadTeams() {
You can’t perform that action at this time.
0 commit comments