Skip to content

Commit e4d8123

Browse files
committed
Feat: 유저 이미지 보이도록 api연결 #65
1 parent 14a7463 commit e4d8123

File tree

7 files changed

+39
-55
lines changed

7 files changed

+39
-55
lines changed

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

+1-11
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,7 @@ export default function BoardsList({
3838
}}
3939
className="w-full"
4040
>
41-
<FeedBoardCard
42-
boardId={board.id}
43-
userName={board.writer}
44-
content={board.content}
45-
imgs={board.fileNames}
46-
setShowModal={setShowModal}
47-
comments={board.replyListDto}
48-
commentsCount={board.replyCount}
49-
likedCount={board.likedCount}
50-
createdDate={board.createdDate}
51-
/>
41+
<FeedBoardCard board={board} setShowModal={setShowModal} />
5242
</div>
5343
))
5444
) : (

components/ui/BoardCard/BoardCardPackage/BoardCardModalPackage/ModalComments.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@
22

33
import Image from 'next/image';
44
import { useState } from 'react';
5+
import Avatar from '@/components/ui/Avatar';
56
import FlexBox from '../../../FlexBox';
67
import Modal from '../../../Modal';
78

89
export default function BoardCardModalComments({
910
id,
1011
userName,
1112
content,
12-
userImg,
13+
userImage,
1314
}: {
1415
id: number;
1516
userName: string;
1617
content: string;
17-
userImg: string;
18+
userImage: string;
1819
}) {
1920
const [showSmallModal, setShowSmallModal] = useState(false);
2021

2122
return (
2223
<div key={id}>
2324
<FlexBox align="start" className="gap-3 group">
24-
<Image src={userImg} alt="사용자 프로필" width={36} height={36} />
25+
<Avatar size="base" image={userImage} name={userName} />
2526
<FlexBox direction="column" align="start" className="gap-1">
2627
<div>
2728
<div className="inline-block mr-1 body2 text-grey-500">

components/ui/BoardCard/BoardCardPackage/CommentWrapper.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,19 @@ export function BoardCardCommentWrapper({
8484
value={commentText}
8585
onChange={(event) => setCommentText(event.target.value)}
8686
/>
87-
<button type="button" onClick={postNewComment}>
87+
<button
88+
type="button"
89+
onClick={postNewComment}
90+
disabled={commentText.length === 0}
91+
className={`${
92+
commentText.length === 0 ? 'cursor-not-allowed' : null
93+
}`}
94+
>
8895
<PaperPlaneIcon
8996
className={`w-8 h-8 ${
90-
isLoading ? 'fill-grey-300' : 'fill-primary-300'
97+
isLoading || commentText.length === 0
98+
? 'fill-grey-300'
99+
: 'fill-primary-300'
91100
}`}
92101
/>
93102
</button>

components/ui/BoardCard/BoardCardPackage/Header.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@ import BoardCardDropdown from './BoardCardDropdown';
55

66
export default function BoardCardHeader({
77
userName,
8+
userImage,
89
createdDate,
910
}: {
1011
userName: string;
12+
userImage: string;
1113
createdDate: string;
1214
}) {
1315
return (
1416
<FlexBox justify="between" className="w-full">
1517
<FlexBox className="gap-[10px]">
16-
<Avatar
17-
size="xl"
18-
// TODO : 유저 프로필 사진 연결!
19-
image="/Feed/desktop/tempProfilePic.svg"
20-
name={String(userName)}
21-
/>
18+
<Avatar size="xl" image={userImage} name={String(userName)} />
2219
<FlexBox direction="column" align="start" className="gap-1">
2320
<FlexBox className="gap-2">
2421
<div className="header4 text-grey-800">{userName}</div>

components/ui/BoardCard/FeedBoardCard.tsx

+17-29
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,45 @@
11
import { Dispatch, SetStateAction } from 'react';
2-
import { Comment } from '@/types/types';
2+
import { Board } from '@/types/types';
33
import { BoardCard } from '@/components/ui/BoardCard/BoardCardPackage';
44
import FlexBox from '../FlexBox';
55

6-
interface FeedBoardCardProps {
7-
boardId: number;
8-
userName: string;
9-
content: string;
10-
imgs: string[];
11-
setShowModal: Dispatch<SetStateAction<boolean>>;
12-
comments: Comment[];
13-
commentsCount: number;
14-
likedCount: number;
15-
createdDate: string;
16-
}
17-
186
export default function FeedBoardCard({
19-
boardId,
20-
userName,
21-
content,
22-
imgs,
7+
board,
238
setShowModal,
24-
comments,
25-
commentsCount,
26-
likedCount,
27-
createdDate,
28-
}: FeedBoardCardProps) {
9+
}: {
10+
board: Board;
11+
setShowModal: Dispatch<SetStateAction<boolean>>;
12+
}) {
2913
// const { data: commentList } = useGetShortCommentList(boardId);
3014
return (
3115
<FlexBox
3216
direction="column"
3317
justify="between"
3418
className="max-h-[500px] p-9 rounded-[10px] border-[1px] border-grey-200 gap-4"
3519
>
36-
<BoardCard.Header userName={userName} createdDate={createdDate} />
20+
<BoardCard.Header
21+
userName={board.writer}
22+
createdDate={board.createdDate}
23+
userImage={board.userImageUrl}
24+
/>
3725
<BoardCard.Content
3826
type="mainPC"
39-
content={content}
40-
imgs={imgs}
27+
content={board.content}
28+
imgs={board.fileNames}
4129
onClickModal={() => setShowModal(true)}
4230
>
4331
<BoardCard.BoardCardCommentWrapper
44-
boardId={boardId}
45-
commentsCount={commentsCount}
46-
likedCount={likedCount}
32+
boardId={board.id}
33+
commentsCount={board.replyCount}
34+
likedCount={board.likedCount}
4735
>
4836
<FlexBox
4937
direction="column"
5038
justify="start"
5139
align="start"
5240
className="max-h-[74px] overflow-hidden"
5341
>
54-
{comments?.map((comment) => (
42+
{board.replyListDto?.map((comment) => (
5543
<BoardCard.Comments
5644
key={comment.id}
5745
userName={comment.nickname}

service/board.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ export async function postBoard(postBoardData: PostBoardType) {
1616
}
1717

1818
export async function getBoardList(pageParam: number) {
19-
let url = `/endpoint/api/board/list?pageSize=5`;
20-
if (pageParam !== 0) {
21-
url += `&pageNumber=${pageParam}`;
22-
}
19+
const url = `/endpoint/api/board/list?pageSize=5&pageNumber=${pageParam}`;
2320
try {
2421
const response = await fetch(url);
2522
if (response.status === 401) {

types/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export interface Board {
2020
fileNames: string[];
2121
likedCount: number;
2222
replyCount: number;
23+
userImageUrl: string;
24+
boardLiked: boolean;
2325
createdDate: string;
2426
modifiedDate: string;
2527
}

0 commit comments

Comments
 (0)