Commit bbdc25b
feat(predict): cp-7.62.0 adds PredictMarketSportCard (#24601)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
This PR implements the sports market card component and refactors the
scoreboard to derive UI state from API data for the Predict feature.
**Key changes:**
- `PredictMarketSportCard` - New component displaying sports betting
markets with team gradient backgrounds, integrated scoreboard, and
dynamic team data (colors, abbreviations)
- `PredictSportScoreboard` refactor - Updated to use centralized types
(PredictGameStatus, PredictSportTeam) and derive possession/winner state
from props:
- turn prop (team abbreviation) determines possession indicator
- Scores determine winner display when game is final
- Supports 4 UI states: Pre-game (scheduled), In-progress (ongoing),
Halftime (ongoing + period: 'HT'), Final (ended)
- `formatGameStartTime` - New utility function for locale-aware
date/time formatting of ISO 8601 strings
- Type consolidation - Removed `PredictSportScoreboard.types.ts` in
favor of centralized types in `types/index.ts`
- Test coverage - Added comprehensive tests for
`PredictMarketSportCard`, `formatGameStartTime`, and updated
PredictSportScoreboard tests
**Architecture improvement:**
The scoreboard component now derives UI state (`possession`, `winner`)
internally from API data (`turn`, `awayScore`, `homeScore`) rather than
requiring parent components to compute and pass these values. This
reduces coupling and makes the component easier to use with real API
responses.
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: null
## **Related issues**
Fixes:
[PRED-482](https://consensyssoftware.atlassian.net/browse/PRED-482)
## **Manual testing steps**
```gherkin
Feature: my feature name
Scenario: user [verb for user action]
Given [describe expected initial app state]
When user [verb for user action]
Then [describe expected outcome]
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<img width="746" height="400" alt="image"
src="https://github.com/user-attachments/assets/f1aa5ea7-24f3-41dd-8012-2885bcc50f93"
/>
<img width="748" height="408" alt="image"
src="https://github.com/user-attachments/assets/65f96c30-03fc-4478-be7f-9d92dcd40ffa"
/>
<img width="734" height="410" alt="image"
src="https://github.com/user-attachments/assets/b6cb2c87-dae1-4465-bcfe-2f82dc18f1e0"
/>
## **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.
[PRED-482]:
https://consensyssoftware.atlassian.net/browse/PRED-482?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Implements a new sports market card and simplifies scoreboard
integration by deriving UI state directly from API data.
>
> - Adds `PredictMarketSportCard` showing title, gradient,
`PredictSportScoreboard`, conditional action buttons, and navigation;
uses `formatGameStartTime` for date/time
> - Refactors `PredictSportScoreboard` to accept `gameStatus`, `period`,
and `turn`, deriving PreGame/InProgress/Halftime/Final, possession, and
winner internally; removes `PredictSportScoreboard.types.ts` and
re-exports props from implementation
> - Updates `PredictGameDetailsContent` to pass `gameStatus`, `period`,
and `turn` (removes local game state/possession/winner computations)
> - Adds `formatGameStartTime` utility with tests; adds comprehensive
tests for the new card and updated scoreboard
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
2e1d829. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Luis Taniça <matallui@gmail.com>1 parent 95b43cf commit bbdc25b
11 files changed
Lines changed: 916 additions & 242 deletions
File tree
- app/components/UI/Predict
- components
- PredictGameDetailsContent
- PredictMarketSportCard
- PredictSportScoreboard
- utils
Lines changed: 16 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | 95 | | |
99 | 96 | | |
100 | 97 | | |
101 | 98 | | |
102 | | - | |
| 99 | + | |
| 100 | + | |
103 | 101 | | |
104 | 102 | | |
105 | 103 | | |
106 | 104 | | |
107 | | - | |
| 105 | + | |
| 106 | + | |
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
111 | 121 | | |
112 | 122 | | |
113 | 123 | | |
114 | | - | |
| 124 | + | |
115 | 125 | | |
116 | 126 | | |
117 | 127 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | 128 | | |
122 | 129 | | |
123 | 130 | | |
| |||
Lines changed: 4 additions & 47 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 29 | + | |
34 | 30 | | |
35 | 31 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | 32 | | |
67 | 33 | | |
68 | 34 | | |
| |||
120 | 86 | | |
121 | 87 | | |
122 | 88 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | 89 | | |
133 | 90 | | |
134 | 91 | | |
| |||
194 | 151 | | |
195 | 152 | | |
196 | 153 | | |
197 | | - | |
| 154 | + | |
| 155 | + | |
198 | 156 | | |
199 | 157 | | |
200 | 158 | | |
201 | 159 | | |
202 | | - | |
203 | | - | |
| 160 | + | |
204 | 161 | | |
205 | 162 | | |
206 | 163 | | |
| |||
0 commit comments