@dubsdotapp/expo 0.2.44 → 0.2.46
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 +45 -4
- package/dist/index.d.mts +42 -4
- package/dist/index.d.ts +42 -4
- package/dist/index.js +182 -125
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +156 -100
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +9 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useUFCFighterDetail.ts +34 -0
- package/src/index.ts +2 -0
- package/src/types.ts +33 -1
- package/src/ui/game/CreateCustomGameSheet.tsx +75 -64
- package/src/ui/game/JoinGameSheet.tsx +47 -26
package/dist/index.js
CHANGED
|
@@ -72,7 +72,8 @@ __export(index_exports, {
|
|
|
72
72
|
useHasClaimed: () => useHasClaimed,
|
|
73
73
|
useJoinGame: () => useJoinGame,
|
|
74
74
|
useNetworkGames: () => useNetworkGames,
|
|
75
|
-
useUFCFightCard: () => useUFCFightCard
|
|
75
|
+
useUFCFightCard: () => useUFCFightCard,
|
|
76
|
+
useUFCFighterDetail: () => useUFCFighterDetail
|
|
76
77
|
});
|
|
77
78
|
module.exports = __toCommonJS(index_exports);
|
|
78
79
|
|
|
@@ -291,6 +292,13 @@ var DubsClient = class {
|
|
|
291
292
|
);
|
|
292
293
|
return res.events;
|
|
293
294
|
}
|
|
295
|
+
async getUFCFighterDetail(athleteId) {
|
|
296
|
+
const res = await this.request(
|
|
297
|
+
"GET",
|
|
298
|
+
`/ufc/fighters/${encodeURIComponent(athleteId)}`
|
|
299
|
+
);
|
|
300
|
+
return res.fighter;
|
|
301
|
+
}
|
|
294
302
|
// ── Game Lifecycle ──
|
|
295
303
|
async validateEvent(id) {
|
|
296
304
|
const res = await this.request(
|
|
@@ -583,7 +591,7 @@ function createSecureStoreStorage() {
|
|
|
583
591
|
}
|
|
584
592
|
|
|
585
593
|
// src/provider.tsx
|
|
586
|
-
var
|
|
594
|
+
var import_react17 = require("react");
|
|
587
595
|
|
|
588
596
|
// src/ui/theme.ts
|
|
589
597
|
var import_react = require("react");
|
|
@@ -1617,7 +1625,7 @@ function ManagedWalletProvider({
|
|
|
1617
1625
|
}
|
|
1618
1626
|
|
|
1619
1627
|
// src/ui/AuthGate.tsx
|
|
1620
|
-
var
|
|
1628
|
+
var import_react16 = __toESM(require("react"));
|
|
1621
1629
|
var import_react_native6 = require("react-native");
|
|
1622
1630
|
|
|
1623
1631
|
// src/hooks/useEvents.ts
|
|
@@ -2253,6 +2261,36 @@ function useUFCFightCard() {
|
|
|
2253
2261
|
return { data, loading, error, refetch: fetchData };
|
|
2254
2262
|
}
|
|
2255
2263
|
|
|
2264
|
+
// src/hooks/useUFCFighterDetail.ts
|
|
2265
|
+
var import_react15 = require("react");
|
|
2266
|
+
function useUFCFighterDetail(athleteId) {
|
|
2267
|
+
const { client } = useDubs();
|
|
2268
|
+
const [data, setData] = (0, import_react15.useState)(null);
|
|
2269
|
+
const [loading, setLoading] = (0, import_react15.useState)(false);
|
|
2270
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
2271
|
+
const fetchData = (0, import_react15.useCallback)(async () => {
|
|
2272
|
+
if (!athleteId) {
|
|
2273
|
+
setData(null);
|
|
2274
|
+
setLoading(false);
|
|
2275
|
+
return;
|
|
2276
|
+
}
|
|
2277
|
+
setLoading(true);
|
|
2278
|
+
setError(null);
|
|
2279
|
+
try {
|
|
2280
|
+
const result = await client.getUFCFighterDetail(athleteId);
|
|
2281
|
+
setData(result);
|
|
2282
|
+
} catch (err) {
|
|
2283
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
2284
|
+
} finally {
|
|
2285
|
+
setLoading(false);
|
|
2286
|
+
}
|
|
2287
|
+
}, [client, athleteId]);
|
|
2288
|
+
(0, import_react15.useEffect)(() => {
|
|
2289
|
+
fetchData();
|
|
2290
|
+
}, [fetchData]);
|
|
2291
|
+
return { data, loading, error, refetch: fetchData };
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2256
2294
|
// src/ui/AuthGate.tsx
|
|
2257
2295
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2258
2296
|
var DICEBEAR_STYLES = [
|
|
@@ -2281,9 +2319,9 @@ function AuthGate({
|
|
|
2281
2319
|
}) {
|
|
2282
2320
|
const { client } = useDubs();
|
|
2283
2321
|
const auth = useAuth();
|
|
2284
|
-
const [phase, setPhase] = (0,
|
|
2285
|
-
const [registrationPhase, setRegistrationPhase] = (0,
|
|
2286
|
-
(0,
|
|
2322
|
+
const [phase, setPhase] = (0, import_react16.useState)("init");
|
|
2323
|
+
const [registrationPhase, setRegistrationPhase] = (0, import_react16.useState)(false);
|
|
2324
|
+
(0, import_react16.useEffect)(() => {
|
|
2287
2325
|
let cancelled = false;
|
|
2288
2326
|
(async () => {
|
|
2289
2327
|
try {
|
|
@@ -2309,18 +2347,18 @@ function AuthGate({
|
|
|
2309
2347
|
cancelled = true;
|
|
2310
2348
|
};
|
|
2311
2349
|
}, []);
|
|
2312
|
-
(0,
|
|
2350
|
+
(0, import_react16.useEffect)(() => {
|
|
2313
2351
|
if (auth.status === "needsRegistration") setRegistrationPhase(true);
|
|
2314
2352
|
}, [auth.status]);
|
|
2315
|
-
(0,
|
|
2353
|
+
(0, import_react16.useEffect)(() => {
|
|
2316
2354
|
if (auth.token) onSaveToken(auth.token);
|
|
2317
2355
|
}, [auth.token]);
|
|
2318
|
-
const retry = (0,
|
|
2356
|
+
const retry = (0, import_react16.useCallback)(() => {
|
|
2319
2357
|
setRegistrationPhase(false);
|
|
2320
2358
|
auth.reset();
|
|
2321
2359
|
auth.authenticate();
|
|
2322
2360
|
}, [auth]);
|
|
2323
|
-
const handleRegister = (0,
|
|
2361
|
+
const handleRegister = (0, import_react16.useCallback)(
|
|
2324
2362
|
(username, referralCode, avatarUrl) => {
|
|
2325
2363
|
auth.register(username, referralCode, avatarUrl);
|
|
2326
2364
|
},
|
|
@@ -2399,7 +2437,7 @@ function DefaultErrorScreen({ error, onRetry, appName, accentColor }) {
|
|
|
2399
2437
|
function StepIndicator({ currentStep }) {
|
|
2400
2438
|
const t = useDubsTheme();
|
|
2401
2439
|
const steps = [0, 1, 2, 3];
|
|
2402
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: s.stepRow, children: steps.map((i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: s.stepRow, children: steps.map((i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react16.default.Fragment, { children: [
|
|
2403
2441
|
i > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: [s.stepLine, { backgroundColor: i <= currentStep ? t.success : t.border }] }),
|
|
2404
2442
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2405
2443
|
import_react_native6.View,
|
|
@@ -2423,19 +2461,19 @@ function DefaultRegistrationScreen({
|
|
|
2423
2461
|
}) {
|
|
2424
2462
|
const t = useDubsTheme();
|
|
2425
2463
|
const accent = accentColor || t.accent;
|
|
2426
|
-
const [step, setStep] = (0,
|
|
2427
|
-
const [avatarSeed, setAvatarSeed] = (0,
|
|
2428
|
-
const [avatarStyle, setAvatarStyle] = (0,
|
|
2429
|
-
const [showStyles, setShowStyles] = (0,
|
|
2430
|
-
const [username, setUsername] = (0,
|
|
2431
|
-
const [referralCode, setReferralCode] = (0,
|
|
2432
|
-
const [checking, setChecking] = (0,
|
|
2433
|
-
const [availability, setAvailability] = (0,
|
|
2434
|
-
const debounceRef = (0,
|
|
2435
|
-
const fadeAnim = (0,
|
|
2436
|
-
const slideAnim = (0,
|
|
2464
|
+
const [step, setStep] = (0, import_react16.useState)(0);
|
|
2465
|
+
const [avatarSeed, setAvatarSeed] = (0, import_react16.useState)(generateSeed);
|
|
2466
|
+
const [avatarStyle, setAvatarStyle] = (0, import_react16.useState)("adventurer");
|
|
2467
|
+
const [showStyles, setShowStyles] = (0, import_react16.useState)(false);
|
|
2468
|
+
const [username, setUsername] = (0, import_react16.useState)("");
|
|
2469
|
+
const [referralCode, setReferralCode] = (0, import_react16.useState)("");
|
|
2470
|
+
const [checking, setChecking] = (0, import_react16.useState)(false);
|
|
2471
|
+
const [availability, setAvailability] = (0, import_react16.useState)(null);
|
|
2472
|
+
const debounceRef = (0, import_react16.useRef)(null);
|
|
2473
|
+
const fadeAnim = (0, import_react16.useRef)(new import_react_native6.Animated.Value(1)).current;
|
|
2474
|
+
const slideAnim = (0, import_react16.useRef)(new import_react_native6.Animated.Value(0)).current;
|
|
2437
2475
|
const avatarUrl = getAvatarUrl(avatarStyle, avatarSeed);
|
|
2438
|
-
(0,
|
|
2476
|
+
(0, import_react16.useEffect)(() => {
|
|
2439
2477
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
2440
2478
|
const trimmed = username.trim();
|
|
2441
2479
|
if (trimmed.length < 3) {
|
|
@@ -2458,7 +2496,7 @@ function DefaultRegistrationScreen({
|
|
|
2458
2496
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
2459
2497
|
};
|
|
2460
2498
|
}, [username, client]);
|
|
2461
|
-
const animateToStep = (0,
|
|
2499
|
+
const animateToStep = (0, import_react16.useCallback)((newStep) => {
|
|
2462
2500
|
const dir = newStep > step ? 1 : -1;
|
|
2463
2501
|
import_react_native6.Keyboard.dismiss();
|
|
2464
2502
|
import_react_native6.Animated.parallel([
|
|
@@ -2757,7 +2795,7 @@ var s = import_react_native6.StyleSheet.create({
|
|
|
2757
2795
|
|
|
2758
2796
|
// src/provider.tsx
|
|
2759
2797
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2760
|
-
var DubsContext = (0,
|
|
2798
|
+
var DubsContext = (0, import_react17.createContext)(null);
|
|
2761
2799
|
function DubsProvider({
|
|
2762
2800
|
apiKey,
|
|
2763
2801
|
children,
|
|
@@ -2779,11 +2817,11 @@ function DubsProvider({
|
|
|
2779
2817
|
const baseUrl = baseUrlOverride || config.baseUrl;
|
|
2780
2818
|
const rpcUrl = rpcUrlOverride || config.rpcUrl;
|
|
2781
2819
|
const cluster = config.cluster;
|
|
2782
|
-
const client = (0,
|
|
2783
|
-
const connection = (0,
|
|
2784
|
-
const storage = (0,
|
|
2785
|
-
const [uiConfig, setUiConfig] = (0,
|
|
2786
|
-
(0,
|
|
2820
|
+
const client = (0, import_react17.useMemo)(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
2821
|
+
const connection = (0, import_react17.useMemo)(() => new import_web34.Connection(rpcUrl, { commitment: "confirmed" }), [rpcUrl]);
|
|
2822
|
+
const storage = (0, import_react17.useMemo)(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
|
|
2823
|
+
const [uiConfig, setUiConfig] = (0, import_react17.useState)(null);
|
|
2824
|
+
(0, import_react17.useEffect)(() => {
|
|
2787
2825
|
client.getAppConfig().then((config2) => {
|
|
2788
2826
|
console.log("[DubsProvider] UI config loaded:", JSON.stringify(config2));
|
|
2789
2827
|
setUiConfig(config2);
|
|
@@ -2864,11 +2902,11 @@ function ManagedInner({
|
|
|
2864
2902
|
children
|
|
2865
2903
|
}) {
|
|
2866
2904
|
const managedDisconnect = useDisconnect();
|
|
2867
|
-
const disconnect = (0,
|
|
2905
|
+
const disconnect = (0, import_react17.useCallback)(async () => {
|
|
2868
2906
|
client.setToken(null);
|
|
2869
2907
|
await managedDisconnect?.();
|
|
2870
2908
|
}, [client, managedDisconnect]);
|
|
2871
|
-
const value = (0,
|
|
2909
|
+
const value = (0, import_react17.useMemo)(
|
|
2872
2910
|
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig }),
|
|
2873
2911
|
[client, wallet, connection, appName, network, disconnect, uiConfig]
|
|
2874
2912
|
);
|
|
@@ -2904,13 +2942,13 @@ function ExternalWalletProvider({
|
|
|
2904
2942
|
uiConfig,
|
|
2905
2943
|
children
|
|
2906
2944
|
}) {
|
|
2907
|
-
const disconnect = (0,
|
|
2945
|
+
const disconnect = (0, import_react17.useCallback)(async () => {
|
|
2908
2946
|
client.setToken(null);
|
|
2909
2947
|
await storage.deleteItem(STORAGE_KEYS.JWT_TOKEN).catch(() => {
|
|
2910
2948
|
});
|
|
2911
2949
|
await wallet.disconnect?.();
|
|
2912
2950
|
}, [client, storage, wallet]);
|
|
2913
|
-
const value = (0,
|
|
2951
|
+
const value = (0, import_react17.useMemo)(
|
|
2914
2952
|
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig }),
|
|
2915
2953
|
[client, wallet, connection, appName, network, disconnect, uiConfig]
|
|
2916
2954
|
);
|
|
@@ -2935,19 +2973,19 @@ function ExternalWalletProvider({
|
|
|
2935
2973
|
) });
|
|
2936
2974
|
}
|
|
2937
2975
|
function useDubs() {
|
|
2938
|
-
const ctx = (0,
|
|
2976
|
+
const ctx = (0, import_react17.useContext)(DubsContext);
|
|
2939
2977
|
if (!ctx) {
|
|
2940
2978
|
throw new Error("useDubs must be used within a <DubsProvider>");
|
|
2941
2979
|
}
|
|
2942
2980
|
return ctx;
|
|
2943
2981
|
}
|
|
2944
2982
|
function useAppConfig() {
|
|
2945
|
-
const ctx = (0,
|
|
2983
|
+
const ctx = (0, import_react17.useContext)(DubsContext);
|
|
2946
2984
|
return ctx?.uiConfig || {};
|
|
2947
2985
|
}
|
|
2948
2986
|
|
|
2949
2987
|
// src/ui/UserProfileCard.tsx
|
|
2950
|
-
var
|
|
2988
|
+
var import_react18 = require("react");
|
|
2951
2989
|
var import_react_native7 = require("react-native");
|
|
2952
2990
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2953
2991
|
function truncateAddress(address, chars = 4) {
|
|
@@ -2967,7 +3005,7 @@ function UserProfileCard({
|
|
|
2967
3005
|
memberSince
|
|
2968
3006
|
}) {
|
|
2969
3007
|
const t = useDubsTheme();
|
|
2970
|
-
const imageUri = (0,
|
|
3008
|
+
const imageUri = (0, import_react18.useMemo)(
|
|
2971
3009
|
() => avatarUrl || `https://api.dicebear.com/9.x/avataaars/png?seed=${walletAddress}&size=128`,
|
|
2972
3010
|
[avatarUrl, walletAddress]
|
|
2973
3011
|
);
|
|
@@ -3160,7 +3198,7 @@ var styles3 = import_react_native8.StyleSheet.create({
|
|
|
3160
3198
|
});
|
|
3161
3199
|
|
|
3162
3200
|
// src/ui/game/GamePoster.tsx
|
|
3163
|
-
var
|
|
3201
|
+
var import_react19 = require("react");
|
|
3164
3202
|
var import_react_native9 = require("react-native");
|
|
3165
3203
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3166
3204
|
function computeCountdown(lockTimestamp) {
|
|
@@ -3210,7 +3248,7 @@ function GamePoster({ game, ImageComponent }) {
|
|
|
3210
3248
|
] });
|
|
3211
3249
|
}
|
|
3212
3250
|
function TeamLogoInternal({ url, size, Img }) {
|
|
3213
|
-
const [failed, setFailed] = (0,
|
|
3251
|
+
const [failed, setFailed] = (0, import_react19.useState)(false);
|
|
3214
3252
|
if (!url || failed) {
|
|
3215
3253
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native9.View, { style: [styles4.logoPlaceholder, { width: size, height: size, borderRadius: size / 2 }] });
|
|
3216
3254
|
}
|
|
@@ -3311,7 +3349,7 @@ var styles4 = import_react_native9.StyleSheet.create({
|
|
|
3311
3349
|
});
|
|
3312
3350
|
|
|
3313
3351
|
// src/ui/game/LivePoolsCard.tsx
|
|
3314
|
-
var
|
|
3352
|
+
var import_react20 = require("react");
|
|
3315
3353
|
var import_react_native10 = require("react-native");
|
|
3316
3354
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3317
3355
|
function LivePoolsCard({
|
|
@@ -3327,7 +3365,7 @@ function LivePoolsCard({
|
|
|
3327
3365
|
const homePool = game.homePool || 0;
|
|
3328
3366
|
const awayPool = game.awayPool || 0;
|
|
3329
3367
|
const totalPool = game.totalPool || 0;
|
|
3330
|
-
const { homePercent, awayPercent, homeOdds, awayOdds } = (0,
|
|
3368
|
+
const { homePercent, awayPercent, homeOdds, awayOdds } = (0, import_react20.useMemo)(() => {
|
|
3331
3369
|
return {
|
|
3332
3370
|
homePercent: totalPool > 0 ? homePool / totalPool * 100 : 50,
|
|
3333
3371
|
awayPercent: totalPool > 0 ? awayPool / totalPool * 100 : 50,
|
|
@@ -3390,7 +3428,7 @@ var styles5 = import_react_native10.StyleSheet.create({
|
|
|
3390
3428
|
});
|
|
3391
3429
|
|
|
3392
3430
|
// src/ui/game/PickWinnerCard.tsx
|
|
3393
|
-
var
|
|
3431
|
+
var import_react21 = require("react");
|
|
3394
3432
|
var import_react_native11 = require("react-native");
|
|
3395
3433
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3396
3434
|
function PickWinnerCard({
|
|
@@ -3408,7 +3446,7 @@ function PickWinnerCard({
|
|
|
3408
3446
|
const totalPool = game.totalPool || 0;
|
|
3409
3447
|
const homePool = game.homePool || 0;
|
|
3410
3448
|
const awayPool = game.awayPool || 0;
|
|
3411
|
-
const { homeOdds, awayOdds, homeBets, awayBets } = (0,
|
|
3449
|
+
const { homeOdds, awayOdds, homeBets, awayBets } = (0, import_react21.useMemo)(() => ({
|
|
3412
3450
|
homeOdds: homePool > 0 ? (totalPool / homePool).toFixed(2) : "\u2014",
|
|
3413
3451
|
awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : "\u2014",
|
|
3414
3452
|
homeBets: bettors.filter((b) => b.team === "home").length,
|
|
@@ -3461,7 +3499,7 @@ function TeamOption({
|
|
|
3461
3499
|
ImageComponent,
|
|
3462
3500
|
t
|
|
3463
3501
|
}) {
|
|
3464
|
-
const [imgFailed, setImgFailed] = (0,
|
|
3502
|
+
const [imgFailed, setImgFailed] = (0, import_react21.useState)(false);
|
|
3465
3503
|
const Img = ImageComponent || require("react-native").Image;
|
|
3466
3504
|
const showImage = imageUrl && !imgFailed;
|
|
3467
3505
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
@@ -3502,7 +3540,7 @@ var styles6 = import_react_native11.StyleSheet.create({
|
|
|
3502
3540
|
});
|
|
3503
3541
|
|
|
3504
3542
|
// src/ui/game/PlayersCard.tsx
|
|
3505
|
-
var
|
|
3543
|
+
var import_react22 = require("react");
|
|
3506
3544
|
var import_react_native12 = require("react-native");
|
|
3507
3545
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3508
3546
|
function truncateWallet(addr, chars) {
|
|
@@ -3551,7 +3589,7 @@ function BettorRow({
|
|
|
3551
3589
|
ImageComponent,
|
|
3552
3590
|
t
|
|
3553
3591
|
}) {
|
|
3554
|
-
const [imgFailed, setImgFailed] = (0,
|
|
3592
|
+
const [imgFailed, setImgFailed] = (0, import_react22.useState)(false);
|
|
3555
3593
|
const Img = ImageComponent || require("react-native").Image;
|
|
3556
3594
|
const showAvatar = bettor.avatar && !imgFailed;
|
|
3557
3595
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native12.View, { style: [styles7.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }], children: [
|
|
@@ -3578,7 +3616,7 @@ var styles7 = import_react_native12.StyleSheet.create({
|
|
|
3578
3616
|
});
|
|
3579
3617
|
|
|
3580
3618
|
// src/ui/game/JoinGameButton.tsx
|
|
3581
|
-
var
|
|
3619
|
+
var import_react23 = require("react");
|
|
3582
3620
|
var import_react_native13 = require("react-native");
|
|
3583
3621
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
3584
3622
|
var STATUS_LABELS = {
|
|
@@ -3589,7 +3627,7 @@ var STATUS_LABELS = {
|
|
|
3589
3627
|
};
|
|
3590
3628
|
function JoinGameButton({ game, walletAddress, selectedTeam, status, onJoin }) {
|
|
3591
3629
|
const t = useDubsTheme();
|
|
3592
|
-
const alreadyJoined = (0,
|
|
3630
|
+
const alreadyJoined = (0, import_react23.useMemo)(() => {
|
|
3593
3631
|
if (!walletAddress) return false;
|
|
3594
3632
|
return (game.bettors || []).some((b) => b.wallet === walletAddress);
|
|
3595
3633
|
}, [game.bettors, walletAddress]);
|
|
@@ -3630,7 +3668,7 @@ var styles8 = import_react_native13.StyleSheet.create({
|
|
|
3630
3668
|
});
|
|
3631
3669
|
|
|
3632
3670
|
// src/ui/game/CreateCustomGameSheet.tsx
|
|
3633
|
-
var
|
|
3671
|
+
var import_react24 = require("react");
|
|
3634
3672
|
var import_react_native14 = require("react-native");
|
|
3635
3673
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3636
3674
|
var STATUS_LABELS2 = {
|
|
@@ -3650,23 +3688,24 @@ function CreateCustomGameSheet({
|
|
|
3650
3688
|
metadata,
|
|
3651
3689
|
onAmountChange,
|
|
3652
3690
|
onSuccess,
|
|
3653
|
-
onError
|
|
3691
|
+
onError,
|
|
3692
|
+
isPoolModeEnabled = false
|
|
3654
3693
|
}) {
|
|
3655
3694
|
const t = useDubsTheme();
|
|
3656
3695
|
const { wallet } = useDubs();
|
|
3657
3696
|
const mutation = useCreateCustomGame();
|
|
3658
|
-
const [selectedAmount, setSelectedAmount] = (0,
|
|
3659
|
-
const [customAmount, setCustomAmount] = (0,
|
|
3660
|
-
const [isCustom, setIsCustom] = (0,
|
|
3661
|
-
const overlayOpacity = (0,
|
|
3662
|
-
(0,
|
|
3697
|
+
const [selectedAmount, setSelectedAmount] = (0, import_react24.useState)(null);
|
|
3698
|
+
const [customAmount, setCustomAmount] = (0, import_react24.useState)("");
|
|
3699
|
+
const [isCustom, setIsCustom] = (0, import_react24.useState)(false);
|
|
3700
|
+
const overlayOpacity = (0, import_react24.useRef)(new import_react_native14.Animated.Value(0)).current;
|
|
3701
|
+
(0, import_react24.useEffect)(() => {
|
|
3663
3702
|
import_react_native14.Animated.timing(overlayOpacity, {
|
|
3664
3703
|
toValue: visible ? 1 : 0,
|
|
3665
3704
|
duration: 250,
|
|
3666
3705
|
useNativeDriver: true
|
|
3667
3706
|
}).start();
|
|
3668
3707
|
}, [visible, overlayOpacity]);
|
|
3669
|
-
(0,
|
|
3708
|
+
(0, import_react24.useEffect)(() => {
|
|
3670
3709
|
if (visible) {
|
|
3671
3710
|
setSelectedAmount(defaultAmount ?? null);
|
|
3672
3711
|
setCustomAmount("");
|
|
@@ -3674,7 +3713,7 @@ function CreateCustomGameSheet({
|
|
|
3674
3713
|
mutation.reset();
|
|
3675
3714
|
}
|
|
3676
3715
|
}, [visible]);
|
|
3677
|
-
(0,
|
|
3716
|
+
(0, import_react24.useEffect)(() => {
|
|
3678
3717
|
if (mutation.status === "success" && mutation.data) {
|
|
3679
3718
|
onSuccess?.(mutation.data);
|
|
3680
3719
|
const timer = setTimeout(() => {
|
|
@@ -3683,23 +3722,23 @@ function CreateCustomGameSheet({
|
|
|
3683
3722
|
return () => clearTimeout(timer);
|
|
3684
3723
|
}
|
|
3685
3724
|
}, [mutation.status, mutation.data]);
|
|
3686
|
-
(0,
|
|
3725
|
+
(0, import_react24.useEffect)(() => {
|
|
3687
3726
|
if (mutation.status === "error" && mutation.error) {
|
|
3688
3727
|
onError?.(mutation.error);
|
|
3689
3728
|
}
|
|
3690
3729
|
}, [mutation.status, mutation.error]);
|
|
3691
|
-
const handlePresetSelect = (0,
|
|
3730
|
+
const handlePresetSelect = (0, import_react24.useCallback)((amount) => {
|
|
3692
3731
|
setSelectedAmount(amount);
|
|
3693
3732
|
setIsCustom(false);
|
|
3694
3733
|
setCustomAmount("");
|
|
3695
3734
|
onAmountChange?.(amount);
|
|
3696
3735
|
}, [onAmountChange]);
|
|
3697
|
-
const handleCustomSelect = (0,
|
|
3736
|
+
const handleCustomSelect = (0, import_react24.useCallback)(() => {
|
|
3698
3737
|
setIsCustom(true);
|
|
3699
3738
|
setSelectedAmount(null);
|
|
3700
3739
|
onAmountChange?.(null);
|
|
3701
3740
|
}, [onAmountChange]);
|
|
3702
|
-
const handleCustomAmountChange = (0,
|
|
3741
|
+
const handleCustomAmountChange = (0, import_react24.useCallback)((text) => {
|
|
3703
3742
|
const cleaned = text.replace(/[^0-9.]/g, "").replace(/(\..*?)\..*/g, "$1");
|
|
3704
3743
|
setCustomAmount(cleaned);
|
|
3705
3744
|
const parsed = parseFloat(cleaned);
|
|
@@ -3709,24 +3748,25 @@ function CreateCustomGameSheet({
|
|
|
3709
3748
|
}, [onAmountChange]);
|
|
3710
3749
|
const effectiveAmount = selectedAmount;
|
|
3711
3750
|
const playerCount = maxPlayers || 2;
|
|
3712
|
-
const
|
|
3751
|
+
const finalAmount = isPoolModeEnabled ? defaultAmount ?? 0.1 : effectiveAmount;
|
|
3752
|
+
const pot = finalAmount ? finalAmount * playerCount : 0;
|
|
3713
3753
|
const winnerTakes = pot * (1 - fee / 100);
|
|
3714
3754
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
3715
|
-
const canCreate =
|
|
3716
|
-
const handleCreate = (0,
|
|
3717
|
-
if (!
|
|
3755
|
+
const canCreate = finalAmount !== null && finalAmount > 0 && !isMutating && mutation.status !== "success";
|
|
3756
|
+
const handleCreate = (0, import_react24.useCallback)(async () => {
|
|
3757
|
+
if (!finalAmount || !wallet.publicKey) return;
|
|
3718
3758
|
try {
|
|
3719
3759
|
await mutation.execute({
|
|
3720
3760
|
playerWallet: wallet.publicKey.toBase58(),
|
|
3721
3761
|
teamChoice: "home",
|
|
3722
|
-
wagerAmount:
|
|
3762
|
+
wagerAmount: finalAmount,
|
|
3723
3763
|
title,
|
|
3724
3764
|
maxPlayers,
|
|
3725
3765
|
metadata
|
|
3726
3766
|
});
|
|
3727
3767
|
} catch {
|
|
3728
3768
|
}
|
|
3729
|
-
}, [
|
|
3769
|
+
}, [finalAmount, wallet.publicKey, mutation.execute, title, maxPlayers, metadata]);
|
|
3730
3770
|
const statusLabel = STATUS_LABELS2[mutation.status] || "";
|
|
3731
3771
|
const playersLabel = playerCount === 2 ? "2 (1v1)" : `${playerCount} players`;
|
|
3732
3772
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -3746,10 +3786,10 @@ function CreateCustomGameSheet({
|
|
|
3746
3786
|
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.View, { style: styles9.sheetPositioner, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native14.View, { style: [styles9.sheet, { backgroundColor: t.background }], children: [
|
|
3747
3787
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.View, { style: styles9.handleRow, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.View, { style: [styles9.handle, { backgroundColor: t.textMuted }] }) }),
|
|
3748
3788
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native14.View, { style: styles9.header, children: [
|
|
3749
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.headerTitle, { color: t.text }], children: "New Game" }),
|
|
3789
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.headerTitle, { color: t.text }], children: isPoolModeEnabled ? "Create Pool" : "New Game" }),
|
|
3750
3790
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.TouchableOpacity, { onPress: onDismiss, activeOpacity: 0.8, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.closeButton, { color: t.textMuted }], children: "\u2715" }) })
|
|
3751
3791
|
] }),
|
|
3752
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native14.View, { style: styles9.section, children: [
|
|
3792
|
+
!isPoolModeEnabled && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native14.View, { style: styles9.section, children: [
|
|
3753
3793
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.sectionLabel, { color: t.textSecondary }], children: "Buy-In Amount" }),
|
|
3754
3794
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native14.View, { style: styles9.chipsRow, children: [
|
|
3755
3795
|
presetAmounts.map((amount) => {
|
|
@@ -3801,20 +3841,20 @@ function CreateCustomGameSheet({
|
|
|
3801
3841
|
] }),
|
|
3802
3842
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native14.View, { style: [styles9.summaryCard, { backgroundColor: t.surface, borderColor: t.border }], children: [
|
|
3803
3843
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native14.View, { style: styles9.summaryRow, children: [
|
|
3804
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.summaryLabel, { color: t.textMuted }], children: "
|
|
3805
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.summaryValue, { color: t.text }], children:
|
|
3844
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.summaryLabel, { color: t.textMuted }], children: "Buy-in" }),
|
|
3845
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.summaryValue, { color: t.text }], children: finalAmount ? `${finalAmount} SOL` : "\u2014" })
|
|
3806
3846
|
] }),
|
|
3807
3847
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.View, { style: [styles9.summarySep, { backgroundColor: t.border }] }),
|
|
3808
3848
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native14.View, { style: styles9.summaryRow, children: [
|
|
3809
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.summaryLabel, { color: t.textMuted }], children: "Players" }),
|
|
3810
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.summaryValue, { color: t.text }], children: playersLabel })
|
|
3849
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.summaryLabel, { color: t.textMuted }], children: isPoolModeEnabled ? "Max players" : "Players" }),
|
|
3850
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.summaryValue, { color: t.text }], children: isPoolModeEnabled ? playerCount : playersLabel })
|
|
3811
3851
|
] }),
|
|
3812
3852
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.View, { style: [styles9.summarySep, { backgroundColor: t.border }] }),
|
|
3813
3853
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native14.View, { style: styles9.summaryRow, children: [
|
|
3814
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.summaryLabel, { color: t.textMuted }], children: "Winner Takes" }),
|
|
3854
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.summaryLabel, { color: t.textMuted }], children: isPoolModeEnabled ? "Max pot" : "Winner Takes" }),
|
|
3815
3855
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native14.View, { style: styles9.winnerCol, children: [
|
|
3816
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.summaryValue, { color: t.success }], children:
|
|
3817
|
-
|
|
3856
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.summaryValue, { color: t.success }], children: finalAmount ? `${(finalAmount * playerCount * (1 - fee / 100)).toFixed(4)} SOL` : "\u2014" }),
|
|
3857
|
+
finalAmount ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native14.Text, { style: [styles9.feeNote, { color: t.textDim }], children: [
|
|
3818
3858
|
fee,
|
|
3819
3859
|
"% platform fee"
|
|
3820
3860
|
] }) : null
|
|
@@ -3835,7 +3875,7 @@ function CreateCustomGameSheet({
|
|
|
3835
3875
|
children: isMutating ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native14.View, { style: styles9.ctaLoading, children: [
|
|
3836
3876
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.ActivityIndicator, { size: "small", color: "#FFFFFF" }),
|
|
3837
3877
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: styles9.ctaText, children: statusLabel })
|
|
3838
|
-
] }) : mutation.status === "success" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: styles9.ctaText, children: STATUS_LABELS2.success }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.ctaText, !canCreate && { opacity: 0.5 }], children: effectiveAmount ? `Create Game \u2014 ${effectiveAmount} SOL` : "Select buy-in amount" })
|
|
3878
|
+
] }) : mutation.status === "success" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: styles9.ctaText, children: isPoolModeEnabled ? "Pool Created!" : STATUS_LABELS2.success }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native14.Text, { style: [styles9.ctaText, !canCreate && { opacity: 0.5 }], children: isPoolModeEnabled ? `Create Pool \u2014 ${finalAmount} SOL` : effectiveAmount ? `Create Game \u2014 ${effectiveAmount} SOL` : "Select buy-in amount" })
|
|
3839
3879
|
}
|
|
3840
3880
|
)
|
|
3841
3881
|
] }) })
|
|
@@ -3982,7 +4022,7 @@ var styles9 = import_react_native14.StyleSheet.create({
|
|
|
3982
4022
|
});
|
|
3983
4023
|
|
|
3984
4024
|
// src/ui/game/JoinGameSheet.tsx
|
|
3985
|
-
var
|
|
4025
|
+
var import_react25 = require("react");
|
|
3986
4026
|
var import_react_native15 = require("react-native");
|
|
3987
4027
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3988
4028
|
var STATUS_LABELS3 = {
|
|
@@ -4001,28 +4041,29 @@ function JoinGameSheet({
|
|
|
4001
4041
|
homeColor = "#3B82F6",
|
|
4002
4042
|
awayColor = "#EF4444",
|
|
4003
4043
|
onSuccess,
|
|
4004
|
-
onError
|
|
4044
|
+
onError,
|
|
4045
|
+
isPoolModeEnabled = false
|
|
4005
4046
|
}) {
|
|
4006
4047
|
const t = useDubsTheme();
|
|
4007
4048
|
const { wallet } = useDubs();
|
|
4008
4049
|
const mutation = useJoinGame();
|
|
4009
4050
|
const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
|
|
4010
|
-
const [selectedTeam, setSelectedTeam] = (0,
|
|
4011
|
-
const overlayOpacity = (0,
|
|
4012
|
-
(0,
|
|
4051
|
+
const [selectedTeam, setSelectedTeam] = (0, import_react25.useState)(null);
|
|
4052
|
+
const overlayOpacity = (0, import_react25.useRef)(new import_react_native15.Animated.Value(0)).current;
|
|
4053
|
+
(0, import_react25.useEffect)(() => {
|
|
4013
4054
|
import_react_native15.Animated.timing(overlayOpacity, {
|
|
4014
4055
|
toValue: visible ? 1 : 0,
|
|
4015
4056
|
duration: 250,
|
|
4016
4057
|
useNativeDriver: true
|
|
4017
4058
|
}).start();
|
|
4018
4059
|
}, [visible, overlayOpacity]);
|
|
4019
|
-
(0,
|
|
4060
|
+
(0, import_react25.useEffect)(() => {
|
|
4020
4061
|
if (visible) {
|
|
4021
|
-
setSelectedTeam(isCustomGame ? "away" : null);
|
|
4062
|
+
setSelectedTeam(isPoolModeEnabled ? "home" : isCustomGame ? "away" : null);
|
|
4022
4063
|
mutation.reset();
|
|
4023
4064
|
}
|
|
4024
4065
|
}, [visible]);
|
|
4025
|
-
(0,
|
|
4066
|
+
(0, import_react25.useEffect)(() => {
|
|
4026
4067
|
if (mutation.status === "success" && mutation.data) {
|
|
4027
4068
|
onSuccess?.(mutation.data);
|
|
4028
4069
|
const timer = setTimeout(() => {
|
|
@@ -4031,7 +4072,7 @@ function JoinGameSheet({
|
|
|
4031
4072
|
return () => clearTimeout(timer);
|
|
4032
4073
|
}
|
|
4033
4074
|
}, [mutation.status, mutation.data]);
|
|
4034
|
-
(0,
|
|
4075
|
+
(0, import_react25.useEffect)(() => {
|
|
4035
4076
|
if (mutation.status === "error" && mutation.error) {
|
|
4036
4077
|
onError?.(mutation.error);
|
|
4037
4078
|
}
|
|
@@ -4042,7 +4083,7 @@ function JoinGameSheet({
|
|
|
4042
4083
|
const homePool = game.homePool || 0;
|
|
4043
4084
|
const awayPool = game.awayPool || 0;
|
|
4044
4085
|
const buyIn = game.buyIn;
|
|
4045
|
-
const { homeOdds, awayOdds, homeBets, awayBets } = (0,
|
|
4086
|
+
const { homeOdds, awayOdds, homeBets, awayBets } = (0, import_react25.useMemo)(() => ({
|
|
4046
4087
|
homeOdds: homePool > 0 ? (totalPool / homePool).toFixed(2) : "\u2014",
|
|
4047
4088
|
awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : "\u2014",
|
|
4048
4089
|
homeBets: bettors.filter((b) => b.team === "home").length,
|
|
@@ -4054,14 +4095,14 @@ function JoinGameSheet({
|
|
|
4054
4095
|
const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";
|
|
4055
4096
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
4056
4097
|
const selectedName = selectedTeam === "home" ? homeName : selectedTeam === "away" ? awayName : "\u2014";
|
|
4057
|
-
const alreadyJoined = (0,
|
|
4098
|
+
const alreadyJoined = (0, import_react25.useMemo)(() => {
|
|
4058
4099
|
if (!wallet.publicKey) return false;
|
|
4059
4100
|
const addr = wallet.publicKey.toBase58();
|
|
4060
4101
|
return bettors.some((b) => b.wallet === addr);
|
|
4061
4102
|
}, [bettors, wallet.publicKey]);
|
|
4062
4103
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
4063
4104
|
const canJoin = selectedTeam !== null && !isMutating && mutation.status !== "success" && !alreadyJoined;
|
|
4064
|
-
const handleJoin = (0,
|
|
4105
|
+
const handleJoin = (0, import_react25.useCallback)(async () => {
|
|
4065
4106
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
4066
4107
|
try {
|
|
4067
4108
|
await mutation.execute({
|
|
@@ -4091,10 +4132,10 @@ function JoinGameSheet({
|
|
|
4091
4132
|
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.View, { style: styles10.sheetPositioner, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.View, { style: [styles10.sheet, { backgroundColor: t.background }], children: [
|
|
4092
4133
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.View, { style: styles10.handleRow, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.View, { style: [styles10.handle, { backgroundColor: t.textMuted }] }) }),
|
|
4093
4134
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.View, { style: styles10.header, children: [
|
|
4094
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.headerTitle, { color: t.text }], children: "Join Game" }),
|
|
4135
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.headerTitle, { color: t.text }], children: isPoolModeEnabled ? "Join Pool" : "Join Game" }),
|
|
4095
4136
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.TouchableOpacity, { onPress: onDismiss, activeOpacity: 0.8, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.closeButton, { color: t.textMuted }], children: "\u2715" }) })
|
|
4096
4137
|
] }),
|
|
4097
|
-
!isCustomGame && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.View, { style: styles10.section, children: [
|
|
4138
|
+
!isCustomGame && !isPoolModeEnabled && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.View, { style: styles10.section, children: [
|
|
4098
4139
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.sectionLabel, { color: t.textSecondary }], children: "Pick Your Side" }),
|
|
4099
4140
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.View, { style: styles10.teamsRow, children: [
|
|
4100
4141
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
@@ -4136,25 +4177,40 @@ function JoinGameSheet({
|
|
|
4136
4177
|
] })
|
|
4137
4178
|
] }),
|
|
4138
4179
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.View, { style: [styles10.summarySep, { backgroundColor: t.border }] }),
|
|
4139
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
4140
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4180
|
+
isPoolModeEnabled ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
4181
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.View, { style: styles10.summaryRow, children: [
|
|
4182
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.summaryLabel, { color: t.textMuted }], children: "Players in" }),
|
|
4183
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.summaryValue, { color: t.text }], children: bettors.length })
|
|
4184
|
+
] }),
|
|
4185
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.View, { style: [styles10.summarySep, { backgroundColor: t.border }] }),
|
|
4186
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.View, { style: styles10.summaryRow, children: [
|
|
4187
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.summaryLabel, { color: t.textMuted }], children: "Current pot" }),
|
|
4188
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.Text, { style: [styles10.summaryValue, { color: t.success }], children: [
|
|
4189
|
+
totalPool,
|
|
4190
|
+
" SOL"
|
|
4191
|
+
] })
|
|
4192
|
+
] })
|
|
4193
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
4194
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.View, { style: styles10.summaryRow, children: [
|
|
4195
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.summaryLabel, { color: t.textMuted }], children: "Your side" }),
|
|
4196
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.summaryValue, { color: t.text }], children: selectedName })
|
|
4197
|
+
] }),
|
|
4198
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.View, { style: [styles10.summarySep, { backgroundColor: t.border }] }),
|
|
4199
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.View, { style: styles10.summaryRow, children: [
|
|
4200
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.summaryLabel, { color: t.textMuted }], children: "Total pool" }),
|
|
4201
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.Text, { style: [styles10.summaryValue, { color: t.text }], children: [
|
|
4202
|
+
poolAfterJoin,
|
|
4203
|
+
" SOL"
|
|
4204
|
+
] })
|
|
4205
|
+
] }),
|
|
4206
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.View, { style: [styles10.summarySep, { backgroundColor: t.border }] }),
|
|
4207
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.View, { style: styles10.summaryRow, children: [
|
|
4208
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.summaryLabel, { color: t.textMuted }], children: "Potential winnings" }),
|
|
4209
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.summaryValue, { color: t.success }], children: potentialWinnings !== "\u2014" ? `${potentialWinnings} SOL` : "\u2014" })
|
|
4149
4210
|
] })
|
|
4150
|
-
] }),
|
|
4151
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.View, { style: [styles10.summarySep, { backgroundColor: t.border }] }),
|
|
4152
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.View, { style: styles10.summaryRow, children: [
|
|
4153
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.summaryLabel, { color: t.textMuted }], children: "Potential winnings" }),
|
|
4154
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.summaryValue, { color: t.success }], children: potentialWinnings !== "\u2014" ? `${potentialWinnings} SOL` : "\u2014" })
|
|
4155
4211
|
] })
|
|
4156
4212
|
] }),
|
|
4157
|
-
alreadyJoined && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.View, { style: [styles10.errorBox, { backgroundColor: t.surface, borderColor: t.border }], children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.errorText, { color: t.textMuted }], children: "You've already joined this game." }) }),
|
|
4213
|
+
alreadyJoined && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.View, { style: [styles10.errorBox, { backgroundColor: t.surface, borderColor: t.border }], children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.errorText, { color: t.textMuted }], children: isPoolModeEnabled ? "You've already joined this pool." : "You've already joined this game." }) }),
|
|
4158
4214
|
mutation.error && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.View, { style: [styles10.errorBox, { backgroundColor: t.errorBg, borderColor: t.errorBorder }], children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.errorText, { color: t.errorText }], children: mutation.error.message }) }),
|
|
4159
4215
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
4160
4216
|
import_react_native15.TouchableOpacity,
|
|
@@ -4169,7 +4225,7 @@ function JoinGameSheet({
|
|
|
4169
4225
|
children: isMutating ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native15.View, { style: styles10.ctaLoading, children: [
|
|
4170
4226
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.ActivityIndicator, { size: "small", color: "#FFFFFF" }),
|
|
4171
4227
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: styles10.ctaText, children: statusLabel })
|
|
4172
|
-
] }) : mutation.status === "success" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: styles10.ctaText, children: STATUS_LABELS3.success }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.ctaText, !canJoin && { opacity: 0.5 }], children: alreadyJoined ? "Already Joined" : selectedTeam ? `Join Game \u2014 ${buyIn} SOL` : "Pick a side to join" })
|
|
4228
|
+
] }) : mutation.status === "success" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: styles10.ctaText, children: isPoolModeEnabled ? "Joined!" : STATUS_LABELS3.success }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native15.Text, { style: [styles10.ctaText, !canJoin && { opacity: 0.5 }], children: alreadyJoined ? "Already Joined" : isPoolModeEnabled ? `Join Pool \u2014 ${buyIn} SOL` : selectedTeam ? `Join Game \u2014 ${buyIn} SOL` : "Pick a side to join" })
|
|
4173
4229
|
}
|
|
4174
4230
|
)
|
|
4175
4231
|
] }) })
|
|
@@ -4190,7 +4246,7 @@ function TeamButton({
|
|
|
4190
4246
|
ImageComponent,
|
|
4191
4247
|
t
|
|
4192
4248
|
}) {
|
|
4193
|
-
const [imgFailed, setImgFailed] = (0,
|
|
4249
|
+
const [imgFailed, setImgFailed] = (0, import_react25.useState)(false);
|
|
4194
4250
|
const Img = ImageComponent || require("react-native").Image;
|
|
4195
4251
|
const showImage = imageUrl && !imgFailed;
|
|
4196
4252
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
@@ -4367,7 +4423,7 @@ var styles10 = import_react_native15.StyleSheet.create({
|
|
|
4367
4423
|
});
|
|
4368
4424
|
|
|
4369
4425
|
// src/ui/game/ClaimPrizeSheet.tsx
|
|
4370
|
-
var
|
|
4426
|
+
var import_react26 = require("react");
|
|
4371
4427
|
var import_react_native16 = require("react-native");
|
|
4372
4428
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
4373
4429
|
var STATUS_LABELS4 = {
|
|
@@ -4388,18 +4444,18 @@ function ClaimPrizeSheet({
|
|
|
4388
4444
|
const t = useDubsTheme();
|
|
4389
4445
|
const { wallet } = useDubs();
|
|
4390
4446
|
const mutation = useClaim();
|
|
4391
|
-
const overlayOpacity = (0,
|
|
4392
|
-
const celebrationScale = (0,
|
|
4393
|
-
const celebrationOpacity = (0,
|
|
4394
|
-
const [showCelebration, setShowCelebration] = (0,
|
|
4395
|
-
(0,
|
|
4447
|
+
const overlayOpacity = (0, import_react26.useRef)(new import_react_native16.Animated.Value(0)).current;
|
|
4448
|
+
const celebrationScale = (0, import_react26.useRef)(new import_react_native16.Animated.Value(0)).current;
|
|
4449
|
+
const celebrationOpacity = (0, import_react26.useRef)(new import_react_native16.Animated.Value(0)).current;
|
|
4450
|
+
const [showCelebration, setShowCelebration] = (0, import_react26.useState)(false);
|
|
4451
|
+
(0, import_react26.useEffect)(() => {
|
|
4396
4452
|
import_react_native16.Animated.timing(overlayOpacity, {
|
|
4397
4453
|
toValue: visible ? 1 : 0,
|
|
4398
4454
|
duration: 250,
|
|
4399
4455
|
useNativeDriver: true
|
|
4400
4456
|
}).start();
|
|
4401
4457
|
}, [visible, overlayOpacity]);
|
|
4402
|
-
(0,
|
|
4458
|
+
(0, import_react26.useEffect)(() => {
|
|
4403
4459
|
if (visible) {
|
|
4404
4460
|
mutation.reset();
|
|
4405
4461
|
setShowCelebration(false);
|
|
@@ -4407,7 +4463,7 @@ function ClaimPrizeSheet({
|
|
|
4407
4463
|
celebrationOpacity.setValue(0);
|
|
4408
4464
|
}
|
|
4409
4465
|
}, [visible]);
|
|
4410
|
-
(0,
|
|
4466
|
+
(0, import_react26.useEffect)(() => {
|
|
4411
4467
|
if (mutation.status === "success" && mutation.data) {
|
|
4412
4468
|
setShowCelebration(true);
|
|
4413
4469
|
import_react_native16.Animated.parallel([
|
|
@@ -4430,14 +4486,14 @@ function ClaimPrizeSheet({
|
|
|
4430
4486
|
return () => clearTimeout(timer);
|
|
4431
4487
|
}
|
|
4432
4488
|
}, [mutation.status, mutation.data]);
|
|
4433
|
-
(0,
|
|
4489
|
+
(0, import_react26.useEffect)(() => {
|
|
4434
4490
|
if (mutation.status === "error" && mutation.error) {
|
|
4435
4491
|
onError?.(mutation.error);
|
|
4436
4492
|
}
|
|
4437
4493
|
}, [mutation.status, mutation.error]);
|
|
4438
4494
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
4439
4495
|
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
4440
|
-
const handleClaim = (0,
|
|
4496
|
+
const handleClaim = (0, import_react26.useCallback)(async () => {
|
|
4441
4497
|
if (!wallet.publicKey) return;
|
|
4442
4498
|
try {
|
|
4443
4499
|
await mutation.execute({
|
|
@@ -4670,7 +4726,7 @@ var styles11 = import_react_native16.StyleSheet.create({
|
|
|
4670
4726
|
});
|
|
4671
4727
|
|
|
4672
4728
|
// src/ui/game/ClaimButton.tsx
|
|
4673
|
-
var
|
|
4729
|
+
var import_react27 = require("react");
|
|
4674
4730
|
var import_react_native17 = require("react-native");
|
|
4675
4731
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
4676
4732
|
function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
@@ -4678,9 +4734,9 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
4678
4734
|
const { wallet } = useDubs();
|
|
4679
4735
|
const game = useGame(gameId);
|
|
4680
4736
|
const claimStatus = useHasClaimed(gameId);
|
|
4681
|
-
const [sheetVisible, setSheetVisible] = (0,
|
|
4737
|
+
const [sheetVisible, setSheetVisible] = (0, import_react27.useState)(false);
|
|
4682
4738
|
const walletAddress = wallet.publicKey?.toBase58() ?? null;
|
|
4683
|
-
const myBet = (0,
|
|
4739
|
+
const myBet = (0, import_react27.useMemo)(() => {
|
|
4684
4740
|
if (!walletAddress || !game.data?.bettors) return null;
|
|
4685
4741
|
return game.data.bettors.find((b) => b.wallet === walletAddress) ?? null;
|
|
4686
4742
|
}, [walletAddress, game.data?.bettors]);
|
|
@@ -4689,7 +4745,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
4689
4745
|
const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
|
|
4690
4746
|
const isEligible = myBet != null && isResolved && (isWinner || isRefund);
|
|
4691
4747
|
const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
|
|
4692
|
-
const handleSuccess = (0,
|
|
4748
|
+
const handleSuccess = (0, import_react27.useCallback)(
|
|
4693
4749
|
(result) => {
|
|
4694
4750
|
claimStatus.refetch();
|
|
4695
4751
|
onSuccess?.(result);
|
|
@@ -4818,6 +4874,7 @@ var styles12 = import_react_native17.StyleSheet.create({
|
|
|
4818
4874
|
useHasClaimed,
|
|
4819
4875
|
useJoinGame,
|
|
4820
4876
|
useNetworkGames,
|
|
4821
|
-
useUFCFightCard
|
|
4877
|
+
useUFCFightCard,
|
|
4878
|
+
useUFCFighterDetail
|
|
4822
4879
|
});
|
|
4823
4880
|
//# sourceMappingURL=index.js.map
|