diff --git a/app/api/config.ts b/app/api/config.ts index e2e47d5..63b92ac 100644 --- a/app/api/config.ts +++ b/app/api/config.ts @@ -78,5 +78,7 @@ export const ENDPOINTS = { discover: { interesting: `${API_PREFIX}/discover/interesting`, discussing: `${API_PREFIX}/discover/discussing`, + watching: `${API_PREFIX}/discover/watching`, + collections: `${API_PREFIX}/collection/all` } }; diff --git a/app/components/CollectionCourusel/CollectionCourusel.module.css b/app/components/CollectionCourusel/CollectionCourusel.module.css index fce52de..1f56115 100644 --- a/app/components/CollectionCourusel/CollectionCourusel.module.css +++ b/app/components/CollectionCourusel/CollectionCourusel.module.css @@ -6,6 +6,12 @@ display: none !important; } +@media (hover: hover) and (min-width: 1024px) { + .swiper { + overflow: visible !important; + } +} + @media (hover: hover) { .section:hover .swiper-button { display: flex !important; diff --git a/app/components/CollectionCourusel/CollectionCourusel.tsx b/app/components/CollectionCourusel/CollectionCourusel.tsx index c3b920e..e53bcd8 100644 --- a/app/components/CollectionCourusel/CollectionCourusel.tsx +++ b/app/components/CollectionCourusel/CollectionCourusel.tsx @@ -55,7 +55,7 @@ export const CollectionCourusel = (props: { )}
-
+
{props.isMyCollections && (
diff --git a/app/components/Discovery/CollectionsOfTheWeek.tsx b/app/components/Discovery/CollectionsOfTheWeek.tsx new file mode 100644 index 0000000..a132684 --- /dev/null +++ b/app/components/Discovery/CollectionsOfTheWeek.tsx @@ -0,0 +1,31 @@ +"use client"; + +import { ENDPOINTS } from "#/api/config"; +import { useSWRfetcher } from "#/api/utils"; +import useSWR from "swr"; +import { CollectionCourusel } from "../CollectionCourusel/CollectionCourusel"; +import { useUserStore } from "#/store/auth"; + +export const CollectionsOfTheWeek = () => { + const token = useUserStore((state) => state.token); + const { data, isLoading, error } = useSWR( + `${ENDPOINTS.discover.collections}/-1?previous_page=0&where=2&sort=4${token ? `&token=${token}` : ""}`, + useSWRfetcher, + { + revalidateOnFocus: false, + revalidateIfStale: false, + revalidateOnReconnect: false, + } + ); + + if (error) return <>; + if (isLoading) return <>; + + return ( + + ); +}; diff --git a/app/components/Discovery/DiscussingTodayCarousel.tsx b/app/components/Discovery/DiscussingToday.tsx similarity index 74% rename from app/components/Discovery/DiscussingTodayCarousel.tsx rename to app/components/Discovery/DiscussingToday.tsx index 7af3de7..71a4692 100644 --- a/app/components/Discovery/DiscussingTodayCarousel.tsx +++ b/app/components/Discovery/DiscussingToday.tsx @@ -7,7 +7,7 @@ import Link from "next/link"; import { PosterWithStuff } from "../ReleasePoster/PosterWithStuff"; import useSWR from "swr"; -export const DiscussingTodayCarousel = () => { +export const DiscussingToday = () => { const token = useUserStore((state) => state.token); const { data, isLoading, error } = useSWR( `${ENDPOINTS.discover.discussing}${token ? `?token=${token}` : ""}`, @@ -19,14 +19,7 @@ export const DiscussingTodayCarousel = () => { } ); - if (error) - return ( -
-
-

Произошла ошибка загрузки обсуждаемых релизов

-
-
- ); + if (error) return <>; if (isLoading) return <>; return ( diff --git a/app/components/Discovery/InterestingCarousel.tsx b/app/components/Discovery/InterestingCarousel.tsx index d6c4c41..fa4e366 100644 --- a/app/components/Discovery/InterestingCarousel.tsx +++ b/app/components/Discovery/InterestingCarousel.tsx @@ -22,14 +22,7 @@ export const InterestingCarousel = () => { } ); - if (error) - return ( -
-
-

Произошла ошибка загрузки интересных релизов

-
-
- ); + if (error) return <>; if (isLoading) return <>; return ( @@ -45,12 +38,6 @@ export const InterestingCarousel = () => { prevEl: ".swiper-button-prev", }} allowTouchMove={true} - breakpoints={{ - 1800: { - initialSlide: 1, - centeredSlides: true, - }, - }} className={Styles.swiper} > {data.content.map((item) => { diff --git a/app/components/Discovery/WatchingNowCarousel.tsx b/app/components/Discovery/WatchingNowCarousel.tsx new file mode 100644 index 0000000..0bb20a1 --- /dev/null +++ b/app/components/Discovery/WatchingNowCarousel.tsx @@ -0,0 +1,25 @@ +"use client"; + +import { ENDPOINTS } from "#/api/config"; +import { useSWRfetcher } from "#/api/utils"; +import { useUserStore } from "#/store/auth"; +import { ReleaseCourusel } from "../ReleaseCourusel/ReleaseCourusel"; +import useSWR from "swr"; + +export const WatchingNowCarousel = () => { + const token = useUserStore((state) => state.token); + const { data, isLoading, error } = useSWR( + `${ENDPOINTS.discover.watching}/0${token ? `?token=${token}` : ""}`, + useSWRfetcher, + { + revalidateOnFocus: false, + revalidateIfStale: false, + revalidateOnReconnect: false, + } + ); + + if (error) return <>; + if (isLoading) return <>; + + return ; +}; diff --git a/app/components/ReleaseCourusel/ReleaseCourusel.tsx b/app/components/ReleaseCourusel/ReleaseCourusel.tsx index 503c814..3fa90a1 100644 --- a/app/components/ReleaseCourusel/ReleaseCourusel.tsx +++ b/app/components/ReleaseCourusel/ReleaseCourusel.tsx @@ -40,12 +40,6 @@ export const ReleaseCourusel = (props: { prevEl: ".swiper-button-prev" }} allowTouchMove={true} - breakpoints={{ - 1800: { - initialSlide: 2, - centeredSlides: true - } - }} className={Styles.swiper} > {props.content.map((release) => { diff --git a/app/pages/Discover.tsx b/app/pages/Discover.tsx index 841a6d7..b36e430 100644 --- a/app/pages/Discover.tsx +++ b/app/pages/Discover.tsx @@ -1,6 +1,8 @@ "use client"; -import { DiscussingTodayCarousel } from "#/components/Discovery/DiscussingTodayCarousel"; +import { CollectionsOfTheWeek } from "#/components/Discovery/CollectionsOfTheWeek"; +import { DiscussingToday } from "#/components/Discovery/DiscussingToday"; import { InterestingCarousel } from "#/components/Discovery/InterestingCarousel"; +import { WatchingNowCarousel } from "#/components/Discovery/WatchingNowCarousel"; import { Button } from "flowbite-react"; export const DiscoverPage = () => { @@ -25,7 +27,9 @@ export const DiscoverPage = () => { Фильтр
- + + + ); };