Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

팔로잉,팔로워-팔로우/언팔로우-버튼-분기 #88

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/components/post/PostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const PostCard = ({
);

return (
<Card sx={{ display: "flex", gap: 2, p: 2 }}>
<Card sx={{ display: "flex", gap: 2, py:2 }} elevation={0}>
<Link href={USER_PAGE(createdBy)}>
<UserAvatar
src={profileImgUrls[0]?.attachUrl}
jobkaeHenry marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
27 changes: 20 additions & 7 deletions client/src/components/user/followList/FollowUserCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import UserAvatar from "@/components/user/info/UserAvatar";
import { useRouter } from "next/navigation";
import { USER_PAGE } from "@/const/clientPath";
import useUnFollowMutation from "@/queries/user/useUnFollowMutation";
import useFollowMutation from "@/queries/user/useFollowMutation";

type Props = {
imageUrl?: string;
nickName: string;
userId: string;
content: string;
userPk: number;
isFollowedByMe?: boolean;
};

const FollowUserCard = ({
Expand All @@ -19,10 +21,11 @@ const FollowUserCard = ({
nickName,
userId,
content,
isFollowedByMe,
}: Props) => {
const router = useRouter();
const { mutate: unfollowHandler } = useUnFollowMutation();

const { mutate: followHandler } = useFollowMutation();
return (
<Stack direction="row" gap={1} py={1}>
<UserAvatar
Expand All @@ -45,12 +48,22 @@ const FollowUserCard = ({
@{userId}
</Typography>
</Stack>
<Button
variant="outlined"
onClick={() => unfollowHandler(String(userPk))}
>
언팔로우
</Button>

{isFollowedByMe ? (
<Button
variant="outlined"
onClick={() => unfollowHandler(String(userPk))}
>
언팔로우
</Button>
) : (
<Button
variant="contained"
onClick={() => followHandler(String(userPk))}
>
팔로우
</Button>
)}
</Stack>
<Typography>{content}</Typography>
</Stack>
jobkaeHenry marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
21 changes: 12 additions & 9 deletions client/src/components/user/followList/FollowerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ const FollowerList = () => {
return (
<>
{data.pages.map((page) =>
page.content.map(({ nickname, id, introduction, userNo }) => (
<FollowUserCard
key={id}
nickName={nickname}
userId={id}
userPk={userNo}
content={introduction}
/>
))
page.content.map(
({ nickname, id, introduction, userNo, isFollowedByMe }) => (
<FollowUserCard
key={id}
nickName={nickname}
userId={id}
userPk={userNo}
isFollowedByMe={isFollowedByMe}
content={introduction}
/>
)
)
)}
{isFetchingNextPage ? (
<ComponentRepeater count={5}>
jobkaeHenry marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/user/followList/FollowingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ const FollowingList = () => {
return (
<>
{data.pages.map((page) =>
page.content.map(({ nickname, id, introduction, profileImgUrls, userNo }) => (
page.content.map(({ nickname, id, introduction, profileImgUrls, userNo,isFollowedByMe }) => (
<FollowUserCard
key={id}
nickName={nickname}
userId={id}
userPk={userNo}
isFollowedByMe={isFollowedByMe}
imageUrl={profileImgUrls[0]?.attachUrl}
content={introduction}
/>
jobkaeHenry marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
1 change: 1 addition & 0 deletions client/src/types/user/followingUserInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface FollowingUserInterface {
id: string;
userNo: number;
introduction: string;
isFollowedByMe:boolean;
createdBy: number;
profileImgUrls: AttachInterface[];
}
jobkaeHenry marked this conversation as resolved.
Show resolved Hide resolved
Expand Down