Skip to content

Commit

Permalink
REFACTOR: ♻️ 카테고리 빈값 validate
Browse files Browse the repository at this point in the history
  • Loading branch information
bbung95 committed Sep 24, 2024
1 parent 024f455 commit e34b592
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/FilterBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,20 @@ const FilterBox = () => {
};

const handleAddCategory = () => {
if (!category) {
const trimValue = category.trimStart();

if (!trimValue) {
addToast({ message: '카테고리를 입력해주세요', type: 'error' });

return;
}
if (category === '전체') {
if (trimValue === '전체') {
setIsError(true);
addToast({ message: '카테고리가 이미 존재해요', type: 'error' });
return;
}

mutateSaveCategory(category).then((res) => {
mutateSaveCategory(trimValue).then((res) => {
if (res.data.code === 'C002') {
setIsError(true);
addToast({ message: res.data.message, type: 'error' });
Expand Down

0 comments on commit e34b592

Please sign in to comment.