import React from 'react';
import { Badge } from '../../ui';
import { Plus, Edit, Trash2, Check, X, Eye, RefreshCw } from 'lucide-react';

interface ActionBadgeProps {
  action: string;
  showIcon?: boolean;
}

export const ActionBadge: React.FC<ActionBadgeProps> = ({ action, showIcon = true }) => {
  const actionConfig: Record<string, { label: string; color: 'green' | 'blue' | 'red' | 'purple' | 'orange' | 'gray'; icon: any }> = {
    create: {
      label: 'Crear',
      color: 'green',
      icon: Plus,
    },
    update: {
      label: 'Actualizar',
      color: 'blue',
      icon: Edit,
    },
    delete: {
      label: 'Eliminar',
      color: 'red',
      icon: Trash2,
    },
    approve: {
      label: 'Aprobar',
      color: 'green',
      icon: Check,
    },
    reject: {
      label: 'Rechazar',
      color: 'red',
      icon: X,
    },
    view: {
      label: 'Ver',
      color: 'gray',
      icon: Eye,
    },
    sync: {
      label: 'Sincronizar',
      color: 'purple',
      icon: RefreshCw,
    },
  };

  const config = actionConfig[action.toLowerCase()] || {
    label: action,
    color: 'gray' as const,
    icon: RefreshCw,
  };

  const { label, color, icon: Icon } = config;

  return (
    <Badge color={color}>
      {showIcon && <Icon className="mr-1 h-3 w-3" />}
      {label}
    </Badge>
  );
};
