Skip to content

Commit

Permalink
refactor: cr
Browse files Browse the repository at this point in the history
  • Loading branch information
ArekChr committed Feb 14, 2024
1 parent e5a4b98 commit 3914f71
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pages/workspace/categories/WorkspaceCategoriesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function WorkspaceCategoriesPage({policyCategories}: WorkspaceCategoriesPageProp
const {translate} = useLocalize();
const [selectedCategories, setSelectedCategories] = useState<string[]>([]);

const data = useMemo(
const categoryList = useMemo<PolicyForList[]>(
() =>
Object.values(policyCategories ?? {}).map((value) => ({
value: value.name,
Expand Down Expand Up @@ -75,11 +75,11 @@ function WorkspaceCategoriesPage({policyCategories}: WorkspaceCategoriesPageProp
};

const toggleAllCategories = () => {
const isAllSelected = data.every((category) => category.isSelected);
const isAllSelected = categoryList.every((category) => category.isSelected);
if (isAllSelected) {
setSelectedCategories([]);
} else {
setSelectedCategories(data.map((item) => item.value));
setSelectedCategories(categoryList.map((item) => item.value));
}
};

Expand All @@ -97,7 +97,7 @@ function WorkspaceCategoriesPage({policyCategories}: WorkspaceCategoriesPageProp
/>
<SelectionList
canSelectMultiple
sections={[{data, indexOffset: 0, isDisabled: false}]}
sections={[{data: categoryList, indexOffset: 0, isDisabled: false}]}
onSelectRow={toggleCategory}
onSelectAll={toggleAllCategories}
showScrollIndicator
Expand Down

0 comments on commit 3914f71

Please sign in to comment.