Skip to content

Commit

Permalink
Merge pull request #3096 from Northeastern-Electric-Racing/#2693-requ…
Browse files Browse the repository at this point in the history
…ired-and-optional-tabs-do-not-need-to-be-mutually-exclusive

#2693 Made Required and Optional Users Not Mutually Exclusive When Editing Design Reviews
  • Loading branch information
walker-sean authored Dec 24, 2024
2 parents af04987 + 85f92ca commit 61ecfee
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ const DesignReviewDetailPage: React.FC<DesignReviewDetailPageProps> = ({ designR
}
};

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

const handleEdit = async (data?: FinalizeReviewInformation) => {
const times = [];
for (let i = startTime; i < endTime; i++) {
Expand Down Expand Up @@ -254,9 +261,9 @@ const DesignReviewDetailPage: React.FC<DesignReviewDetailPageProps> = ({ designR
limitTags={1}
renderTags={() => null}
id="required-users"
options={users.filter((user) => !optionalUsers.some((optUser) => optUser.id === user.id))}
options={users}
value={requiredUsers}
onChange={(_event, newValue) => setRequiredUsers(newValue)}
onChange={(_event, newValue) => handleSelectingRequiredUser(newValue)}
getOptionLabel={(option) => option.label}
renderOption={(props, option, { selected }) => (
<li {...props}>
Expand Down

0 comments on commit 61ecfee

Please sign in to comment.