import moment from 'moment';

export type TUseGetColumns = {
  title: string;
  dataIndex: string;
  key: string;
  render?: (text: string) => JSX.Element;
  responsive?: string[];
  width?: number | string;
  align?: string;
  disabled?: boolean;
  sortOrder?: boolean | string;
  sorter?: boolean;
  onFilter?: (value: string, record: any) => void;
};

export type TUseGetColumnsMessages = {
  data: string;
  message: string;
  sigName: string;
  severity: string;
  category: string;
  sourceIp: string;
  destinationIp: string;
};

export const useGetColumns = (
  translations: TUseGetColumnsMessages,
): TUseGetColumns[] => {
  const {
    data,
    message,
    sigName,
    severity,
    category,
    sourceIp,
    destinationIp,
  } = translations;

  return [
    {
      title: data,
      dataIndex: '@created',
      key: '@created',
      align: 'center',
      render: (text) => <div>{moment(text).format('DD.MM.YYYY hh:mm:ss')}</div>,
      width: '10%',
      sorter: true,
    },
    {
      title: message,
      disabled: true,
      dataIndex: 'event_src_msg',
      key: 'event_src_msg',
      width: '40%',
      responsive: ['md'],
      align: 'center',
      sorter: true,
    },
    {
      title: sigName,
      dataIndex: 'sign_name',
      key: 'sign_name',
      align: 'center',
      width: '10%',
      sorter: true,
    },
    {
      title: severity,
      dataIndex: 'event_severity',
      key: 'event_severity',
      width: '10%',
      align: 'center',
      sorter: true,
    },
    {
      title: category,
      dataIndex: 'sign_category',
      key: 'sign_category',
      align: 'center',
      width: '10%',
      sorter: true,
    },
    {
      title: sourceIp,
      dataIndex: 'source_ip',
      key: 'source_ip',
      align: 'center',
      width: '10%',
      sorter: true,
    },
    {
      title: destinationIp,
      dataIndex: 'destination_ip',
      key: 'destination_ip',
      align: 'center',
      width: '10%',
      sorter: true,
    },
  ];
};
