@onereach/channel-transformer
Version:
Convert data model between different channels (Slack, Microsoft Teams, Generic...)
25 lines (22 loc) • 657 B
text/typescript
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;
};