@@ -57,25 +56,23 @@ const NicknamePage = () => {
-
닉네임
-
-
+ 닉네임
+
diff --git a/frontend/src/pages/NicknamePage/useMakeOrEnterRoom.ts b/frontend/src/pages/NicknamePage/useMakeOrEnterRoom.ts
index 15af3929a..a6bda8bb2 100644
--- a/frontend/src/pages/NicknamePage/useMakeOrEnterRoom.ts
+++ b/frontend/src/pages/NicknamePage/useMakeOrEnterRoom.ts
@@ -1,20 +1,17 @@
import { useMutation } from '@tanstack/react-query';
-import { useRef, useState } from 'react';
+import { useRef } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import { useRecoilState } from 'recoil';
-import createRandomNickname from './createRandomNickname';
-
import { enterRoom, createRoom } from '@/apis/room';
import { ROUTES } from '@/constants/routes';
import { memberInfoState, roomUuidState } from '@/recoil/atom';
import { CreateOrEnterRoomResponse } from '@/types/room';
-export const useMakeOrEnterRoom = (showModal: () => void) => {
- const randomNickname = createRandomNickname();
+
+const useMakeOrEnterRoom = (showModal: () => void) => {
const nicknameInputRef = useRef
(null);
const navigate = useNavigate();
const [{ isMaster }, setMemberInfo] = useRecoilState(memberInfoState);
- const [, setIsLoading] = useState(false);
const [, setRoomUuidState] = useRecoilState(roomUuidState);
const { roomUuid } = useParams();
@@ -27,8 +24,7 @@ export const useMakeOrEnterRoom = (showModal: () => void) => {
memberId: data.member.memberId,
}));
setRoomUuidState(data.roomUuid || '');
- navigate(ROUTES.ready(Number(data.roomId)));
- setIsLoading(false);
+ navigate(ROUTES.ready(Number(data.roomId)), { replace: true });
},
onError: () => {
showModal();
@@ -44,8 +40,7 @@ export const useMakeOrEnterRoom = (showModal: () => void) => {
onSuccess: (data) => {
setMemberInfo((prev) => ({ ...prev, memberId: data.member.memberId }));
setRoomUuidState(data.roomUuid || '');
- navigate(ROUTES.ready(Number(data.roomId)));
- setIsLoading(false);
+ navigate(ROUTES.ready(Number(data.roomId)), { replace: true });
},
onError: () => {
showModal();
@@ -53,7 +48,7 @@ export const useMakeOrEnterRoom = (showModal: () => void) => {
});
const handleMakeOrEnterRoom = () => {
- const nickname = nicknameInputRef.current?.value || randomNickname;
+ const nickname = nicknameInputRef.current?.value || nicknameInputRef.current?.placeholder || '';
if (isMaster) {
createRoomMutation.mutate(nickname);
} else {
@@ -62,9 +57,10 @@ export const useMakeOrEnterRoom = (showModal: () => void) => {
};
return {
- randomNickname,
nicknameInputRef,
handleMakeOrEnterRoom,
isLoading: isMaster ? createRoomMutation.isPending : enterRoomMutation.isPending,
};
};
+
+export default useMakeOrEnterRoom;
diff --git a/frontend/src/pages/ReadyPage/useGetRoomInfo.ts b/frontend/src/pages/ReadyPage/useGetRoomInfo.ts
index cd02e8f9e..e5e25d0fd 100644
--- a/frontend/src/pages/ReadyPage/useGetRoomInfo.ts
+++ b/frontend/src/pages/ReadyPage/useGetRoomInfo.ts
@@ -3,9 +3,9 @@ import { useEffect } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import { getRoomInfo } from '@/apis/room';
+import { POLLING_DELAY } from '@/constants/config';
import { QUERY_KEYS } from '@/constants/queryKeys';
import { ROUTES } from '@/constants/routes';
-import { ONE_SECOND } from '@/constants/time';
export const useGetRoomInfo = () => {
const { roomId } = useParams();
@@ -14,7 +14,7 @@ export const useGetRoomInfo = () => {
const { data, isLoading, isError } = useQuery({
queryKey: [QUERY_KEYS.roomMembers, Number(roomId)],
queryFn: ({ queryKey: [, roomId] }) => getRoomInfo(Number(roomId)),
- refetchInterval: ONE_SECOND,
+ refetchInterval: POLLING_DELAY,
gcTime: 0,
});
@@ -24,5 +24,11 @@ export const useGetRoomInfo = () => {
}
}, [data?.isGameStart, roomId, navigate]);
- return { members: data?.members, roomSetting: data?.roomSetting, isLoading, isError };
+ return {
+ members: data?.members,
+ roomSetting: data?.roomSetting,
+ master: data?.master,
+ isLoading,
+ isError,
+ };
};
diff --git a/frontend/src/types/room.ts b/frontend/src/types/room.ts
index 8de69e20f..a14dbad68 100644
--- a/frontend/src/types/room.ts
+++ b/frontend/src/types/room.ts
@@ -20,6 +20,7 @@ export interface RoomInfo {
isGameStart: boolean;
roomSetting: RoomSetting;
members: Member[];
+ master: Omit;
}
export interface RoomMembers {