@devrongx/games 0.4.13 → 0.4.15
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
|
@@ -172,6 +172,12 @@ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp
|
|
|
172
172
|
setBets(restored);
|
|
173
173
|
if (answeredCount >= 5) {
|
|
174
174
|
// 5+ questions answered — skip straight to game screen
|
|
175
|
+
// Expand cards that have no amount set so the picker is visible
|
|
176
|
+
const pickers: Record<number, number> = {};
|
|
177
|
+
for (const [mIdxStr, entry] of Object.entries(restored)) {
|
|
178
|
+
if (entry.amount === 0) pickers[Number(mIdxStr)] = entry.optionIdx;
|
|
179
|
+
}
|
|
180
|
+
setExpandedPicker(pickers);
|
|
175
181
|
setUserFlowState("game");
|
|
176
182
|
} else {
|
|
177
183
|
// Partial — restore into questions at the first unanswered question
|
|
@@ -184,22 +190,22 @@ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp
|
|
|
184
190
|
|
|
185
191
|
const saveDraftTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
186
192
|
|
|
187
|
-
//
|
|
188
|
-
const
|
|
193
|
+
// Unified debounced draft save — call with current bets (includes amounts)
|
|
194
|
+
const saveDraftDebounced = useCallback((currentBets: IUserBets) => {
|
|
189
195
|
if (!poolId || !config) return;
|
|
190
196
|
if (saveDraftTimerRef.current) clearTimeout(saveDraftTimerRef.current);
|
|
191
197
|
saveDraftTimerRef.current = setTimeout(async () => {
|
|
192
198
|
try {
|
|
193
199
|
const draft = config.markets
|
|
194
200
|
.map((m, mIdx) => {
|
|
195
|
-
const b =
|
|
201
|
+
const b = currentBets[mIdx];
|
|
196
202
|
if (!b || !m.backendChallengeId) return null;
|
|
197
203
|
const option = m.options[b.optionIdx];
|
|
198
204
|
if (!option) return null;
|
|
199
205
|
return {
|
|
200
206
|
challenge_id: m.backendChallengeId,
|
|
201
207
|
selected_option: option.label.toLowerCase().replace(/\s+/g, "_"),
|
|
202
|
-
coin_amount:
|
|
208
|
+
coin_amount: b.amount,
|
|
203
209
|
};
|
|
204
210
|
})
|
|
205
211
|
.filter((b): b is NonNullable<typeof b> => b !== null);
|
|
@@ -208,6 +214,11 @@ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp
|
|
|
208
214
|
}, 1000);
|
|
209
215
|
}, [poolId, config]);
|
|
210
216
|
|
|
217
|
+
// Called from PreMatchQuestions on each option pick
|
|
218
|
+
const handleQuestionSelectionChange = useCallback((selections: IUserBets) => {
|
|
219
|
+
saveDraftDebounced(selections);
|
|
220
|
+
}, [saveDraftDebounced]);
|
|
221
|
+
|
|
211
222
|
const betSummary = useMemo(
|
|
212
223
|
() => config ? calcBetSummary(bets, config) : { selectedCount: 0, compoundMultiplier: 0, totalEntry: 0, baseReward: 0, compoundedReward: 0, remainingBalance: 0, riskPercent: 0, potentialBalance: 0 },
|
|
213
224
|
[bets, config],
|
|
@@ -259,11 +270,12 @@ export const PreMatchBetsPopup = ({ poolId, matchId: _matchId, match: matchProp
|
|
|
259
270
|
}, []);
|
|
260
271
|
|
|
261
272
|
const handleAmountSelect = useCallback((mIdx: number, oIdx: number, amount: number) => {
|
|
262
|
-
setBets((prev) =>
|
|
263
|
-
...prev,
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
273
|
+
setBets((prev) => {
|
|
274
|
+
const next = { ...prev, [mIdx]: { optionIdx: oIdx, amount, parlaySlot: prev[mIdx]?.parlaySlot ?? null } };
|
|
275
|
+
saveDraftDebounced(next);
|
|
276
|
+
return next;
|
|
277
|
+
});
|
|
278
|
+
}, [saveDraftDebounced]);
|
|
267
279
|
|
|
268
280
|
const handleSubmitBets = useCallback(async () => {
|
|
269
281
|
if (!poolId || !config) return;
|