@devrongx/games 0.4.28 → 0.4.30

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devrongx/games",
3
- "version": "0.4.28",
3
+ "version": "0.4.30",
4
4
  "description": "Game UI components for sports prediction markets",
5
5
  "license": "MIT",
6
6
  "main": "./src/index.ts",
@@ -221,9 +221,12 @@ export const PreMatchGame = ({
221
221
 
222
222
  // ── Helper: is a market's options clickable? ─────────────────────────────
223
223
  const isMarketInteractive = useCallback((mIdx: number) => {
224
- if (!hasSubmitted) return true; // fresh state: all markets interactive
225
- return editingMarkets.has(mIdx); // post-submit: only editing markets
226
- }, [hasSubmitted, editingMarkets]);
224
+ if (!hasSubmitted) return true;
225
+ // Post-submit: markets without a submitted bet stay interactive (new bets allowed)
226
+ if (!submittedBets?.[mIdx]) return true;
227
+ // Markets with a submitted bet: only interactive when in editing mode
228
+ return editingMarkets.has(mIdx);
229
+ }, [hasSubmitted, submittedBets, editingMarkets]);
227
230
 
228
231
  // ── Render ───────────────────────────────────────────────────────────────
229
232
 
@@ -338,32 +341,16 @@ export const PreMatchGame = ({
338
341
  );
339
342
  })()}
340
343
 
341
- {/* Per-market action: edit / ignore / confirm+cancel */}
344
+ {/* Per-market header action: pencil or ignore */}
342
345
  {hasSubmittedBet ? (
343
- isEditingThis ? (
344
- <div className="flex items-center gap-1.5 flex-shrink-0">
345
- <button onClick={(e) => { e.stopPropagation(); onCancelMarketEdit?.(mIdx); }}
346
- className="w-[22px] h-[22px] rounded-full flex items-center justify-center bg-white/[0.06]">
347
- <X size={12} className="text-white/50" />
348
- </button>
349
- {isDirty && (
350
- <button onClick={(e) => { e.stopPropagation(); onConfirmMarketEdit?.(mIdx); }}
351
- className="w-[22px] h-[22px] rounded-full flex items-center justify-center"
352
- style={{ background: "rgba(34,227,232,0.15)", border: "1px solid rgba(34,227,232,0.3)" }}>
353
- {editSubmitting === mIdx
354
- ? <Loader2 size={12} className="animate-spin text-[#22E3E8]" />
355
- : <Check size={12} className="text-[#22E3E8]" />}
356
- </button>
357
- )}
358
- </div>
359
- ) : (
346
+ !isEditingThis && (
360
347
  <button onClick={(e) => { e.stopPropagation(); onEditMarket?.(mIdx); }}
361
348
  className="flex-shrink-0 w-[22px] h-[22px] rounded-full flex items-center justify-center bg-white/[0.04]">
362
349
  <Pencil size={11} className="text-white/40" />
363
350
  </button>
364
351
  )
365
352
  ) : (
366
- onToggleIgnore && (
353
+ !selection && onToggleIgnore && (
367
354
  <button onClick={(e) => { e.stopPropagation(); onToggleIgnore(mIdx); }}
368
355
  className="flex-shrink-0 w-[22px] h-[22px] rounded-full flex items-center justify-center"
369
356
  style={{ background: ignoredMarkets.has(mIdx) ? "rgba(34,227,232,0.1)" : "transparent" }}>
@@ -541,6 +528,48 @@ export const PreMatchGame = ({
541
528
  </motion.div>
542
529
  )}
543
530
  </AnimatePresence>
531
+
532
+ {/* Per-market save/cancel — new bet */}
533
+ {hasSubmitted && !hasSubmittedBet && selection && (
534
+ <div className="col-span-2 flex items-center gap-4 mt-1.5 px-0.5">
535
+ {betAmount > 0 && (
536
+ <button
537
+ onClick={(e) => { e.stopPropagation(); onConfirmMarketEdit?.(mIdx); }}
538
+ disabled={editSubmitting === mIdx}
539
+ className="text-[11px] font-semibold"
540
+ style={{ ...OUTFIT, color: "#22E3E8", opacity: editSubmitting === mIdx ? 0.5 : 1 }}>
541
+ {editSubmitting === mIdx ? "Saving..." : "Save bet"}
542
+ </button>
543
+ )}
544
+ <button
545
+ onClick={(e) => { e.stopPropagation(); onCancelMarketEdit?.(mIdx); }}
546
+ className="text-[11px] font-semibold"
547
+ style={{ ...OUTFIT, color: "rgba(255,255,255,0.4)" }}>
548
+ Cancel
549
+ </button>
550
+ </div>
551
+ )}
552
+
553
+ {/* Per-market save/cancel — editing existing bet */}
554
+ {hasSubmitted && isEditingThis && (
555
+ <div className="col-span-2 flex items-center gap-4 mt-1.5 px-0.5">
556
+ {isDirty && (
557
+ <button
558
+ onClick={(e) => { e.stopPropagation(); onConfirmMarketEdit?.(mIdx); }}
559
+ disabled={editSubmitting === mIdx}
560
+ className="text-[11px] font-semibold"
561
+ style={{ ...OUTFIT, color: "#22E3E8", opacity: editSubmitting === mIdx ? 0.5 : 1 }}>
562
+ {editSubmitting === mIdx ? "Saving..." : "Change bet"}
563
+ </button>
564
+ )}
565
+ <button
566
+ onClick={(e) => { e.stopPropagation(); onCancelMarketEdit?.(mIdx); }}
567
+ className="text-[11px] font-semibold"
568
+ style={{ ...OUTFIT, color: "rgba(255,255,255,0.4)" }}>
569
+ Cancel
570
+ </button>
571
+ </div>
572
+ )}
544
573
  </div>
545
574
  </motion.div>
546
575
  )}