Skip to content

Commit

Permalink
fix: console.log 제거, follow/create api 수정, Card 사용하는 곳에 이미지 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
chogyejin committed Jun 22, 2022
1 parent 56250ad commit aa65ded
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/api/follow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from "@lib/axios";

export const fetchPostFollowByUserId = (userId: string) =>
axios.post("/follow/create", {
data: { userId },
userId,
});

export const fetchDeleteFollowByUserId = (id: string) =>
Expand Down
1 change: 0 additions & 1 deletion src/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const fetchGetUserById = (userId: string) =>
axios.get(`/users/${userId}`);

export const fetchGetFollowUserList = async (followUserIdList: string[]) => {
console.log(followUserIdList);
return await Promise.all(
followUserIdList.map((followUserId) => fetchGetUserById(followUserId))
);
Expand Down
1 change: 1 addition & 0 deletions src/components/domain/ChallengesPage/Challenges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const Challenges = ({ posts }: ChallengesProps) => {
text={jsonObject.reward}
commentCount={challenge.comments.length}
cheerCount={challenge.likes.length}
avatarSrc={challenge.author.image}
></Card>
</CardContainer>
);
Expand Down
8 changes: 5 additions & 3 deletions src/components/domain/ProfilePage/MyChallenges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ const MyChallenges = ({ challenges }: UserChallengesProps) => {
<Text>챌린지가 없어요!</Text>
) : (
challenges.map((challenge) => {
console.log(challenge);

const jsonString = challenge.title.replaceAll("'", '"');
const jsonObject = JSON.parse(jsonString);
return (
<CardContainer
key={challenge._id}
onClick={() =>
handleChallengeClick(challenge.channel._id, challenge._id)
}
onClick={() => {
handleChallengeClick(challenge.channel._id, challenge._id);
}}
>
<Card
type="challenge"
Expand Down
14 changes: 11 additions & 3 deletions src/components/domain/ProfilePage/MySummary.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Button, Text } from "@chakra-ui/react";
import styled from "@emotion/styled";
import { Link } from "react-router-dom";
import { Link, useNavigate } from "react-router-dom";

interface UserSummaryProps {
introduce: string;
followerCount: number;
followingCount: number;
id: string;
}

const IntroduceText = styled(Text)`
Expand Down Expand Up @@ -43,17 +44,24 @@ const MySummary = ({
introduce,
followerCount,
followingCount,
id,
}: UserSummaryProps) => {
const navigate = useNavigate();

const handleFollowingClick = () => {
navigate(`/follow/${id}`);
};

return (
<UserSummaryContainer>
<IntroduceText textAlign="center">{introduce}</IntroduceText>
<FollowContainer>
<div>
<Text>{followerCount}</Text>
<Text onClick={handleFollowingClick}>{followerCount}</Text>
<div>팔로워</div>
</div>
<div>
<Text>{followingCount}</Text>
<Text onClick={handleFollowingClick}>{followingCount}</Text>
<div>팔로잉</div>
</div>
</FollowContainer>
Expand Down
19 changes: 15 additions & 4 deletions src/components/domain/ProfilePage/OtherSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { fetchPostFollowByUserId } from "@api/follow";
import { Button, Text } from "@chakra-ui/react";
import styled from "@emotion/styled";
import { Link } from "react-router-dom";
import { useNavigate } from "react-router-dom";

interface UserSummaryProps {
introduce: string;
followerCount: number;
followingCount: number;
id: string;
}

const IntroduceText = styled(Text)`
Expand Down Expand Up @@ -43,21 +45,30 @@ const OtherSummary = ({
introduce,
followerCount,
followingCount,
id,
}: UserSummaryProps) => {
const navigate = useNavigate();

const handleFollowingClick = () => {
navigate(`/follow/${id}`);
};

const handleFollowClick = () => {
console.log("팔로우 클릭");
void (async () => {
await fetchPostFollowByUserId(id);
})();
};

return (
<UserSummaryContainer>
<IntroduceText textAlign="center">{introduce}</IntroduceText>
<FollowContainer>
<div>
<Text>{followerCount}</Text>
<Text onClick={handleFollowingClick}>{followerCount}</Text>
<div>팔로워</div>
</div>
<div>
<Text>{followingCount}</Text>
<Text onClick={handleFollowingClick}>{followingCount}</Text>
<div>팔로잉</div>
</div>
</FollowContainer>
Expand Down
1 change: 1 addition & 0 deletions src/pages/ChallengesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const ChallengesPage = () => {
if (channelResult.data) {
const channelId = channelResult.data._id;
const challengesResult = await fetchGetPostListByChannel(channelId);
console.log(challengesResult.data);
setChallenges(challengesResult.data);
}
})();
Expand Down
4 changes: 0 additions & 4 deletions src/pages/EditProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ const EditProfilePage = () => {
const [newPassword, setNewPassword] = useState("");
const navigate = useNavigate();

const onChangeProfileImageClick = () => {
// console.log("프로필이미지변경클릭");
};

const onFullNameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const fullName = e.target.value;
setNewFullName(fullName);
Expand Down
10 changes: 1 addition & 9 deletions src/pages/FollowPage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { useState } from "react";
import { useState } from "react";
import { User } from "src/types";
import PageTab from "@domain/FollowPage/FollowPageTab";
import { useAtom } from "jotai";
import userAtom from "@store/user";
import useGetFollowUserList from "@hooks/quries/useGetFollowUserList";
import { useEffect } from "react";
import useGetUserById from "@hooks/quries/useGetUser";
Expand All @@ -12,41 +10,35 @@ const FollowPage = () => {
//const [user] = useAtom(userAtom);

const { userId } = useParams();
console.log(userId);
const { data: userRes } = useGetUserById(userId);

const [user, setUser] = useState<User>({} as User);
const [followerList, setFollowerList] = useState<User[]>([]);
const [followingList, setFollowingList] = useState<User[]>([]);

console.log(user);
const followerIdList: string[] =
user?.followers?.map((follow) => follow.follower) ?? [];
const followingIdList: string[] =
user?.following?.map((following) => following.user).filter((id) => id) ??
[];

console.log(followerIdList);
const { data: followerResList } = useGetFollowUserList(followerIdList);
const { data: followingResList } = useGetFollowUserList(followingIdList);

useEffect(() => {
if (userRes) {
console.log(userRes);
setUser(userRes.data);
}
}, [userRes]);

useEffect(() => {
if (followerResList) {
console.log(followerResList.map((res) => res.data));
setFollowerList(followerResList.map((res) => res.data));
}
}, [userRes, followerResList]);

useEffect(() => {
if (followingResList) {
console.log(followingResList.map((res) => res.data));
setFollowingList(followingResList.map((res) => res.data));
}
}, [userRes, followingResList]);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const HomePage = () => {

useEffect(() => {
if (res) {
console.log(res);
setPostLists(res.map((r) => r.data));
}
}, [res]);
Expand Down Expand Up @@ -76,6 +75,7 @@ const HomePage = () => {
text={challenge.reward}
commentCount={post.comments.length}
cheerCount={post.likes.length}
avatarSrc={post.author.image}
margin="16px 0"
onClick={() => {
onClickChallenge(post.channel._id, post._id);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface LoginResponse {
}

const LoginPage = () => {
usePageTitle("Shallange");
usePageTitle("Shallenge");
const navigate = useNavigate();
const toast = useToast();
const [myUser, setMyUser] = useAtom(userAtom);
Expand Down
5 changes: 3 additions & 2 deletions src/pages/MyProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useAtom } from "jotai";

import UserAvatar from "@domain/ProfilePage/UserAvatar";
import MyChallenges from "@domain/ProfilePage/MyChallenges";
import UserSummary from "@domain/ProfilePage/MySummary";
import MySummary from "@domain/ProfilePage/MySummary";
import userAtom from "@store/user";
import usePageTitle from "@hooks/usePageTitle";

Expand All @@ -22,10 +22,11 @@ const MyProfilePage = () => {
<>
<UserInfo>
<UserAvatar image={myUser.image} name={myUser.fullName} />
<UserSummary
<MySummary
introduce={myUser.coverImage}
followerCount={myUser.followers.length}
followingCount={myUser.following.length}
id={myUser._id}
/>
</UserInfo>
<MyChallenges challenges={myUser.posts} />
Expand Down
3 changes: 1 addition & 2 deletions src/pages/OtherProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ const OtherProfilePage = () => {
})();
}, []);

console.log(user);

return (
user && (
<>
Expand All @@ -40,6 +38,7 @@ const OtherProfilePage = () => {
introduce={user.coverImage}
followerCount={user.followers.length}
followingCount={user.following.length}
id={user._id}
/>
</UserInfo>
<OtherChallenges challenges={user.posts} />
Expand Down
3 changes: 3 additions & 0 deletions src/styles/GlobalStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ const style = css`
border-collapse: collapse;
border-spacing: 0;
}
* {
font-family: "Spoqa Han Sans Neo", "sans-serif";
}
`;

const GlobalStyles = () => {
Expand Down

2 comments on commit aa65ded

@vercel
Copy link

@vercel vercel bot commented on aa65ded Jun 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on aa65ded Jun 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

shallenge – ./

shallenge.vercel.app
shallenge-jaeho-team.vercel.app
shallenge-git-main-jaeho-team.vercel.app

Please sign in to comment.