import { IGenericSelect, IGenericSection } from '../../../generic/types';
import { IMessage } from "../../types";
import { transformText } from "./text";
import { transformMenuOptions } from './options';

export const transformPicker = (msg: IMessage): IGenericSection => {
  const result: IGenericSection = {
    type: 'section',
    children: [] 
  };
  const text = msg.promptMsg || msg.label;
  if (text) {
    result.children.push(transformText(text));
  }

  const selectSection: IGenericSelect = {
    type: 'select',
    props: {
      options: transformMenuOptions(msg.options)
    }
  };
  result.children.push(selectSection);

  return result;
};