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;
};