'use client'; import React, { useState, useEffect } from 'react'; import { Search, Grid, List, User, Plus, Image, Upload, X } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Card, CardContent } from '@/components/ui/card'; import { useSearch, SearchResult } from '@/hooks/useSearch'; import { SearchResults } from '@/components/SearchResults'; import { ImageDropzone } from '@/components/ImageDropzone'; import { ItemDetailsModal } from '@/components/ItemDetailsModal'; export default function Home() { const [activeView, setActiveView] = useState('library'); const [showDropzone, setShowDropzone] = useState(false); const [searchQuery, setSearchQuery] = useState(''); const [selectedItem, setSelectedItem] = useState(null); const [showItemModal, setShowItemModal] = useState(false); const { query, results, isLoading, error, hasSearched, total, searchTime, search, clearSearch } = useSearch(); // Handle search input changes const handleSearchChange = (e: React.ChangeEvent) => { const value = e.target.value; setSearchQuery(value); if (value.trim()) { search(value); } else { clearSearch(); } }; // Handle search result item click const handleItemClick = (item: SearchResult) => { setSelectedItem(item); setShowItemModal(true); }; // Handle modal close const handleModalClose = () => { setShowItemModal(false); setSelectedItem(null); }; // Handle item actions const handleEditItem = (item: SearchResult) => { console.log('Edit item:', item); // TODO: Open edit modal/form }; const handleDeleteItem = (item: SearchResult) => { console.log('Delete item:', item); // TODO: Implement delete functionality if (confirm('Are you sure you want to delete this item?')) { // Delete logic here handleModalClose(); } }; const handleAddToCollection = (item: SearchResult) => { console.log('Add to collection:', item); // TODO: Open collection selector }; const handleToggleFavorite = (item: SearchResult) => { console.log('Toggle favorite:', item); // TODO: Implement favorite toggle }; // Handle image upload const handleImageUpload = async (file: File) => { try { const formData = new FormData(); formData.append('file', file); const response = await fetch('/api/upload', { method: 'POST', body: formData, }); if (!response.ok) { throw new Error('Upload failed'); } const result = await response.json(); console.log('Upload successful:', result); // TODO: Perform image-based search after upload // This would call the search API with the uploaded image // For now, just show a success message alert('Image uploaded successfully! Image-based search coming soon.'); } catch (error) { console.error('Upload error:', error); alert('Upload failed. Please try again.'); } }; // Handle URL upload const handleUrlUpload = async (url: string) => { try { const formData = new FormData(); formData.append('url', url); const response = await fetch('/api/upload', { method: 'POST', body: formData, }); if (!response.ok) { throw new Error('URL processing failed'); } const result = await response.json(); console.log('URL processed:', result); // TODO: Perform image-based search after processing // For now, just show a success message alert('URL processed successfully! Image-based search coming soon.'); } catch (error) { console.error('URL processing error:', error); alert('URL processing failed. Please check the URL and try again.'); } }; // Mock data for library items const mockItems = [ { id: 1, height: 200, width: 'normal' }, { id: 2, height: 280, width: 'wide' }, { id: 3, height: 160, width: 'normal' }, { id: 4, height: 240, width: 'normal' }, { id: 5, height: 200, width: 'normal' }, { id: 6, height: 300, width: 'wide' }, { id: 7, height: 180, width: 'normal' }, { id: 8, height: 220, width: 'normal' }, { id: 9, height: 260, width: 'wide' }, { id: 10, height: 190, width: 'normal' }, { id: 11, height: 240, width: 'normal' }, { id: 12, height: 200, width: 'wide' }, { id: 13, height: 220, width: 'normal' }, { id: 14, height: 180, width: 'normal' }, { id: 15, height: 260, width: 'normal' }, { id: 16, height: 200, width: 'wide' }, { id: 17, height: 240, width: 'normal' }, { id: 18, height: 180, width: 'normal' }, ]; // Mock data for collections const mockCollections = [ { id: 1, name: 'Brand Identity', itemCount: 47 }, { id: 2, name: 'UI Inspiration', itemCount: 132 }, { id: 3, name: 'Typography', itemCount: 28 }, { id: 4, name: 'Color Palettes', itemCount: 64 }, { id: 5, name: 'Illustration', itemCount: 89 }, { id: 6, name: 'Photography', itemCount: 156 }, { id: 7, name: 'Web Design', itemCount: 93 }, { id: 8, name: 'Motion Graphics', itemCount: 41 }, ]; const LibraryView = () => ( <> {/* Compact Horizontal Filters Toolbar */}
1,427 items
{/* Main Content - Tightly Packed Masonry Grid */}
{mockItems.map((item, index) => { const colorClasses = [ 'bg-orange-500', 'bg-amber-400', 'bg-stone-700', 'bg-orange-600' ]; const itemColorClass = colorClasses[index % colorClasses.length]; return (
); })}
); const CollectionsView = () => ( <> {/* Collections Toolbar */}

Your Collections

{mockCollections.length} collections
{/* Collections Grid */}
{mockCollections.map((collection, idx) => { const colorClasses = [ ['bg-orange-500', 'bg-amber-400', 'bg-orange-600', 'bg-orange-500'], ['bg-amber-400', 'bg-orange-500', 'bg-amber-400', 'bg-orange-600'], ['bg-orange-600', 'bg-orange-500', 'bg-amber-400', 'bg-orange-500'], ['bg-orange-500', 'bg-orange-600', 'bg-amber-400', 'bg-orange-500'] ]; const previewColors = colorClasses[idx % colorClasses.length]; return (
{/* Collection Preview Grid */}
{previewColors.map((colorClass, colorIdx) => (
))}
{/* Hover Overlay with Info */}

{collection.name}

{collection.itemCount} items
); })} {/* Create New Collection Card */}
Create Collection
); return (
{/* Header */}
INSPIRATION
{/* Prominent Central Search with Image Toggle */}
{searchQuery && ( )}
{/* Image Search Dropzone */} setShowDropzone(false)} onUpload={handleImageUpload} onUrlUpload={handleUrlUpload} />
{/* Active View */} {hasSearched ? ( ) : ( activeView === 'library' ? : )} {/* Item Details Modal */}
); }