Skip to content

Commit

Permalink
Merge pull request #18395 from abdulrahuman5196/InviteFollowup
Browse files Browse the repository at this point in the history
Followup fixes on invite message page implementation
  • Loading branch information
mountiny authored May 4, 2023
2 parents b6eb637 + a08d870 commit 81a0609
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
9 changes: 8 additions & 1 deletion src/pages/workspace/WorkspaceInviteMessagePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const propTypes = {
/** All of the personal details for everyone */
personalDetails: PropTypes.objectOf(personalDetailsPropTypes),

/** Beta features list */
betas: PropTypes.arrayOf(PropTypes.string),

invitedMembersDraft: PropTypes.arrayOf(PropTypes.string),

/** URL Route params */
Expand All @@ -60,6 +63,7 @@ const propTypes = {
const defaultProps = {
...policyDefaultProps,
personalDetails: {},
betas: [],
invitedMembersDraft: [],
};

Expand Down Expand Up @@ -109,7 +113,7 @@ class WorkspaceInviteMessagePage extends React.Component {
}

sendInvitation() {
Policy.addMembersToWorkspace(this.props.invitedMembersDraft, this.state.welcomeNote || this.getWelcomeNote(), this.props.route.params.policyID);
Policy.addMembersToWorkspace(this.props.invitedMembersDraft, this.state.welcomeNote || this.getWelcomeNote(), this.props.route.params.policyID, this.props.betas);
Policy.setWorkspaceInviteMembersDraft(this.props.route.params.policyID, []);
Navigation.navigate(ROUTES.getWorkspaceMembersRoute(this.props.route.params.policyID));
}
Expand Down Expand Up @@ -221,6 +225,9 @@ export default compose(
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS,
},
betas: {
key: ONYXKEYS.BETAS,
},
invitedMembersDraft: {
key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`,
},
Expand Down
21 changes: 9 additions & 12 deletions src/pages/workspace/WorkspaceInvitePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class WorkspaceInvitePage extends React.Component {
personalDetails,
selectedOptions: [],
userToInvite,
shouldDisableButton: false,
};
}

Expand Down Expand Up @@ -247,16 +246,14 @@ class WorkspaceInvitePage extends React.Component {
return;
}

this.setState({shouldDisableButton: true}, () => {
const logins = _.map(this.state.selectedOptions, option => option.login);
const filteredLogins = _.chain(logins)
.map(login => login.toLowerCase().trim())
.compact()
.uniq()
.value();
Policy.setWorkspaceInviteMembersDraft(this.props.route.params.policyID, filteredLogins);
Navigation.navigate(ROUTES.getWorkspaceInviteMessageRoute(this.props.route.params.policyID));
});
const logins = _.map(this.state.selectedOptions, option => option.login);
const filteredLogins = _.chain(logins)
.map(login => login.toLowerCase().trim())
.compact()
.uniq()
.value();
Policy.setWorkspaceInviteMembersDraft(this.props.route.params.policyID, filteredLogins);
Navigation.navigate(ROUTES.getWorkspaceInviteMessageRoute(this.props.route.params.policyID));
}

/**
Expand Down Expand Up @@ -321,7 +318,7 @@ class WorkspaceInvitePage extends React.Component {
</View>
<View style={[styles.flexShrink0]}>
<FormAlertWithSubmitButton
isDisabled={!this.state.selectedOptions.length || this.state.shouldDisableButton}
isDisabled={!this.state.selectedOptions.length}
isAlertVisible={this.getShouldShowAlertPrompt()}
buttonText={this.props.translate('common.next')}
onSubmit={this.inviteUser}
Expand Down

0 comments on commit 81a0609

Please sign in to comment.