Skip to content

Commit

Permalink
Merge pull request #147 from IT-Cotato/feat/#141
Browse files Browse the repository at this point in the history
[FEAT] 대대댓글 연동
  • Loading branch information
Ki-Tak authored Feb 21, 2025
2 parents fd8ceef + cbb36ef commit 64bbd88
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/components/board/FilterBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const FilterBox = () => {
setIsSortOpen(false);
};
return (
<div className="flex gap-[0.875rem]">
<div className="flex gap-[0.875rem] z-50">
<DropBox
dropList={categoriesWithAll}
state={isCategoryOpen}
Expand Down
21 changes: 12 additions & 9 deletions src/components/board/PostComment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import { useRef } from "react"
import { cn } from "@/utils/cn"
export const PostComment = ({ data, setInputFocus, focusedComment, setFocusedComment, handleCommentLike }) => {
const commentRef = useRef(null);
const handleComment = (ref, commentId) => {
const handleComment = (ref, commentId, parentId) => {
ref.current?.scrollIntoView({
behavior: "smooth",
block: "start"
})
setFocusedComment(commentId)
setFocusedComment({
parentId: commentId,
targetId: commentId
})
setInputFocus(true)
}

Expand All @@ -22,8 +25,8 @@ export const PostComment = ({ data, setInputFocus, focusedComment, setFocusedCom
<div ref={commentRef}
className={cn("flex flex-col gap-2 px-4 py-[0.9375rem] text-base",
{
"bg-primary-10": focusedComment === data.commentId,
"bg-white": focusedComment !== data.commentId
"bg-primary-10": focusedComment?.targetId === data.commentId,
"bg-white": focusedComment?.targetId !== data.commentId
})}>
<div className="flex justify-between">
<div className="flex items-center gap-2">
Expand Down Expand Up @@ -54,7 +57,7 @@ export const PostComment = ({ data, setInputFocus, focusedComment, setFocusedCom
<div className="text-neutral-border-50"
onClick={(e) => {
e.stopPropagation();
handleComment(commentRef, data.commentId)
handleComment(commentRef, data.commentId, data.parentId)
}}>
Reply
</div>
Expand All @@ -76,13 +79,13 @@ const ReplyComment = ({ reply, data, focusedComment, handleComment, handleCommen
<div ref={commentRef}
className={cn("flex flex-col gap-2 pl-[2.8125rem] pr-4 py-[0.9375rem] text-base",
{
"bg-primary-10": focusedComment === data.commentId,
"bg-white": focusedComment !== data.commentId
"bg-primary-10": focusedComment?.targetId === data.commentId,
"bg-white": focusedComment?.targetId !== data.commentId
})}>
<div className="flex justify-between" >
<div className="flex items-center gap-2">
<img src={anonymous} className="w-[1.375rem] h-[1.375rem]" />
<p>{data.author === "Author" ? <span className="text-[#2768FF]">Anonimity(Author)</span> : data.author}</p>
<p>{data.targetAuthor === "Author" ? <span className="text-[#2768FF]">Anonimity(Author)</span> : data.targetAuthor}</p>
<p className="text-neutral-border-50">{formatTime(data.createdTime)}</p>
</div>
<button className="flex gap-[0.125rem] cursor-pointer"
Expand All @@ -103,7 +106,7 @@ const ReplyComment = ({ reply, data, focusedComment, handleComment, handleCommen
<div className="text-neutral-border-50"
onClick={(e) => {
e.stopPropagation()
handleComment(commentRef, data.commentId)
handleComment(commentRef, data.commentId, data.parentId)
}}>
Reply
</div>
Expand Down
8 changes: 6 additions & 2 deletions src/pages/board/post.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PostHeader } from '@/components/board/PostHeader';
import { ScrapComponent } from '@/components/common/ScrapComponent';
import { path } from '@/routes/path';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import anonymous from '@/assets/imgs/anonymous.svg';
import kampus from '@/assets/imgs/kampusPost.svg';
import Like from '@/assets/imgs/like.svg?react';
Expand Down Expand Up @@ -90,10 +90,14 @@ export const Post = () => {
const submitComment = () => {
const buildComment = {
content: input,
parentId: focusedComment
parentId: focusedComment?.parentId,
targetId: focusedComment?.targetId
};
handleComment({ type: true, param: postId, data: buildComment });
}
useEffect(() => {
console.log(commentData)
})
const handleTranslate = () => {
if (translatedPost) {
setTranslateState(true);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const Home = () => {
</div>
</div>
{userDetail?.universityId !== -1 && (
<h1 className="text-pageTitle text-neutral-title">OO University</h1>
<h1 className="text-pageTitle text-neutral-title">{userDetail?.universityName}</h1>
)}
<div className="flex flex-col gap-[1.625rem]">
<div className="flex justify-center w-fit h-28 flex-col gap-[.625rem] rounded-[.625rem] border-[0.03125rem] border-primary-30 px-[.875rem] py-8">
Expand Down

0 comments on commit 64bbd88

Please sign in to comment.