-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 댓글 삭제 api 추가 및 item isSelected 추가 (#23)
* fix: deleteComment body에서 params로 가져오는 방식 변경 * feat: 댓글 삭제 api 추가 * feat: item isSelected 추가
- Loading branch information
Showing
10 changed files
with
109 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { axiosInstance } from '.'; | ||
import END_POINTS from '../constants/api'; | ||
|
||
export default async function deleteComment(commentId) { | ||
const { data } = await axiosInstance.delete(END_POINTS.DELETE_COMMENT(commentId)); | ||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import deleteComment from '../../apis/deleteComment'; | ||
import QUERY_KEYS from '../../constants/queryKeys'; | ||
import { toast } from 'react-toastify'; | ||
|
||
export default function useDeleteComment(commentId, itemId) { | ||
const queryClient = useQueryClient(); | ||
const itemIdNumber = parseInt(itemId); | ||
return useMutation({ | ||
mutationFn: async () => { | ||
return await deleteComment(commentId); | ||
}, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries([QUERY_KEYS.COMMENTS, { itemId: itemIdNumber }]); | ||
queryClient.invalidateQueries([QUERY_KEYS.BEST_COMMENTS, { itemId: itemIdNumber }]); | ||
toast.success('댓글이 삭제되었습니다.'); | ||
}, | ||
onError: () => { | ||
toast.error('댓글 삭제에 실패했습니다.'); | ||
}, | ||
}); | ||
} |