'use client'; import { useState, useMemo } from "react"; import { CommentData } from "@/data/comments"; import Form from "./Form"; import CommentList from "./CommentList"; export default function Comment() { const [star, setStar] = useState(null); const productComment = CommentData.list.filter( (item:any) => item.item_type === "product" ); const filteredComments = useMemo(() => { if (star === null) return productComment; return productComment.filter(item => Number(item.rate) === star); }, [star]); return (

{filteredComments.length} Bình luận

{[5,4,3,2,1].map(s => ( ))}
{filteredComments.length > 0 && ( )}
) }