mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-28 08:59:40 +05:00
feat: add release user list and release user favorite to the ReleaseLink on Index and Index Category pages
This commit is contained in:
parent
c4a9b4f91a
commit
35c79559ab
5 changed files with 68 additions and 22 deletions
|
@ -3,10 +3,20 @@ import useSWR from "swr";
|
|||
import { ReleaseCourusel } from "@/app/components/ReleaseCourusel/ReleaseCourusel";
|
||||
import { Spinner } from "@/app/components/Spinner/Spinner";
|
||||
const fetcher = (...args) => fetch(...args).then((res) => res.json());
|
||||
import { useUserStore } from "@/app/store/auth";
|
||||
|
||||
export function IndexPage() {
|
||||
const userStore = useUserStore((state) => state);
|
||||
const token = userStore.token;
|
||||
|
||||
function useFetchReleases(status) {
|
||||
const { data } = useSWR(`/api/home?status=${status}`, fetcher);
|
||||
let url;
|
||||
|
||||
url = `/api/home?status=${status}`;
|
||||
if (token) {
|
||||
url += `&token=${token}`;
|
||||
}
|
||||
const { data } = useSWR(url, fetcher);
|
||||
return [data];
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import { ReleaseSection } from "@/app/components/ReleaseSection/ReleaseSection";
|
|||
import { Spinner } from "@/app/components/Spinner/Spinner";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useScrollPosition } from "@/app/hooks/useScrollPosition";
|
||||
import { useUserStore } from "../store/auth";
|
||||
|
||||
const fetcher = async url => {
|
||||
const res = await fetch(url);
|
||||
|
@ -19,8 +20,13 @@ const fetcher = async url => {
|
|||
};
|
||||
|
||||
export function IndexCategoryPage(props) {
|
||||
const userStore = useUserStore((state) => state);
|
||||
const token = userStore.token;
|
||||
const getKey = (pageIndex, previousPageData) => {
|
||||
if (previousPageData && !previousPageData.content.length) return null;
|
||||
if (token) {
|
||||
return `/api/home?status=${props.slug}&page=${pageIndex}&token=${token}`;
|
||||
}
|
||||
return `/api/home?status=${props.slug}&page=${pageIndex}`;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue