'use client';
import Image from 'next/image';
import * as React from 'react';
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);
if (images.length === 0) {
return (
Chưa có hình ảnh
);
}
return (
{/* Main image */}
{images.length > 1 && (
<>
>
)}
{selectedIndex + 1} / {images.length}
{/* Thumbnails */}
{images.length > 1 && (
{images.map((img, index) => (
))}
)}
);
}