import { useState, useEffect } from 'react'; import apiClient from '../api/client'; export default function ImagePicker({ slug, currentImage, onSelect }) { const [images, setImages] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function loadImages() { try { const res = await apiClient.get('/api/templates/images'); setImages(res.data.images || []); } catch (err) { console.error('Failed to load images', err); } finally { setLoading(false); } } loadImages(); }, []); if (loading) { return
Loading brand images…
; } if (images.length === 0) { return
No images available for this brand.
; } return (
{images.map((img, i) => { const isSelected = currentImage === img.url; return ( ); })}
); }