Skip to content

Commit

Permalink
feat :: 댓글 좋아요 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
six-standard committed Dec 6, 2023
1 parent 4348f96 commit df0f989
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Components/BoardPage/Comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { theme } from "../../styles/theme"
import { SubComment } from "./SubComment"
import { useEffect, useRef, useState } from "react"
import { Write } from "./Write"
import { deleteComment, getCoComent, getPostDetail, patchComment, postCoComent } from "../../apis/Board"
import { deleteComment, getCoComent, getPostDetail, patchComment, postCoComent, postCommentLike } from "../../apis/Board"

export const Comment = ({ profile, content, metaData, setContent }) => {
const [hidden, setHidden] = useState(true);
Expand Down Expand Up @@ -76,6 +76,14 @@ export const Comment = ({ profile, content, metaData, setContent }) => {
setComment("");
}

const handleLikeComment = () => {
postCommentLike(id).then(() => {
getPostDetail(metaData.postId).then(res => {
setContent(prev => { return { ...prev, commentResponseList: res.data.commentResponseList} });
});
})
}

return <Component>
<img src={profile.profileImg ? profile.profileImg : "/imgs/Profile.png"} width="50" height="50" alt="" />
<Data>
Expand All @@ -89,7 +97,7 @@ export const Comment = ({ profile, content, metaData, setContent }) => {
<Bottom $edit={edit.edit}>
<Left $edit={edit.edit}>
<div>
<img src="/imgs/icons/Like.svg" alt="" />
<Like src="/imgs/icons/Like.svg" alt="" $liked={metaData.liked} onClick={handleLikeComment}/>
<h1>{metaData.likes}</h1>
</div>
<div>
Expand Down
1 change: 1 addition & 0 deletions src/pages/DetailPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const DetailPage = () => {
likes: i.commentLikeCount,
postId: id,
id: i.id,
liked: i.liked
}}
setContent={setContent}
/>
Expand Down

0 comments on commit df0f989

Please sign in to comment.