'use client'; import { useState, useRef, useEffect } from 'react'; import { useTranslations } from 'next-intl'; import { motion, AnimatePresence } from 'framer-motion'; interface ExperiencePosition { role: string; company: string; period: string; highlights: string[]; } const Experience = () => { const t = useTranslations('pages.home.experience'); const [currentPage, setCurrentPage] = useState(0); const [touchStart, setTouchStart] = useState(null); const [touchEnd, setTouchEnd] = useState(null); const [itemsPerPage, setItemsPerPage] = useState(2); const containerRef = useRef(null); const experiences = t.raw('positions') as ExperiencePosition[]; useEffect(() => { const updateItemsPerPage = () => { setItemsPerPage(window.innerWidth >= 768 ? 2 : 1); }; updateItemsPerPage(); window.addEventListener('resize', updateItemsPerPage); return () => window.removeEventListener('resize', updateItemsPerPage); }, []); const totalPages = Math.ceil((Array.isArray(experiences) ? experiences.length : 0) / itemsPerPage); const handleTouchStart = (e: React.TouchEvent) => { setTouchStart(e.touches[0].clientX); }; const handleTouchMove = (e: React.TouchEvent) => { setTouchEnd(e.touches[0].clientX); }; const handleTouchEnd = () => { if (!touchStart || !touchEnd) return; const distance = touchStart - touchEnd; const isLeftSwipe = distance > 50; const isRightSwipe = distance < -50; if (isLeftSwipe && currentPage < totalPages - 1) { setCurrentPage(prev => prev + 1); } if (isRightSwipe && currentPage > 0) { setCurrentPage(prev => prev - 1); } setTouchStart(null); setTouchEnd(null); }; const getCurrentPageItems = () => { if (!Array.isArray(experiences)) return []; const startIndex = currentPage * itemsPerPage; return experiences.slice(startIndex, startIndex + itemsPerPage); }; return (

{t('title')}

{getCurrentPageItems().map((exp, index) => (

{exp.role}

{exp.company}

{exp.period}

    {exp.highlights?.map((highlight: string, hIndex: number) => ( {highlight} ))}
))}
{/* Navigation Dots */} {totalPages > 1 && (
{[...Array(totalPages)].map((_, index) => ( ))}
)}
); }; export default Experience;