From 56334893b4439bd72086e534a95f50edd422c908 Mon Sep 17 00:00:00 2001 From: Radiquum Date: Mon, 25 Aug 2025 18:02:35 +0500 Subject: [PATCH] anix/feat: add recommended to discovery page --- app/api/config.ts | 3 ++- .../Discovery/RecommendedCarousel.tsx | 26 +++++++++++++++++++ app/pages/Discover.tsx | 2 ++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 app/components/Discovery/RecommendedCarousel.tsx diff --git a/app/api/config.ts b/app/api/config.ts index 63b92ac..e75acb0 100644 --- a/app/api/config.ts +++ b/app/api/config.ts @@ -79,6 +79,7 @@ export const ENDPOINTS = { interesting: `${API_PREFIX}/discover/interesting`, discussing: `${API_PREFIX}/discover/discussing`, watching: `${API_PREFIX}/discover/watching`, - collections: `${API_PREFIX}/collection/all` + recommendations: `${API_PREFIX}/discover/recommendations`, + collections: `${API_PREFIX}/collection/all`, } }; diff --git a/app/components/Discovery/RecommendedCarousel.tsx b/app/components/Discovery/RecommendedCarousel.tsx new file mode 100644 index 0000000..d1212d9 --- /dev/null +++ b/app/components/Discovery/RecommendedCarousel.tsx @@ -0,0 +1,26 @@ +"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 RecommendedCarousel = () => { + const token = useUserStore((state) => state.token); + const { data, isLoading, error } = useSWR( + `${ENDPOINTS.discover.recommendations}/-1?previous_page=-1${token ? `&token=${token}` : ""}`, + useSWRfetcher, + { + revalidateOnFocus: false, + revalidateIfStale: false, + revalidateOnReconnect: false, + } + ); + + if (!token) return <>; + if (error) return <>; + if (isLoading) return <>; + + return ; +}; diff --git a/app/pages/Discover.tsx b/app/pages/Discover.tsx index b36e430..e75d63b 100644 --- a/app/pages/Discover.tsx +++ b/app/pages/Discover.tsx @@ -2,6 +2,7 @@ import { CollectionsOfTheWeek } from "#/components/Discovery/CollectionsOfTheWeek"; import { DiscussingToday } from "#/components/Discovery/DiscussingToday"; import { InterestingCarousel } from "#/components/Discovery/InterestingCarousel"; +import { RecommendedCarousel } from "#/components/Discovery/RecommendedCarousel"; import { WatchingNowCarousel } from "#/components/Discovery/WatchingNowCarousel"; import { Button } from "flowbite-react"; @@ -27,6 +28,7 @@ export const DiscoverPage = () => { Фильтр +