'use client'; import Image from 'next/image'; import * as React from 'react'; import { ImageLightbox } from '@/components/listings/image-lightbox'; import { shimmerBlurDataURL } from '@/lib/image-blur'; import type { PropertyMedia } from '@/lib/listings-api'; import { cn } from '@/lib/utils'; interface ImageGalleryProps { media: PropertyMedia[]; className?: string; } export function ImageGallery({ media, className }: ImageGalleryProps) { const images = media.filter((m) => m.type === 'image').sort((a, b) => a.order - b.order); const [selectedIndex, setSelectedIndex] = React.useState(0); const [lightboxOpen, setLightboxOpen] = React.useState(false); const openLightbox = React.useCallback((index: number) => { setSelectedIndex(index); setLightboxOpen(true); }, []); if (images.length === 0) { return (
Chưa có hình ảnh
); } return (
{/* Main image */}
)}
{selectedIndex + 1} / {images.length}
{/* Expand hint icon */}
Xem toàn màn hình
{/* Thumbnails */} {images.length > 1 && (
{images.map((img, index) => ( ))}
)} {/* Lightbox */} setLightboxOpen(false)} />
); }