diff --git a/src/app/ClientPage.tsx b/src/app/ClientPage.tsx
index 0d1cbf6..4a3f59b 100644
--- a/src/app/ClientPage.tsx
+++ b/src/app/ClientPage.tsx
@@ -41,7 +41,12 @@ export default function ClientPage({ initialAppData }: ClientPageProps) {
Points Table:
-
| ))} | ||
| + |
- FL (+{flPoints.points})
+ FL (+{flPoints})
|
|
| - {track.name} - | -- {track.fastestLapInitials || ""} - | - {appData.drivers.map((driver, driverIndex) => { - const driverInitials = driver.initials; - let result = track.results[driverIndex]; - // DNS fallback - if (result === undefined || result === null || result === "") { - result = "DNS"; - } - const pointsNum = parsePoints(result); - const style = findStyleByPoints(appData, pointsNum); + {appData.tracks.map((track, trackIndex) => { + // Find driver name for fastest lap + const flDriver = appData.drivers.find( + (d) => d.id === track.fastestLapDriverId + ); + return ( +|
| + {track.name} + | ++ {flDriver?.initials || ""} + | + {appData.drivers.map((driver) => { + const raceResult = track.results.find( + (r) => r.driverId === driver.id + ); + let result = raceResult?.score; + // DNS fallback + if (result === undefined || result === null || result === "") { + result = "DNS"; + } + const pointsNum = parsePoints(result); + const style = findStyleByPoints(appData, pointsNum); - let cellStyles: React.CSSProperties = { - backgroundColor: style.color, - color: style.textColor, - }; + let cellStyles: React.CSSProperties = { + backgroundColor: style.color, + color: style.textColor, + }; - let hasFL = false; - if ( - track.fastestLapInitials && - track.fastestLapInitials === driverInitials && - appData.flPoints.points - ) { - hasFL = true; - const flColor = appData.flPoints.color; - if (pointsNum === 0) { + let hasFL = false; + if (track.fastestLapDriverId === driver.id && appData.flPoints) { + hasFL = true; + const flColor = appData.flColor; + if (pointsNum === 0) { + cellStyles = { + backgroundColor: flColor, + color: appData.flTextColor, + }; + } else { + cellStyles = { + background: `linear-gradient(135deg, ${style.color} 50%, ${flColor} 50%)`, + color: style.textColor, + }; + } + } + + if (hasFL) { cellStyles = { - backgroundColor: flColor, - color: appData.flPoints.textColor, + ...cellStyles, + display: "flex", + justifyContent: "space-between", + alignItems: "center", + flexDirection: "row", + paddingLeft: "0.75rem", + paddingRight: "0.75rem", }; } else { cellStyles = { - background: `linear-gradient(135deg, ${style.color} 50%, ${flColor} 50%)`, - color: style.textColor, + ...cellStyles, + textAlign: "center", }; } - } - if (hasFL) { - cellStyles = { - ...cellStyles, - display: "flex", - justifyContent: "space-between", - alignItems: "center", - flexDirection: "row", - paddingLeft: "0.75rem", - paddingRight: "0.75rem", - }; - } else { - cellStyles = { - ...cellStyles, - textAlign: "center", - }; - } - - return ( -- {hasFL ? ( - <> - - {result} - - - (+{appData.flPoints.points}) - - > - ) : ( - {result} - )} - | - ); - })} -+ {hasFL ? ( + <> + + {result} + + + (+{appData.flPoints}) + + > + ) : ( + {result} + )} + | + ); + })} + + ); + })}