"use client"; import { useState } from "react"; import Image from "next/image"; import { X, ChevronLeft, ChevronRight, Camera } from "lucide-react"; import { motion, AnimatePresence } from "framer-motion"; import { Button } from "@/components/ui/button"; export function Gallery() { /* eslint-disable react/no-array-index-key */ const [lightboxOpen, setLightboxOpen] = useState(false); const [activeItemIndex, setActiveItemIndex] = useState(null); const [currentPhotoIndex, setCurrentPhotoIndex] = useState(0); const [direction, setDirection] = useState(0); const galleryItems = [ { title: "Pokój 1-osobowy", badge: "Nr 31", cover: "/31_1.webp", images: [ "/31_1.webp", "/31_2.webp", "/31_3.webp", "/31_4.webp", "/31_5.webp", "/31_6.webp" ], }, { title: "Pokój 2-osobowy", badge: "Nr 30, 32", cover: "/placeholder.svg", images: ["/placeholder.svg"], }, { title: "Domek 2-osobowy", badge: "Nr 5, 5a", cover: "/5_1.webp", images: [ "/5_1.webp", "/5_2.webp", "/5_3.webp", "/5_4.webp", "/5_5.webp", "/5_6.webp" ], }, { title: "Domek 3-osobowy", badge: "Nr 7-9, 20-23", cover: "/placeholder.svg", images: ["/placeholder.svg"], }, { title: "Domek 4-osobowy (1 pomieszczenie)", badge: "Nr 10-14", cover: "/11_1.webp", images: [ "/11_1.webp", "/11_2.webp", "/11_3.webp", "/11_4.webp", "/11_5.webp", "/11_6.webp", "/11_7.webp" ], }, { title: "Domek 4-osobowy (2 pomieszczenia)", badge: "Nr 6, 33, 4, 2, 3", cover: "/4_1.webp", images: [ "/4_1.webp", "/4_2.webp", "/4_3.webp", "/4_4.webp", "/4_5.webp", "/4_6.webp" ], }, { title: "Domek 4-osobowy", badge: "Nr 15-19", cover: "/19_1.webp", images: [ "/19_1.webp", "/19_2.webp", "/19_3.webp", "/19_4.webp", "/19_5.webp", "/19_6.webp", "/19_7.webp" ], }, { title: "Domek 4-osobowy", badge: "Nr 24-26", cover: "/26_1.webp", images: [ "/26_1.webp", "/26_2.webp", "/26_3.webp", "/26_4.webp", "/26_5.webp", "/26_6.webp" ], }, { title: "Pokój studio 5 osobowy", badge: "Nr 27-29", cover: "/29_1.webp", images: [ "/29_1.webp", "/29_2.webp", "/29_3.webp", "/29_4.webp", "/29_5.webp", "/29_6.webp", "/29_7.webp", "/29_8.webp", "/29_9.webp" ], }, ]; const openLightbox = (index: number) => { setActiveItemIndex(index); setCurrentPhotoIndex(0); setLightboxOpen(true); document.body.style.overflow = "hidden"; }; const closeLightbox = () => { setLightboxOpen(false); setActiveItemIndex(null); document.body.style.overflow = ""; }; const goToPrevious = () => { setDirection(-1); if (activeItemIndex === null) return; const images = galleryItems[activeItemIndex].images; setCurrentPhotoIndex((prev) => (prev === 0 ? images.length - 1 : prev - 1)); }; const goToNext = () => { setDirection(1); if (activeItemIndex === null) return; const images = galleryItems[activeItemIndex].images; setCurrentPhotoIndex((prev) => (prev === images.length - 1 ? 0 : prev + 1)); }; const currentImages = activeItemIndex !== null ? galleryItems[activeItemIndex].images : []; const swipeConfidenceThreshold = 10000; const swipePower = (offset: number, velocity: number) => { return Math.abs(offset) * velocity; }; return ( ); }