import { Badge } from '~/components/ui/badge';
import { titleize } from '~/utils/format';

const toneForStatus = (status?: string) => {
  if (status === 'up_to_date' || status === 'active') return 'success';
  if (status === 'behind' || status === 'diverged' || status === 'conflict') {
    return 'warning';
  }
  if (status === 'error' || status === 'archived') return 'danger';
  if (status === 'checking') return 'primary';
  return 'neutral';
};

export const SpoonStatusBadge = ({ status }: { status?: string }) => (
  <Badge label={titleize(status)} tone={toneForStatus(status)} />
);
