diff --git a/app/api/config.ts b/app/api/config.ts index 316d19e..a685cb3 100644 --- a/app/api/config.ts +++ b/app/api/config.ts @@ -74,5 +74,8 @@ export const ENDPOINTS = { releaseInCollections: `${API_PREFIX}/collection/all/release`, userCollections: `${API_PREFIX}/collection/all/profile`, favoriteCollections: `${API_PREFIX}/collectionFavorite`, + }, + discover: { + interesting: `${API_PREFIX}/discover/interesting`, } }; diff --git a/app/components/Discovery/InterestingCarousel.module.css b/app/components/Discovery/InterestingCarousel.module.css new file mode 100644 index 0000000..ed205c5 --- /dev/null +++ b/app/components/Discovery/InterestingCarousel.module.css @@ -0,0 +1,21 @@ +.swiper-button:global(.swiper-button-disabled) { + opacity: 0 !important; +} + +.swiper-button { + display: none !important; +} + +@media (hover: hover) and (min-width: 1024px) { + .swiper { + overflow: visible !important; + } +} + +@media (hover: hover) { + .swiper:hover .swiper-button { + display: flex !important; + width: 64px; + height: 64px; + } +} diff --git a/app/components/Discovery/InterestingCarousel.tsx b/app/components/Discovery/InterestingCarousel.tsx new file mode 100644 index 0000000..7740c8f --- /dev/null +++ b/app/components/Discovery/InterestingCarousel.tsx @@ -0,0 +1,91 @@ +"use client"; + +import { ENDPOINTS } from "#/api/config"; +import { useSWRfetcher } from "#/api/utils"; +import useSWR from "swr"; +import Image from "next/image"; +import { Swiper, SwiperSlide } from "swiper/react"; +import "swiper/css"; +import "swiper/css/navigation"; +import { Navigation } from "swiper/modules"; +import Styles from "./InterestingCarousel.module.css"; +import Link from "next/link"; + +export const InterestingCarousel = () => { + const { data, isLoading, error } = useSWR( + ENDPOINTS.discover.interesting, + useSWRfetcher, + { + revalidateOnFocus: false, + revalidateIfStale: false, + revalidateOnReconnect: false, + } + ); + + if (error) + return ( +
+
+

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

+
+
+ ); + if (isLoading) return <>; + + return ( +
+ + {data.content.map((item) => { + return ( + + +
+ +
+
+

{item.title}

+

{item.description}

+
+
+ +
+ ); + })} +
+
+
+
+ ); +}; diff --git a/app/discover/page.tsx b/app/discovery/page.tsx similarity index 100% rename from app/discover/page.tsx rename to app/discovery/page.tsx diff --git a/app/pages/Discover.tsx b/app/pages/Discover.tsx index 2695dc3..068f412 100644 --- a/app/pages/Discover.tsx +++ b/app/pages/Discover.tsx @@ -1,19 +1,10 @@ "use client"; -import { useState, useEffect } from "react"; -import { useUserStore } from "../store/auth"; -import { useRouter } from "next/navigation"; +import { InterestingCarousel } from "#/components/Discovery/InterestingCarousel"; export const DiscoverPage = () => { - const token = useUserStore((state) => state.token); - const authState = useUserStore((state) => state.state); - const router = useRouter(); - - useEffect(() => { - if (authState === "finished" && !token) { - router.push("/login?redirect=/discover"); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [authState, token]); - - return <>; + return ( + <> + + + ); };