Skip to content

Commit

Permalink
optimized method for filtering optional users
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Yao authored and Eric Yao committed Dec 23, 2024
1 parent aa20a64 commit 85f92ca
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ const DesignReviewDetailPage: React.FC<DesignReviewDetailPageProps> = ({ designR
};

const handleSelectingRequiredUser = (newValue: { label: string; id: string }[]) => {
let filteredOptionalUsers = optionalUsers;
for (const reqUser of newValue) {
filteredOptionalUsers = filteredOptionalUsers.filter((user) => user.id !== reqUser.id);
}
const newRequiredUserIds = new Set(newValue.map((user) => user.id));
const filteredOptionalUsers = optionalUsers.filter((user) => !newRequiredUserIds.has(user.id));
setOptionalUsers(filteredOptionalUsers);
setRequiredUsers(newValue);
};
Expand Down

0 comments on commit 85f92ca

Please sign in to comment.