import React, { useState, useRef } from 'react' import './VideoCarousel.css' import VideoCard from '../VideoCard/VideoCard' import { buildVideoMetadata } from 'utils/transformations' import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faChevronRight, faChevronLeft } from "@fortawesome/free-solid-svg-icons"; import { scrollTo } from 'utils/animations' const VideoCarousel = props => { const { carouselVideo, carouselName, carouselHoverHandler, videoInfo, carouselClickHandler } = props const carouselRef = useRef() const [disableScrolling, setDisableScrolling] = useState(false) const isNetflixOriginalCard = carouselName === "Netflix Originals" ? true : false const itemClass = [] const itemsClass = [] // Setting different transition styles for the netflix original card if (!isNetflixOriginalCard) { itemClass.push("item") itemsClass.push("items") } else { itemClass.push("netflix-item") itemsClass.push("netflix-items") } const scrollOnAbsoluteButtonClick = scrollOffset => { setDisableScrolling(true) scrollTo(carouselRef.current, carouselRef.current.scrollLeft + scrollOffset, 1250, () => { setDisableScrolling(false) }) } /** * The mediaType property only exists in the trending API call. For the sake of using the same * function 'videoDetailRequest' for multiple individual API calls, I use this mediaType * variable to judge whether a video is a TV show or a movie. This fails for API calls, such as * top rated or netflix originals. Thus, I have created a 'hacky' way of determining that by * checking if two properties exist: the first_air_date (only for tv shows) or the release_date * (only for movies). */ const videoCards = carouselVideo.map(item => { const { mediaType, extraInfo } = buildVideoMetadata(item, videoInfo) return ( item.poster_path &&