Skip to content

Feature/issue 954 betting pending state#971

Open
Dami24-hub wants to merge 3 commits into
Netwalls:mainfrom
Dami24-hub:feature/issue-954-betting-pending-state
Open

Feature/issue 954 betting pending state#971
Dami24-hub wants to merge 3 commits into
Netwalls:mainfrom
Dami24-hub:feature/issue-954-betting-pending-state

Conversation

@Dami24-hub

Copy link
Copy Markdown
Contributor

This PR resolves issue #954 by enhancing the user experience of the BettingInterface component during active, in-flight ledger transactions. Previously, the interface lacked adequate visual feedback during processing, which introduced a risk of accidental double-submissions.

With this update, the interface dynamically tracks the isLoading state from the usePlaceBet hook to disable form controls, display a loading indicator, and manage transactional toast notifications for pending, successful, and failed states.

Key Changes
UI State Management: Bound the disabled property of all inputs, selection fields, and submission buttons within BettingInterface to the isLoading state of usePlaceBet().

In-Flight Feedback: Added a loading spinner and a "Confirming transaction..." text overlay/indicator inside the UI while a transaction is processing.

Notification Integration:

Triggered a pending toast notification: "Transaction submitted. Waiting for ledger confirmation..." upon form submission.

Triggered a success toast notification and invoked onBetPlaced() upon a successful ledger response.

Triggered an error toast notification with the server/ledger error message if the transaction fails.

Form Lifecycle: Added logic to automatically reset the form fields to their initial states only upon a successful transaction, while preserving user input on failure to allow for quick corrections.

Acceptance Criteria Verified
[x] All form inputs and buttons are completely disabled during an in-flight transaction.

[x] Pending toast is visibly dispatched while waiting for ledger confirmation.

[x] Double-submission is programmatically blocked via input disabling and form submission guards.

[x] Success and error toasts render correctly depending on the hook's resolution.

[x] Verified functionality via manual browser testing.

Deployment / Regression Risks
Risk: High latency in ledger confirmation keeping the UI locked.

Mitigation: The implementation relies directly on the existing usePlaceBet hook's state management, which includes native timeout and error handling to ensure the form re-enables if a request times out.

**Closes #954 **

  - Requires admin auth and panics if protocol is not paused
  - Drains full BALANCE via token transfer, resets balance to 0
  - Appends entry to WITHDRAWAL_LOG, emits EmergencyDrain event
  - Returns total amount drained in stroops
  - Adds unit tests: success, not-paused guard, unauthorized guard
- Add app/layout.tsx with viewport meta and overflow-x:hidden body
- Add app/globals.css with Tailwind directives and 44px touch target base styles
- Implement Navbar with hamburger menu on <768px (md:hidden pattern)
- Implement Home Page with responsive tab bar and 1-col mobile grid
- Implement Market Detail Page: FighterCards use flex-col on mobile,
  flex-row on md+; BettingInterface is full-width below chart
- Implement Portfolio Page with PortfolioTable using overflow-x-auto
  scoped to its container to prevent page-level horizontal scroll
- Implement all stub components: FighterCard, BettingInterface,
  PortfolioTable, MarketList, MarketCard, MarketOddsBar, MarketOddsChart,
  MarketStatusBadge, CountdownTimer, LoadingSkeleton, ClaimButton,
  WalletConnectButton, BetAmountInput
- Add tsconfig.json, next.config.js, tailwind.config.ts, postcss.config.js
- Fix useMarkets.ts type reference (MarketFilters -> MarketQueryParams)
- Implement useWallet and usePortfolio hooks
- Add .gitignore to exclude node_modules, .next, dist, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[frontend] Add transaction pending state to betting UI

1 participant