import { EActionType } from 'components/DashboardTable/types';
import { DeleteFilled, ExportOutlined, RedoOutlined } from '@ant-design/icons';

import {
  EnumButtonActions,
  TypeActionButtonsConfig,
} from 'components/DashboardTable/components/useActionsWithSelectedCards/types';
import { TypeCollectiveActionMessages } from './types';

type TypeActions = 'exports' | 'delete' | 'changeStatus';

export const collectionButtonForAssetsCollectiveActions = (
  collectiveActionsMessages: TypeCollectiveActionMessages,
  collectiveHandleActions: {
    onExports: () => void;
    onCollectiveAssetsDelete: () => void;
    onCollectiveAssetsChangeStatus: () => void;
  },
  hasSelected?: boolean,
): { [key in TypeActions]: TypeActionButtonsConfig } => {
  const {
    onExports,
    onCollectiveAssetsDelete,
    onCollectiveAssetsChangeStatus,
  } = collectiveHandleActions;

  return {
    exports: {
      alwaysVisible: true,
      actionType: EActionType.SpecificAction,
      name: 'exports',
      action: onExports,
      translationsKey: EnumButtonActions.Exports,
      icon: ExportOutlined,
    },
    delete: {
      actionType: EActionType.SpecificAction,
      hasSelected,
      name: 'delete',
      action: onCollectiveAssetsDelete,
      translationsKey: EnumButtonActions.Delete,
      icon: DeleteFilled,
      popoverMessage: collectiveActionsMessages.deleteSelectedAssetPopover,
      confirmMessage: collectiveActionsMessages.deleteSelectedAssetQuestion,
    },
    changeStatus: {
      actionType: EActionType.SpecificAction,
      name: 'changeStatus',
      action: onCollectiveAssetsChangeStatus,
      translationsKey: EnumButtonActions.Update,
      icon: RedoOutlined,
      hasSelected,
      popoverMessage:
        collectiveActionsMessages.changeStatusSelectedAssetsPopover,
      confirmMessage:
        collectiveActionsMessages.changeStatusSelectedAssetsQuestion,
    },
  };
};
