Skip to content

Commit 140f1c9

Browse files
committed
feat: 비로그인 사용자 좋아요 클릭 시 토스트
1 parent dff6dc4 commit 140f1c9

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/common/hooks/useHandleError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const useHandleError = () => {
88
const handleError = (error: Error, customMessage?: string) => {
99
if (isAxiosError<ErrorResponse>(error)) {
1010
openToast({
11-
message: error.response?.data.message || customMessage || '알 수 없는 오류가 발생했습니다',
11+
message: customMessage || error.response?.data.message || '알 수 없는 오류가 발생했습니다',
1212
});
1313
}
1414
};

src/features/detail/apis/usePostLike.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useHandleError } from '@/common/hooks/useHandleError';
12
import client from '@/common/utils/client';
23
import { QUERY_KEYS } from '@/libs/queryKeys';
34
import { useMutation, useQueryClient } from '@tanstack/react-query';
@@ -9,12 +10,16 @@ const postLike = async (itemId: number) => {
910

1011
export const usePostLike = () => {
1112
const queryClient = useQueryClient();
13+
const handleError = useHandleError();
1214

1315
return useMutation({
1416
mutationFn: postLike,
1517
onSuccess: () => {
1618
queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.ITEM_DETAIL] });
1719
queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.ITEM_LIST] });
1820
},
21+
onError: error => {
22+
handleError(error, '로그인 후 시도해 주세요.');
23+
},
1924
});
2025
};

src/libs/constants/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const VERSION_NAME = 'v1.0.1';
1+
export const VERSION_NAME = 'v1.0.2';
22

33
export const MAX_PRICE = 999999;
44
export const MAX_LOCATION = 100;

0 commit comments

Comments
 (0)