import { formatCaseSentLines } from '@/components/treatment/caseSendLabel';
import type { LinkedOrganizationOption, PastTreatmentCase, TreatmentCaseDraft } from '@/types/treatment';

interface CaseSentLabelProps {
  treatmentCase: Pick<
    PastTreatmentCase | TreatmentCaseDraft,
    'sends' | 'sendToOrganizationIds' | 'sentAt'
  >;
  orgs?: LinkedOrganizationOption[];
  className?: string;
}

export function CaseSentLabel({ treatmentCase, orgs, className = 'text-xs text-text-muted' }: CaseSentLabelProps) {
  const lines = formatCaseSentLines(treatmentCase.sends, {
    organizationIds: treatmentCase.sendToOrganizationIds ?? [],
    sentAt: treatmentCase.sentAt ?? null,
    orgs,
  });

  if (lines.length === 0) return null;

  return (
    <div className={className}>
      {lines.map((line, i) => (
        <span key={`${line}-${i}`} className="block">
          {line}
        </span>
      ))}
    </div>
  );
}
