import { ButtonDownloadXLS } from 'app/modules/exportToXls/components/buttonDownloadXLS/buttonDownloadXLS';
import React from 'react';
import { useSelector } from 'react-redux';
import { ButtonDownloadConfig } from 'app/modules/exportToXls/components/buttonDownloadXLS/buttonDownloadXLS.types';
import { COLUMN_NAMES } from 'app/modules/vesselDetails/earnings/store/vesselDetailsEarnings.constants';
import { TceDevelopmentRowData } from './tceDevelopmentModal';
import { selectTceDevelopmentModalData } from '../store/tceDevelopment.selectors';
import { selectVesselName } from 'app/modules/vesselDetails/root/store/vesselDetails.selectors';

const columnsConfig: ButtonDownloadConfig<TceDevelopmentRowData>[] = [
  {
    header: COLUMN_NAMES.PERIOD,
    key: 'period',
    width: 20,
  },
  {
    header: COLUMN_NAMES.SCRUBBER,
    key: 'scrubberBonus',
    width: 10,

  },
  {
    header: COLUMN_NAMES.POOL_POINTS,
    key: 'poolPoints',
    width: 13,

  },
  {
    header: COLUMN_NAMES.BUNKER_ADJUSTMENT_PER_DAY,
    key: 'bunkerAdjustmentPerDay',
    width: 30,

  },
  {
    header: COLUMN_NAMES.PP_EARNINGS,
    key: 'poolPointsEarnings',
    width: 15,

  },
  {
    header: COLUMN_NAMES.BUNKER_ADJUSTMENT,
    key: 'bunkerAdjustment',
    width: 20,

  },
  {
    header: COLUMN_NAMES.SCRUBBER_BONUS,
    key: 'scrubberBonus',
    width: 18,

  },
  {
    header: COLUMN_NAMES.WAF_DTA_CBP_COMPENSATION,
    key: 'waf',
    width: 30,

  },
  {
    header: COLUMN_NAMES.SPECIAL_COMPENSATIONS,
    key: 'specialCompensation',
    width: 25,

  },
  {
    header: COLUMN_NAMES.TCE,
    key: 'tce',
    width: 15,

  },
  {
    header: COLUMN_NAMES.MONTHLY_EARNINGS,
    key: 'monthlyAdjustment',
    width: 30,

  },
  {
    header: COLUMN_NAMES.PERIOD_TO_DATE,
    key: 'totalAdjustmentToDate',
    width: 35,

  },
  {
    header: COLUMN_NAMES.PRIOR_PERIOD_IMPACT,
    key: 'previousPeriodImpact',
    width: 45,

  },

];


const TceDevelopmentButtonDownloadXLS = () => {
  const vesselName = useSelector(selectVesselName);
  const data = useSelector(selectTceDevelopmentModalData);
  return (
    <ButtonDownloadXLS
      columnsConfig={columnsConfig}
      rowsData={data}
      excelFileName={vesselName}
      excelFileSuffix={'earnings'}
    />
  );
};

export { TceDevelopmentButtonDownloadXLS };
