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