feat: dynamically display average rating and testimonial count in the testimonials section.

This commit is contained in:
pradeepkumar
2026-03-27 06:32:06 +05:30
parent 76ab856c20
commit d598637380

View File

@@ -19,12 +19,16 @@ export function TestimonialsSection({ testimonials }: TestimonialsSectionProps)
return null;
}
const averageRating = testimonials.length > 0
? (testimonials.reduce((sum, t) => sum + t.rating, 0) / testimonials.length).toFixed(1)
: '0.0';
return (
<div className="bg-white rounded-[20px] p-8">
<h2 className="text-[20px] font-bold text-[#00293D] font-fractul leading-[24px] text-center mb-4">Testimonials</h2>
<div className="w-full h-px bg-[#00293D]/20 mb-4" />
<p className="font-serif font-normal text-[14px] leading-[19px] text-[#00293D] text-center mb-8">
Clients rate our real estate services 4.9 out of 5 on average, based on recent client reviews.
Clients rate our real estate services {averageRating} out of 5 on average, based on {testimonials.length} recent client review{testimonials.length !== 1 ? 's' : ''}.
</p>
<div className="flex flex-col lg:grid lg:grid-cols-3 gap-6">
{testimonials.map((testimonial) => (