import { formatDuration, formatDistance, formatPace, formatHeartRate, formatCadence } from '../../utils/format' const RUNNING_TYPES = new Set(['running', 'hiking', 'walking']) export default function LapTable({ laps, sportType, lapBests }) { const showPower = !RUNNING_TYPES.has(sportType?.toLowerCase()) const hasBests = lapBests && Object.keys(lapBests).length > 0 return (
| Lap | Distance | Time | {hasBests &&Best | } {hasBests &&Δ | }Pace | Avg HR | Cadence | {showPower &&Power | }
|---|---|---|---|---|---|---|---|---|
| {lap.lap_number} | {formatDistance(lap.distance_m)} | {formatDuration(lap.duration_s)} | {hasBests && ({best != null ? formatDuration(best) : '--'} | )} {hasBests && ({delta == null ? '--' : isBest ? '🏆' : `${delta > 0 ? '+' : '−'}${formatDuration(Math.abs(delta))}`} | )}{formatPace(lap.avg_speed_ms, sportType)} | {formatHeartRate(lap.avg_heart_rate)} | {lap.avg_cadence ? formatCadence(lap.avg_cadence, sportType) : '--'} | {showPower && ({lap.avg_power ? `${Math.round(lap.avg_power)} W` : '--'} | )}