Skip to content

Commit

Permalink
🎉 모두 읽음 처리 API 에러 처리 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
doggopawer committed Nov 27, 2023
1 parent c83e61d commit 8adc043
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/hooks/api/mutations/useNotificationListUpdateMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
useMutation,
useQueryClient,
} from '@tanstack/react-query'
import { toast } from '@/hooks/useToast'
import {
GetNotificationListRes,
putNotificationList,
Expand All @@ -21,18 +22,22 @@ export const useNotificationListUpdateMutation = () => {
)
await putNotificationList({ notificationIds })
},
onMutate: async () => {
console.log('onMutate')
// TODO : 에러처리 및 각 종 Optimistic Update 관련 기능 처리하기
},

onSettled: () => {
queryClient.invalidateQueries({
queryKey: ['notifications', true],
})
queryClient.invalidateQueries({
queryKey: ['notifications', false],
})
},
onSuccess: () => {
toast({
title: '모두 읽음 처리가 완료되었습니다.',
duration: 1000,
})
},
onError: () => {
toast({
title: '알림 모두 읽음 처리 중 문제가 발생하였습니다.',
duration: 2000,
})
},
})
}

0 comments on commit 8adc043

Please sign in to comment.