Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit f4347e4

Browse files
authored
fix: 0402 카테고리 기능수정 (#66) #patch
* 선택중인 카테고리도 삭제 가능하도록 * 생성할때 잠시 에러메시지 나오는거 숨기기
1 parent 95e26bd commit f4347e4

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/renderer/features/category/ui/change-category-drawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ const DeleteModeDrawerContent = ({ setMode }: DeleteModeDrawerContentProps) => {
266266
)}
267267
>
268268
{categories?.map((category, index) => {
269-
const disabled = index === 0 || category.isSelected;
269+
const disabled = index === 0;
270270
const checked = selectedCategoryIds.includes(`${category.no}`);
271271
return (
272272
<SelectGroupItem

src/renderer/pages/category.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,20 @@ const CategoryPage = () => {
6161

6262
useEffect(() => {
6363
const isTooLong = trimmedCategoryName.length > CATEGORY_NAME_MAX_LENGTH;
64-
const isDuplicated = categories?.some(
65-
(category) => category.title === trimmedCategoryName && category.no !== categoryNo,
66-
);
64+
const isDuplicated = isPending
65+
? // @note: 낙관적 업데이트를 하기 때문에 카테고리 생성 중에 중복 에러 메시지 보이지 않도록 함
66+
false
67+
: categories?.some(
68+
(category) => category.title === trimmedCategoryName && category.no !== categoryNo,
69+
);
6770
if (isTooLong) {
6871
return setErrorMessage(`최대 ${CATEGORY_NAME_MAX_LENGTH}글자까지 입력할 수 있어요.`);
6972
}
7073
if (isDuplicated) {
7174
return setErrorMessage('이미 존재하는 카테고리예요.');
7275
}
7376
setErrorMessage(null);
74-
}, [trimmedCategoryName, categories, categoryNo]);
77+
}, [trimmedCategoryName, categories, categoryNo, isPending]);
7578

7679
const handleClickChangeIconButton = () => {
7780
drawerProps.setIsOpen(true);

0 commit comments

Comments
 (0)