import React, { useState } from 'react'; import { AnimatePresence, motion, PanInfo } from 'framer-motion'; import { ChevronLeftIcon, ChevronRightIcon, QuoteIcon } from 'lucide-react'; import { SectionHeading } from '../SectionHeading'; import { useSite } from '../../api'; import { useLang } from '../../i18n/lang'; import { EditableItem } from '../../admin/Editable'; export function Testimonials() { const { testimonials } = useSite(); const { t } = useLang(); const [index, setIndex] = useState(0); const current = testimonials[Math.min(index, Math.max(testimonials.length - 1, 0))]; if (!current) return null; const go = (dir: number) => { setIndex((prev) => (prev + dir + testimonials.length) % testimonials.length); }; const handleDragEnd = (_: MouseEvent | TouchEvent | PointerEvent, info: PanInfo) => { if (info.offset.x > 50) { go(1); // سوایپ به راست } else if (info.offset.x < -50) { go(-1); // سوایپ به چپ } }; return (
); }