import React from "react"; import { TESTIMONIALS_THEME, TESTIMONIALS_TYPE, TestimonialsProps, TESTIMONIALS_VARIANT, DATA_TYPE } from "../../types"; import { cn } from "../../lib/utils"; import { MasonryLayout } from "./MasonryLayout"; import { CarouselLayout } from "./CarouselLayout"; import { ScrollLayout } from "./ScrollLayout"; import { ListLayout } from "./ListLayout"; import { useFetch } from "../../hooks/useFetch"; import { API_BASE } from "../../constants/t"; import { TestimonialCardSkeleton } from "./TestimonialCardSkeleton"; import { TestimonialCardError } from "./TestimonialCardError"; import { Heart } from "lucide-react"; const Testimonials = ({ data = [], collectionId, variant = "masonry", theme = "light", className, }: TestimonialsProps) => { const shouldFetch = !data || data.length === 0; const { data: fetchedTestimonials, loading, error, } = useFetch(shouldFetch ? API_BASE(collectionId) : null); const testimonials = shouldFetch ? fetchedTestimonials : data; if (shouldFetch && loading) { return (
{[...Array(6)].map((_, i) => ( ))}
); } if (shouldFetch && error) { return ; } if (!testimonials || testimonials.length === 0) { return ; } const renderLayout = () => { const commonProps = { testimonials, theme, columns: { sm: variant === "list" ? 1 : 1, md: variant === "list" ? 1 : 2, lg: variant === "list" ? 1 : 3, xl: variant === "list" ? 1 : 4, }, className: "w-full", }; switch (variant) { case "carousel": return ; case "scroll": return ; case "list": return ; case "masonry": default: return ; } }; return ( ); }; export { Testimonials, DATA_TYPE, TESTIMONIALS_TYPE, TESTIMONIALS_THEME, TESTIMONIALS_VARIANT };