@dubsdotapp/expo 0.2.43 → 0.2.45
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/dist/index.d.mts +34 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +123 -88
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -60
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +11 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useUFCFightCard.ts +29 -0
- package/src/index.ts +5 -0
- package/src/types.ts +36 -0
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -35,6 +35,7 @@ import type {
|
|
|
35
35
|
CheckUsernameResult,
|
|
36
36
|
LiveScore,
|
|
37
37
|
UiConfig,
|
|
38
|
+
UFCEvent,
|
|
38
39
|
} from './types';
|
|
39
40
|
|
|
40
41
|
export interface DubsClientConfig {
|
|
@@ -145,6 +146,16 @@ export class DubsClient {
|
|
|
145
146
|
return res.match;
|
|
146
147
|
}
|
|
147
148
|
|
|
149
|
+
// ── UFC ──
|
|
150
|
+
|
|
151
|
+
async getUFCFightCard(): Promise<UFCEvent[]> {
|
|
152
|
+
const res = await this.request<{ success: true; events: UFCEvent[] }>(
|
|
153
|
+
'GET',
|
|
154
|
+
'/ufc/fightcard',
|
|
155
|
+
);
|
|
156
|
+
return res.events;
|
|
157
|
+
}
|
|
158
|
+
|
|
148
159
|
// ── Game Lifecycle ──
|
|
149
160
|
|
|
150
161
|
async validateEvent(id: string): Promise<ValidateEventResult> {
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
2
|
+
import { useDubs } from '../provider';
|
|
3
|
+
import type { UFCEvent, QueryResult } from '../types';
|
|
4
|
+
|
|
5
|
+
export function useUFCFightCard(): QueryResult<UFCEvent[]> {
|
|
6
|
+
const { client } = useDubs();
|
|
7
|
+
const [data, setData] = useState<UFCEvent[] | null>(null);
|
|
8
|
+
const [loading, setLoading] = useState(true);
|
|
9
|
+
const [error, setError] = useState<Error | null>(null);
|
|
10
|
+
|
|
11
|
+
const fetchData = useCallback(async () => {
|
|
12
|
+
setLoading(true);
|
|
13
|
+
setError(null);
|
|
14
|
+
try {
|
|
15
|
+
const result = await client.getUFCFightCard();
|
|
16
|
+
setData(result);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
19
|
+
} finally {
|
|
20
|
+
setLoading(false);
|
|
21
|
+
}
|
|
22
|
+
}, [client]);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
fetchData();
|
|
26
|
+
}, [fetchData]);
|
|
27
|
+
|
|
28
|
+
return { data, loading, error, refetch: fetchData };
|
|
29
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -59,6 +59,10 @@ export type {
|
|
|
59
59
|
LiveScore,
|
|
60
60
|
LiveScoreCompetitor,
|
|
61
61
|
UiConfig,
|
|
62
|
+
UFCFighter,
|
|
63
|
+
UFCData,
|
|
64
|
+
UFCFight,
|
|
65
|
+
UFCEvent,
|
|
62
66
|
} from './types';
|
|
63
67
|
|
|
64
68
|
// Provider
|
|
@@ -84,6 +88,7 @@ export {
|
|
|
84
88
|
useClaim,
|
|
85
89
|
useHasClaimed,
|
|
86
90
|
useAuth,
|
|
91
|
+
useUFCFightCard,
|
|
87
92
|
} from './hooks';
|
|
88
93
|
export type {
|
|
89
94
|
CreateGameMutationResult,
|
package/src/types.ts
CHANGED
|
@@ -415,6 +415,42 @@ export interface LiveScore {
|
|
|
415
415
|
};
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
+
// ── UFC Fight Card ──
|
|
419
|
+
|
|
420
|
+
export interface UFCFighter {
|
|
421
|
+
name: string;
|
|
422
|
+
headshotUrl: string | null;
|
|
423
|
+
flagUrl: string | null;
|
|
424
|
+
country: string | null;
|
|
425
|
+
abbreviation: string;
|
|
426
|
+
record: string | null;
|
|
427
|
+
winner: boolean;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export interface UFCData {
|
|
431
|
+
currentRound: number;
|
|
432
|
+
totalRounds: number;
|
|
433
|
+
clock: string;
|
|
434
|
+
fightState: 'pre' | 'in' | 'post';
|
|
435
|
+
statusDetail: string;
|
|
436
|
+
statusShortDetail?: string;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export interface UFCFight {
|
|
440
|
+
id: string | null;
|
|
441
|
+
home: UFCFighter;
|
|
442
|
+
away: UFCFighter;
|
|
443
|
+
weightClass: string | null;
|
|
444
|
+
status: string;
|
|
445
|
+
ufcData: UFCData | null;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export interface UFCEvent {
|
|
449
|
+
eventName: string;
|
|
450
|
+
date: string | null;
|
|
451
|
+
fights: UFCFight[];
|
|
452
|
+
}
|
|
453
|
+
|
|
418
454
|
// ── UI Config (developer branding) ──
|
|
419
455
|
|
|
420
456
|
export interface UiConfig {
|