Skip to content

Commit 7b2f086

Browse files
committed
Refactor: 이미지, 좋아요 수 api연결 #65
1 parent 8bcb5d7 commit 7b2f086

File tree

8 files changed

+49
-28
lines changed

8 files changed

+49
-28
lines changed

components/pages/main/Feed/BoardsList/index.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ export default function BoardsList({
3939
className="w-full"
4040
>
4141
<FeedBoardCard
42-
userId={board.writer}
42+
boardId={board.id}
43+
userName={board.writer}
4344
content={board.content}
4445
imgs={board.fileNames}
4546
setShowModal={setShowModal}
4647
comments={board.replyListDto}
4748
commentsCount={board.replyCount}
48-
boardId={board.id}
49+
likedCount={board.likedCount}
4950
/>
5051
</div>
5152
))

components/pages/mypage/MyPageMain/BookmarkedBoardsList/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ export default function BookmarkedBoardsList() {
3737
<MyBoardCard
3838
userName={board.writer}
3939
content={board.content}
40-
// TODO: 이미지 연결
41-
imgs={[]}
42-
commentsCount={board.replyCount}
40+
imgs={board.fileNames}
4341
setShowModal={setShowModal}
42+
commentsCount={board.replyCount}
43+
likedCount={board.likedCount}
4444
/>
4545
</div>
4646
)),

components/ui/BoardCard/BoardCardPackage/CommentWrapper.tsx

+11-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import Button from '../../Button';
88
export function BoardCardCommentWrapper({
99
children,
1010
isModal = false,
11-
commentsNum,
1211
boardId,
12+
commentsCount,
13+
likedCount,
1314
}: {
1415
children: React.ReactNode;
1516
isModal?: boolean;
16-
commentsNum: number;
1717
boardId: number;
18+
commentsCount: number;
19+
likedCount: number;
1820
}) {
1921
const [commentText, setCommentText] = useState('');
2022
const [isUploading, setIsUploading] = useState(false);
@@ -54,11 +56,11 @@ export function BoardCardCommentWrapper({
5456
<FlexBox className="gap-5">
5557
<FlexBox className="gap-2 body3 text-grey-500">
5658
<div>댓글</div>
57-
<div>{commentsNum}</div>
59+
<div>{commentsCount}</div>
5860
</FlexBox>
5961
<FlexBox className="gap-2 body3 text-grey-500">
6062
<div>좋아요</div>
61-
<div>2</div>
63+
<div>{likedCount}</div>
6264
</FlexBox>
6365
</FlexBox>
6466
{isModal ? (
@@ -104,11 +106,13 @@ export function BoardCardCommentWrapper({
104106
}
105107

106108
export function MyPageBoardCardCommentWrapper({
107-
commentsCount,
108109
onClickModal,
110+
commentsCount,
111+
likedCount,
109112
}: {
110-
commentsCount: number;
111113
onClickModal: () => void;
114+
commentsCount: number;
115+
likedCount: number;
112116
}) {
113117
return (
114118
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
@@ -127,7 +131,7 @@ export function MyPageBoardCardCommentWrapper({
127131
</FlexBox>
128132
<FlexBox className="gap-2 body3 text-grey-500">
129133
<div>좋아요</div>
130-
<div>2</div>
134+
<div>{likedCount}</div>
131135
</FlexBox>
132136
</FlexBox>
133137
</FlexBox>

components/ui/BoardCard/BoardCardPackage/Header.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ import Avatar from '../../Avatar';
33
import FlexBox from '../../FlexBox';
44
import BoardCardDropdown from './BoardCardDropdown';
55

6-
export default function BoardCardHeader({ userId }: { userId: string }) {
6+
export default function BoardCardHeader({ userName }: { userName: string }) {
77
return (
88
<FlexBox justify="between" className="w-full">
99
<FlexBox className="gap-[10px]">
1010
<Avatar
1111
size="xl"
12+
// TODO : 유저 프로필 사진 연결!
1213
image="/Feed/desktop/tempProfilePic.svg"
13-
name={String(userId)}
14+
name={String(userName)}
1415
/>
1516
<FlexBox direction="column" align="start" className="gap-1">
1617
<FlexBox className="gap-2">
17-
<div className="header4 text-grey-800">{userId}</div>
18+
<div className="header4 text-grey-800">{userName}</div>
1819
</FlexBox>
1920
<div className="caption2 text-grey-400">
2021
고양이 아무튼 자격증 보유중 ・ 3시간 전

components/ui/BoardCard/FeedBoardCard.tsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,43 @@ import { BoardCard } from '@/components/ui/BoardCard/BoardCardPackage';
44
import FlexBox from '../FlexBox';
55

66
interface FeedBoardCardProps {
7-
userId: string;
7+
boardId: number;
8+
userName: string;
89
content: string;
910
imgs: string[];
1011
setShowModal: Dispatch<SetStateAction<boolean>>;
1112
comments: Comment[] | undefined;
1213
commentsCount: number;
13-
boardId: number;
14+
likedCount: number;
1415
}
1516

1617
export default function FeedBoardCard({
17-
userId,
18+
boardId,
19+
userName,
1820
content,
1921
imgs,
2022
setShowModal,
2123
comments,
2224
commentsCount,
23-
boardId,
25+
likedCount,
2426
}: FeedBoardCardProps) {
2527
return (
2628
<FlexBox
2729
direction="column"
2830
justify="between"
2931
className="max-h-[500px] p-9 rounded-[10px] border-[1px] border-grey-200 gap-4"
3032
>
31-
<BoardCard.Header userId={userId} />
33+
<BoardCard.Header userName={userName} />
3234
<BoardCard.Content
3335
type="mainPC"
3436
content={content}
3537
imgs={imgs}
3638
onClickModal={() => setShowModal(true)}
3739
>
3840
<BoardCard.BoardCardCommentWrapper
39-
commentsNum={commentsCount}
4041
boardId={boardId}
42+
commentsCount={commentsCount}
43+
likedCount={likedCount}
4144
>
4245
<FlexBox
4346
direction="column"

components/ui/BoardCard/ModalBoardCard.tsx

+11-4
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,39 @@ import { Comment } from '@/types/types';
22
import { BoardCardModal } from '@/components/ui/BoardCard/BoardCardPackage/BoardCardModalPackage';
33

44
interface ModalBoardCardProps {
5-
userId: string;
5+
boardId: number;
6+
userName: string;
67
imgs: string[];
78
content: string;
89
comments: Comment[] | undefined;
910
commentsCount: number;
11+
likedCount: number;
1012
}
1113
export default function ModalBoardCard({
12-
userId,
14+
boardId,
15+
userName,
1316
imgs,
1417
content,
1518
comments,
1619
commentsCount,
20+
likedCount,
1721
}: ModalBoardCardProps) {
1822
return (
1923
<BoardCardModal imgs={imgs}>
20-
<BoardCardModal.Header userId={userId} />
24+
<BoardCardModal.Header userName={userName} />
2125
<BoardCardModal.Content type="modal" content={content} imgs={imgs}>
2226
<BoardCardModal.BoardCardCommentWrapper
23-
commentsNum={commentsCount}
2427
isModal
28+
boardId={boardId}
29+
commentsCount={commentsCount}
30+
likedCount={likedCount}
2531
>
2632
{comments?.map((comment) => (
2733
<BoardCardModal.ModalComments
2834
id={comment.id}
2935
userName={comment.nickname}
3036
content={comment.content}
37+
// TODO: 유저 프로필 사진 연결!
3138
userImg="/Feed/desktop/tempProfilePic.svg"
3239
/>
3340
))}

components/ui/BoardCard/MyPageBoardCard.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ interface MyBoardCardProps {
77
imgs: string[];
88
setShowModal: Dispatch<SetStateAction<boolean>>;
99
commentsCount: number;
10+
likedCount: number;
1011
}
1112

1213
export default function MyPageBoardCard({
@@ -15,19 +16,21 @@ export default function MyPageBoardCard({
1516
imgs,
1617
setShowModal,
1718
commentsCount,
19+
likedCount,
1820
}: MyBoardCardProps) {
1921
return (
2022
<BoardCard>
21-
<BoardCard.Header userId={userName} />
23+
<BoardCard.Header userName={userName} />
2224
<BoardCard.Content
2325
type="myPage"
2426
content={content}
2527
imgs={imgs}
2628
onClickModal={() => setShowModal(true)}
2729
>
2830
<BoardCard.MyPageBoardCardCommentWrapper
29-
commentsCount={commentsCount}
3031
onClickModal={() => setShowModal(true)}
32+
commentsCount={commentsCount}
33+
likedCount={likedCount}
3134
/>
3235
</BoardCard.Content>
3336
</BoardCard>

components/ui/BoardModal/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ export default function BoardModal({
3232
</FlexBox>
3333
{board ? (
3434
<ModalBoardCard
35-
userId={board.writer}
35+
boardId={board.id}
36+
userName={board.writer}
3637
imgs={board.fileNames}
3738
content={board.title}
3839
comments={comments}
3940
commentsCount={board.replyCount}
41+
likedCount={board.likedCount}
4042
/>
4143
) : (
4244
<div>내용이 없습니다.</div>

0 commit comments

Comments
 (0)