import React from "react"; import { CommentNode } from "@/server/db/schema"; import Avatar from "../avatar"; import { formatCommentDate } from "@/lib/utils/format"; import { Button } from "../ui/button"; import CommentEditor from "../editor/comment-editor"; import CommentVoteButton from "./comment-vote-button"; import { Session } from "next-auth"; import { Badge } from "../ui/badge"; import CommentDeleteButton from "./comment-delete-button"; import { cn } from "@/lib/utils"; const Comment = React.memo( (props: { comment: CommentNode; setReplyComment: (comment: CommentNode) => void; setRef: (el: HTMLDivElement | null) => void; session: Session | null; level?: number; }) => { const { comment, setReplyComment, setRef, session, level = 0 } = props; const isAuthor = session?.user?.id === comment?.author?.id; return (
0 && "ml-4 border-l", comment?.children?.length && "border-l", comment?.missingParent && "border-l", )} > {comment.missingParent && (
Antwort auf: Kommentar wurde gelöscht
)}
{comment.author?.name}
{isAuthor && ( DU )} {formatCommentDate(comment.createdAt)}
{isAuthor && }
{comment?.children && comment.children.length > 0 && (
{comment.children.map((child, idx) => ( ))}
)}
); }, ); export default Comment;