import React from 'react';
import { FileText, Table, Box } from 'lucide-react';
import { Button } from './ui/button';
import { useI18n } from '../store/i18nStore';
import { exportGalpaoToCSV } from '../lib/export-csv';
import { exportGalpaoToPDF } from '../lib/export-pdf';
import { exportGalpaoToFtool } from '../lib/export-ftool';

interface ExportMenuProps {
  onExportCSV?: () => void;
  onExportPDF?: () => void;
  onExportFtool?: () => void;
}

const ExportMenu: React.FC<ExportMenuProps> = ({ onExportCSV, onExportPDF, onExportFtool }) => {
  const { t } = useI18n();
  const handleCSV = onExportCSV || exportGalpaoToCSV;
  const handlePDF = onExportPDF || exportGalpaoToPDF;
  
  // Exibir o Ftool apenas se explicitamente fornecido, ou se for a configuração padrão (Galpão)
  const isGalpao = !onExportCSV && !onExportPDF && !onExportFtool;

  return (
    <div className="flex gap-2">
      <Button
        variant="outline"
        size="sm"
        onClick={handleCSV}
        className="text-orange-600 border-orange-200 hover:bg-orange-50 hover:text-orange-700"
        title={t('export_csv')}
      >
        <Table className="w-4 h-4 mr-2" />
        {t('export_csv')}
      </Button>
      <Button
        variant="outline"
        size="sm"
        onClick={handlePDF}
        className="text-purple-600 border-purple-200 hover:bg-purple-50 hover:text-purple-700"
        title={t('export_pdf')}
      >
        <FileText className="w-4 h-4 mr-2" />
        {t('export_pdf')}
      </Button>
      {(onExportFtool || isGalpao) && (
        <Button
          variant="outline"
          size="sm"
          onClick={onExportFtool || exportGalpaoToFtool}
          className="text-emerald-600 border-emerald-200 hover:bg-emerald-50 hover:text-emerald-700"
          title={t('ftool_desc')}
        >
          <Box className="w-4 h-4 mr-2" />
          {t('export_ftool')}
        </Button>
      )}
    </div>
  );
};

export default ExportMenu;
