Commit df5d5e9
chore(runway): cherry-pick fix(predict): cp-7.62.0 show correct action buttons when NFL game ends (#24899)
- fix(predict): cp-7.62.0 show correct action buttons when NFL game ends
(#24897)
## **Description**
**Problem**: When an NFL game ended and the market was closed, the feed
card was still showing bet buttons instead of the "Claim winnings"
button. However, the game details screen correctly showed the claim
button.
**Root Cause**:
1. `PredictSportCardFooter` only fetched active positions via
`usePredictPositions({ marketId })` and tried to filter them locally for
claimable positions
2. The game details screen (`PredictMarketDetails`) correctly fetched
claimable positions separately using `usePredictPositions({ marketId,
claimable: true })` which retrieves them from the Redux selector
3. Additionally, when `market.status` hadn't synced yet but
`game.status` was already "ended", bet buttons could still appear
**Solution**:
1. Added a separate `usePredictPositions({ claimable: true })` call in
`PredictSportCardFooter` to properly fetch claimable positions (matching
the details screen approach)
2. Added `market.game?.status === 'ended'` check to both
`PredictSportCardFooter` and `PredictGameDetailsFooter` to handle cases
where game status updates before market status
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes: N/A (found during manual testing)
## **Manual testing steps**
```gherkin
Feature: Predict NFL game action buttons
Scenario: user sees claim button after game ends
Given user has placed a bet on an NFL game
And the game has ended with a winner
When user views the game card in the Predict feed
Then the card displays "Claim winnings" button (not bet buttons)
When user taps on the game card to view details
Then the details screen footer also shows "Claim winnings" button
```
## **Screenshots/Recordings**
### **Before**
Feed card showed "HOU · 0¢" and "NE · 100¢" bet buttons after game ended
### **After**
Feed card shows "Claim winnings" button matching the details screen
behavior
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Ensures cards and details show the correct actions when a game ends
and accurately compute claimable winnings.
>
> - Fetches claimable positions separately in `PredictSportCardFooter`
using `usePredictPositions({ claimable: true })`; derives
`claimableAmount` from these positions
> - Treats ended games as closed by checking `market.game?.status ===
'ended'` in both `PredictSportCardFooter` and `PredictGameDetailsFooter`
(prevents bet buttons)
> - Refactors `isMarketOpen` and position flags; removes unnecessary
`useMemo`
> - Updates tests to mock active vs. claimable positions, verify
claimable hook usage, and validate action visibility and amounts
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
2cb38fa. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
[647b11f](647b11f)
Co-authored-by: Luis Taniça <matallui@gmail.com>
Co-authored-by: João Loureiro <175489935+joaoloureirop@users.noreply.github.com>1 parent dd1bee8 commit df5d5e9
3 files changed
Lines changed: 103 additions & 200 deletions
File tree
- app/components/UI/Predict/components
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
0 commit comments