Skip to content

Commit

Permalink
chore: simplify selected departments comparison logic
Browse files Browse the repository at this point in the history
  • Loading branch information
yumincho committed May 23, 2024
1 parent 1115a90 commit dc61799
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ const FavoriteDepartmentsSubSection = () => {
return null;
}

// TODO: Change comparison logic
const hasChange =
new Set(user.favorite_departments.map((d) => d.id.toString())).size !==
selectedDepartments.size ||
[...new Set(user.favorite_departments.map((d) => d.id.toString()))].some(
(d) => !selectedDepartments.has(d),
);
user.favorite_departments.length !== selectedDepartments.size ||
user.favorite_departments.some(({ id }) => !selectedDepartments.has(id.toString()));

Check warning on line 42 in src/components/sections/account/FavoriteDepartmentsSubSection.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/sections/account/FavoriteDepartmentsSubSection.tsx#L42

Added line #L42 was not covered by tests

return (

Check warning on line 44 in src/components/sections/account/FavoriteDepartmentsSubSection.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/sections/account/FavoriteDepartmentsSubSection.tsx#L44

Added line #L44 was not covered by tests
<div className={classNames('subsection', 'subsection--favorite-department')}>
Expand Down

0 comments on commit dc61799

Please sign in to comment.