Skip to content

Commit 16eff7e

Browse files
committed
Fix: getCurrentUserId로 받아오는 모든 개별 변수명을 currentUserId로 통일
1 parent 37f0db6 commit 16eff7e

8 files changed

Lines changed: 18 additions & 25 deletions

File tree

src/pages/Post/PostBase/LikeCommentBottomSheetContent/index.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const LikeCommentBottomSheetContent: React.FC<LikeCommentBottomSheetProps> = ({
6969

7070
const { postId } = useParams<{ postId: string }>();
7171
const nav = useNavigate();
72+
const currentUserId = getCurrentUserId();
7273

7374
// 댓글 메뉴 클릭한 경우
7475
const handleMenuOpen = (comment: Comment, event: React.MouseEvent<HTMLButtonElement>) => {
@@ -80,10 +81,7 @@ const LikeCommentBottomSheetContent: React.FC<LikeCommentBottomSheetProps> = ({
8081

8182
// 유저 클릭한 경우
8283
const handleUserClick = (userId: number) => {
83-
// 로컬 스토리지에서 사용자 ID 가져오기
84-
const myUserId = getCurrentUserId(); // 로컬 스토리지에 저장된 사용자 ID를 가져옴
85-
86-
if (String(myUserId) === String(userId)) {
84+
if (currentUserId === userId) {
8785
// 나인 경우
8886
nav(`/profile/${userId}`);
8987
} else {
@@ -190,18 +188,16 @@ const LikeCommentBottomSheetContent: React.FC<LikeCommentBottomSheetProps> = ({
190188

191189
// 유저 차단 api
192190
const postUserBlock = async () => {
193-
const storedUserId = getCurrentUserId();
194-
195191
// 사용자 ID 또는 선택된 댓글이 없으면 함수 종료
196-
if (!storedUserId || !selectedComment) {
192+
if (!currentUserId || !selectedComment) {
197193
setModalContent('유저 정보를 찾을 수 없습니다.');
198194
setIsStatusModalOpen(true);
199195
return;
200196
}
201197

202198
try {
203199
const blockRequest: PostUserBlockRequest = {
204-
requesterId: Number(storedUserId),
200+
requesterId: currentUserId,
205201
targetId: selectedComment.user.id,
206202
action: 'block',
207203
};

src/pages/Post/PostBase/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import theme from '@styles/theme';
1010
import { getPostDetailApi } from '@apis/post';
1111
import { togglePostLikeStatusApi } from '@apis/post-like';
1212
import { postIdAtom, userAtom, isPostRepresentativeAtom } from '@recoil/Post/PostAtom';
13-
import { getCurrentUserId } from '@utils/getCurrentUserId';
1413

1514
import Left from '@assets/arrow/left.svg';
1615
import Message from '@assets/default/message.svg';

src/pages/Post/PostImageSelect/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ const PostImageSelect: React.FC = () => {
3737
const fileInputRef = useRef<HTMLInputElement | null>(null);
3838
const location = useLocation();
3939
const navigate = useNavigate();
40-
const userId = getCurrentUserId();
40+
const currentUserId = getCurrentUserId();
4141

4242
const handleClose = () => {
43-
navigate(`/profile/${userId}`);
43+
navigate(`/profile/${currentUserId}`);
4444
};
4545

4646
const handlePrev = () => {

src/pages/Post/PostInstaFeedSelect/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const PostInstaFeedSelect: React.FC = () => {
2626
const [posts, setPosts] = useState<Post[]>([]); // Post 타입으로 지정
2727
const [, setImages] = useRecoilState(postImagesAtom);
2828
const navigate = useNavigate();
29-
const userId = getCurrentUserId();
29+
const currentUserId = getCurrentUserId();
3030

3131
// 인스타그램 데이터 가져오는 함수
3232
const fetchInstagramData = async (accessToken: string) => {
@@ -75,7 +75,7 @@ const PostInstaFeedSelect: React.FC = () => {
7575

7676
// 페이지 종료 함수
7777
const handleClose = () => {
78-
navigate(`/profile/${userId}`);
78+
navigate(`/profile/${currentUserId}`);
7979
};
8080

8181
return (

src/pages/Post/PostUpload/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const PostUpload: React.FC<PostUploadModalProps> = () => {
6969
const [modalContent, setModalContent] = useState('알 수 없는 오류입니다.\n관리자에게 문의해 주세요.');
7070
const location = useLocation();
7171
const navigate = useNavigate();
72-
const userId = getCurrentUserId();
72+
const currentUserId = getCurrentUserId();
7373

7474
const styletags = [
7575
'classic',
@@ -240,7 +240,7 @@ const PostUpload: React.FC<PostUploadModalProps> = () => {
240240
setSelectedStyletag([]);
241241
setMode('');
242242

243-
navigate(`/profile/${userId}`);
243+
navigate(`/profile/${currentUserId}`);
244244
} catch (error) {
245245
const errorMessage = handleError(error, 'post');
246246
setModalContent(errorMessage);

src/pages/Post/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const Post: React.FC = () => {
3838
const [postPinStatus, setPostPinStatus] = useState<'지정' | '해제'>('지정');
3939

4040
const navigate = useNavigate();
41-
const userId = getCurrentUserId();
41+
const currentUserId = getCurrentUserId();
4242

4343
const handleMenuOpen = () => {
4444
if (isMyPost) {
@@ -73,7 +73,7 @@ const Post: React.FC = () => {
7373
setModalContent('OOTD 삭제에 성공했어요');
7474

7575
setTimeout(() => {
76-
navigate(`/profile/${userId}`);
76+
navigate(`/profile/${currentUserId}`);
7777
}, 1000);
7878
} else {
7979
setModalContent(`OOTD 삭제에 실패했어요\n잠시 뒤 다시 시도해 보세요`);
@@ -89,7 +89,7 @@ const Post: React.FC = () => {
8989
useEffect(() => {
9090
// 현재 게시글이 내 게시글인지 확인
9191
if (user?.id && postId) {
92-
setIsMyPost(Number(userId) === user.id);
92+
setIsMyPost(currentUserId === user.id);
9393
}
9494
}, [user, postId]);
9595

src/pages/Profile/ProfileEdit/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@ const ProfileEdit: React.FC = () => {
5454
const [modalContent, setModalContent] = useState<string | null>(null);
5555
const [isModalVisible, setIsModalVisible] = useState<boolean>(false);
5656
const [uploading, setUploading] = useState<boolean>(false);
57-
const userId = getCurrentUserId();
57+
const currentUserId = getCurrentUserId();
5858

5959
useEffect(() => {
6060
const getUserInfo = async () => {
6161
try {
62-
const currentUserId = getCurrentUserId();
6362
if (!currentUserId) {
6463
console.error('User ID not found');
6564
return;
@@ -114,7 +113,6 @@ const ProfileEdit: React.FC = () => {
114113

115114
const handleSave = async () => {
116115
try {
117-
const currentUserId = getCurrentUserId();
118116
if (!currentUserId) {
119117
console.error('User ID not found');
120118
return;
@@ -140,7 +138,7 @@ const ProfileEdit: React.FC = () => {
140138

141139
setTimeout(() => {
142140
handleModalClose();
143-
navigate(`/profile/${userId}`);
141+
navigate(`/profile/${currentUserId}`);
144142
}, 2000);
145143
} else {
146144
setModalContent('프로필 수정에 실패했습니다.');

src/pages/Profile/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import {
4949
const Profile: React.FC = () => {
5050
const { userId } = useParams<{ userId: string }>();
5151
const profileUserId = Number(userId);
52-
const loggedInUserId = getCurrentUserId();
52+
const currentUserId = getCurrentUserId();
5353
const otherUser = useRecoilValue(OtherUserAtom);
5454

5555
const [isLoading, setIsLoading] = useState<boolean>(true);
@@ -62,7 +62,7 @@ const Profile: React.FC = () => {
6262
const [modalContent, setModalContent] = useState('');
6363
const navigate = useNavigate();
6464

65-
const isMyPage = loggedInUserId === profileUserId;
65+
const isMyPage = currentUserId === profileUserId;
6666

6767
useEffect(() => {
6868
const fetchData = async () => {
@@ -83,7 +83,7 @@ const Profile: React.FC = () => {
8383

8484
const createMatching = async (message: string) => {
8585
const matchingRequestData = {
86-
requesterId: loggedInUserId,
86+
requesterId: currentUserId,
8787
targetId: otherUser?.id || profileUserId,
8888
message: message,
8989
};

0 commit comments

Comments
 (0)