@onereach/channel-transformer
Version:
Convert data model between different channels (Slack, Microsoft Teams, Generic...)
16 lines (13 loc) • 597 B
text/typescript
import { IGenericCarousel } from "../../../../generic/types";
import { getMethods } from "../methods";
import { IRWCAnswerComponent } from '../../../types';
import { RWCAnswerComponent } from '../../../classes/v5';
export const transformCarousel = ( {children, props }: IGenericCarousel): IRWCAnswerComponent => {
const type = "rwc-carousel";
const result: any = {...props.rwc, options: []};
result.options = children.reduce((cards, child) => {
cards.push(getMethods(child.type)(child));
return cards;
}, []);
return new RWCAnswerComponent(result, type);
};