-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
22875 Add API Calls when clicking “Reveal details” buttons #29017
22875 Add API Calls when clicking “Reveal details” buttons #29017
Conversation
@@ -1,11 +1,11 @@ | |||
import lodashGet from 'lodash/get'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing should change in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right!
error: string; | ||
}; | ||
|
||
type Action = {type: 'START'} | {type: 'SUCCESS'; payload: State['details']} | {type: 'FAIL'; payload: string}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, Id move 'START', 'SUCCESS', 'FAIL' to some kind of const variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's TS typed, so the right values should be autocompleted by the IDE, hence no constants needed imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Card page is in .js tho. Im not sure if any checks happen there when dispatching actions
}; | ||
}; | ||
}; | ||
loading: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be named isLoading
Would it be possible to get some videos from happy path too? |
@rushatgabhane Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes! Unfortunately, it is not yet ready...
Please check the documentation for the App architecture. The PR is running counter to several foundational designs that will hopefully be more clear after reading the following:
https://github.com/Expensify/App/tree/main#philosophy
https://github.com/Expensify/App/blob/main/contributingGuides/API.md
https://github.com/Expensify/App/blob/main/contributingGuides/OFFLINE_UX.md
Let me know if there are any questions
@@ -1,5 +1,5 @@ | |||
import PropTypes from 'prop-types'; | |||
import React, {useState} from 'react'; | |||
import React, {useReducer} from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should start with useReducer
. We have avoided it until now and it looks like the incorrect pattern for what we are trying to achieve here.
@@ -18,6 +18,10 @@ import styles from '../../../styles/styles'; | |||
import * as CardUtils from '../../../libs/CardUtils'; | |||
import Button from '../../../components/Button'; | |||
import CardDetails from './WalletPage/CardDetails'; | |||
// eslint-disable-next-line rulesdir/no-api-in-views | |||
import * as API from '../../../libs/API'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is here for a reason. If you want to call an API you need to create an "action" in the Card.js
file
@marcaaron Thanks for clarifying some stuff. Working on the changes now. |
@marcaaron made some fixes, please have a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the changes!
I will do some local testing.
src/libs/actions/Card.ts
Outdated
API.makeRequestWithSideEffects('RevealVirtualCardDetails', {cardID}) | ||
.then((response) => { | ||
if (response.jsonCode !== CONST.JSON_CODE.SUCCESS) { | ||
reject(response.message || Localize.translateLocal('cardPage.cardDetailsLoadingFailure')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not return the response.message
error. It could be anything. Same with the catch below. Just return the default translated error in either case since the user will end up seeing this.
@rushatgabhane Any status? The PR is related to our product roadmap and needs priority. |
got it! reviewing |
src/languages/en.ts
Outdated
@@ -843,6 +843,7 @@ export default { | |||
revealDetails: 'Reveal details', | |||
copyCardNumber: 'Copy card number', | |||
}, | |||
cardDetailsLoadingFailure: 'An error occurred loading card details, please try again.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this reads better
cardDetailsLoadingFailure: 'An error occurred loading card details, please try again.', | |
cardDetailsLoadingFailure: 'An error occurred while loading the card details. Please try again.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed this copy was already approved by marketing.
@lukemorawski @MrMuzyk @grgia is this wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no error message copy for this in the Design Doc @marcaaron
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I think we need to get the copy looked at. All copy needs to be approved. 🙃
Where did this error message come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukemorawski am i missing something? are there any prerequisities to test this PR?
Bug:
Steps:
- navigate to
/settings/wallet/card/expensify
- run in JS console
Onyx.merge(`cardList`, {
5678: {
cardID: 5678,
state: 4,
bank: '1000',
availableSpend: 10000,
domainName: 'Expensify',
lastFourPAN: '2345',
isVirtual: true,
},
});
- Click on Reveal Details
Expected: Network request is made
Actual: no request is made, and we have a console error : TypeError: Cannot read properties of undefined (reading 'revealVirtualCardDetails') at Object.handleRevealDetails [as onPress] (ExpensifyCardPage.js:77:9)
@grgia yep |
@rushatgabhane Are you on the checklist for this one? |
Co-authored-by: Rushat Gabhane <rushatgabhane@gmail.com>
updated @rushatgabhane |
Reviewer Checklist
Screenshots/VideosMobile Web - Safarimy emulator is broken |
@lukemorawski am i missing something? I don't see the card. steps:
I'm on the latest commit and re-ran |
@rushatgabhane the domain check is case sensitive, could you try changing the data to:
|
Co-authored-by: Rushat Gabhane <rushatgabhane@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grgia LGTM!
Hey @rushatgabhane we've decided to move the error handling into a follow up PR, would you mind doing a final pass through on the final branch? |
cool Code LGTM! The promise can be removed later Screen.Recording.2023-10-25.at.20.43.06.mov |
Sounds good! added removing the promise to the issue as well - #30329 |
🚀 Deployed to staging by https://github.com/marcaaron in version: 1.3.91-0 🚀
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.3.91-8 🚀
|
Details
This PR add a call to the Expensify API to upon the tap on card "Reveal Details" button, to get the that card details and display it to the user.
The call is done locally and saved in components state, and not to Onyx for security reasons.
When the call progresses, the loading indicator is displayed in the button and the button is disabled to prevent concurrent calls.
There's also error handling displaying the error message under the MenuItem.
To test fully this feature we would need a way to add a real virtual card to the account. Currently we can only test that call has been made and also test the error handling.
Mocking the success response locally is also possible.
Here's a mocked happy path scenario:
happy.path.mov
Fixed Issues
$ #22875
PROPOSAL: no proposal
Tests
Offline tests
QA Steps
/settings/wallet/card/expensify
(you'll see "not found" page)PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
web.desktop.mov
Mobile Web - Chrome
web.android.mov
Mobile Web - Safari
web.ios.mov
Desktop
native.desktop.mov
iOS
native.ios.mp4
Android
web.android.mov