Skip to content

Commit

Permalink
Merge pull request #117 from Gamegoo-repo/fix/#116
Browse files Browse the repository at this point in the history
[Fix] 오류 수정
  • Loading branch information
yyypearl authored Oct 13, 2024
2 parents 1e52588 + 2e29c31 commit 709f15e
Show file tree
Hide file tree
Showing 46 changed files with 300 additions and 433 deletions.
2 changes: 0 additions & 2 deletions src/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ AuthAxios.interceptors.response.use(
try {
/* 토큰 재발급 요청 */
const response = await reissueToken();
console.log(response);
const newAccessToken = response.result.accessToken;
const originRequest = config; // 이전 요청 저장

// 로컬 또는 세션에 재발급된 토큰 저장
console.log(newAccessToken);
if (localStorage.getItem('accessToken')) {
localStorage.setItem('accessToken', newAccessToken);
localStorage.setItem('refreshToken', response.result.refreshToken);
Expand Down
10 changes: 0 additions & 10 deletions src/api/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ interface ListInterface {
export const postBoard = async (params: PostReq) => {
try {
const response = await AuthAxios.post("/v1/posts", params);
console.log("글쓰기 완료:", response.data);
return response.data;
} catch (error) {
console.error("글쓰기 실패:", error);
Expand All @@ -22,7 +21,6 @@ export const postBoard = async (params: PostReq) => {
export const getBoardList = async (params: ListInterface) => {
try {
const response = await AuthAxios.get("/v1/posts/list", { params });
console.log("게시판 목록:", response.data);
return response.data;
} catch (error) {
console.error("게시판 목록 불러오기 실패:", error);
Expand All @@ -34,9 +32,7 @@ export const getBoardList = async (params: ListInterface) => {
export const getMemberPost = async (postId: number) => {
try {
const response = await AuthAxios.get(`/v1/posts/member/list/${postId}`);
console.log("로그인 상태 게시글 조회 성공:", response.data);
return response.data;

} catch (error) {
console.error("로그인 상태 게시글 조회 실패:", error);
throw error;
Expand All @@ -47,9 +43,7 @@ export const getMemberPost = async (postId: number) => {
export const getNonMemberPost = async (postId: number) => {
try {
const response = await Axios.get(`/v1/posts/list/${postId}`);
console.log("로그아웃 상태 게시글 조회 성공:", response.data);
return response.data;

} catch (error) {
console.error("로그아웃 상태 게시글 조회 실패:", error);
throw error;
Expand All @@ -60,9 +54,7 @@ export const getNonMemberPost = async (postId: number) => {
export const editPost = async (postId: number, params: PostReq) => {
try {
const response = await AuthAxios.put(`/v1/posts/${postId}`, params);
console.log("게시글 수정 성공:", response.data);
return response.data;

} catch (error) {
console.error("게시글 수정 실패:", error);
throw error;
Expand All @@ -73,9 +65,7 @@ export const editPost = async (postId: number, params: PostReq) => {
export const deletePost = async (postId: number) => {
try {
const response = await AuthAxios.delete(`/v1/posts/${postId}`);
console.log("게시글 삭제 성공:", response.data);
return response.data;

} catch (error) {
console.error("게시글 삭제 실패:", error);
throw error;
Expand Down
13 changes: 0 additions & 13 deletions src/api/chat.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Axios from ".";
import { AuthAxios } from "./auth";

/* 채팅방 목록 조회 */
Expand All @@ -7,10 +6,8 @@ export const getChatrooms = async (cursor?: number) => {

try {
const response = await AuthAxios.get(url);
console.log("채팅방 목록 조회 완료:", response.data);
return response.data;
} catch (error) {
console.error("채팅방 목록 조회 실패:", error);
throw error;
}
};
Expand All @@ -19,10 +16,8 @@ export const getChatrooms = async (cursor?: number) => {
export const enterUsingUuid = async (uuid: string) => {
try {
const response = await AuthAxios.get(`/v1/chat/${uuid}/enter`);
console.log("채팅방 입장 성공:", response.data);
return response.data;
} catch (error) {
console.error("채팅방 입장 실패:", error);
throw error;
}
};
Expand All @@ -31,10 +26,8 @@ export const enterUsingUuid = async (uuid: string) => {
export const enterUsingMemberId = async (memberId: number) => {
try {
const response = await AuthAxios.get(`/v1/chat/start/member/${memberId}`);
console.log("채팅방 입장 성공:", response.data);
return response.data;
} catch (error) {
console.error("채팅방 입장 실패:", error);
throw error;
}
};
Expand All @@ -43,10 +36,8 @@ export const enterUsingMemberId = async (memberId: number) => {
export const enterUsingBoardId = async (boardId: number) => {
try {
const response = await AuthAxios.get(`/v1/chat/start/board/${boardId}`);
console.log("채팅방 입장 성공:", response.data);
return response.data;
} catch (error) {
console.error("채팅방 입장 실패:", error);
throw error;
}
};
Expand All @@ -66,10 +57,8 @@ export const getChatList = async (uuid: string, cursor?: number | null) => {
export const leaveChatroom = async (uuid: string) => {
try {
const response = await AuthAxios.patch(`/v1/chat/${uuid}/exit `);
console.log("채팅방 나가기 성공:", response.data);
return response.data;
} catch (error) {
console.error("채팅방 나가기 실패:", error);
throw error;
}
};
Expand All @@ -81,10 +70,8 @@ export const markChatAsRead = async (uuid: string, timestamp: null | number) =>
: `/v1/chat/${uuid}/read`;
try {
const response = await AuthAxios.patch(url);
console.log("채팅 메시지 읽음 처리 성공:", response.data);
return response.data;
} catch (error) {
console.error("채팅 메시지 읽음 처리 실패:", error);
throw error;
}
};
Expand Down
11 changes: 0 additions & 11 deletions src/api/friends.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { AuthAxios } from "./auth";
import Axios from ".";
import { notify } from "@/hooks/notify";

/* 친구 요청 */
export const reqFriend = async (memberId: number) => {
try {
const response = await AuthAxios.post(`/v1/friends/request/${memberId}`);
console.log("친구 요청 완료:", response.data);
return response.data;
} catch (error: any) {
if (error.response && error.response.data) {
Expand Down Expand Up @@ -38,7 +36,6 @@ export const reqFriend = async (memberId: number) => {
}

notify({ text: errorMessage, icon: '🚫', type: 'error' });
console.error(errorMessage);
} else {
console.error("친구 요청 실패:", error);
}
Expand All @@ -50,7 +47,6 @@ export const reqFriend = async (memberId: number) => {
export const cancelFriendReq = async (memberId: number) => {
try {
const response = await AuthAxios.delete(`/v1/friends/request/${memberId}`);
console.log("친구 요청 취소 성공:", response.data);
return response.data;
} catch (error: any) {
let errorMessage = "친구 요청 취소에 실패했습니다.";
Expand All @@ -69,7 +65,6 @@ export const cancelFriendReq = async (memberId: number) => {
break;
}
}
console.error(errorMessage);
} else {
console.error("친구 요청 취소 실패:", error);
}
Expand All @@ -82,10 +77,8 @@ export const cancelFriendReq = async (memberId: number) => {
export const acceptFreindReq = async (memberId: number) => {
try {
const response = await AuthAxios.patch(`/v1/friends/request/${memberId}/accept`);
console.log("친구 요청 수락 성공:", response.data);
return response.data;
} catch (error) {
console.log("친구 요청 수락 실패:", error);
throw error;
}
};
Expand All @@ -94,10 +87,8 @@ export const acceptFreindReq = async (memberId: number) => {
export const rejectFreindReq = async (memberId: number) => {
try {
const response = await AuthAxios.patch(`/v1/friends/request/${memberId}/reject`);
console.log("친구 요청 거절 성공:", response.data);
return response.data;
} catch (error) {
console.log("친구 요청 거절 실패:", error);
throw error;
}
};
Expand All @@ -106,10 +97,8 @@ export const rejectFreindReq = async (memberId: number) => {
export const deleteFriend = async (memberId: number) => {
try {
const response = await AuthAxios.delete(`/v1/friends/${memberId}`);
console.log("친구 삭제 완료:", response.data);
return response.data;
} catch (error) {
console.error("친구 삭제 실패:", error);
throw error;
}
};
Expand Down
52 changes: 23 additions & 29 deletions src/api/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import Axios from ".";

interface joinProps {
isAgree: boolean;
email: string;
password: string;
gameName: string;
tag: string;
email: string;
password: string;
gameName: string;
tag: string;
}

export const sendJoinEmail= async ({ email }: { email: string }) => {
export const sendJoinEmail = async ({ email }: { email: string }) => {
const endpoint = '/v1/member/email/send/join';

try {
Expand All @@ -21,7 +21,7 @@ export const sendJoinEmail= async ({ email }: { email: string }) => {
}
};

export const sendAuth= async ({ email, code }: { email: string, code: string }) => {
export const sendAuth = async ({ email, code }: { email: string, code: string }) => {
const endpoint = '/v1/member/email/verify';
try {
const response = await Axios.post(endpoint, { email, code });
Expand All @@ -46,26 +46,20 @@ export const checkRiot = async ({ gameName, tag }: { gameName: string, tag: stri
};

export const joinMember = async ({
isAgree,
email,
password,
gameName,
tag
}: joinProps) => {
console.log(isAgree,
email,
password,
gameName,
tag);
try {
const response = await Axios.post('/v1/member/join', {
isAgree, email, password, gameName, tag
});
console.log('회원가입 성공:', response.data);
return response.data;
} catch (error) {
console.error('회원가입 실패:', error);
console.log()
throw error;
}
};
isAgree,
email,
password,
gameName,
tag
}: joinProps) => {
try {
const response = await Axios.post('/v1/member/join', {
isAgree, email, password, gameName, tag
});
console.log('회원가입 성공:', response.data);
return response.data;
} catch (error) {
console.error('회원가입 실패:', error);
throw error;
}
};
1 change: 0 additions & 1 deletion src/api/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const postLogin = async ({
"Content-Type": "multipart/form-data",
},
});
console.log('로그인 성공:', response.data);

return response.data;
} catch (error) {
Expand Down
15 changes: 0 additions & 15 deletions src/api/manner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ interface MannerReqInterface {
export const getMannerValues = async (memberId: number) => {
try {
const response = await AuthAxios.get(`/v1/manner/good/${memberId}`);
console.log("매너 평가 조회 완료:", response.data);
return response.data;
} catch (error) {
console.error("매너 평가 조회 실패:", error);
throw error;
}
};
Expand All @@ -26,10 +24,8 @@ export const getMannerValues = async (memberId: number) => {
export const getBadMannerValues = async (memberId: number) => {
try {
const response = await AuthAxios.get(`/v1/manner/bad/${memberId}`);
console.log("비매너 평가 조회 완료:", response.data);
return response.data;
} catch (error) {
console.error("비매너 평가 조회 실패:", error);
throw error;
}
};
Expand All @@ -38,10 +34,8 @@ export const getBadMannerValues = async (memberId: number) => {
export const getOthersManner = async (memberId: number) => {
try {
const response = await AuthAxios.get(`/v1/manner/${memberId}`);
console.log("평가 조회 완료:", response.data);
return response.data;
} catch (error) {
console.error("평가 조회 실패:", error);
throw error;
}
};
Expand All @@ -50,11 +44,8 @@ export const getOthersManner = async (memberId: number) => {
export const postMannerValue = async (params: MannerInterface) => {
try {
const response = await AuthAxios.post(`/v1/manner/good`, params);
console.log("매너 평가 등록 성공:", response.data);
await localStorage.setItem('mannerId', response.data.result.mannerId);
return response.data;
} catch (error) {
console.error("매너 평가 등록 실패:", error);
throw error;
}
};
Expand All @@ -63,11 +54,8 @@ export const postMannerValue = async (params: MannerInterface) => {
export const postBadMannerValue = async (params: MannerInterface) => {
try {
const response = await AuthAxios.post(`/v1/manner/bad`, params);
console.log("비매너 평가 등록 성공:", response.data);
await localStorage.setItem('badMannerId', response.data.result.mannerId);
return response.data;
} catch (error) {
console.error("비매너 평가 등록 실패:", error);
throw error;
}
};
Expand All @@ -76,7 +64,6 @@ export const postBadMannerValue = async (params: MannerInterface) => {
export const editManners = async (mannerId: number, params: MannerReqInterface) => {
try {
const response = await AuthAxios.put(`/v1/manner/${mannerId}`, params);
console.log('수정')
return response.data;
} catch (error) {
throw error;
Expand All @@ -86,10 +73,8 @@ export const editManners = async (mannerId: number, params: MannerReqInterface)
export const getOtherManner = async (memberId: number) => {
try {
const response = await AuthAxios.get(`/v1/manner/${memberId}`);
console.log("다른 유저 매너 평가 조회 완료:", response.data);
return response.data;
} catch (error) {
console.error("다른 유저 평가 조회 실패:", error);
throw error;
}
};
Loading

0 comments on commit 709f15e

Please sign in to comment.