"use client" import { useState } from "react" import { Send } from "lucide-react" import { Button } from "@/components/ui/button" import { Textarea } from "@/components/ui/textarea" import { useAuth } from "@/lib/auth-context" import type { Comment } from "@/lib/types" import Link from "next/link" interface CommentSectionProps { comments: Comment[] novelId: string chapterId?: string } export function CommentSection({ comments: initialComments, novelId, chapterId }: CommentSectionProps) { const { user } = useAuth() const [comments, setComments] = useState(initialComments) const [content, setContent] = useState("") const handleSubmit = (e: React.FormEvent) => { e.preventDefault() if (!content.trim() || !user) return const newComment: Comment = { id: `c-${Date.now()}`, userId: user.id, username: user.username, avatarColor: user.avatarColor, novelId, chapterId, content: content.trim(), createdAt: new Date().toISOString().split("T")[0], } setComments((prev) => [newComment, ...prev]) setContent("") } return (
Chưa có bình luận nào. Hãy là người đầu tiên!
) : ( comments.map((comment) => ({comment.content}