website refactor
This commit is contained in:
51
apps/website/components/races/RacePenaltyRowWrapper.tsx
Normal file
51
apps/website/components/races/RacePenaltyRowWrapper.tsx
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
|
||||
import { PenaltyRow } from '@/components/races/PenaltyRow';
|
||||
|
||||
interface PenaltyEntry {
|
||||
driverId: string;
|
||||
driverName: string;
|
||||
type: 'time_penalty' | 'grid_penalty' | 'points_deduction' | 'disqualification' | 'warning' | 'license_points';
|
||||
value: number;
|
||||
reason: string;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
interface RacePenaltyRowProps {
|
||||
penalty: PenaltyEntry;
|
||||
}
|
||||
|
||||
export function RacePenaltyRow({ penalty }: RacePenaltyRowProps) {
|
||||
const getValue = () => {
|
||||
switch (penalty.type) {
|
||||
case 'time_penalty': return `+${penalty.value}`;
|
||||
case 'grid_penalty': return `+${penalty.value}`;
|
||||
case 'points_deduction': return `-${penalty.value}`;
|
||||
case 'disqualification': return 'DSQ';
|
||||
case 'warning': return 'Warning';
|
||||
case 'license_points': return `${penalty.value}`;
|
||||
default: return penalty.value;
|
||||
}
|
||||
};
|
||||
|
||||
const getValueLabel = () => {
|
||||
switch (penalty.type) {
|
||||
case 'time_penalty': return 's';
|
||||
case 'grid_penalty': return 'grid';
|
||||
case 'points_deduction': return 'pts';
|
||||
case 'license_points': return 'LP';
|
||||
default: return '';
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<PenaltyRow
|
||||
driverName={penalty.driverName}
|
||||
type={penalty.type}
|
||||
reason={penalty.reason}
|
||||
notes={penalty.notes}
|
||||
value={getValue()}
|
||||
valueLabel={getValueLabel()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user