UNPKG

@onereach/channel-transformer

Version:

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

19 lines (16 loc) 635 B
import { IGenericCard } from "../../../../generic/types"; import { IRWCAnswerComponent } from "../../../types"; import { transformCard } from '../index'; export const transformCarousel = (msg: IRWCAnswerComponent): Array<IGenericCard> => { const carousel = []; if (msg.vBind?.options?.length) { const cards = msg.vBind.options.map(transformCard); carousel.push(...cards); } if (msg.vBind?.hasOtherOption && msg.vBind.otherOptionData) { const card = transformCard(msg.vBind.otherOptionData); card.props.rwc = { hasOtherOption: true }; // is alternative card carousel.push(card); } return carousel; };