import { useState, useEffect } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; import { ArrowLeft, X, ChevronLeft, ChevronRight } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; // 모바일 앨범 갤러리 페이지 function MobileAlbumGallery() { const { name } = useParams(); const navigate = useNavigate(); const [album, setAlbum] = useState(null); const [photos, setPhotos] = useState([]); const [loading, setLoading] = useState(true); const [selectedIndex, setSelectedIndex] = useState(null); useEffect(() => { fetch('/api/albums') .then(res => res.json()) .then(data => { const found = data.find(a => a.folder_name === name); if (found) { setAlbum(found); fetch(`/api/albums/${found.id}/photos`) .then(res => res.json()) .then(setPhotos) .catch(console.error); } setLoading(false); }) .catch(console.error); }, [name]); // 이미지 네비게이션 const goToImage = (delta) => { const newIndex = selectedIndex + delta; if (newIndex >= 0 && newIndex < photos.length) { setSelectedIndex(newIndex); } }; if (loading) { return (