import {useCallback, useState} from 'react'; import {AnimatePresence, motion} from 'motion/react'; import {ChevronLeft, ChevronRight, Quote, Star} from 'lucide-react'; import {PAGE_TITLE_TYPOGRAPHY_CLASS} from '~/lib/pageTitle'; import {useSwipeNavigate} from '~/lib/useSwipeNavigate'; import type {TestimonialsSectionCms} from '~/lib/testimonials'; import {MOCK_TESTIMONIALS_SECTION_CMS} from '~/lib/testimonials'; /** * GROQ: `home` singleton โ†’ testimonials module. * Use with `context.sanity.loadQuery(TESTIMONIALS_SECTION_GROQ)` or `useQuery` in the browser. */ export const TESTIMONIALS_SECTION_GROQ = `*[_type == "home" && _id == "home"][0].testimonialsSection{ title, testimonials[]{ name, location, avatarInitials, rating, product, text, verified }, stats[]{ value, label, sub }, sectionBackground, cardBackground, gold, charcoal, muted, verifiedGreen, gridLine, dotInactive }` as const; export {MOCK_TESTIMONIALS_SECTION_CMS}; export type {TestimonialsSectionCms}; export type TestimonialsProps = { cms: TestimonialsSectionCms; }; /** * `React/src/app/components/Testimonials.tsx` โ€” carousel + stats grid; avatars are initials (no raster in reference). */ export function Testimonials({cms}: TestimonialsProps) { const [currentIndex, setCurrentIndex] = useState(0); const [direction, setDirection] = useState(1); const sectionBg = cms.sectionBackground; const cardBg = cms.cardBackground; const gold = cms.gold; const charcoal = cms.charcoal; const muted = cms.muted; const verifiedGreen = cms.verifiedGreen; const gridLine = cms.gridLine; const dotInactive = cms.dotInactive; const list = cms.testimonials; const len = list.length; const goNext = useCallback(() => { setDirection(1); setCurrentIndex((prev) => (prev + 1) % len); }, [len]); const goPrev = useCallback(() => { setDirection(-1); setCurrentIndex((prev) => (prev - 1 + len) % len); }, [len]); const swipe = useSwipeNavigate(goPrev, goNext); const current = list[currentIndex]; return (
{cms.title}
1 ? swipe : {})} >
{Array.from({length: current.rating}).map((_, i) => ( ))}

“{current.text}”

{current.avatarInitials}

{current.name}

{current.verified ? ( {'\u2713'} Verified ) : null}

{current.location?.trim() ? `${current.location.trim()} ยท ${current.product}` : current.product}

{list.map((t, i) => (
{cms.stats.map((stat) => (

{stat.value}

{stat.label}

{stat.sub}

))}
); }