Lib: Display full driver names in dropdown labels + sort alphabetically

This commit is contained in:
2025-02-26 23:37:22 +01:00
parent dcd62cdbfa
commit 53396fce19

View File

@ -13,40 +13,46 @@ import {
* Generates a list of [DropdownOptions] for a <Dropdown> component. * Generates a list of [DropdownOptions] for a <Dropdown> component.
*/ */
export const team_dropdown_options = (teams: Team[]): DropdownOption[] => export const team_dropdown_options = (teams: Team[]): DropdownOption[] =>
teams.map((team: Team) => { teams
return { .sort((a: Team, b: Team) => a.name.localeCompare(b.name))
label: team.name, .map((team: Team) => {
value: team.id, return {
icon_url: team.banner_url, label: team.name,
icon_width: TEAM_BANNER_WIDTH, value: team.id,
icon_height: TEAM_BANNER_HEIGHT, icon_url: team.banner_url,
}; icon_width: TEAM_BANNER_WIDTH,
}); icon_height: TEAM_BANNER_HEIGHT,
};
});
/** /**
* Generates a list of [DropdownOptions] for a <Dropdown> component. * Generates a list of [DropdownOptions] for a <Dropdown> component.
*/ */
export const driver_dropdown_options = (drivers: Driver[]): DropdownOption[] => export const driver_dropdown_options = (drivers: Driver[]): DropdownOption[] =>
drivers.map((driver: Driver) => { drivers
return { .sort((a: Driver, b: Driver) => a.firstname.localeCompare(b.firstname))
label: driver.code, .map((driver: Driver) => {
value: driver.id, return {
icon_url: driver.headshot_url, label: `${driver.firstname} ${driver.lastname}`,
icon_width: DRIVER_HEADSHOT_WIDTH, value: driver.id,
icon_height: DRIVER_HEADSHOT_HEIGHT, icon_url: driver.headshot_url,
}; icon_width: DRIVER_HEADSHOT_WIDTH,
}); icon_height: DRIVER_HEADSHOT_HEIGHT,
};
});
/** /**
* Generates a list of [DropdownOptions] for a <Dropdown> component. * Generates a list of [DropdownOptions] for a <Dropdown> component.
*/ */
export const race_dropdown_options = (races: Race[]): DropdownOption[] => export const race_dropdown_options = (races: Race[]): DropdownOption[] =>
races.map((race: Race) => { races
return { .sort((a: Race, b: Race) => a.step - b.step)
label: race.name, .map((race: Race) => {
value: race.id, return {
icon_url: race.pictogram_url, label: race.name,
icon_width: RACE_PICTOGRAM_WIDTH, value: race.id,
icon_height: RACE_PICTOGRAM_HEIGHT, icon_url: race.pictogram_url,
}; icon_width: RACE_PICTOGRAM_WIDTH,
}); icon_height: RACE_PICTOGRAM_HEIGHT,
};
});