import { IGenericSelect } from '../../../../generic/types/select';
import { ISlackOverflow } from '../../../types';
import { convertOptions } from '../helpers/convert-options';
import { transformConfirm } from '../confirm';

export const transformOverflow = ({
  type,
  action_id,
  options,
  confirm
}: ISlackOverflow): IGenericSelect => {
  const res: IGenericSelect = {
    type: 'select',
    props: {
      value: '',
      options: convertOptions(options),
      variableName: action_id,
      slack: {
        type
      }
    }
  };

  if (confirm) {
    res.props.slack.confirm = transformConfirm(confirm);
  }

  return res;
};
