// File: components/custom/workflow-visualizer.tsx import React from 'react'; import { Check, Clock, XCircle, AlertCircle } from 'lucide-react'; import { cn } from '@/lib/utils'; /** * สถานะของขั้นตอนใน Workflow */ export type StepStatus = 'completed' | 'current' | 'pending' | 'rejected' | 'skipped'; export interface WorkflowStep { id: string | number; label: string; subLabel?: string; // เช่น ชื่อองค์กร หรือ ชื่อผู้อนุมัติ status: StepStatus; date?: string; // วันที่ดำเนินการ (ถ้ามี) } interface WorkflowVisualizerProps { steps: WorkflowStep[]; className?: string; } /** * WorkflowVisualizer Component * แสดงเส้นเวลา (Timeline) ของกระบวนการอนุมัติแบบแนวนอน */ export function WorkflowVisualizer({ steps, className }: WorkflowVisualizerProps) { return (
{steps.map((step, index) => { const isLast = index === steps.length - 1; // กำหนดสีตามสถานะ let statusColor = 'bg-muted text-muted-foreground border-muted'; // pending let icon = {index + 1}; let lineColor = 'bg-muted'; switch (step.status) { case 'completed': statusColor = 'bg-green-600 text-white border-green-600'; icon = ; lineColor = 'bg-green-600'; break; case 'current': statusColor = 'bg-blue-600 text-white border-blue-600 ring-4 ring-blue-100'; icon = ; lineColor = 'bg-muted'; // เส้นต่อไปยังเป็นสีเทา break; case 'rejected': statusColor = 'bg-destructive text-destructive-foreground border-destructive'; icon = ; lineColor = 'bg-destructive'; break; case 'skipped': statusColor = 'bg-orange-400 text-white border-orange-400'; icon = ; lineColor = 'bg-orange-400'; break; case 'pending': default: // ใช้ default break; } return (
{/* Connector Line (Left & Right) */}
{/* Left Half Line (Previous step connection) */}
{/* Right Half Line (Next step connection) */}
{/* Step Circle */}
{icon}
{/* Step Label */}

{step.label}

{step.subLabel && (

{step.subLabel}

)} {step.date && (

{step.date}

)}
); })}
); }