@dubsdotapp/expo 0.2.6 → 0.2.8
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 +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useCreateCustomGame.ts +2 -0
- package/src/ui/game/CreateCustomGameSheet.tsx +14 -6
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@ export interface CreateCustomGameMutationResult {
|
|
|
8
8
|
gameAddress: string;
|
|
9
9
|
signature: string;
|
|
10
10
|
explorerUrl: string;
|
|
11
|
+
buyIn: number;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export function useCreateCustomGame() {
|
|
@@ -62,6 +63,7 @@ export function useCreateCustomGame() {
|
|
|
62
63
|
gameAddress: createResult.gameAddress,
|
|
63
64
|
signature,
|
|
64
65
|
explorerUrl,
|
|
66
|
+
buyIn: params.wagerAmount,
|
|
65
67
|
};
|
|
66
68
|
|
|
67
69
|
setData(result);
|
|
@@ -23,7 +23,9 @@ export interface CreateCustomGameSheetProps {
|
|
|
23
23
|
maxPlayers?: number;
|
|
24
24
|
fee?: number;
|
|
25
25
|
presetAmounts?: number[];
|
|
26
|
+
defaultAmount?: number;
|
|
26
27
|
metadata?: Record<string, unknown>;
|
|
28
|
+
onAmountChange?: (amount: number | null) => void;
|
|
27
29
|
onSuccess?: (result: CreateCustomGameMutationResult) => void;
|
|
28
30
|
onError?: (error: Error) => void;
|
|
29
31
|
}
|
|
@@ -41,8 +43,10 @@ export function CreateCustomGameSheet({
|
|
|
41
43
|
title,
|
|
42
44
|
maxPlayers = 2,
|
|
43
45
|
fee = 5,
|
|
44
|
-
presetAmounts = [0.1, 0.5, 1],
|
|
46
|
+
presetAmounts = [0.01, 0.1, 0.5, 1],
|
|
47
|
+
defaultAmount = 0.01,
|
|
45
48
|
metadata,
|
|
49
|
+
onAmountChange,
|
|
46
50
|
onSuccess,
|
|
47
51
|
onError,
|
|
48
52
|
}: CreateCustomGameSheetProps) {
|
|
@@ -68,7 +72,7 @@ export function CreateCustomGameSheet({
|
|
|
68
72
|
// Reset state when sheet opens
|
|
69
73
|
useEffect(() => {
|
|
70
74
|
if (visible) {
|
|
71
|
-
setSelectedAmount(null);
|
|
75
|
+
setSelectedAmount(defaultAmount ?? null);
|
|
72
76
|
setCustomAmount('');
|
|
73
77
|
setIsCustom(false);
|
|
74
78
|
mutation.reset();
|
|
@@ -97,20 +101,24 @@ export function CreateCustomGameSheet({
|
|
|
97
101
|
setSelectedAmount(amount);
|
|
98
102
|
setIsCustom(false);
|
|
99
103
|
setCustomAmount('');
|
|
100
|
-
|
|
104
|
+
onAmountChange?.(amount);
|
|
105
|
+
}, [onAmountChange]);
|
|
101
106
|
|
|
102
107
|
const handleCustomSelect = useCallback(() => {
|
|
103
108
|
setIsCustom(true);
|
|
104
109
|
setSelectedAmount(null);
|
|
105
|
-
|
|
110
|
+
onAmountChange?.(null);
|
|
111
|
+
}, [onAmountChange]);
|
|
106
112
|
|
|
107
113
|
const handleCustomAmountChange = useCallback((text: string) => {
|
|
108
114
|
// Allow only numbers and single decimal point
|
|
109
115
|
const cleaned = text.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');
|
|
110
116
|
setCustomAmount(cleaned);
|
|
111
117
|
const parsed = parseFloat(cleaned);
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
const amount = parsed > 0 ? parsed : null;
|
|
119
|
+
setSelectedAmount(amount);
|
|
120
|
+
onAmountChange?.(amount);
|
|
121
|
+
}, [onAmountChange]);
|
|
114
122
|
|
|
115
123
|
const effectiveAmount = selectedAmount;
|
|
116
124
|
const playerCount = maxPlayers || 2;
|