Skip to content

Commit

Permalink
fix : 콘솔로그 함수 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
ohsuhyeon0119 committed Jan 25, 2024
1 parent 4abc4a2 commit 21c3041
Show file tree
Hide file tree
Showing 16 changed files with 9 additions and 71 deletions.
3 changes: 0 additions & 3 deletions src/apis/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ export async function getUserRatingMovies(
.map(([key, value]) => `${key}=${value}`)
.join("&");

console.log(`${BASE_API_URL}/users/${userId}/ratings?${result}`);

return fetch(`${BASE_API_URL}/users/${userId}/ratings?${result}`);
}
export async function getUserWatchings(userId: number) {
Expand All @@ -76,7 +74,6 @@ export async function postCreateWatchingState(
return fetch(`${BASE_API_URL}/contents/${movieCD}/state`, {
method: "POST",


headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
Expand Down
12 changes: 0 additions & 12 deletions src/components/CommentInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { Link, useParams } from "react-router-dom";
import userImage from "../assets/user_default.jpg";
import styles from "./CommentInfo.module.scss";


import ReplyList from "./ReplyList";
import elapsedTime from "../utils/elapsedTime";
import { CommentType } from "../type";
import { useEffect, useState } from "react";


import { defaultResponseHandler } from "../apis/custom";
import { ReplyType } from "../type";
import CommentPageWriteModal from "./CommentPageWriteModal";
Expand All @@ -19,17 +17,14 @@ import DeleteComReplyModal from "./DeleteComReplyModal";
import { MdEdit } from "react-icons/md";
import { RiDeleteBin6Line } from "react-icons/ri";


function CommentHeader({ comment }: { comment: CommentType }) {
const { movie, rating, created_by, created_at } = comment;
console.log("target:", comment.movie);

return (
<div className={styles.commentHeader}>
<div className={styles.commentUser}>
<Link
className={styles.userLink}

to={`/users/${created_by.id}`}
title={created_by.nickname}
>
Expand All @@ -48,7 +43,6 @@ function CommentHeader({ comment }: { comment: CommentType }) {
<div className={styles.movieName}>{movie.title_ko}</div>
<div className={styles.releaseYear}>
영화 · {new Date(movie.release_date).getFullYear()}

</div>
</Link>
)}
Expand All @@ -74,7 +68,6 @@ function CommentHeader({ comment }: { comment: CommentType }) {
<div className={styles.poster}>
<img src={movie.poster} alt={movie.title_ko + "의 포스터"} />
</div>

</Link>
)}
</div>
Expand Down Expand Up @@ -270,17 +263,13 @@ export default function CommentInfo({
const [replies, setReplies] = useState<ReplyType[]>([]);
const { accessToken } = useAuthContext();
const [nextRepliesUrl, setNextRepliesUrl] = useState<string | null>(null); // 업로드한 댓글 ui에 반영하기 위해서는 commentInfo에 다음 state들이 있어야 함.
console.log("replies :", replies);

console.log(comment.movie);

useEffect(() => {
if (!commentId) return;

getCommentReplies(parseInt(commentId), accessToken ?? undefined)
.then(defaultResponseHandler)
.then((data) => {
console.log("success replies !!!!:", data);
const repliesResponse = data;
setReplies(repliesResponse.results);
setNextRepliesUrl(repliesResponse.next);
Expand Down Expand Up @@ -331,7 +320,6 @@ export default function CommentInfo({

<CommentHeader comment={comment} />


<CommentBody comment={comment} />
<CommentLikeReply
comment={comment}
Expand Down
2 changes: 0 additions & 2 deletions src/components/CommentPageWriteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export default function CommentPageWriteModal({
)
.then(defaultResponseHandler)
.then((data: ReplyType) => {
console.log("댓글 작성 성공", data);
addReply(data);
setCurrentModal(null);
})
Expand All @@ -134,7 +133,6 @@ export default function CommentPageWriteModal({
)
.then(defaultResponseHandler)
.then((data: ReplyType) => {
console.log("댓글 수정 성공", data);
updateReply(data);
setCurrentModal(null);
})
Expand Down
5 changes: 1 addition & 4 deletions src/components/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function ContentPanel({
return postCreateWatchingState(content.movieCD, accessToken, targetState)
.then(defaultResponseHandler)
.then((myState) => {
console.log(myState);
setMyState(myState);
});

Expand All @@ -84,7 +83,6 @@ function ContentPanel({
putUpdateWatchingState(content.my_state.id, accessToken, targetState)
.then(defaultResponseHandler)
.then((myState) => {
console.log(myState);
setMyState(myState);
})
);
Expand Down Expand Up @@ -254,7 +252,7 @@ function ContentComments({ content }: { content: MovieType }) {
setCommentsLength(comments.length);
const repComment =
comments.length <= 4 ? comments : comments.slice(0, 4);
console.log(repComment);

setComments(repComment);
})
.catch(() => alert("잘못된 요청입니다"));
Expand All @@ -276,7 +274,6 @@ function ContentComments({ content }: { content: MovieType }) {
<div className={styles.commentGridCon}>
<ul className={styles.commentsGrid}>
{comments.map((comment) => {
console.log(comment);
return <CommentCard key={comment.id} comment={comment} />;
})}
</ul>
Expand Down
2 changes: 0 additions & 2 deletions src/components/ReplyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,10 @@ export default function ReplyList({
comment.reply_count === replies.length ? "hidden" : "visible",
}}
onClick={() => {
console.log("nextRepliesUrl :", nextRepliesUrl);
nextRepliesUrl &&
replies &&
getNextCommentReplies(nextRepliesUrl, accessToken ?? undefined)
.then((res) => {
console.log("res :", res);
return res.json();
})
.then((data) => {
Expand Down
5 changes: 1 addition & 4 deletions src/components/SignupModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ export default function SignupModal({ setCurrentModal }: SignupModalProps) {
isAllInputsValid &&
postSignup(nameInput, idInput, passwordInput1, passwordInput2)
.then((res) => {
if (!res.ok) {
console.log(res); // res.json()에 에러 메시지가 담겨 있음
}
return res.json();
})
.then((data) => {
Expand Down Expand Up @@ -280,7 +277,7 @@ export default function SignupModal({ setCurrentModal }: SignupModalProps) {
window.open(
"/auth/toKakao",
"_blank",
"width=350,height=600",
"width=350,height=600"
);
}}
>
Expand Down
8 changes: 0 additions & 8 deletions src/components/StarRating.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export default function StarRating({
movieCD,
refetch,
}: StarRatingProps) {
console.log("my_Rate :", my_rate);
const savedRating = my_rate ? my_rate.my_rate : 0;
const [selectedRating, setSelectedRating] = useState(savedRating);
const { isLogined, accessToken } = useAuthContext();
Expand All @@ -74,15 +73,9 @@ export default function StarRating({
setSelectedRating(savedRating);
};
const onClickStarHandler = (rating: number) => {
console.log("my_rate", my_rate);
console.log("clicked rating: ", rating);

if (!isLogined) {
// loginModal;
} else {
console.log("clicked rating: ", rating);
console.log("accessToken", accessToken);

if (!my_rate)
return createRatingRequest(movieCD, rating, accessToken ?? "").then(
() => {
Expand All @@ -98,7 +91,6 @@ export default function StarRating({
refetch();
}
);

}
};

Expand Down
6 changes: 1 addition & 5 deletions src/components/WritingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function WritingModal(props: WritingModalProps) {
action=""
onSubmit={(e) => {
e.preventDefault();
console.log(movieCD, accessToken, commentInput, !hasSpoiler);

currentModal === "createComment" &&
accessToken &&
createCommentRequest(
Expand All @@ -61,8 +61,6 @@ export default function WritingModal(props: WritingModalProps) {
)
.then(defaultResponseHandler)
.then((data: CommentType) => {
console.log("data : ", data);
console.log("content : ", data.content);
setContent({
...content,
my_comment: data,
Expand All @@ -80,8 +78,6 @@ export default function WritingModal(props: WritingModalProps) {
)
.then(defaultResponseHandler)
.then((data: CommentType) => {
console.log("data : ", data);
console.log("content : ", data.content);
setContent({
...content,
my_comment: data,
Expand Down
13 changes: 2 additions & 11 deletions src/components/user/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default function User() {
// otherPage : 팔로우 버튼 보여준다(팔로우or언팔로우) / 좋아요 섹션 보여주지 않는다.
// isLoggedIn : 팔로우 버튼 보여준다(무조건 팔로우) / 좋아요 섹션 보여주지 않는다.


const [pageUser, setPageUser] = useState<UserDataType | null>(null); // PageUserType은 아래에 정의되어 있습니다.
const [pageUserloading, setPageUserLoading] = useState(true);
const [isMyFollowing, setIsMyFollowing] = useState<boolean>(false);
Expand All @@ -42,17 +41,15 @@ export default function User() {
isMyFollowing
? postUnFollow(accessToken, pageUser.id)
.then(defaultResponseHandler)
.then((data) => {
console.log(data);
.then(() => {
setIsMyFollowing(false);
})
.catch(() => {
console.log("팔로우 취소 실패");
})
: postAddFollow(accessToken, pageUser.id)
.then(defaultResponseHandler)
.then((data) => {
console.log(data);
.then(() => {
setIsMyFollowing(true);
})
.catch(() => {
Expand All @@ -76,7 +73,6 @@ export default function User() {
});
}, [pageUserId]);


// 유저데이터에 팔로잉 리스트가 없어서 추가로 가져와야 함

useEffect(() => {
Expand All @@ -89,8 +85,6 @@ export default function User() {
const isMyFollowing =
!!pageUserId && myFollowingIdList.includes(parseInt(pageUserId));

console.log("isfollw", isMyFollowing);

setIsMyFollowing(isMyFollowing);
})
.catch((e) => {
Expand All @@ -102,7 +96,6 @@ export default function User() {
}, [pageUserId]);

useEffect(() => {

const scrollToTop = () => {
window.scrollTo({
top: 0,
Expand Down Expand Up @@ -144,7 +137,6 @@ export default function User() {
isMyFollowing && styles.unfollow
}`}
onClick={followButtonClickHandler}

>
{isMyFollowing ? "팔로잉" : "팔로우"}
</button>
Expand Down Expand Up @@ -190,7 +182,6 @@ export default function User() {
</svg>
</div>
<span>영화</span>

</Link>
</section>
{/* likeSection 내가 좋아한 코멘트 목록 섹션 */}
Expand Down
10 changes: 3 additions & 7 deletions src/components/user/UserCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ export default function UserCard({
isFollowing
? postUnFollow(accessToken, follower.id)
.then(defaultResponseHandler)
.then((data) => {
console.log(data);
setIsFollowing(false); // 고쳐야 함!!!!!
.then(() => {
setIsFollowing(false);
})
.catch(() => {
console.log("팔로우 취소 실패");
})
: postAddFollow(accessToken, follower.id)
.then(defaultResponseHandler)
.then((data) => {
console.log(data);
.then(() => {
setIsFollowing(true);
})
.catch(() => {
Expand Down Expand Up @@ -66,9 +64,7 @@ export default function UserCard({
}
onClick={buttonClickHandler}
>

{isFollowing ? "팔로잉" : "팔로우"}

</button>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/AuthCallBackKakaoPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defaultResponseHandler } from "../apis/custom";
import { getKakaoAutoCallback } from "../apis/auth";
export default function AuthCallBackKakaoPage() {
const code = new URL(window.location.href).searchParams.get("code");
console.log("code : ", code);

// const navigate = useNavigate();
useEffect(() => {
// 이 엔드포인트로 code를 보내고 최종적으로는 api 서버에서 발급한 access token을 받아온다.
Expand Down
4 changes: 0 additions & 4 deletions src/pages/CommentListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ export default function CommentListPage() {
getCommentListRequest(movieCD, sortQuery)
.then(defaultResponseHandler)
.then((data) => {

console.log("success!!!!", data);

const commentsResponse = data;
setComments(commentsResponse.results);
setNextCommentsUrl(commentsResponse.next);
Expand All @@ -39,7 +36,6 @@ export default function CommentListPage() {
fetch(nextCommentsUrl)
.then(defaultResponseHandler)
.then((data) => {
console.log("scroll success :", data);
const commentsResponse = data;
setComments(comments.concat(commentsResponse.results));
setNextCommentsUrl(commentsResponse.next);
Expand Down
1 change: 0 additions & 1 deletion src/pages/CommentPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default function CommentPage() {
getCommentRequest(parseInt(id), accessToken ?? undefined)
.then(defaultResponseHandler)
.then((data: CommentType) => {
console.log("comment apge : ", data);
setCommentData(data);
})
.catch(() => {
Expand Down
4 changes: 0 additions & 4 deletions src/pages/user/UserLikesCommentListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default function UserLikesCommentListPage() {
getMyLikesComments(accessToken)
.then(defaultResponseHandler)
.then((data) => {
console.log("success!!!!", data);
const commentsResponse = data;
setComments(commentsResponse.results);
setNextCommentsUrl(commentsResponse.next);
Expand All @@ -44,7 +43,6 @@ export default function UserLikesCommentListPage() {
fetch(nextCommentsUrl)
.then(defaultResponseHandler)
.then((data) => {
console.log("scroll success :", data);
const commentsResponse = data;
setComments(comments.concat(commentsResponse.results));
setNextCommentsUrl(commentsResponse.next);
Expand All @@ -64,7 +62,6 @@ export default function UserLikesCommentListPage() {
getMyLikesComments(accessToken)
.then(defaultResponseHandler)
.then((data) => {
console.log("user likes comment list page : ", data);
const commentsResponse = data;
setComments(commentsResponse.results);
setNextCommentsUrl(commentsResponse.next);
Expand All @@ -85,7 +82,6 @@ export default function UserLikesCommentListPage() {
fetch(nextCommentsUrl)
.then(defaultResponseHandler)
.then((data) => {
console.log("scroll success :", data);
const commentsResponse = data;
setComments(comments.concat(commentsResponse.results));
setNextCommentsUrl(commentsResponse.next);
Expand Down
Loading

0 comments on commit 21c3041

Please sign in to comment.