Skip to content
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

Merged
merged 33 commits into from
Oct 13, 2023
Merged
Changes from 2 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
183e3fe
Trim the value when going back on connect bank account
dukenv0307 Sep 27, 2023
99477df
use draft if the default value is empty
dukenv0307 Sep 27, 2023
04e7887
fix typo
dukenv0307 Sep 27, 2023
161abe5
save value to draft after updating data successfully
dukenv0307 Sep 27, 2023
15ef37f
fix merge main
dukenv0307 Sep 27, 2023
883db65
fix jest
dukenv0307 Sep 27, 2023
10f72f8
fix lint
dukenv0307 Sep 27, 2023
0fa5251
Merge branch 'main' into fix/25996
dukenv0307 Sep 27, 2023
4532a36
add comment
dukenv0307 Sep 27, 2023
3c4be81
create a const for fields of the step
dukenv0307 Sep 27, 2023
936289c
fix lint
dukenv0307 Sep 27, 2023
88fc114
Merge branch 'fix/25996' of https://github.com/dukenv0307/App into fi…
dukenv0307 Sep 27, 2023
25c2366
reuse the const
dukenv0307 Sep 27, 2023
6caa796
revert const
dukenv0307 Sep 28, 2023
270eddf
fix jest
dukenv0307 Sep 28, 2023
12f5f05
fix lint
dukenv0307 Sep 28, 2023
a58a10e
fix no update when clicking on go back
dukenv0307 Sep 29, 2023
f2b02f1
don't call update when unnecessary
dukenv0307 Sep 29, 2023
6139ff2
Merge branch 'main' into fix/25996
dukenv0307 Oct 3, 2023
96bf07d
Merge branch 'fix/25996' of https://github.com/dukenv0307/App into fi…
dukenv0307 Oct 3, 2023
0de5e86
add default value for param
dukenv0307 Oct 3, 2023
b4bfd76
add check for shouldUpdateDataToDraft
dukenv0307 Oct 3, 2023
1c1dd14
rename variable
dukenv0307 Oct 3, 2023
401e05d
fix lint
dukenv0307 Oct 3, 2023
cc35473
remove unuse field
dukenv0307 Oct 3, 2023
0314480
Update src/pages/ReimbursementAccount/ReimbursementAccountPage.js
dukenv0307 Oct 3, 2023
abb6b20
add description
dukenv0307 Oct 4, 2023
bec41b8
add more detail description
dukenv0307 Oct 4, 2023
4e75345
fix typo
dukenv0307 Oct 4, 2023
c0e74b9
Update src/libs/actions/BankAccounts.js
dukenv0307 Oct 6, 2023
0f48962
rename the variable
dukenv0307 Oct 6, 2023
8d692b0
Update src/pages/ReimbursementAccount/ReimbursementAccountPage.js
dukenv0307 Oct 9, 2023
26e9552
fix lint
dukenv0307 Oct 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
* @returns {Object}
*/
function getVBBADataForOnyx(currentStep = undefined) {
Expand All @@ -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
Copy link
Contributor Author

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.

Copy link
Contributor

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.

// So we need to add this field in successData to update the current data from reimbursement account to the draft value of the form
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, maybe yes?

// if currentStep is undefined that means the step doesn't need update to the draft
Copy link
Contributor

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?

stepToUpdateToDraft: currentStep,
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

@flodnv flodnv Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right... maybe draftStep then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

},
},
Expand Down