import { ReactNode } from "react"; import { Link } from "react-router"; import { CheckCircleIcon, TimeIcon, ArrowRightIcon } from "../../icons"; import { Tooltip } from "../ui/tooltip"; export interface WorkflowStep { number: number; title: string; status: "completed" | "in_progress" | "pending"; count: number; path: string; description?: string; details?: string; // Additional details for tooltip } interface WorkflowPipelineProps { steps: WorkflowStep[]; onStepClick?: (step: WorkflowStep) => void; showConnections?: boolean; className?: string; } export default function WorkflowPipeline({ steps, onStepClick, showConnections = true, className = "", }: WorkflowPipelineProps) { const getStatusColor = (status: WorkflowStep["status"]) => { switch (status) { case "completed": return "bg-success-500 border-success-500 text-white"; case "in_progress": return "bg-warning-500 border-warning-500 text-white"; case "pending": return "bg-gray-200 border-gray-300 text-gray-600 dark:bg-gray-700 dark:border-gray-600 dark:text-gray-400"; } }; const getStatusIcon = (status: WorkflowStep["status"], stepNumber: number) => { switch (status) { case "completed": return ; case "in_progress": return ; case "pending": return {stepNumber}; } }; const getConnectionColor = (currentStatus: WorkflowStep["status"], nextStatus?: WorkflowStep["status"]) => { if (currentStatus === "completed" && nextStatus === "completed") { return "bg-success-500"; } if (currentStatus === "completed") { return "bg-success-500"; } return "bg-gray-300 dark:bg-gray-600"; }; return (
{steps.map((step, index) => { const isLast = index === steps.length - 1; const nextStep = !isLast ? steps[index + 1] : null; return (
{/* Step Node */}
{ if (onStepClick) { e.preventDefault(); onStepClick(step); } }} className={` relative flex flex-col items-center justify-center w-20 h-20 rounded-full border-2 transition-all duration-300 ${getStatusColor(step.status)} hover:scale-110 hover:shadow-lg cursor-pointer group `} >
{getStatusIcon(step.status, step.number)}
{step.status === "in_progress" && (
)} {/* Step Label */}

{step.title}

{step.count > 0 ? ( <> {step.count} {step.title.toLowerCase().includes('keyword') ? 'keywords' : step.title.toLowerCase().includes('cluster') ? 'clusters' : step.title.toLowerCase().includes('idea') ? 'ideas' : step.title.toLowerCase().includes('task') ? 'tasks' : 'items'} ) : ( No items )}

{step.status === "pending" && step.count === 0 && ( { if (onStepClick) { e.preventDefault(); onStepClick(step); } }} > Start Now )}
{/* Connection Line */} {!isLast && showConnections && (
)}
); })}
); }