import React from 'react';
import { Button } from 'antd';
import { DeleteOutlined, DownloadOutlined } from '@ant-design/icons';
import { TStoreType } from './types';

export const getCards = (
  storageList: TStoreType[],
  handleAction: (
    e: React.MouseEvent<HTMLElement>,
    type: string,
    id: number,
  ) => void,
): TStoreType[] => {
  return storageList.map((item) => {
    return {
      ...item,
      actions: (
        <div style={{ display: 'flex', justifyContent: 'center' }}>
          <Button
            type="link"
            onClick={(e) => {
              handleAction(e, 'download', item.id);
            }}
          >
            <DownloadOutlined />
          </Button>
          <Button
            type="link"
            onClick={(e) => handleAction(e, 'delete', item.id)}
          >
            <DeleteOutlined />
          </Button>
        </div>
      ),
    };
  });
};
