@devrongx/games 0.4.13 → 0.4.14
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
|
@@ -184,22 +184,22 @@ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp
|
|
|
184
184
|
|
|
185
185
|
const saveDraftTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
186
186
|
|
|
187
|
-
//
|
|
188
|
-
const
|
|
187
|
+
// Unified debounced draft save — call with current bets (includes amounts)
|
|
188
|
+
const saveDraftDebounced = useCallback((currentBets: IUserBets) => {
|
|
189
189
|
if (!poolId || !config) return;
|
|
190
190
|
if (saveDraftTimerRef.current) clearTimeout(saveDraftTimerRef.current);
|
|
191
191
|
saveDraftTimerRef.current = setTimeout(async () => {
|
|
192
192
|
try {
|
|
193
193
|
const draft = config.markets
|
|
194
194
|
.map((m, mIdx) => {
|
|
195
|
-
const b =
|
|
195
|
+
const b = currentBets[mIdx];
|
|
196
196
|
if (!b || !m.backendChallengeId) return null;
|
|
197
197
|
const option = m.options[b.optionIdx];
|
|
198
198
|
if (!option) return null;
|
|
199
199
|
return {
|
|
200
200
|
challenge_id: m.backendChallengeId,
|
|
201
201
|
selected_option: option.label.toLowerCase().replace(/\s+/g, "_"),
|
|
202
|
-
coin_amount:
|
|
202
|
+
coin_amount: b.amount,
|
|
203
203
|
};
|
|
204
204
|
})
|
|
205
205
|
.filter((b): b is NonNullable<typeof b> => b !== null);
|
|
@@ -208,6 +208,11 @@ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp
|
|
|
208
208
|
}, 1000);
|
|
209
209
|
}, [poolId, config]);
|
|
210
210
|
|
|
211
|
+
// Called from PreMatchQuestions on each option pick
|
|
212
|
+
const handleQuestionSelectionChange = useCallback((selections: IUserBets) => {
|
|
213
|
+
saveDraftDebounced(selections);
|
|
214
|
+
}, [saveDraftDebounced]);
|
|
215
|
+
|
|
211
216
|
const betSummary = useMemo(
|
|
212
217
|
() => config ? calcBetSummary(bets, config) : { selectedCount: 0, compoundMultiplier: 0, totalEntry: 0, baseReward: 0, compoundedReward: 0, remainingBalance: 0, riskPercent: 0, potentialBalance: 0 },
|
|
213
218
|
[bets, config],
|
|
@@ -259,11 +264,12 @@ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp
|
|
|
259
264
|
}, []);
|
|
260
265
|
|
|
261
266
|
const handleAmountSelect = useCallback((mIdx: number, oIdx: number, amount: number) => {
|
|
262
|
-
setBets((prev) =>
|
|
263
|
-
...prev,
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
+
setBets((prev) => {
|
|
268
|
+
const next = { ...prev, [mIdx]: { optionIdx: oIdx, amount, parlaySlot: prev[mIdx]?.parlaySlot ?? null } };
|
|
269
|
+
saveDraftDebounced(next);
|
|
270
|
+
return next;
|
|
271
|
+
});
|
|
272
|
+
}, [saveDraftDebounced]);
|
|
267
273
|
|
|
268
274
|
const handleSubmitBets = useCallback(async () => {
|
|
269
275
|
if (!poolId || !config) return;
|