Skip to content

Commit

Permalink
refactor: 카테고리 이름 클릭 도메인 로직 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
jhy979 authored and summerlunaa committed Sep 7, 2022
1 parent 7fc8021 commit b0124fb
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions frontend/src/components/FilterCategoryItem/FilterCategoryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,9 @@ function FilterCategoryItem({ subscription }: FilterItemProps) {
}
);

const handleClickFilledCheckBox = (colorCode: string) => {
const handleClickCategoryItem = (checked: boolean, colorCode: string) => {
mutate({
checked: false,
colorCode,
});
};

const handleClickBlankCheckBox = (colorCode: string) => {
mutate({
checked: true,
colorCode,
});
};

const handleClickCategoryName = (checked: boolean, colorCode: string) => {
if (checked) {
mutate({
checked: false,
colorCode,
});
return;
}

mutate({
checked: true,
checked: !checked,
colorCode,
});
};
Expand All @@ -93,22 +71,22 @@ function FilterCategoryItem({ subscription }: FilterItemProps) {
size={20}
color={subscription.colorCode}
onClick={() => {
handleClickFilledCheckBox(subscription.colorCode);
handleClickCategoryItem(subscription.checked, subscription.colorCode);
}}
/>
) : (
<RiCheckboxBlankLine
size={20}
color={subscription.colorCode}
onClick={() => {
handleClickBlankCheckBox(subscription.colorCode);
handleClickCategoryItem(subscription.checked, subscription.colorCode);
}}
/>
)}
<span
css={nameStyle}
onClick={() => {
handleClickCategoryName(subscription.checked, subscription.colorCode);
handleClickCategoryItem(subscription.checked, subscription.colorCode);
}}
>
{subscription.category.name}
Expand Down

0 comments on commit b0124fb

Please sign in to comment.