trying to get sub label showed properly

This commit is contained in:
Davide Scaini
2026-03-30 20:09:01 +02:00
parent c58bc8f7d5
commit 877472e620
11 changed files with 157 additions and 24 deletions
+15 -1
View File
@@ -75,10 +75,24 @@ export function sportColor(sport: Sport): string {
return SPORT_COLORS[sport] ?? '#a78bfa';
}
const SUB_SPORT_LABELS: Record<string, string> = {
road: 'Road',
mountain: 'MTB',
gravel: 'Gravel',
indoor: 'Indoor',
trail: 'Trail',
track: 'Track',
nordic: 'Nordic',
alpine: 'Alpine',
open_water: 'Open Water',
pool: 'Pool',
};
export function sportLabel(sport: Sport, subSport?: string | null): string {
const base = sport.charAt(0).toUpperCase() + sport.slice(1);
if (subSport && subSport !== 'generic') {
return `${subSport.charAt(0).toUpperCase() + subSport.slice(1)} ${base}`;
const sub = SUB_SPORT_LABELS[subSport] ?? (subSport.charAt(0).toUpperCase() + subSport.slice(1));
return `${sub} ${base}`;
}
return base;
}
+1 -1
View File
@@ -1,7 +1,7 @@
/** TypeScript types mirroring BAS v1.0 schema. */
export type Sport = "cycling" | "running" | "hiking" | "walking" | "swimming" | "skiing" | "other";
export type SubSport = "road" | "mountain" | "gravel" | "indoor" | "trail" | "track" | "nordic" | null;
export type SubSport = "road" | "mountain" | "gravel" | "indoor" | "trail" | "track" | "nordic" | "alpine" | "open_water" | "pool" | null;
export type Privacy = "public" | "blur_start" | "no_gps" | "private";
/** [duration_s, avg_watts] pairs, sorted by duration ascending. */