feat: enhance CommentThreads component with commentClicked prop and update reply structure
This commit is contained in:
parent
e8524cffd6
commit
07b98b92ee
|
@ -1,7 +1,11 @@
|
|||
import React, { useState } from "react";
|
||||
import { getAvatarColor } from "../../../modules/collaboration/functions/getAvatarColor";
|
||||
|
||||
const CommentThreads: React.FC = () => {
|
||||
interface CommentThreadsProps {
|
||||
commentClicked: () => void;
|
||||
}
|
||||
|
||||
const CommentThreads: React.FC<CommentThreadsProps> = ({ commentClicked }) => {
|
||||
const [expand, setExpand] = useState(false);
|
||||
const commentsedUsers = [{ creatorId: "1" }];
|
||||
|
||||
|
@ -12,11 +16,25 @@ const CommentThreads: React.FC = () => {
|
|||
createdAt: "2 hours ago",
|
||||
comment: "Thread check",
|
||||
lastUpdatedAt: "string",
|
||||
replies: [],
|
||||
replies: [
|
||||
{
|
||||
replyId: 'string',
|
||||
creatorId: 'string',
|
||||
createdAt: 'string',
|
||||
lastUpdatedAt: 'string',
|
||||
reply: 'string',
|
||||
},
|
||||
{
|
||||
replyId: 'string',
|
||||
creatorId: 'string',
|
||||
createdAt: 'string',
|
||||
lastUpdatedAt: 'string',
|
||||
reply: 'string',
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
function getUsername(userId: string) {
|
||||
console.log(userId);
|
||||
const UserName = "username";
|
||||
return UserName;
|
||||
}
|
||||
|
@ -24,6 +42,7 @@ const CommentThreads: React.FC = () => {
|
|||
function getDetails(type?: "clicked") {
|
||||
if (type === "clicked") {
|
||||
setExpand(true);
|
||||
commentClicked();
|
||||
} else {
|
||||
setExpand((prev) => !prev);
|
||||
}
|
||||
|
@ -35,9 +54,8 @@ const CommentThreads: React.FC = () => {
|
|||
onPointerEnter={() => getDetails()}
|
||||
onPointerLeave={() => getDetails()}
|
||||
onClick={() => getDetails("clicked")}
|
||||
className={`comments-threads-container ${
|
||||
expand ? "open" : "closed"
|
||||
} unread`}
|
||||
className={`comments-threads-container ${expand ? "open" : "closed"
|
||||
} unread`}
|
||||
>
|
||||
<div className="users-commented">
|
||||
{commentsedUsers.map((val, i) => (
|
||||
|
@ -61,7 +79,7 @@ const CommentThreads: React.FC = () => {
|
|||
</div>
|
||||
<div className="message">{CommentDetails.comment}</div>
|
||||
{CommentDetails.replies.length > 0 && (
|
||||
<div className="replies">{CommentDetails.replies.length}</div>
|
||||
<div className="replies">{CommentDetails.replies.length} reply(s)</div>
|
||||
)}
|
||||
</div>
|
||||
</button>
|
||||
|
|
|
@ -26,6 +26,11 @@ function CommentInstance({ comment }: { comment: CommentSchema }) {
|
|||
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||
}, [selectedComment]);
|
||||
|
||||
const commentClicked = () => {
|
||||
console.log('hii');
|
||||
setSelectedComment(comment);
|
||||
}
|
||||
|
||||
if (comment.state === 'inactive' || isPlaying) return null;
|
||||
|
||||
return (
|
||||
|
@ -41,7 +46,7 @@ function CommentInstance({ comment }: { comment: CommentSchema }) {
|
|||
rotation={comment.rotation}
|
||||
className='comments-main-wrapper'
|
||||
>
|
||||
<CommentThreads />
|
||||
<CommentThreads commentClicked={commentClicked} />
|
||||
</Html>
|
||||
{CommentRef.current && transformMode && (
|
||||
<TransformControls
|
||||
|
|
|
@ -6,7 +6,7 @@ function CommentInstances() {
|
|||
const { comments } = useCommentStore();
|
||||
|
||||
useEffect(() => {
|
||||
console.log('comments: ', comments);
|
||||
// console.log('comments: ', comments);
|
||||
}, [comments])
|
||||
|
||||
return (
|
||||
|
|
|
@ -10,7 +10,7 @@ interface CommentSchema {
|
|||
replies: Reply[];
|
||||
}
|
||||
|
||||
export interface Reply {
|
||||
interface Reply {
|
||||
replyId: string;
|
||||
creatorId: string;
|
||||
createdAt: string;
|
||||
|
|
Loading…
Reference in New Issue