feat: dynamically display average rating and testimonial count in the testimonials section.
This commit is contained in:
@@ -19,12 +19,16 @@ export function TestimonialsSection({ testimonials }: TestimonialsSectionProps)
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const averageRating = testimonials.length > 0
|
||||||
|
? (testimonials.reduce((sum, t) => sum + t.rating, 0) / testimonials.length).toFixed(1)
|
||||||
|
: '0.0';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white rounded-[20px] p-8">
|
<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>
|
<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" />
|
<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">
|
<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>
|
</p>
|
||||||
<div className="flex flex-col lg:grid lg:grid-cols-3 gap-6">
|
<div className="flex flex-col lg:grid lg:grid-cols-3 gap-6">
|
||||||
{testimonials.map((testimonial) => (
|
{testimonials.map((testimonial) => (
|
||||||
|
|||||||
Reference in New Issue
Block a user