@@ -56,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;