import { getVideoPreviewImage } from '../videoHelpers';

export const hasScreenshots = screenshots => Boolean(screenshots && screenshots.items && screenshots.items.length);
export const hasDemoVideo = overview => Boolean(overview && overview.callToActions && overview.callToActions.demo);

export const getSlides = (screenshots, overview) => {
    const slides = hasScreenshots(screenshots) ? [...screenshots.items] : [];

    if (hasDemoVideo(overview)) {
        const { callToActions } = overview;
        const { label: name, iFrameFriendlyUrl: videoUrl } = callToActions.demo;
        const imageUrl = getVideoPreviewImage(videoUrl);

        slides.push({
            name,
            imageUrl,
            videoUrl
        });
    }

    return slides;
};
