import { IGenericContext, IGenericSection } from '../../../generic/types';
import { ISlackContext } from '../../types'; 
import { getMethods } from '../methods';

export const transformContext = (
  { elements, block_id }: ISlackContext
): IGenericContext|IGenericSection => {
  // const res: IGenericContext = {
  //   type: 'context',
  //   children: elements.map(item => getMethods(item.type)(item)),
  //   props: {
  //     slack: {
  //       type: 'context'
  //     }
  //   }
  // };

  const res: IGenericSection = {
    type: 'section',
    children: elements.map(item => getMethods(item.type)(item)),
    props: {
      slack: {
        type: 'context'
      }
    }
  };

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

  return res;
};