anix/feat: add recommended to discovery page

This commit is contained in:
Kentai Radiquum 2025-08-25 18:02:35 +05:00
parent 05cb74b7f2
commit 56334893b4
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
3 changed files with 30 additions and 1 deletions

View file

@ -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 <ReleaseCourusel content={data.content} sectionTitle={"Рекомендации"} showAllLink={"/discovery/recommendations"} />;
};