'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { motion } from 'framer-motion'; import { PatentUpload } from '@/components/PatentUpload'; import { uploadPatent, executeWorkflow } from '@/lib/api'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Sparkles } from 'lucide-react'; import { toast } from 'sonner'; export default function UploadPage() { const router = useRouter(); const [uploading, setUploading] = useState(false); const [error, setError] = useState(null); const handleUpload = async (file: File) => { console.log('🎯 Parent handleUpload called with file:', file); try { setUploading(true); setError(null); // Step 1: Upload patent console.log('📤 Uploading patent:', file.name); toast.info('Uploading patent...', { description: `Uploading ${file.name}`, }); console.log('🌐 Calling uploadPatent API...'); const uploadResponse = await uploadPatent(file); console.log('✅ Upload response:', uploadResponse); toast.success('Patent uploaded successfully!', { description: `Patent ID: ${uploadResponse.patent_id.slice(0, 8)}...`, }); // Step 2: Start workflow console.log('🚀 About to execute workflow for patent:', uploadResponse.patent_id); toast.info('Starting analysis...', { description: 'Initializing Patent Wake-Up workflow', }); console.log('📞 Calling executeWorkflow API...'); const workflowResponse = await executeWorkflow(uploadResponse.patent_id); console.log('✅ Workflow response:', workflowResponse); toast.success('Analysis started!', { description: 'Redirecting to progress page...', }); // Step 3: Redirect to workflow progress page setTimeout(() => { router.push(`/workflow/${workflowResponse.workflow_id}`); }, 1500); } catch (err: any) { console.error('❌ Error in handleUpload:', err); console.error('Error details:', { message: err.message, response: err.response?.data, stack: err.stack }); const errorMessage = err.response?.data?.detail || err.message || 'Failed to upload patent'; setError(errorMessage); toast.error('Upload failed', { description: errorMessage, duration: 10000, // Show error for 10 seconds }); } finally { setUploading(false); } }; return (
{/* Header */}

Upload Your Patent

Upload a patent PDF to begin the AI-powered analysis process. We'll identify market opportunities and match you with relevant partners.

{/* Upload Component */} {/* Info Cards */}
📄 File Requirements
  • • PDF format only
  • • Maximum 50MB
  • • Clear, readable text
⚡ Processing Time
  • • Patent Analysis: ~30s
  • • Market Research: ~1min
  • • Partner Matching: ~2min
  • • Total: 2-5 minutes
🎯 What You'll Get
  • • TRL Assessment
  • • Market Opportunities
  • • Partner Matches
  • • Valorization Brief
{/* Features List */}

🤖 Powered by Multi-Agent AI System

PlannerAgent orchestrates the workflow
CriticAgent ensures quality
DocumentAnalysisAgent extracts innovations
MarketAnalysisAgent finds opportunities
MatchmakingAgent finds partners
OutreachAgent generates brief
); }