mirror of
https://github.com/Radiquum/AniX.git
synced 2025-09-04 13:35:36 +05:00
anix/feat: add recommended to discovery page
This commit is contained in:
parent
05cb74b7f2
commit
56334893b4
3 changed files with 30 additions and 1 deletions
|
@ -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`,
|
||||
}
|
||||
};
|
||||
|
|
26
app/components/Discovery/RecommendedCarousel.tsx
Normal file
26
app/components/Discovery/RecommendedCarousel.tsx
Normal 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"} />;
|
||||
};
|
|
@ -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 = () => {
|
|||
<span>Фильтр</span>
|
||||
</Button>
|
||||
</div>
|
||||
<RecommendedCarousel />
|
||||
<DiscussingToday />
|
||||
<WatchingNowCarousel />
|
||||
<CollectionsOfTheWeek />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue