@devrongx/games 0.4.4 → 0.4.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devrongx/games",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "Game UI components for sports prediction markets",
5
5
  "license": "MIT",
6
6
  "main": "./src/index.ts",
@@ -21,8 +21,8 @@ import { PreMatchLive } from "./PreMatchLive";
21
21
  import { PreMatchResults } from "./PreMatchResults";
22
22
  import { FullLeaderboard } from "./FullLeaderboard";
23
23
  import { useTDPool, useTDPoolEntry, useTDLeaderboard } from "../../pools/hooks";
24
- import { useTDMatches } from "../../matches/useTDMatches";
25
24
  import { buildPMBConfig } from "../../pools/mapper";
25
+ import type { ITDMatch } from "../../matches/types";
26
26
  import { joinTDPool, placeTDBets } from "../../pools/actions";
27
27
  import type { ITDLeaderboardEntry } from "../../pools/types";
28
28
  import { TDPoolStatus } from "../../pools/types";
@@ -89,27 +89,28 @@ interface PreMatchBetsPopupProps {
89
89
  /** When provided, fetches real data. When absent, uses hardcoded CSK_VS_RCB demo. */
90
90
  poolId?: number;
91
91
  matchId?: number;
92
+ /** Pass the ITDMatch directly (from MatchCalendar's onPoolPress) to skip a redundant fetch. */
93
+ match?: ITDMatch;
92
94
  }
93
95
 
94
96
  // ─── Component ───────────────────────────────────────────────────────────────
95
97
 
96
- export const PreMatchBetsPopup = ({ poolId, matchId }: PreMatchBetsPopupProps) => {
98
+ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp }: PreMatchBetsPopupProps) => {
97
99
  const { activeView: storeView } = useGamePopupStore();
98
100
 
99
101
  // ── Real API data (only when poolId provided) ────────────────────────────
100
102
  const { pool, loading: poolLoading, refetch: refetchPool } = useTDPool(poolId ?? 0);
101
103
  const { data: entryData, refetch: refetchEntry } = useTDPoolEntry(poolId ?? 0);
102
104
  const { rankings, refetch: refetchLB } = useTDLeaderboard(poolId ?? 0, { pollMs: poolId ? 30_000 : 0 });
103
- const { matches } = useTDMatches(matchId !== undefined ? { tournamentId: undefined } : undefined);
104
- const match = useMemo(() => matches.find((m) => m.id === matchId) ?? null, [matches, matchId]);
105
105
 
106
106
  // ── Config: real or fallback ─────────────────────────────────────────────
107
+ // matchProp is passed directly from MatchCalendar's onPoolPress — no extra fetch needed
107
108
  const config = useMemo(() => {
108
- if (poolId && pool && match) {
109
- try { return buildPMBConfig(pool, match); } catch { /* fall through */ }
109
+ if (poolId && pool && matchProp) {
110
+ try { return buildPMBConfig(pool, matchProp); } catch { /* fall through */ }
110
111
  }
111
112
  return poolId ? null : CSK_VS_RCB_CHALLENGE;
112
- }, [poolId, pool, match]);
113
+ }, [poolId, pool, matchProp]);
113
114
 
114
115
  const fallbackPool = poolId ? null : CSK_VS_RCB_POOL;
115
116
 
@@ -209,7 +209,7 @@ function MatchGameSection({
209
209
 
210
210
  /* ── Match card with border shine animation ── */
211
211
 
212
- function MatchCard({ match, onPoolPress, partnerSource }: { match: ITDMatch; onPoolPress?: (pool: ITDPool) => void; partnerSource?: string }) {
212
+ function MatchCard({ match, onPoolPress, partnerSource }: { match: ITDMatch; onPoolPress?: (pool: ITDPool, match: ITDMatch) => void; partnerSource?: string }) {
213
213
  const isLive = match.status === MATCH_STATUS.LIVE;
214
214
  const isCompleted = match.status === MATCH_STATUS.COMPLETED;
215
215
  const time = match.scheduled_start_at ? formatTime(toLocalDate(match.scheduled_start_at)) : "";
@@ -333,7 +333,7 @@ function MatchCard({ match, onPoolPress, partnerSource }: { match: ITDMatch; onP
333
333
  <MatchGameSection
334
334
  matchId={match.id}
335
335
  isCompleted={isCompleted}
336
- onPoolPress={onPoolPress}
336
+ onPoolPress={onPoolPress ? (pool) => onPoolPress(pool, match) : undefined}
337
337
  partnerSource={partnerSource}
338
338
  />
339
339
  </motion.div>
@@ -343,7 +343,7 @@ function MatchCard({ match, onPoolPress, partnerSource }: { match: ITDMatch; onP
343
343
 
344
344
  /* ── Day column ── */
345
345
 
346
- function DayColumn({ day, index, onPoolPress, partnerSource }: { day: IMatchDay; index: number; onPoolPress?: (pool: ITDPool) => void; partnerSource?: string }) {
346
+ function DayColumn({ day, index, onPoolPress, partnerSource }: { day: IMatchDay; index: number; onPoolPress?: (pool: ITDPool, match: ITDMatch) => void; partnerSource?: string }) {
347
347
  const hasToday = day.label === "TODAY";
348
348
  const hasLive = day.matches.some((m) => m.status === MATCH_STATUS.LIVE);
349
349
  const allCompleted = day.matches.every((m) => m.status === MATCH_STATUS.COMPLETED);
@@ -395,8 +395,8 @@ function DayColumn({ day, index, onPoolPress, partnerSource }: { day: IMatchDay;
395
395
 
396
396
  interface MatchCalendarProps {
397
397
  tournamentId?: number;
398
- /** Called when user taps a pool pill. Pass poolId + matchId to open the popup. */
399
- onPoolPress?: (pool: ITDPool) => void;
398
+ /** Called when user taps a pool pill. Receives both the pool and its parent match. */
399
+ onPoolPress?: (pool: ITDPool, match: ITDMatch) => void;
400
400
  /** Filter pools to a specific partner source (e.g. "iamgame") */
401
401
  partnerSource?: string;
402
402
  }