import { IGenericSection } from '../../../generic/types';
import { ISlackActions } from '../../types';
import { getMethods } from '../methods';

export const transformActions = (
  { elements, block_id }: ISlackActions
): IGenericSection => {
  const res: IGenericSection = {
    type: 'section',
    children: elements.map(item => getMethods(item.type)(item)),
    props: {
      slack: {
        type: 'actions'
      }
    }
  };

  if (block_id) {
    res.props.slack.block_id = block_id;
  }
  
  return res;
};