Skip to content

Commit

Permalink
Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Samueljh1 committed Oct 11, 2023
1 parent 7254e5a commit 095359d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/pages/workspace/WorkspaceInvitePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,34 @@ function WorkspaceInvitePage(props) {

useEffect(() => {
let emails = searchTerm.replace(/\s,\s/g, ',').split(',');
emails = _.filter(_.map(emails, word => word.trim()), email => email !== '');
emails = _.filter(
_.map(emails, (word) => word.trim()),
(email) => email !== '',
);

const newUsersToInviteDict = {};
const newPersonalDetailsDict = {};
const newSelectedOptionsDict = {};

_.forEach(emails, (email) => {
const inviteOptions = OptionsListUtils.getMemberInviteOptions(props.personalDetails, props.betas, email, excludedUsers);

// Update selectedOptions with the latest personalDetails and policyMembers information
const detailsMap = {};
_.forEach(inviteOptions.personalDetails, (detail) => (detailsMap[detail.login] = OptionsListUtils.formatMemberForList(detail)));

const newSelectedOptions = [];
_.forEach(selectedOptions, (option) => {
newSelectedOptions.push(_.has(detailsMap, option.login) ? {...detailsMap[option.login], isSelected: true} : option);
});

const userToInvite = inviteOptions.userToInvite;

// Only add the user to the invites list if it is valid
if (userToInvite) {
if (userToInvite) {
newUsersToInviteDict[userToInvite.accountID] = userToInvite;
}

// Add all personal details to the new dict
_.forEach(inviteOptions.personalDetails, (details) => {
newPersonalDetailsDict[details.accountID] = details;
Expand All @@ -119,7 +122,7 @@ function WorkspaceInvitePage(props) {
newSelectedOptionsDict[option.accountID] = option;
});
});

// Strip out dictionary keys and update arrays
setUsersToInvite(_.map(newUsersToInviteDict, (v) => v));
setPersonalDetails(_.map(newPersonalDetailsDict, (v) => v));
Expand Down

0 comments on commit 095359d

Please sign in to comment.