import { useEffect } from 'react'; import { debugImageProxyUrl, type DebugImageSearchManyResult, type DebugImageSearchResultItem } from '../api/client'; import './DebugSearchResultsModal.css'; interface Props { open: boolean; title: string; data: DebugImageSearchManyResult | null; loading: boolean; error: string | null; applyingUrl: string | null; onClose: () => void; onSelect: (item: DebugImageSearchResultItem) => void; } export default function DebugSearchResultsModal({ open, title, data, loading, error, applyingUrl, onClose, onSelect, }: Props) { useEffect(() => { if (!open) return; const onKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', onKeyDown); return () => window.removeEventListener('keydown', onKeyDown); }, [open, onClose]); if (!open) return null; return (
e.stopPropagation()}>

{title}

{data?.query &&

{data.query}

}
{loading &&

Loading results…

} {error &&

{error}

} {!loading && !error && data && data.results.length === 0 && (

No images found.

)} {!loading && data && data.results.length > 0 && ( <>

Click an image to replace the current one.

{data.results.map((item, index) => { const busy = applyingUrl === item.imageUrl; return ( ); })}
)}
); }