import React, { useState, useRef } from 'react'; import { useTranslation } from 'react-i18next'; import { motion, AnimatePresence } from 'framer-motion'; const Experience = () => { const { t } = useTranslation(); const [currentPage, setCurrentPage] = useState(0); const [touchStart, setTouchStart] = useState(null); const [touchEnd, setTouchEnd] = useState(null); const containerRef = useRef(null); // Entfernen des 'translation.' Prefixes, da dies nicht in der Struktur vorhanden ist const experiences = t('pages.home.experience.positions', { returnObjects: true, defaultValue: [] }); const itemsPerPage = window.innerWidth >= 768 ? 2 : 1; 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('pages.home.experience.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;