UNPKG

@onereach/channel-transformer

Version:

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

27 lines (21 loc) 777 B
import { IGenericSwitch } from '../../../../generic/types'; import { IRWCOption, IRWCMessage, IRWCAnswerComponent } from '../../../types'; import { getAnswerComponent } from '../../../helpers/answer-types'; export const transformSwitch = ({ props }: IGenericSwitch): IRWCMessage => { const options: Array<IRWCOption> = [ { label: 'True', value: true }, { label: 'False', value: false } ]; const selected = options.filter(op => op.value === props.value); const defaultValue = selected?.map(o => o.label); const answerComponent: IRWCAnswerComponent = getAnswerComponent('rwc-radio-group'); answerComponent.vBind = { options, defaultValue }; const result: IRWCMessage = { message: props.label, answerComponent }; return result; };