"use client"; import { useState } from "react"; import { FaReply, FaTrash, FaEye, FaEyeSlash, FaEdit, FaSave, FaTimes } from "react-icons/fa"; type Reply = { id: string; text: string; timestamp: string; username: string; hidden?: boolean; like_count?: number; }; type Comment = { id: string; text: string; username: string; timestamp: string; like_count?: number; hidden?: boolean; replies?: { data: Reply[] }; }; interface SocialCommentItemProps { comment: Comment; onReply: (commentId: string, text: string) => void; onDelete: (commentId: string, isReply?: boolean, parentId?: string) => void; onHide: (commentId: string, currentHiddenStatus: boolean, isReply?: boolean) => void; onEdit: (commentId: string, newText: string, isReply: boolean, parentId?: string) => void; } const SocialCommentItem = ({ comment, onReply, onDelete, onHide, onEdit }: SocialCommentItemProps) => { const [replyText, setReplyText] = useState(""); const [isReplying, setIsReplying] = useState(false); const [isEditing, setIsEditing] = useState(false); const [editText, setEditText] = useState(comment.text); const handlePostReply = () => { if (!replyText.trim()) return; onReply(comment.id, replyText); setReplyText(""); setIsReplying(false); }; const handleSaveEdit = () => { if (!editText.trim()) return; onEdit(comment.id, editText, false, undefined); setIsEditing(false); }; return (
{/* TOP LEVEL COMMENT */}
{comment.username} {new Date(comment.timestamp).toLocaleString()} {comment.hidden && ( Hidden )}
{isEditing ? (