'use client' import React from 'react' import { DSRStatus, DSR_STATUS_INFO } from '@/lib/sdk/dsr/types' interface WorkflowStep { id: DSRStatus label: string description?: string } const WORKFLOW_STEPS: WorkflowStep[] = [ { id: 'intake', label: 'Eingang', description: 'Anfrage dokumentiert' }, { id: 'identity_verification', label: 'ID-Pruefung', description: 'Identitaet verifizieren' }, { id: 'processing', label: 'Bearbeitung', description: 'Anfrage bearbeiten' }, { id: 'completed', label: 'Abschluss', description: 'Antwort versenden' } ] interface DSRWorkflowStepperProps { currentStatus: DSRStatus onStepClick?: (status: DSRStatus) => void className?: string } export function DSRWorkflowStepper({ currentStatus, onStepClick, className = '' }: DSRWorkflowStepperProps) { const currentIndex = WORKFLOW_STEPS.findIndex(s => s.id === currentStatus) const isRejectedOrCancelled = currentStatus === 'rejected' || currentStatus === 'cancelled' const getStepState = (index: number): 'completed' | 'current' | 'upcoming' => { if (isRejectedOrCancelled) { return index <= currentIndex ? 'completed' : 'upcoming' } if (index < currentIndex) return 'completed' if (index === currentIndex) return 'current' return 'upcoming' } return (
{WORKFLOW_STEPS.map((step, index) => { const state = getStepState(index) const isLast = index === WORKFLOW_STEPS.length - 1 return ( {/* Step */}
onStepClick && state !== 'upcoming' && onStepClick(step.id)} > {/* Circle */}
{state === 'completed' ? ( ) : ( index + 1 )}
{/* Label */}
{step.label}
{step.description && (
{step.description}
)}
{/* Connector Line */} {!isLast && (
)} ) })}
{/* Rejected/Cancelled Badge */} {isRejectedOrCancelled && (
{currentStatus === 'rejected' ? 'Anfrage wurde abgelehnt' : 'Anfrage wurde storniert'}
)}
) } // Compact version for list views export function DSRWorkflowStepperCompact({ currentStatus, className = '' }: { currentStatus: DSRStatus className?: string }) { const statusInfo = DSR_STATUS_INFO[currentStatus] const currentIndex = WORKFLOW_STEPS.findIndex(s => s.id === currentStatus) const totalSteps = WORKFLOW_STEPS.length const isTerminal = currentStatus === 'rejected' || currentStatus === 'cancelled' || currentStatus === 'completed' return (
{/* Mini progress dots */}
{WORKFLOW_STEPS.map((step, index) => (
))}
{/* Status label */} {statusInfo.label}
) }