diff --git a/src/apis/myroom.ts b/src/apis/myroom.ts index d86c7bd..df4b477 100644 --- a/src/apis/myroom.ts +++ b/src/apis/myroom.ts @@ -1,5 +1,10 @@ import { BaseResponse } from '@interfaces/api/base'; -import { IsPublicResponseDTO, MyRoomResponseDTO, RoomRequestDTO } from '@interfaces/api/room'; +import { + GetDetailResponseDTO, + IsPublicResponseDTO, + MyRoomResponseDTO, + RoomRequestDTO, +} from '@interfaces/api/room'; import { c } from 'node_modules/vite/dist/node/types.d-aGj9QkWt'; import { apiAnonymousClient, apiClient } from './axios'; @@ -92,7 +97,7 @@ export const postMyRoomModifyStuff = async (request: FormData): Promise> => { +): Promise> => { try { const response = await apiClient.get(`/myroom/post/${postId}`, { params: { memberId: memberId }, @@ -106,14 +111,9 @@ export const getMyRoomPost = async ( } }; -export const getRoomPost = async ( - memberId: number, - postId: number -): Promise> => { +export const getRoomPost = async (postId: string): Promise> => { try { - const response = await apiAnonymousClient.get(`/myroom/post/postId=${postId}`, { - params: { memberId: memberId }, - }); + const response = await apiAnonymousClient.get(`/myroom/post?postId=${postId}`); return response.data; } catch (error) { console.error('게시물 상세보기 실패:', error); diff --git a/src/routers/home/detail/Detail.tsx b/src/routers/home/detail/Detail.tsx index fb925f0..deaa82a 100644 --- a/src/routers/home/detail/Detail.tsx +++ b/src/routers/home/detail/Detail.tsx @@ -41,10 +41,12 @@ const Detail = () => { const anonymousToken = localStorage.getItem('anonymousToken'); const memberId = useAuthStore((store) => store.memberId); const isLogin = useAuthStore((store) => store.isLoggedIn); + const [postDetail, setPostDetail] = useState(); const myRoomMutation = useMutation(() => getMyRoomPost(memberId!, Number(postId)), { onSuccess: (data) => { if (data.code === 1000) { console.log('마이룸 상세 조회 성공:', data); + setPostDetail(data.result); } }, onError: (error) => { @@ -52,10 +54,11 @@ const Detail = () => { }, }); - const anonymousRoomMutation = useMutation(() => getRoomPost(memberId!, Number(postId)), { + const anonymousRoomMutation = useMutation(() => getRoomPost(postId || ''), { onSuccess: (data) => { if (data.code === 1000) { console.log('익명 상세 조회 성공:', data); + setPostDetail(data.result); } }, onError: (error) => { @@ -74,10 +77,6 @@ const Detail = () => { } }, [memberId, postId]); - const postDetail: GetDetailResponseDTO | undefined = myRoomMutation.data?.result as - | GetDetailResponseDTO - | undefined; - const handleArrowClick = () => { postDetail?.ownerId === memberId ? navigate('/') : navigate(-1); }; diff --git a/src/routers/home/homemenu/HomeMenuSlider.tsx b/src/routers/home/homemenu/HomeMenuSlider.tsx index 74a7245..31e92a8 100644 --- a/src/routers/home/homemenu/HomeMenuSlider.tsx +++ b/src/routers/home/homemenu/HomeMenuSlider.tsx @@ -75,10 +75,15 @@ const HomeMenuSlider = ({ }; const handlePopularFeedOnClick = () => { - if (lastSegment === 'others-home') { - handleMenu(); + if (isLogin) { + if (lastSegment === 'others-home') { + handleMenu(); + } else { + navigate('/others-home'); + } } else { - navigate('/others-home'); + console.log('first'); + setIsLogoutAlert(true); } }; @@ -86,43 +91,8 @@ const HomeMenuSlider = ({ setIsOn(isPublic); }, [isPublic]); - const logout = useAuthStore((state) => state.logout); - const renderTitle = () => { + const renderAlert = () => { return isLogin ? ( - - - {nickName} - - - 님의 홈 - - - ) : ( - - - 회원가입/로그인 하고 - - - - in&out - - - 에 함께해요 - - - - ); - }; - - return ( - <> } /> + ) : ( + + 로그아웃이 필요해요 + 인기피드는 로그인 후 보실 수 있어요 + + } + button={ + setIsLogoutAlert(false)} + color={colors.red600} + fontColor={colors.white} + /> + } + /> + ); + }; + + const logout = useAuthStore((state) => state.logout); + const renderTitle = () => { + return isLogin ? ( + + + {nickName} + + + 님의 홈 + + + ) : ( + + + 회원가입/로그인 하고 + + + + in&out + + + 에 함께해요 + + + + ); + }; + + return ( + <> + {renderAlert()}