-
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
Require validateCode when requesting replacement cards #51147
Merged
Merged
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
2df4f36
Sort command alphabetically
youssef-lr e0af600
Move commands to side effect commands list
youssef-lr 4e26e41
Use a side effect request when report virtual card fraud
youssef-lr e631c0a
Navigate back to the card page on error
youssef-lr 172e11f
Set description of ValidateCodeActionModal
youssef-lr 85a9dd7
Cleanup code
youssef-lr f60a62f
Make sure all validateCode modals have confirmation button docked
youssef-lr f53f47f
Handle loading state and display validetCode error
youssef-lr 5845c87
Navigate to new cardID page and fix brief display of 404 page
youssef-lr 2c3e090
Cleanup unused stuff
youssef-lr d774a7f
Merge branch 'main' into youssef_validateCode_replacement_cards
youssef-lr 00ae18e
Merge branch 'main' into youssef_validateCode_replacement_cards
youssef-lr de7bf8a
Show validateCode error in the valideCode modal
youssef-lr 9feb1cd
Use makeRequestWithSideEffects when requesting physical replacement card
youssef-lr 0bfa399
Require validate code when replacing physical cards
youssef-lr e777ee5
Lint
youssef-lr 419167a
More lint
youssef-lr 73e89c1
Don't break existing code
youssef-lr 4cec967
Remove usage of withOnyx from ReportCardLostPage
youssef-lr 37edf51
Merge branch 'main' into youssef_validateCode_replacement_cards
youssef-lr dc649ea
Fix spinner not showing
youssef-lr 1d830fc
Use ACCOUNT key for handling loading state
youssef-lr c7b2059
Display validateCode error above submit button
youssef-lr 62b7fea
Merge branch 'main' into youssef_validateCode_replacement_cards
youssef-lr 7ed59ee
Merge branch 'main' into youssef_validateCode_replacement_cards
youssef-lr e4af3c8
Keep offline pattern
youssef-lr 1868fcb
Remove usage of withOnyx and other lint fixes
youssef-lr ff17b0e
Merge branch 'main' into youssef_validateCode_replacement_cards
youssef-lr cc4c172
Lint
youssef-lr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/libs/API/parameters/ReportVirtualExpensifyCardFraudParams.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
type ReportVirtualExpensifyCardFraudParams = { | ||
cardID: number; | ||
validateCode: string; | ||
}; | ||
export default ReportVirtualExpensifyCardFraudParams; |
1 change: 1 addition & 0 deletions
1
src/libs/API/parameters/RequestReplacementExpensifyCardParams.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
type RequestReplacementExpensifyCardParams = { | ||
cardID: number; | ||
reason: string; | ||
validateCode: string; | ||
}; | ||
|
||
export default RequestReplacementExpensifyCardParams; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Returning promises from action methods is a discouraged pattern - it looks like we can do this without the side effects.
We just want the new cardID here, so we could probably just have it update an onyx key and only re-direct if we have that key present and are done loading. Alternatively, it seems like we didn't have a redirect before so maybe we don't need to have it still
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.
@thienlnam without the side effects we used to redirect to the old card page and we display a "$0" limit which looks like a bug to the user
Screen_Recording_2024-10-23_at_22.04.03-2024-10-30.17_36_55.334.mov
We also use side effects for reveal virtual card details here
App/src/libs/actions/Card.ts
Line 197 in 084b104
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.
We use side effects there because we can't store those details in onyx since they're sensitive - but for this which is just a cardID is fine to store in onyx
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.
Hmm let me see how I can make this work without side effects and also prevent the bug above.
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.
👍 lmk if you need some ideas - usually the way we get around this is by adding a loading indicator on a loading key on the onyx key for the page
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.
Something like this, wdyt?
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.
@thienlnam IMO I think we can keep the side effect call here, you can see in the comment that our use case here is allowed, we are both calling Marqeta and redirecting based on the response
Also given that we display a spinner and make the user wait, I don't see how is using the optimistic pattern is helpful?
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.
Yup something along those lines would work - you'd need to have the API command send an onyx update for the newCardID if you wanted to redirect to the new card.
Though thinking about this more though, if you only added the redirect so that the card doesn't show with a $0 limit we could also just not do the redirect because then it forces this flow to happen online.
In App, in the optimistic data you could set a new key called isReplacing or something on the cardID and so when you open that cardID you would see some note that it's been replaced and then when the API completes it would remove the card and have the new card in the list. That's probably easier and then allows the user to take other actions offline with the command queued - what do you think?
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 hear you. However I think that this stuff is out of scope, so it's best if I kept this PR focused on validateCode using the same offline pattern we have now, which means not fixing the $0 bug, I think we can open an issue to fix separately. Sounds good?
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.
Yeah that works for me - the main concern for me here is to remove the side effect so if we can do that here and have an external contributor handle the UI update seperately