diff --git a/frontend/app/text/alt-text/page.tsx b/frontend/app/text/alt-text/page.tsx index e2366e1..fad8082 100644 --- a/frontend/app/text/alt-text/page.tsx +++ b/frontend/app/text/alt-text/page.tsx @@ -7,6 +7,7 @@ import { FileText, Copy, Check, Sparkles, Download, Trash2, RefreshCw } from 'lu import FileUpload from '@/components/FileUpload'; import { modulesApi, assetsApi, jobsApi } from '@/lib/api'; import { useStore } from '@/lib/store'; +import { useDragFromCarousel } from '@/hooks/useDragFromCarousel'; interface QueueItem { id: string; @@ -69,6 +70,38 @@ export default function AltTextPage() { } }, [searchParams, router]); + // Handle drag-and-drop from carousel + useDragFromCarousel({ + onAssetDrop: async (assetIds) => { + try { + const responses = await Promise.all(assetIds.map(id => assetsApi.get(id))); + const newItems = responses + .map((r: any) => r.data) + .filter((asset: any) => asset.file_type === 'image') + .map((asset: any) => ({ + id: Math.random().toString(36).substring(7), + assetId: asset.id, + filename: asset.original_filename, + status: 'pending' as const + })); + + if (newItems.length > 0) { + setQueue(prev => { + const existing = new Set(prev.map(p => p.assetId)); + return [...prev, ...newItems.filter(i => !existing.has(i.assetId))]; + }); + toast.success(`${newItems.length} images added from carousel`); + } else { + toast.error('No valid images in selection'); + } + } catch (err) { + console.error('Failed to load dragged assets', err); + toast.error('Failed to add assets'); + } + }, + enabled: true + }); + const handleFileUpload = (files: File[]) => { const newItems: QueueItem[] = files.map(file => ({ id: Math.random().toString(36).substring(7),