Skip to content

Commit

Permalink
Chore: console.log 삭제 및 dist 파일 생성 (#28)
Browse files Browse the repository at this point in the history
- 불필요한 console.log 구문 제거로 코드 정리
- 배포를 위한 dist 파일 생성 및 확인
  • Loading branch information
sunglitter committed Dec 11, 2024
1 parent 2fb8cae commit 1a62e9c
Show file tree
Hide file tree
Showing 21 changed files with 5,413 additions and 5,564 deletions.
5,341 changes: 0 additions & 5,341 deletions dist/assets/index-BgC4eDEl.js

This file was deleted.

5,299 changes: 5,299 additions & 0 deletions dist/assets/index-Dp4wxnjx.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<!-- 페이지 타이틀 설정 -->
<title>Good-Buy-Us</title>
<script type="module" crossorigin src="/assets/index-BgC4eDEl.js"></script>
<script type="module" crossorigin src="/assets/index-Dp4wxnjx.js"></script>
</head>
<body>
<div id="root"></div>
Expand Down
63 changes: 27 additions & 36 deletions src/components/common/ChatRoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,21 @@ const ChatRoom: React.FC<ChatRoomProps> = ({
useEffect(() => {
// 채팅방 초기 메시지 및 채팅 메시지 가져오기
const fetchMessages = async () => {
try {
const fetchedMessages = await fetchChatMessages(chatRoomId);

// 입장 메시지 추가
const joinMessage: Message = {
senderId: 'system',
content: `${chatMembers
.map((member) => getNicknameDisplay(member))
.join(', ')}님이 입장하셨습니다.`,
timestamp: null, // timestamp 표시하지 않음
};

// 그룹 채팅 안내 메시지 추가
const groupChatNotice: Message = {
senderId: 'system',
content: `
const fetchedMessages = await fetchChatMessages(chatRoomId);

// 입장 메시지 추가
const joinMessage: Message = {
senderId: 'system',
content: `${chatMembers
.map((member) => getNicknameDisplay(member))
.join(', ')}님이 입장하셨습니다.`,
timestamp: null, // timestamp 표시하지 않음
};

// 그룹 채팅 안내 메시지 추가
const groupChatNotice: Message = {
senderId: 'system',
content: `
안내사항: 환불 및 이탈 관련 정책
1. 환불 및 수령 시간/위치 조율
- 공구 진행 중(최종 승인 이후)인 채팅방에서
Expand All @@ -73,13 +72,10 @@ const ChatRoom: React.FC<ChatRoomProps> = ({
공구 진행에 차질이 없도록 적극적인 협조
부탁드립니다. 😊`,
timestamp: null,
};
timestamp: null,
};

setMessages([joinMessage, groupChatNotice, ...fetchedMessages]);
} catch (error) {
console.error('Failed to fetch messages:', error);
}
setMessages([joinMessage, groupChatNotice, ...fetchedMessages]);
};

fetchMessages();
Expand All @@ -96,20 +92,15 @@ const ChatRoom: React.FC<ChatRoomProps> = ({
setMessages((prev) => [...prev, data]);
};

webSocketService.connect(
() => {
webSocketService.subscribe(
`/sub/message/${chatRoomId}`,
(messageOutput) => {
const data = JSON.parse(messageOutput.body);
handleIncomingMessage(data);
}
);
console.log('WebSocket connected to room');
},
() => console.log('WebSocket disconnected'),
() => console.error('WebSocket connection error')
);
webSocketService.connect(() => {
webSocketService.subscribe(
`/sub/message/${chatRoomId}`,
(messageOutput) => {
const data = JSON.parse(messageOutput.body);
handleIncomingMessage(data);
}
);
});

return () => {
webSocketService.unsubscribe(`/sub/message/${chatRoomId}`);
Expand Down
8 changes: 2 additions & 6 deletions src/components/pages/admin/ChatRoomManagementPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ const ChatRoomManagementPage = () => {

useEffect(() => {
const fetchData = async () => {
try {
const rooms = await fetchAllChatRooms();
setChatRooms(rooms);
} catch (error) {
console.error('Failed to fetch chat rooms:', error);
}
const rooms = await fetchAllChatRooms();
setChatRooms(rooms);
};

fetchData();
Expand Down
12 changes: 4 additions & 8 deletions src/components/pages/admin/PostApprovalPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ const PostApprovalPage = () => {
navigate('/admin/post'); // postId가 없을 경우 관리자 페이지로 리다이렉트
return;
}
try {
const postDetails = await fetchPostById(postId); // 포스트 세부 정보 가져오기
setPost(postDetails.communityPost);
} catch (error) {
console.error('Failed to fetch post details:', error);
}
const postDetails = await fetchPostById(postId); // 포스트 세부 정보 가져오기
setPost(postDetails.communityPost);
};
fetchPost();
}, [postId, navigate]);
Expand Down Expand Up @@ -58,8 +54,8 @@ const PostApprovalPage = () => {
await approvePost(postId, updatedTitle); // 포스트 상태를 APPROVED로 변경
alert('게시물이 승인되었습니다.');
navigate('/admin/post'); // 승인 후 관리자 페이지로 리다이렉트
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.error('Failed to approve post:', error);
alert('승인 처리 중 오류가 발생했습니다.');
}
};
Expand All @@ -75,8 +71,8 @@ const PostApprovalPage = () => {
await rejectPost(postId, updatedTitle); // 포스트 상태를 REJECTED로 변경
alert('게시물이 거절 처리되었습니다.');
navigate('/admin/post'); // 거절 후 관리자 페이지로 리다이렉트
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.error('Failed to reject post:', error);
alert('거절 처리 중 오류가 발생했습니다.');
}
};
Expand Down
8 changes: 2 additions & 6 deletions src/components/pages/admin/PostManagementPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ const PostManagementPage = () => {

useEffect(() => {
const fetchPosts = async () => {
try {
const response = await fetchPendingPosts();
setPosts(response);
} catch (error) {
console.error('Failed to fetch posts:', error);
}
const response = await fetchPendingPosts();
setPosts(response);
};

fetchPosts();
Expand Down
21 changes: 8 additions & 13 deletions src/components/pages/admin/api/adminApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@ import { Post } from '../../../../types/postTypes';

// 관리자용 승인 대기 중인 포스트 목록 조회
export const fetchPendingPosts = async (): Promise<Post[]> => {
try {
const response = await axiosInstance.get('/api/admin/post', {
headers: {
Authorization: `Bearer ${localStorage.getItem('jwt')}`,
},
});
if (response.status !== 200) {
throw new Error('Failed to fetch pending posts');
}
return response.data;
} catch (error) {
console.error('Error fetching pending posts:', error);
throw error;
const response = await axiosInstance.get('/api/admin/post', {
headers: {
Authorization: `Bearer ${localStorage.getItem('jwt')}`,
},
});
if (response.status !== 200) {
throw new Error('Failed to fetch pending posts');
}
return response.data;
};

// 관리자용 포스트 승인 처리
Expand Down
6 changes: 3 additions & 3 deletions src/components/pages/community/PaymentCompletePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const PaymentCompletePage: React.FC = () => {
if (data.status === 'DONE') {
setStatus('DONE');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.error('결제 상태 조회 오류:', error);
alert('결제 상태를 확인할 수 없습니다.');
}
};
Expand All @@ -62,8 +62,8 @@ const PaymentCompletePage: React.FC = () => {
title: postData.communityPost.title,
unitAmount: postData.communityPost.unitAmount,
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.error('게시물 정보 조회 오류:', error);
alert('게시물 정보를 가져올 수 없습니다.');
}
};
Expand All @@ -76,8 +76,8 @@ const PaymentCompletePage: React.FC = () => {
try {
const chatRoom = await createChatRoom(parseInt(communityPostId));
setChatRoom(chatRoom);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.error('채팅방 생성 오류:', error);
alert('채팅방을 생성할 수 없습니다.');
}
};
Expand Down
3 changes: 1 addition & 2 deletions src/components/pages/community/PostCreatePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ const PostCreatePage = () => {
alert('포스트가 작성되었습니다. 관리자의 승인을 대기 중입니다.');
navigate('/community/post');
},
onError: (error) => {
console.error('포스트 생성 중 오류 발생:', error);
onError: () => {
alert('포스트 생성에 실패했습니다.');
},
});
Expand Down
9 changes: 3 additions & 6 deletions src/components/pages/community/PostDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ const PostDetailPage: React.FC = () => {
const data = await fetchPostById(Number(communityPostId!));
setData(data);
setPost(data.communityPost);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.error('Failed to fetch post details:', error);
navigate('*');
}
};
Expand Down Expand Up @@ -106,7 +106,6 @@ const PostDetailPage: React.FC = () => {
};

eventSource.onerror = () => {
console.error('SSE 연결 오류 발생');
eventSource.close();
};

Expand Down Expand Up @@ -209,8 +208,7 @@ const PostDetailPage: React.FC = () => {
alert('공구 참여가 완료되었습니다.');
queryClient.invalidateQueries({ queryKey }); // 정확한 queryKey 사용
},
onError: (error: Error) => {
console.error('공구 참여 실패:', error.message); // 오류 메시지 출력
onError: () => {
alert('공구 참여에 실패했습니다.');
},
});
Expand Down Expand Up @@ -263,8 +261,7 @@ const PostDetailPage: React.FC = () => {
alert('공구 참여가 완료되었습니다.');
queryClient.invalidateQueries({ queryKey });
},
onError: (error: Error) => {
console.error('공구 참여 실패:', error.message);
onError: () => {
alert('공구 참여에 실패했습니다.');
},
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/pages/community/PostEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ const PostEditPage = () => {
await updatePost(Number(communityPostId), updatedPost); // 게시글 수정 API 호출
alert('게시글이 성공적으로 수정되었습니다.');
navigate(`/mypage/post/${communityPostId}`);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.error('게시글 수정 중 오류 발생:', error);
alert('게시글 수정에 실패했습니다. 다시 시도해주세요.');
}
};
Expand Down Expand Up @@ -252,8 +252,8 @@ const PostEditPage = () => {
await deletePostById(Number(communityPostId)); // 삭제 API 호출
alert('게시글이 성공적으로 삭제되었습니다.');
navigate('/mypage/post');
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.error('게시글 삭제 중 오류 발생:', error);
alert('게시글 삭제에 실패했습니다. 다시 시도해주세요.');
}
};
Expand Down
43 changes: 13 additions & 30 deletions src/components/pages/community/api/chatApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ export const createChatRoom = async (postId: number) => {
throw new Error('Failed to create chat room');
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { id, roomName } = response.data;
console.log(`Chat room created: ${roomName} (ID: ${id})`);

// 채팅방 구독 시작
webSocketService.subscribe(
`/sub/message/${id}`,
(message) => {
console.log(`Message in room ${id}:`, message);
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(message) => {},
true
);

Expand All @@ -36,8 +35,6 @@ export const deleteChatRoom = async (chatRoomId: number) => {
throw new Error('Failed to delete chat room');
}

console.log(`Chat room ${chatRoomId} deleted`);

// 채팅방 구독 취소
webSocketService.unsubscribe(`/sub/message/${chatRoomId}`);
return response.data;
Expand All @@ -55,7 +52,6 @@ export const fetchMyChatRooms = async () => {
throw new Error('Failed to fetch my chat rooms');
}

console.log('Fetched my chat rooms:', response.data);
return response.data;
};

Expand All @@ -71,7 +67,6 @@ export const fetchAllChatRooms = async () => {
throw new Error('Failed to fetch all chat rooms');
}

console.log('Fetched all chat rooms:', response.data);
return response.data;
};

Expand All @@ -89,7 +84,6 @@ export const sendMessage = (
};

webSocketService.send(`/pub/message/${chatRoomId}`, payload);
console.log(`Message sent to room ${chatRoomId}:`, payload);
};

// 채팅 메시지 구독
Expand All @@ -99,35 +93,24 @@ export const subscribeToChatMessages = (
callback: (message: any) => void
) => {
webSocketService.subscribe(`/sub/message/${chatRoomId}`, callback, true);
console.log(`Subscribed to messages for room ${chatRoomId}`);
};

// 채팅 메시지 구독 취소
export const unsubscribeFromChatMessages = (chatRoomId: number) => {
webSocketService.unsubscribe(`/sub/message/${chatRoomId}`);
console.log(`Unsubscribed from messages for room ${chatRoomId}`);
};

// 채팅 내용 조회
export const fetchChatMessages = async (chatRoomId: number) => {
try {
const response = await axiosInstance.get(`/api/chat/${chatRoomId}`, {
headers: {
Authorization: `Bearer ${localStorage.getItem('jwt')}`,
},
});

if (response.status !== 200) {
throw new Error('Failed to fetch chat messages');
}

console.log(`Fetched messages for chat room ${chatRoomId}:`, response.data);
return response.data;
} catch (error) {
console.error(
`Error fetching messages for chat room ${chatRoomId}:`,
error
);
throw error;
const response = await axiosInstance.get(`/api/chat/${chatRoomId}`, {
headers: {
Authorization: `Bearer ${localStorage.getItem('jwt')}`,
},
});

if (response.status !== 200) {
throw new Error('Failed to fetch chat messages');
}

return response.data;
};
Loading

0 comments on commit 1a62e9c

Please sign in to comment.