import { useState } from 'react'; import { Image, Wand2, Type } from 'lucide-react'; import CoverGallery from './CoverGallery'; import CoverEditor from './CoverEditor'; import { useCoverStore, Cover } from '../../stores/coverStore'; import { coversApi } from '../../services/api'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; export default function CoverDesigner() { const [activeTab, setActiveTab] = useState<'gallery' | 'editor' | 'ai'>('gallery'); const { activeCover, setActiveCover } = useCoverStore(); const queryClient = useQueryClient(); const { data: coversData } = useQuery({ queryKey: ['covers'], queryFn: async () => { const response = await coversApi.getAll(); return response.data.covers; }, }); const generateCoverMutation = useMutation({ mutationFn: async (prompt: string) => { const response = await coversApi.generate(prompt); return response.data; }, onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['covers'] }); setActiveTab('gallery'); }, }); const handleGenerateAI = (prompt: string) => { generateCoverMutation.mutate(prompt); }; const handleSelectCover = (coverUrl: string) => { const newCover: Cover = { id: `cover-${Date.now()}`, title: 'New Book', author: 'Author Name', backgroundImage: coverUrl, backgroundColor: '#ffffff', width: 1600, height: 2400, layers: [], createdAt: new Date(), updatedAt: new Date(), }; setActiveCover(newCover); setActiveTab('editor'); }; return (

Cover Designer

Design stunning book covers with AI or manual editing

{/* Tab Navigation */}
{activeTab === 'gallery' && ( { coversApi.delete(id).then(() => { queryClient.invalidateQueries({ queryKey: ['covers'] }); }); }} /> )} {activeTab === 'editor' && activeCover && ( )} {activeTab === 'ai' && ( )}
); } function AIGenerator({ onGenerate, isGenerating, }: { onGenerate: (prompt: string) => void; isGenerating: boolean; }) { const [prompt, setPrompt] = useState(''); const [selectedStyle, setSelectedStyle] = useState('modern'); const styles = [ { id: 'modern', name: 'Modern', icon: '✨' }, { id: 'minimal', name: 'Minimalist', icon: '🎯' }, { id: 'vintage', name: 'Vintage', icon: '📜' }, { id: 'bold', name: 'Bold', icon: '🔥' }, { id: 'elegant', name: 'Elegant', icon: '💎' }, { id: 'playful', name: 'Playful', icon: '🎨' }, ]; const genrePresets = [ { genre: 'Mystery', prompt: 'A mysterious book cover with dark shadows, silhouette of a detective, foggy street scene, noir atmosphere', }, { genre: 'Romance', prompt: 'A romantic book cover with soft pastel colors, couple silhouette at sunset, dreamy and emotional', }, { genre: 'Fantasy', prompt: 'An epic fantasy book cover with magical elements, dragon, castle in the background, mystical glowing effects', }, { genre: 'Sci-Fi', prompt: 'A futuristic sci-fi book cover with spaceships, neon lights, cyberpunk city, high-tech atmosphere', }, { genre: 'Self-Help', prompt: 'A clean self-help book cover with inspiring imagery, mountain peak or sunrise, professional and motivating', }, ]; const handleUsePreset = (presetPrompt: string) => { setPrompt(presetPrompt); }; const handleGenerate = () => { if (prompt.trim()) { const enhancedPrompt = `${prompt}, ${selectedStyle} style, professional book cover design, high quality, detailed`; onGenerate(enhancedPrompt); } }; return (

AI Cover Generator

{/* Style Selection */}
{styles.map((style) => ( ))}
{/* Prompt Input */}