-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Trim the value when going back on connect bank account #28305
Conversation
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
@@ -54,6 +54,23 @@ const defaultProps = { | |||
}; | |||
|
|||
function CompanyStep({reimbursementAccount, reimbursementAccountDraft, getDefaultStateForField, onBackButtonPress, translate, session, user, policyID}) { | |||
const defaultWebsite = useMemo(() => (lodashGet(user, 'isFromPublicDomain', false) ? 'https://' : `https://www.${Str.extractEmailDomain(session.email, '')}`), [user, session]); | |||
const [companyInfomation, setCompanyInfomation] = useState({ |
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.
Typo: should be ...Information
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.
Updated.
@dukenv0307 A problem here is that the values will use |
@Ollyws I found another solution that can this issue and the problem above and updated it in the PR. We will save data that returns from BE to draft value instead of using state to control the value. That also can fix for personal detail step as well. |
Thanks for the changes I like the new approach. |
getFieldsOfCurrentStep(currentStep) { | ||
switch (currentStep) { | ||
case CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT: | ||
return ['routingNumber', 'accountNumber', 'bankName', 'plaidAccountID', 'plaidAccessToken', 'isSavings']; |
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 feels like we could be repeating ourselves a bit here, as if someone wanted to add/remove a field they would have to update this list too. Is there any way we could reference the fields in one place?
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.
@Ollyws Here are the list values of the step and this is only called after api update success. If we want to update the change field to draft we will need to compare draft value and achData
, I think it will take the same amount of time when we merge all fields of the step.
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.
@dukenv0307 What I mean is, in RequestorStep for example we already have a list of input IDs could we perhaps use this list instead of creating a new list here, and implement something similar for the other steps?
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.
The list here is the list that I copied in each step.
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.
Should we create a const for the list and re-use this.
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 just updated it.
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.
@dukenv0307 Thanks but I was specifically referring to this list of input IDs, which we could then perhaps get the values of using _.values()
? Let me know what 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.
@Ollyws I see that we only use this in the special form like AddressForm
, other fields doesn't use this. So I think we don't need to create the list input key like this.
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 well if we're not going to implement that then I don't really see the need for a const, just to be used for the requiredFields
. Could you revert those two commits? Thanks!
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.
Updated.
@dukenv0307 Something I've noticed is if you press the back button while the page is still loading the draft values are never updated: backbutton_example.mp4VIDEO |
@Ollyws I updated. |
Could you please fill in the |
src/libs/actions/BankAccounts.js
Outdated
@@ -57,10 +57,10 @@ function clearOnfidoToken() { | |||
|
|||
/** | |||
* Helper method to build the Onyx data required during setup of a Verified Business Bank Account | |||
* | |||
* @param {String | undefined} currentStep |
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.
Can you update the doc to explain why it's valid to pass undefined
and what we should expect to happen in this strange case?
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 updated.
@flodnv Added the note in offline tests. The bank account flow need to enable network to submit form. |
src/libs/actions/BankAccounts.js
Outdated
@@ -57,7 +57,7 @@ function clearOnfidoToken() { | |||
|
|||
/** | |||
* Helper method to build the Onyx data required during setup of a Verified Business Bank Account | |||
* @param {String | undefined} currentStep | |||
* @param {String | undefined} currentStep The step that we need to update the data from BE to draft value |
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.
* @param {String | undefined} currentStep The step that we need to update the data from BE to draft value | |
* @param {String | undefined} currentStep The step that we need to update the data from backend to draft value |
Is this what it means? If yes, let's update it to use the full word, I don't find it necessary to save a few characters. And if yes, I honestly don't really understand the sentence, perhaps you can try rephrasing it?
Also, you did not clarify what happens if you pass undefined
?
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 something like The name of the step for which we will update the draft value when data has been sucessfully submitted to the backend.
would be clearer.
Undefined here is just for the default value currentStep = undefined
as far as I'm aware, in which case the draft will not be updated as this condition will be undefined.
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 something like The name of the step for which we will update the draft value when data has been sucessfully submitted to the backend. would be clearer.
Agreed, I do understand this better. Also, can we say "API" instead of "backend", since that's what we use everywhere?
src/libs/actions/BankAccounts.js
Outdated
@@ -79,6 +79,10 @@ function getVBBADataForOnyx() { | |||
value: { | |||
isLoading: false, | |||
errors: null, | |||
// The value of some fields of the currentStep are changed i.e. being trimmed or phone number is parsed when backend returns the data |
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.
@flodnv Updated more explanation here.
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.
Suggestion:
// The value of some fields of the currentStep are changed (i.e. trimmed, or phone number is formatted) when the API returns the data.
src/libs/actions/BankAccounts.js
Outdated
@@ -79,6 +79,10 @@ function getVBBADataForOnyx() { | |||
value: { | |||
isLoading: false, | |||
errors: null, | |||
// The value of some fields of the currentStep are changed i.e. being trimmed or phone number is parsed when backend returns the data |
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.
Suggestion:
// The value of some fields of the currentStep are changed (i.e. trimmed, or phone number is formatted) when the API returns the data.
src/libs/actions/BankAccounts.js
Outdated
@@ -79,6 +79,9 @@ function getVBBADataForOnyx(currentStep = undefined) { | |||
value: { | |||
isLoading: false, | |||
errors: null, | |||
// The value of some fields of the currentStep are changed i.e. being trimmed or phone number is parsed when backend returns the data | |||
// So we need to add this field in successData to update the current data from reimbursement account to the draft value of the form |
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'm sorry, I read this 5 times and I don't understand what it's trying to convey, can you perhaps rephrase it in other words, and with more punctuation?
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.
@flodnv Is this more clear?
// In bank account flow, we save the form value to the draft in Onyx.
// When we update the information in a step, the value of some fields that are updated from backend
// can be different from the value that we stored to the draft in Onyx (i.e. trimmed, or phone number is formatted).
// So we should store the current step which we call the update API to update the data from backend to the draft in Onyx.
// If currentStep is undefined that means this step don't need to update the data to the draft 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.
Better, maybe this is even better:
// When setting up a bank account, we save the draft form values in Onyx.
// When we update the information for a step, the value of some fields that are returned from the API
// can be different from the value that we stored as the draft in Onyx (i.e. the phone number is formatted).
// This is why we store the current step used to call the API in order to update the corresponding draft data in Onyx.
// If currentStep is undefined that means this step don't need to update the data of the draft 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.
Do we need to move this to the method's doc
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.
Hmmm, maybe yes?
src/libs/actions/BankAccounts.js
Outdated
@@ -79,6 +79,9 @@ function getVBBADataForOnyx(currentStep = undefined) { | |||
value: { | |||
isLoading: false, | |||
errors: null, | |||
// The value of some fields of the currentStep are changed i.e. being trimmed or phone number is parsed when backend returns the data | |||
// So we need to add this field in successData to update the current data from reimbursement account to the draft value of the form | |||
// if currentStep is undefined that means the step doesn't need update to the draft |
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.
Why isn't this in the method's doc?
src/libs/actions/BankAccounts.js
Outdated
// The value of some fields of the currentStep are changed i.e. being trimmed or phone number is parsed when backend returns the data | ||
// So we need to add this field in successData to update the current data from reimbursement account to the draft value of the form | ||
// if currentStep is undefined that means the step doesn't need update to the draft | ||
stepToUpdateToDraft: currentStep, |
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.
So why is this called stepToUpdateToDraft
and not simply currentStep
?
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 already have a field named currentStep
in achData
of reimbursementAccount
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.
Right... maybe draftStep
then?
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.
Updated.
Co-authored-by: Florent De'Neve <florent@expensify.com>
Co-authored-by: Florent De'Neve <florent@expensify.com>
@flodnv Any update here. |
Sorry, in the future please re-request a review, I filter out commit emails because they're so noisy. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/flodnv in version: 1.3.84-0 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.84-10 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.84-10 🚀
|
🚀 Deployed to staging by https://github.com/flodnv in version: 1.3.85-0 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.85-4 🚀
|
Details
We use state and value prop to override the draft value that is not trimmed on connect bank account
Fixed Issues
$ #25996
PROPOSAL: #25996 (comment)
Tests
Offline tests
No offline test step since bank account flow needs to enable the network
QA Steps
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
Screen.Recording.2023-09-27.at.13.48.56.mov
Mobile Web - Chrome
Record_2023-09-27-13-55-25.mp4
Mobile Web - Safari
Screen.Recording.2023-09-27.at.14.01.06.mov
Desktop
Screen.Recording.2023-09-27.at.14.13.12.mov
iOS
Screen.Recording.2023-09-27.at.14.10.10.mov
Android
Screen.Recording.2023-09-27.at.16.40.03.mov