@pitvox/partner-react 0.7.14 → 0.7.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -182,14 +182,26 @@ The `DriverDashboard` is a self-contained component with no routing dependency:
182
182
 
183
183
  ```jsx
184
184
  import { DriverDashboard } from '@pitvox/partner-react'
185
+ import { useNavigate } from 'react-router-dom'
185
186
  import '@pitvox/partner-react/styles.css'
186
187
 
187
188
  function DashboardPage() {
189
+ const navigate = useNavigate()
190
+
191
+ const handleComboSelect = (combo) => {
192
+ const params = new URLSearchParams()
193
+ params.set('track', `${combo.trackId}|${combo.trackLayout || ''}`)
194
+ params.set('car', combo.carId)
195
+ params.set('highlight', user.steamId)
196
+ navigate(`/leaderboards?${params.toString()}`)
197
+ }
198
+
188
199
  return (
189
200
  <DriverDashboard
190
201
  steamId={user.steamId}
191
202
  avatarUrl={user.avatarUrl}
192
203
  memberSince={user.createdAt}
204
+ onComboSelect={handleComboSelect}
193
205
  />
194
206
  )
195
207
  }
@@ -200,36 +212,62 @@ function DashboardPage() {
200
212
  | `steamId` | `string` | — | Driver's Steam ID (required) |
201
213
  | `avatarUrl` | `string` | — | Avatar URL from your auth provider |
202
214
  | `memberSince` | `string` | — | ISO date for "Racing since" display |
215
+ | `onComboSelect` | `(combo) => void` | — | Called when a Recent Combos row is clicked. Wire to your router to take the driver to the partner-scoped leaderboard for that combo (see example above). When omitted, rows render as static. |
216
+ | `onGameRatingSelect` | `(entry) => void` | — | Called when a Driver Rating chip is clicked, with `{game, label, rating, rank, totalDrivers}`. Wire to your rankings page if you have one. |
203
217
  | `className` | `string` | — | Additional class on root container |
204
218
 
205
219
  The dashboard automatically includes:
220
+ - **Stats Cards** — Total Laps, Cars Used (each with a click-to-toggle breakdown popover), and per-game Driver Rating chips (one chip per game where the driver has a rating, with rank info)
206
221
  - **Upcoming Events** — competition rounds the driver is registered for (CDN-based, always available)
222
+ - **Recent Combos** — every (track, layout, car, game, version) the driver has touched in the partner scope, sorted by lastDrivenAt desc, with rank/gap and a leader-trophy icon for combos where the driver holds the record. Replaces the older Records table — held records surface as trophies on the relevant combo rows.
207
223
  - **Notifications** — only when `onFetchNotifications` is provided to the provider (see [Notifications](#notifications))
208
224
 
209
225
  ### Layer components
210
226
 
211
227
  ```jsx
212
- import { DriverProfile, StatsCards, RecordsTable, UpcomingEvents, NotificationsCard } from '@pitvox/partner-react'
228
+ import {
229
+ DriverProfile,
230
+ StatsCards,
231
+ RecentCombosCard,
232
+ RecordsTable,
233
+ UpcomingEvents,
234
+ NotificationsCard,
235
+ } from '@pitvox/partner-react'
213
236
  ```
214
237
 
238
+ - **`<StatsCards>`** — Stats row. Pass `gameRatings` (from `useDriverRatingsByGame`) for the new chips behaviour, or `rating` (from `useDriverRating`) for the legacy single-number layout. Optional `onGameRatingSelect`.
239
+ - **`<RecentCombosCard>`** — Recent combos list with rank/gap and trophy treatment. Accepts `combos` (from `useDriverCombos`) and optional `onComboSelect(combo)` for row navigation.
240
+ - **`<RecordsTable>`** — Legacy "Current Records" list, still exported for consumers that prefer the explicit records UI. The composite `DriverDashboard` no longer renders it (records are surfaced as trophies on `RecentCombosCard` rows instead).
215
241
  - **`<UpcomingEvents>`** — Upcoming competition rounds card (accepts `events` array from `useUpcomingEvents()`)
216
242
  - **`<NotificationsCard>`** — Notifications list with read/unread state (accepts `notifications`, `unreadCount`, `onMarkRead`, `onMarkAllRead`)
217
243
 
218
244
  ### Hooks
219
245
 
220
246
  ```jsx
221
- import { useDriverStats, useDriverRating, useDriverRatings, useUpcomingEvents } from '@pitvox/partner-react'
247
+ import {
248
+ useDriverStats,
249
+ useDriverCombos,
250
+ useDriverRating,
251
+ useDriverRatings,
252
+ useDriverRatingsByGame,
253
+ useUpcomingEvents,
254
+ } from '@pitvox/partner-react'
222
255
  ```
223
256
 
224
- **`useDriverStats(steamId)`** — Driver stats, records, and ranking from CDN.
257
+ **`useDriverStats(steamId)`** — Driver stats, records, and ranking from CDN. Always fetches the *global* index (not partner-scoped) so stats reflect the driver's whole career, not just partner-affiliated activity.
225
258
 
226
- **`useDriverRating(steamId)`** — Single driver's rating from the partner ratings file.
259
+ **`useDriverCombos(steamId)`** — Per-(track, layout, car, game, version) combo list, partner-scoped via the provider's `partnerSlug`. Each entry: `{trackId, trackLayout, carId, game, gameVersion, lapCount, validLapCount, lastDrivenAt, personalBestMs, rank, totalDrivers, gapToLeaderMs, gapToNextMs}`. Sorted server-side by `lastDrivenAt` desc. Rank/gap fields refresh on the 5-min full pass on the partner CDN path; `lapCount` and `lastDrivenAt` are always fresh.
260
+
261
+ **`useDriverRating(steamId)`** — Single driver's rating from the partner ratings file (legacy, single game).
227
262
 
228
263
  **`useDriverRatings(options?)`** — All driver ratings for the rankings table.
229
- - `options.gameVersion` — EVO version filter (null/undefined for ACC)
264
+ - `options.game` — Game identifier (`'evo'`, `'acc'`, `'lmu'`)
265
+ - `options.gameVersion` — Version filter for versioned games
230
266
  - `options.enabled` — Whether to enable the query (default `true`)
231
267
  - Returns `{ data: { drivers: [...], driverCount }, isLoading, error }`
232
268
 
269
+ **`useDriverRatingsByGame(steamId)`** — Per-game rating chips for one driver. Reads default versions from the leaderboard index's `versions` metadata (no hardcode), queries each game's ratings file in parallel, and returns `[{game, label, rating, rank, totalDrivers}]` for games where the driver appears. Order matches the leaderboards page tabs (EVO, ACC, LMU). Drives the chip layout in `<StatsCards>`.
270
+
233
271
  **`useUpcomingEvents()`** — Upcoming competition rounds the current user is registered for (CDN-based). When `onFetchServerPassword` is provided to the provider, each event includes `serverAddress` and `serverPassword` fields.
234
272
 
235
273
  ## Notifications