// Libs
// -----------------------------------------------------------------------------
import { ExportOutlined, ImportOutlined } from '@ant-design/icons';

// App
// -----------------------------------------------------------------------------
import { EActionType } from 'components/DashboardTable/types';
import {
  EnumButtonActions,
  TypeActionButtonsConfig,
} from 'components/DashboardTable/components/useActionsWithSelectedCards/types';
import { CorrelationRulesDashboardLocale } from './types';

type TypeActions = 'exports' | 'imports';

export const collectionButtonForCorrelationRulesCollectiveActions = (
  collectiveHandleActions: {
    onCollectiveRuleImport: (file: FormData) => void;
    onCollectiveRuleExport: () => void;
  },
  locale: CorrelationRulesDashboardLocale,
): { [key in TypeActions]: TypeActionButtonsConfig } => {
  const { onCollectiveRuleImport, onCollectiveRuleExport } =
    collectiveHandleActions;

  return {
    exports: {
      alwaysVisible: true,
      actionType: EActionType.SpecificAction,
      action: onCollectiveRuleExport,
      name: 'exports',
      translationsKey: EnumButtonActions.Exports,
      icon: ExportOutlined,
      confirmMessage: locale.exportConfirmation,
      popoverMessage: locale.exportPopover,
    },
    imports: {
      alwaysVisible: true,
      actionType: EActionType.Upload,
      action: (file) => onCollectiveRuleImport(file as FormData),
      name: 'imports',
      translationsKey: EnumButtonActions.Update,
      icon: ImportOutlined,
      confirmMessage: locale.importConfirmation,
      popoverMessage: locale.importPopover,
    },
  };
};
