'use client'; import { motion } from 'framer-motion'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Progress } from '@/components/ui/progress'; import { Badge } from '@/components/ui/badge'; import { CheckCircle, Circle, Loader2, FileText, BarChart3, Users, Mail } from 'lucide-react'; import { Workflow } from '@/lib/types'; import { cn } from '@/lib/utils'; interface WorkflowProgressProps { workflow: Workflow; } const WORKFLOW_STEPS = [ { key: 'document_analysis', label: 'Patent Analysis', description: 'Extracting key innovations and TRL assessment', icon: FileText, progressRange: [0, 30], }, { key: 'market_analysis', label: 'Market Research', description: 'Identifying commercialization opportunities', icon: BarChart3, progressRange: [30, 60], }, { key: 'matchmaking', label: 'Partner Matching', description: 'Finding relevant stakeholders with semantic search', icon: Users, progressRange: [60, 85], }, { key: 'outreach', label: 'Brief Generation', description: 'Creating valorization brief document', icon: Mail, progressRange: [85, 100], }, ]; export function WorkflowProgress({ workflow }: WorkflowProgressProps) { // Determine current step based on workflow.current_step or progress const currentStepIndex = workflow.current_step ? WORKFLOW_STEPS.findIndex((step) => step.key === workflow.current_step) : Math.floor(workflow.progress / 25); const getStepStatus = (stepIndex: number) => { if (workflow.status === 'failed') { return stepIndex <= currentStepIndex ? 'failed' : 'pending'; } if (workflow.status === 'completed') { return 'completed'; } if (stepIndex < currentStepIndex) { return 'completed'; } if (stepIndex === currentStepIndex) { return 'in-progress'; } return 'pending'; }; return (
{/* Overall Progress */}
{workflow.status === 'completed' && '✅ Analysis Complete'} {workflow.status === 'failed' && '❌ Analysis Failed'} {workflow.status === 'running' && '⚡ Analyzing Patent...'} {workflow.status === 'queued' && '⏳ Queued for Processing'} {workflow.status.toUpperCase()}
Overall Progress {workflow.progress}%
{/* Workflow Steps */}
{WORKFLOW_STEPS.map((step, index) => { const status = getStepStatus(index); const Icon = step.icon; return (
{/* Status Icon */}
{status === 'completed' && ( )} {status === 'in-progress' && ( )} {status === 'pending' && ( )} {status === 'failed' && ( )}
{/* Step Content */}

{step.label}

{status === 'completed' && 'Done'} {status === 'in-progress' && 'Processing...'} {status === 'pending' && 'Pending'} {status === 'failed' && 'Failed'}

{step.description}

{/* Step Progress Bar (only for in-progress step) */} {status === 'in-progress' && ( )}
); })}
{/* Error Display */} {workflow.error && (
⚠️

Error Occurred

{workflow.error}

)} {/* Completion Message */} {workflow.status === 'completed' && (

Analysis Complete!

Your patent analysis is ready. Redirecting to results...

)}
); }