Skip to content

Commit

Permalink
Merge pull request #106 from SWYP-InNOut/dev
Browse files Browse the repository at this point in the history
Dev to Main merge
  • Loading branch information
chaeyoung103 authored Aug 7, 2024
2 parents e3e921d + 0c03cd2 commit 79b9589
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 53 deletions.
18 changes: 9 additions & 9 deletions src/apis/myroom.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -92,7 +97,7 @@ export const postMyRoomModifyStuff = async (request: FormData): Promise<BaseResp
export const getMyRoomPost = async (
memberId: number,
postId: number
): Promise<BaseResponse<string>> => {
): Promise<BaseResponse<GetDetailResponseDTO>> => {
try {
const response = await apiClient.get(`/myroom/post/${postId}`, {
params: { memberId: memberId },
Expand All @@ -106,14 +111,9 @@ export const getMyRoomPost = async (
}
};

export const getRoomPost = async (
memberId: number,
postId: number
): Promise<BaseResponse<string>> => {
export const getRoomPost = async (postId: string): Promise<BaseResponse<GetDetailResponseDTO>> => {
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);
Expand Down
9 changes: 4 additions & 5 deletions src/routers/home/detail/Detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,24 @@ const Detail = () => {
const anonymousToken = localStorage.getItem('anonymousToken');
const memberId = useAuthStore((store) => store.memberId);
const isLogin = useAuthStore((store) => store.isLoggedIn);
const [postDetail, setPostDetail] = useState<GetDetailResponseDTO>();
const myRoomMutation = useMutation(() => getMyRoomPost(memberId!, Number(postId)), {
onSuccess: (data) => {
if (data.code === 1000) {
console.log('마이룸 상세 조회 성공:', data);
setPostDetail(data.result);
}
},
onError: (error) => {
console.error('마이룸 상세 조회 실패:', error);
},
});

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) => {
Expand All @@ -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);
};
Expand Down
107 changes: 68 additions & 39 deletions src/routers/home/homemenu/HomeMenuSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,54 +75,24 @@ 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);
}
};

useEffect(() => {
setIsOn(isPublic);
}, [isPublic]);

const logout = useAuthStore((state) => state.logout);
const renderTitle = () => {
const renderAlert = () => {
return isLogin ? (
<Row padding={'0 28px 64px'} gap={'4'} justifyContent="center" alignItems="end">
<Txt variant="h28" lineHeight={36}>
{nickName}
</Txt>
<Txt variant="t18" color={colors.lightGray}>
님의 홈
</Txt>
</Row>
) : (
<Col padding={'0 0 64px'} justifyContent={'center'} alignItems={'center'}>
<Txt variant="h28" lineHeight={42}>
회원가입/로그인 하고
</Txt>
<Row justifyContent={'center'} alignItems={'center'} gap={4}>
<span
css={css`
color: ${colors.black};
font-size: 32px;
font-weight: 600;
font-family: 'Hancom Sans';
`}
>
in&out
</span>
<Txt variant="h28" lineHeight={42}>
에 함께해요
</Txt>
</Row>
</Col>
);
};

return (
<>
<AlertModal
isOpen={isLogoutAlert}
content={
Expand Down Expand Up @@ -159,6 +129,65 @@ const HomeMenuSlider = ({
</Col>
}
/>
) : (
<AlertModal
isOpen={isLogoutAlert}
content={
<Col gap={'12'} alignItems="center">
<Txt variant="t20">로그아웃이 필요해요</Txt>
<Txt variant="b16">인기피드는 로그인 후 보실 수 있어요</Txt>
</Col>
}
button={
<PrimaryButton
title="확인"
onClick={() => setIsLogoutAlert(false)}
color={colors.red600}
fontColor={colors.white}
/>
}
/>
);
};

const logout = useAuthStore((state) => state.logout);
const renderTitle = () => {
return isLogin ? (
<Row padding={'0 28px 64px'} gap={'4'} justifyContent="center" alignItems="end">
<Txt variant="h28" lineHeight={36}>
{nickName}
</Txt>
<Txt variant="t18" color={colors.lightGray}>
님의 홈
</Txt>
</Row>
) : (
<Col padding={'0 0 64px'} justifyContent={'center'} alignItems={'center'}>
<Txt variant="h28" lineHeight={42}>
회원가입/로그인 하고
</Txt>
<Row justifyContent={'center'} alignItems={'center'} gap={4}>
<span
css={css`
color: ${colors.black};
font-size: 32px;
font-weight: 600;
font-family: 'Hancom Sans';
`}
>
in&out
</span>
<Txt variant="h28" lineHeight={42}>
에 함께해요
</Txt>
</Row>
</Col>
);
};

return (
<>
{renderAlert()}
<HomeMenuSliderContainer right={isOpen ? '0%' : '100%'}>
<Col
padding={'28px 0 0'}
Expand Down

0 comments on commit 79b9589

Please sign in to comment.