Skip to content

Commit

Permalink
[✨feat]: 이미 정원찬 방 입장시도시 alert
Browse files Browse the repository at this point in the history
  • Loading branch information
yejinleee committed Mar 19, 2024
1 parent 5dc3f5a commit 7ee8bb6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hooks/useEnterGameRoom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useMutation } from '@tanstack/react-query';
import { AxiosError, AxiosResponse } from 'axios';
import { useNavigate } from 'react-router-dom';
import { enterGameRoom } from '@/apis/api';
import { ApiResponseGameRoomEnterResponse, ErrorResponse } from '@/generated';

Expand All @@ -14,6 +15,7 @@ export interface I_UseEnterGameRoomMutation {
}

const useEnterGameRoom = ({ onSuccess, onError }: UseEnterGameRoomProps) => {
const navigate = useNavigate();
return useMutation<
AxiosResponse<ApiResponseGameRoomEnterResponse>,
Error | AxiosError<ErrorResponse>,
Expand All @@ -27,6 +29,8 @@ const useEnterGameRoom = ({ onSuccess, onError }: UseEnterGameRoomProps) => {
},
onError: (e) => {
if (e instanceof AxiosError) {
alert(e.response?.data.errorMessage);
navigate(0);
onError?.(e);
}
},
Expand Down

0 comments on commit 7ee8bb6

Please sign in to comment.