-
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
Migrate ACHContractStep.js to function component #20350
Migrate ACHContractStep.js to function component #20350
Conversation
@grgia @allroundexperts One of you needs to 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] |
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-06-09.at.1.14.45.AM.movMobile Web - ChromeScreen.Recording.2023-06-09.at.1.23.06.AM.movMobile Web - SafariScreen.Recording.2023-06-09.at.1.23.53.AM.movDesktopScreen.Recording.2023-06-09.at.1.21.48.AM.moviOSScreen.Recording.2023-06-09.at.1.25.39.AM.movAndroidScreen.Recording.2023-06-09.at.1.26.30.AM.mov |
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.
Looks good mostly. Minor changes needed.
beneficialOwners: lodashGet(this.props.reimbursementAccountDraft, 'beneficialOwners', lodashGet(this.props.reimbursementAccount, 'achData.beneficialOwners', [])), | ||
}; | ||
} | ||
function ACHContractStep (props) { |
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 normally use the following arrow function style for defining the functional components.
const FnName = (props) => {
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 following comment
return {beneficialOwners}; | ||
}); | ||
const removeBeneficialOwner = (ownerKey) => { | ||
const previousBeneficialOwners = _.without(beneficialOwners, ownerKey); |
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 isn't really a previousBeneficialOwner
. I think something like newBeneficialOwners
makes more sense 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.
Also, I think you should set the state in a callback as it was done previously. State in functional components can be updated using the callback syntax as well. Ref.
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.
Yes, you're right.
I think it is more meaningful and will reduce risk.
Updated following your comment.
Thanks.
const addBeneficialOwner = () => { | ||
// Each beneficial owner is assigned a unique key that will connect it to an Identity Form. | ||
// That way we can dynamically render each Identity Form based on which keys are present in the beneficial owners array. | ||
const newBeneficialOwners = [...beneficialOwners, Str.guid()]; | ||
FormActions.setDraftValues(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {beneficialOwners}); | ||
setBeneficialOwners(newBeneficialOwners); |
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.
Same comments as 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.
Updated following your comment.
|
||
const beneficialOwners = !values.hasOtherBeneficialOwners | ||
const updatedBeneficialOwners = !values.hasOtherBeneficialOwners |
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 are you renaming this 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.
Because variable name beneficialOwners
is the same with state variable name.
So I thought it might to bring some confusion or potential risk in further development.
There was any special purpose or meaning beside above reason.
If you require to change it, I will do.
if (ownsMoreThan25Percent && beneficialOwners.length > 3) { | ||
// If the user owns more than 25% of the company, then there can only be a maximum of 3 other beneficial owners who owns more than 25%. | ||
// We have to remove the 4th beneficial owner if the checkbox is checked. | ||
setBeneficialOwners(beneficialOwners.slice(0, -1)); |
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 need to use the same style of using the previous state in a callback. Check my comment 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.
Updated following your comment.
@grgia Do you know why the workflows aren't running? |
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.
Looks good. Thanks @multijump!
@multijump Since the workflow is not running, can you please make sure to run |
Sorry @allroundexperts , it was my mistake. |
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.
LGTM, thank you!
beneficialOwners: lodashGet(this.props.reimbursementAccountDraft, 'beneficialOwners', lodashGet(this.props.reimbursementAccount, 'achData.beneficialOwners', [])), | ||
}; | ||
} | ||
const ACHContractStep = (props) => { |
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.
Sorry about this, but can you please change this to function ACHContractStep
syntax? We've decided to use that on every functional component.
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.
@allroundexperts
Updated per your request.
✋ 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/grgia in version: 1.3.28-0 🚀
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 1.3.28-5 🚀
|
Details
Fixed Issues
$ #16240
#16240 (comment)
Tests
Offline tests
QA Steps
Follow the same steps as above
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.mov
Mobile Web - Chrome
Mobile.Web.-.Chrome.mov
Mobile Web - Safari
Mobile.Web.-.Safari.mov
Desktop
Desktop.mp4
iOS
iOS.mov
Android
Android.mov