Commit 46aa1dd
committed
chore(runway): cherry-pick fix(ramp): cp-7.60.0 fix phone already registered error detection in BasicInfo form (#23299)
## **Description**
Fixed error handling in BasicInfo component to correctly access error
codes from Axios error responses. The code was previously trying to
access `error.error.errorCode` but Axios errors have the structure
`error.response.data.error.errorCode`, which prevented error code 2020
(phone already registered) from being detected correctly.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes: #23302
## **Manual testing steps**
```gherkin
Feature: BasicInfo form error handling
Scenario: user submits form with already registered phone number
Given I am on the BasicInfo screen with valid form data
When I submit the form with a phone number that is already registered
Then I should see an error message indicating the phone is already registered
And I should see a "Log in with email" button
And clicking the logout button should navigate to the email entry screen
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<img width="333" height="720" alt="image"
src="https://github.com/user-attachments/assets/0a01a7be-e4bb-496c-8396-e77d5785b668"
/>
### **After**
https://github.com/user-attachments/assets/e8acba92-1032-4f49-a5bd-84a605bda71f
## **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]
> Fixes BasicInfo to read Axios error response for code 2020, format the
email-based message, and expose a logout-to-email flow; updates tests to
use AxiosError and cover these behaviors.
>
> - **UI (Deposit BasicInfo)**:
> - Parse Axios errors via `response.data.error` to detect Transak
`errorCode` `2020` and set `isPhoneRegisteredError`.
> - Extract email from error message to show localized
`phone_already_registered` banner text.
> - Show "Log in with email" action on the error banner and navigate to
`Routes.DEPOSIT.ENTER_EMAIL`; gracefully handle logout failures.
> - Minor: add `AxiosError` typing and default fallback message.
> - **Tests** (`BasicInfo.test.tsx`):
> - Replace custom errors with `AxiosError` shaped responses; add/import
Axios types.
> - Verify formatted message, presence/absence of logout button by error
type, navigation on logout, and error handling when logout fails.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0961bb6. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 3bdc120 commit 46aa1dd
File tree
2 files changed
+103
-46
lines changed- app/components/UI/Ramp/Deposit/Views/BasicInfo
2 files changed
+103
-46
lines changedLines changed: 78 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
392 | 393 | | |
393 | 394 | | |
394 | 395 | | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
401 | 415 | | |
402 | | - | |
| 416 | + | |
403 | 417 | | |
404 | 418 | | |
405 | 419 | | |
| |||
435 | 449 | | |
436 | 450 | | |
437 | 451 | | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
443 | 470 | | |
444 | | - | |
| 471 | + | |
445 | 472 | | |
446 | 473 | | |
447 | 474 | | |
| |||
505 | 532 | | |
506 | 533 | | |
507 | 534 | | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
513 | 553 | | |
514 | | - | |
| 554 | + | |
515 | 555 | | |
516 | 556 | | |
517 | 557 | | |
| |||
553 | 593 | | |
554 | 594 | | |
555 | 595 | | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
561 | 614 | | |
562 | | - | |
| 615 | + | |
563 | 616 | | |
564 | 617 | | |
565 | 618 | | |
| |||
Lines changed: 25 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
239 | 240 | | |
| 241 | + | |
240 | 242 | | |
241 | 243 | | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
249 | 253 | | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
258 | 262 | | |
259 | 263 | | |
260 | 264 | | |
| |||
0 commit comments