Skip to content

Commit ee02090

Browse files
authored
Merge pull request #100 from oodd-team/feat/OD-157
[OD-157] myPage & profileViewer 조건부렌더링으로 수정
2 parents 53eee14 + 3cf9d35 commit ee02090

File tree

20 files changed

+237
-592
lines changed

20 files changed

+237
-592
lines changed

src/App.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ import SignUp from './pages/SignUp';
66
import LoginComplete from './pages/Login/components/LoginComplete';
77
import TermsAgreement from './pages/TermsAgreement';
88

9-
import MyPage from './pages/MyPage';
9+
import Profile from './pages/Profile';
1010
import ProfileEdit from './pages/ProfileEdit';
1111
import AccountSetting from './pages/AccountSetting';
1212
import AccountEdit from './pages/AccountEdit';
1313
import AccountCancel from './pages/AccountCancel';
1414
import Verification from './pages/verification';
1515

16-
import ProfileViewer from './pages/ProfileViewer';
17-
1816
import Post from './pages/Post';
1917
import MyPost from './pages/MyPost';
2018
import PostUpload from './pages/PostUpload';
@@ -37,13 +35,12 @@ const protectedRoutes = [
3735
{ path: '/', element: <Home /> },
3836

3937
// 사용자 프로필 및 계정 관리
40-
{ path: '/mypage', element: <MyPage /> },
38+
{ path: '/profile/:userId', element: <Profile /> },
4139
{ path: '/profile/edit', element: <ProfileEdit /> },
4240
{ path: '/account-setting', element: <AccountSetting /> },
4341
{ path: '/account-edit', element: <AccountEdit /> },
4442
{ path: '/account-cancel', element: <AccountCancel /> },
4543
{ path: '/verification', element: <Verification /> },
46-
{ path: '/users/:userId', element: <ProfileViewer /> },
4744

4845
{ path: '/post/:postId', element: <Post /> },
4946
{ path: '/my-post/:postId', element: <MyPost /> },

src/components/NavBar/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,18 @@ import { StyledText } from '../Text/StyledText';
3232
import Modal from '../Modal';
3333
import { ModalProps } from '../Modal/dto';
3434

35+
const userId = localStorage.getItem('my_id');
36+
3537
const tabs = [
3638
{ name: 'Chats', iconSelected: Chat_f, iconUnselected: Chat_s, route: '/chats' },
3739
{ name: 'Home', iconSelected: Home_f, iconUnselected: Home_s, route: '/' },
38-
{ name: 'Profile', iconSelected: Profile_f, iconUnselected: Profile_s, route: '/mypage' },
40+
{ name: 'Profile', iconSelected: Profile_f, iconUnselected: Profile_s, route: `/profile/${userId}` },
3941
];
4042

4143
const desktopTabs = [
4244
{ name: 'Home', iconSelected: homeFillDesktopIcon, iconUnselected: homeDesktopIcon, route: '/' },
4345
{ name: 'Chats', iconSelected: chatFillDesktopIcon, iconUnselected: chatDesktopIcon, route: '/chats' },
44-
{ name: 'Profile', iconSelected: profileFillDesktopIcon, iconUnselected: profileDesktopIcon, route: '/mypage' },
46+
{ name: 'Profile', iconSelected: profileFillDesktopIcon, iconUnselected: profileDesktopIcon, route: `/profile/${userId}` },
4547
];
4648

4749
const NavBar: React.FC = () => {

src/components/PostBase/LikeCommentBottomSheetContent/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ const LikeCommentBottomSheetContent: React.FC<LikeCommentBottomSheetProps> = ({
321321

322322
if (String(myUserId) === String(userId)) {
323323
// 나인 경우
324-
nav('/mypage');
324+
nav(`/profile/${userId}`);
325325
} else {
326326
// 다른 유저인 경우
327327
nav(`/users/${userId}`);

src/components/PostBase/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ const PostBase: React.FC<PostBaseProps> = ({ onClickMenu }) => {
6262
const [activeTab, setActiveTab] = useState<'likes' | 'comments'>('likes'); // activeTab state
6363

6464
const nav = useNavigate();
65+
const userId = localStorage.getItem('my_id');
66+
6567

6668
useEffect(() => {
6769
setPostId(Number(postId));
@@ -100,7 +102,7 @@ const PostBase: React.FC<PostBaseProps> = ({ onClickMenu }) => {
100102
const handleUserClick = () => {
101103
if (post?.isPostWriter) {
102104
// 내 게시물인 경우
103-
nav('/mypage');
105+
nav(`/profile/${userId}`);
104106
} else {
105107
// 다른 유저의 게시물인 경우
106108
nav(`/users/${post?.user.id}`);

src/pages/MyPage/index.tsx

Lines changed: 0 additions & 175 deletions
This file was deleted.

src/pages/MyPost/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const MyPost: React.FC = () => {
2828
const [isApiResponseModalOpen, setIsApiResponseModalOpen] = useState(false);
2929
const [pinPostResultlModalContent, setPinPostResultlModalContent] = useState('');
3030
const navigate = useNavigate();
31+
const userId = localStorage.getItem('my_id');
32+
3133

3234
useEffect(() => {
3335
if (isPostRepresentative) {
@@ -105,9 +107,9 @@ const MyPost: React.FC = () => {
105107

106108
if (response.isSuccess) {
107109
setPinPostResultlModalContent('OOTD 삭제에 성공했어요');
108-
// 1초 뒤에 mypage로 이동
110+
109111
setTimeout(() => {
110-
navigate('/mypage');
112+
navigate(`/profile/${userId}`);
111113
}, 1000);
112114
} else {
113115
setPinPostResultlModalContent(`OOTD 삭제에 실패했어요\n잠시 뒤 다시 시도해 보세요`);

src/pages/PostImageSelect/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ const PostImageSelect: React.FC<ImageSelectModalProps> = () => {
3535
const fileInputRef = useRef<HTMLInputElement | null>(null);
3636
const location = useLocation();
3737
const navigate = useNavigate();
38+
const userId = localStorage.getItem('my_id');
3839

3940
const handleClose = () => {
40-
navigate('/mypage');
41+
navigate(`/profile/${userId}`);
4142
};
4243

4344
const handlePrev = () => {

src/pages/PostInstaFeedSelect/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const PostInstaFeedSelect: React.FC<InstaFeedSelectModalProps> = () => {
2222
const [posts, setPosts] = useState<Post[]>([]); // Post 타입으로 지정
2323
const [, setImages] = useRecoilState(postImagesAtom);
2424
const navigate = useNavigate();
25+
const userId = localStorage.getItem('my_id');
2526

2627
// 인스타그램 데이터 가져오는 함수
2728
const fetchInstagramData = async (accessToken: string) => {
@@ -70,7 +71,7 @@ const PostInstaFeedSelect: React.FC<InstaFeedSelectModalProps> = () => {
7071

7172
// 페이지 종료 함수
7273
const handleClose = () => {
73-
navigate('/mypage'); // 마이페이지로 이동
74+
navigate(`/profile/${userId}`);
7475
};
7576

7677
return (

src/pages/PostUpload/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const PostUpload: React.FC<PostUploadModalProps> = () => {
6666
const [modalContent, setModalContent] = useState('알 수 없는 오류입니다.\n관리자에게 문의해 주세요.');
6767
const location = useLocation();
6868
const navigate = useNavigate();
69+
const userId = localStorage.getItem('my_id');
6970

7071
const styletags = [
7172
'classic',
@@ -286,7 +287,7 @@ const PostUpload: React.FC<PostUploadModalProps> = () => {
286287
setSelectedStyletag([]);
287288
setMode('');
288289

289-
navigate('/mypage');
290+
navigate(`/profile/${userId}`);
290291
} catch (error) {
291292
const errorMessage = handleError(error, 'post');
292293
setModalContent(errorMessage);
File renamed without changes.

0 commit comments

Comments
 (0)