fix lap-bests distance matching + show PRs on activity page
This commit is contained in:
@@ -66,6 +66,12 @@ export default function ActivityDetailPage() {
|
||||
enabled: !!activity?.named_route_id,
|
||||
})
|
||||
|
||||
const { data: activityRecords } = useQuery({
|
||||
queryKey: ['activity-records', id],
|
||||
queryFn: () => api.get(`/activities/${id}/records`).then(r => r.data),
|
||||
enabled: !!activity,
|
||||
})
|
||||
|
||||
const { data: routeBoard } = useQuery({
|
||||
queryKey: ['route-leaderboard', id],
|
||||
queryFn: () => api.get(`/activities/${id}/route-leaderboard`).then(r => r.data),
|
||||
@@ -132,6 +138,21 @@ export default function ActivityDetailPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Personal records set in this activity */}
|
||||
{activityRecords && activityRecords.length > 0 && (
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-xs text-gray-500 mr-1">🏆 Personal best{activityRecords.length > 1 ? 's' : ''} set here:</span>
|
||||
{activityRecords.map(pr => (
|
||||
<span
|
||||
key={pr.distance_label}
|
||||
className="text-xs px-2.5 py-1 rounded-full bg-yellow-500/10 text-yellow-400 border border-yellow-500/30 font-medium"
|
||||
>
|
||||
{pr.distance_label} · {formatDuration(pr.duration_s)}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Stats — all on one row */}
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-10 gap-3">
|
||||
<StatCard label="Distance" value={formatDistance(activity.distance_m)} />
|
||||
|
||||
Reference in New Issue
Block a user