'use client'; import Image from 'next/image'; import React, { useState } from 'react'; type Mode = 'light' | 'dark'; interface Testimonial { image: string; name: string; jobtitle: string; text: string; rating: number; } interface TestimonialProps { testimonials: Testimonial[]; mode?: Mode; } const StarRatingTestimonial: React.FC = ({ testimonials, mode = 'light' }) => { const [showAll, setShowAll] = useState(false); const maxDisplayedTestimonials = 6; const handleLoadMore = () => { setShowAll(true); }; return (
Read what people are saying Dummy feedback from virtual customers
using our component library.
{testimonials.slice(0, showAll || testimonials.length <= maxDisplayedTestimonials ? testimonials.length : maxDisplayedTestimonials).map((testimonial, index) => (
{[...Array(testimonial.rating)].map((_, starIndex) => ( ))} {[...Array(Math.max(0, 5 - testimonial.rating))].map((_, starIndex) => ( ))}
{testimonial.text}

profile
{testimonial.name} {testimonial.jobtitle}
))}
{testimonials.length > maxDisplayedTestimonials && !showAll && (
)} {!showAll && (
)}
); }; export default StarRatingTestimonial;