UNPKG

@onereach/channel-transformer

Version:

Convert data model between different channels (Slack, Microsoft Teams, Generic...)

33 lines (26 loc) 757 B
import { IGenericOptions, IGenericSelect } from "../../../generic/types"; import { IRWCAnswerComponent } from "../../types"; export const transformMenu = (msg: IRWCAnswerComponent ): IGenericSelect => { const options: Array<IGenericOptions> = msg.vBind?.options.map(op => { return { label: op.label, value: op.value, key: op.value }; }); const result: IGenericSelect = { type: 'select', props: { options, rwc: { type: 'rwc-menu' } } }; // defaultValue is applicable only for RWCV4; const defaultValue = msg.vBind?.defaultValue && options.find(o => o.value === msg.vBind?.defaultValue); if (defaultValue) { result.props.value = defaultValue; } return result; };