website refactor
This commit is contained in:
24
apps/website/lib/display-objects/FinishDisplay.ts
Normal file
24
apps/website/lib/display-objects/FinishDisplay.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* FinishDisplay
|
||||
*
|
||||
* Deterministic formatting for race finish positions.
|
||||
*/
|
||||
|
||||
export class FinishDisplay {
|
||||
/**
|
||||
* Formats a finish position as "P1", "P2", etc.
|
||||
*/
|
||||
static format(position: number | null | undefined): string {
|
||||
if (position === null || position === undefined) return '—';
|
||||
return `P${position.toFixed(0)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an average finish position with one decimal place.
|
||||
* Example: 5.4 -> "P5.4"
|
||||
*/
|
||||
static formatAverage(avg: number | null | undefined): string {
|
||||
if (avg === null || avg === undefined) return '—';
|
||||
return `P${avg.toFixed(1)}`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user