File size: 1,067 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 31 32 33 34 35 36 37 |
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 Popular = () => {
const [endpoint, setEndpoint] = useState("movie");
const { data, loading } = useFetch(`/${endpoint}/popular`);
const onTabChange = (tab) => {
setEndpoint(tab === "Movies" ? "movie" : "tv");
};
return (
<div className="carouselSection">
<ContentWrapper>
<span className="carouselTitle">What's Popular</span>
<SwitchTabs
data={["Movies", "TV Shows"]}
onTabChange={onTabChange}
/>
</ContentWrapper>
<Carousel
data={data?.results}
loading={loading}
endpoint={endpoint}
/>
</div>
);
};
export default Popular;
|