import { useState, useEffect } from "react" import movieApi from '../../apis/movie.api.js' import "./box-office.module.css" const BoxOffice = () => { const [TMDB_TopRated_Data, setTMDB_TopRated_Data] = useState() useEffect(() => { // getTMDB_TopRated() let items = document.querySelectorAll('.carousel .carousel-item') // console.log("item", items) items.forEach((el) => { const minPerSlide = 4 let next = el.nextElementSibling for (let i = 1; i < minPerSlide; i++) { if (!next) { // wrap carousel by using first child next = items[0] } let cloneChild = next.cloneNode(true) el.appendChild(cloneChild.children[0]) next = next.nextElementSibling } }) }, []) async function getTMDB_TopRated() { const category = "popular" try { const data = await movieApi.getMoviesfromTM(category) console.log(data) setTMDB_TopRated_Data(data) } catch (error) { console.log(error) } } return (
) } export default BoxOffice