diff --git a/frontend/components/AssetLibrary.tsx b/frontend/components/AssetLibrary.tsx index 2fde97d..cc3ead1 100644 --- a/frontend/components/AssetLibrary.tsx +++ b/frontend/components/AssetLibrary.tsx @@ -1,8 +1,9 @@ 'use client'; import { useState, useEffect } from 'react'; -import api from '@/lib/api'; +import api, { assetsApi } from '@/lib/api'; import { clsx } from 'clsx'; +import { toast } from 'react-hot-toast'; import { X, Search, @@ -13,7 +14,9 @@ import { Check, Loader2, FolderOpen, + Upload, } from 'lucide-react'; +import FileUpload from './FileUpload'; interface Asset { id: string; @@ -59,6 +62,8 @@ export default function AssetLibrary({ const [page, setPage] = useState(1); const [totalPages, setTotalPages] = useState(1); const [selectedAssets, setSelectedAssets] = useState>(new Set()); + const [showUpload, setShowUpload] = useState(false); + const [uploading, setUploading] = useState(false); useEffect(() => { if (isOpen) { @@ -108,6 +113,25 @@ export default function AssetLibrary({ onClose(); }; + const handleUpload = async (file: File) => { + setUploading(true); + try { + const response = await assetsApi.upload(file); + toast.success('File uploaded!'); + loadAssets(); // Reload to show new file + // Auto-select the new file + if (!multiple) { + onSelect(response.data); + setShowUpload(false); + onClose(); + } + } catch (error) { + toast.error('Failed to upload file'); + } finally { + setUploading(false); + } + }; + if (!isOpen) return null; return ( @@ -119,12 +143,21 @@ export default function AssetLibrary({

{title}

- +
+ + +
{/* Filters */} @@ -184,6 +217,29 @@ export default function AssetLibrary({ + {/* Upload Section */} + {showUpload && ( +
+ + {uploading && ( +
+ + Uploading... +
+ )} +
+ )} + {/* Asset Grid */}
{loading ? (