@onereach/channel-transformer
Version:
Convert data model between different channels (Slack, Microsoft Teams, Generic...)
29 lines (26 loc) • 852 B
text/typescript
// import { IGenericSection } from "../../../generic/types";
import { getAnswerComponent } from "../../../helpers/answer-types";
import { IRWCAnswerComponent } from "../../../types";
import { getMethods } from "../methods";
export const transformCarousel = ({ children }) => {
if (children.length === 1) {
return {
answerComponent: getMethods('card')(children[0])
};
}
const carousel: IRWCAnswerComponent = getAnswerComponent('rwc-carousel');
children
.map(getMethods('card'))
.forEach(card => {
if (card.vBind?.hasOtherOption) {
carousel.vBind.hasOtherOption = true;
delete card.vBind.hasOtherOption;
Object.assign(carousel.vBind.otherOptionData, card.vBind);
} else {
carousel.vBind.options.push(card.vBind);
}
});
return {
answerComponent: carousel
};
};