-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 선물방 강제 종료하기 API * chore: 선물방 아이디 콘솔 출력 * feat: 선물 삭제 api
- Loading branch information
Showing
3 changed files
with
55 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import { post } from '../../../apis/client'; | ||
|
||
export const MY_TOURNAMENT_QUERY_KEY: string[] = ['myRoomData']; | ||
|
||
export async function deleteRoom(roomId: number) { | ||
await post(`/gift/tournament-end/${roomId}`); | ||
} | ||
|
||
// export const deleteRoom = async (roomId: number): Promise<any> => { | ||
// try { | ||
// const response = await post(`/gift/tournament-end/${roomId}`); | ||
// return response; | ||
// } catch (error) { | ||
// return '중복입니다'; | ||
// } | ||
// }; | ||
export const useDeleteRoom = ({ roomId }: { roomId: number }) => { | ||
const queryClient = useQueryClient(); | ||
|
||
const mutation: any = useMutation({ | ||
mutationFn: deleteRoom, | ||
onSuccess() { | ||
console.log('선물 삭제 성공'); | ||
queryClient.invalidateQueries({ queryKey: [MY_TOURNAMENT_QUERY_KEY[0], roomId] }); | ||
}, | ||
onError: (error) => { | ||
console.log('삭제에러:' + roomId); | ||
console.log('선물 삭제 중 에러가 발생했습니다.', error.message); | ||
}, | ||
}); | ||
|
||
return { mutation }; | ||
}; | ||
|
||
export default useDeleteRoom; |