import { Check, Sparkles, Archive, Trash2 } from 'lucide-react';
import type { Wish } from '@family-wishlist/shared';
import { cn } from '@/lib/cn';
import { useI18n } from '@/i18n/i18n';

interface Props {
  wish: Wish & { isNewForOwner?: boolean };
  view: 'owner' | 'guest';
  className?: string;
}

export function WishBadges({ wish, view, className }: Props) {
  const { t } = useI18n();
  const badges: JSX.Element[] = [];

  const isNew =
    view === 'owner' ? wish.isNewForOwner === true : wish.isNewForGuest === true;
  if (isNew && wish.status === 'ACTIVE') {
    badges.push(
      <span className="wish-badge wish-badge--new" key="new">
        <Sparkles className="h-3 w-3" aria-hidden />
        {t('wish.badge.new')}
      </span>,
    );
  }
  if (wish.status === 'COMPLETED') {
    badges.push(
      <span className="wish-badge wish-badge--completed" key="done">
        <Check className="h-3 w-3" aria-hidden />
        {t('wish.badge.fulfilled')}
      </span>,
    );
  }
  if (wish.status === 'ARCHIVED' && view === 'owner') {
    badges.push(
      <span className="wish-badge wish-badge--archived" key="arch">
        <Archive className="h-3 w-3" aria-hidden />
        {t('wish.badge.archived')}
      </span>,
    );
  }
  if (wish.status === 'DELETED' && view === 'owner') {
    badges.push(
      <span className="wish-badge wish-badge--deleted" key="del">
        <Trash2 className="h-3 w-3" aria-hidden />
        {t('wish.badge.trash')}
      </span>,
    );
  }

  if (badges.length === 0) return null;
  return <div className={cn('flex flex-wrap gap-1.5', className)}>{badges}</div>;
}
