import { useState, useEffect } from 'react'; interface GalleryThumbnailProps { id: string; columns: number; onSelect: (id:string, columns:number) => void; } const GalleryThumbnail = ({ id, columns, onSelect }: GalleryThumbnailProps) => { const [galleryId, setGalleryId] = useState(id); const [thumbnailUrl, setThumbnailUrl] = useState(''); const [isLoading, setIsLoading] = useState(true); const [galleryCollumns, setColumns] = useState(columns); const openGallery = () => { onSelect(galleryId, galleryCollumns); }; const getData = async () => { setIsLoading(true); const thumbnailResponse = await fetch('/api/galleries/'+galleryId+'/thumbnail'); const thumbnailUrl = await thumbnailResponse.text(); setThumbnailUrl(thumbnailUrl); setIsLoading(false); } useEffect(() => { getData(); }, []); return (
{!isLoading && }
); } export default GalleryThumbnail;