import type { ClientView } from '@/lib/client-view';
import { PhaseCard } from './client/PhaseCard';

interface PhaseTimelineProps {
  phases: ClientView['phases'];
  token: string;
}

export function PhaseTimeline({ phases, token }: PhaseTimelineProps) {
  if (phases.length === 0) {
    return <p className="text-sm text-muted-foreground italic">Nessuna fase ancora configurata.</p>;
  }

  return (
    <div className="space-y-6">
      {phases.map((phase) => {
        // done phases start collapsed; active and upcoming start expanded
        const defaultOpen = phase.status !== 'done';
        return <PhaseCard key={phase.id} phase={phase} token={token} defaultOpen={defaultOpen} />;
      })}
    </div>
  );
}
