import ReviewAdd from "@/app/(public)/product/_components/review/ReviewAdd";
import ReviewDetail from "@/app/(public)/product/_components/review/ReviewDetail";
import { NoReview } from "@/app/(public)/product/_components/review/NoReview";
import { getProductReviews } from "@utils/hooks/getProductReviews";


export async function ProductReviewSection({
    productId, 
} : {
    productId:string;
}) { 
    const getAllreviews = await getProductReviews(productId)
    return (
        <>
            <div className="box-border w-full pr-4 pl-4">
                <ReviewAdd productId={productId} />
                {getAllreviews.length > 0 ? (
                  <>
                    <ReviewDetail
                      reviewDetails={getAllreviews}
                      totalReview={getAllreviews.length}
                      productId={productId}
                    />
                  </>
                ) : ( <NoReview />)}

            </div>
            
        </>

    );
}