File size: 922 Bytes
f5071ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import React, { useState } from "react";
import Carousel from "../../../components/carousel/Carousel";
import ContentWrapper from "../../../components/contentWrapper/ContentWrapper";
import SwitchTabs from "../../../components/switchTabs/SwitchTabs";
import useFetch from "../../../hooks/useFetch";
const Trending = () => {
const [endpoint, setEndpoint] = useState("day");
const { data, loading } = useFetch(`/trending/movie/${endpoint}`);
const onTabChange = (tab) => {
setEndpoint(tab === "Day" ? "day" : "week");
};
return (
<div className="carouselSection">
<ContentWrapper>
<span className="carouselTitle">Trending</span>
<SwitchTabs data={["Day", "Week"]} onTabChange={onTabChange} />
</ContentWrapper>
<Carousel data={data?.results} loading={loading} />
</div>
);
};
export default Trending;
|