mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-28 17:09:41 +05:00
feat: add button to show collections containing the release on release page
feat: add release in list widget to release page fix: redirecting if viewing not favorites collection for unauthorized user
This commit is contained in:
parent
723b620749
commit
501d3a1705
5 changed files with 117 additions and 61 deletions
|
@ -35,15 +35,22 @@ export function CollectionsFullPage(props: {
|
|||
|
||||
const getKey = (pageIndex: number, previousPageData: any) => {
|
||||
if (previousPageData && !previousPageData.content.length) return null;
|
||||
if (userStore.token) {
|
||||
if (props.type == "favorites") {
|
||||
return `${ENDPOINTS.collection.favoriteCollections}/all/${pageIndex}?token=${userStore.token}`;
|
||||
} else if (props.type == "profile") {
|
||||
return `${ENDPOINTS.collection.userCollections}/${props.profile_id}/${pageIndex}?token=${userStore.token}`;
|
||||
} else if (props.type == "release") {
|
||||
return `${ENDPOINTS.collection.releaseInCollections}/${props.release_id}/${pageIndex}?token=${userStore.token}`;
|
||||
}
|
||||
|
||||
let url;
|
||||
|
||||
if (props.type == "favorites") {
|
||||
url = `${ENDPOINTS.collection.favoriteCollections}/all/${pageIndex}`;
|
||||
} else if (props.type == "profile") {
|
||||
url = `${ENDPOINTS.collection.userCollections}/${props.profile_id}/${pageIndex}`;
|
||||
} else if (props.type == "release") {
|
||||
url = `${ENDPOINTS.collection.releaseInCollections}/${props.release_id}/${pageIndex}`;
|
||||
}
|
||||
|
||||
if (userStore.token) {
|
||||
url += `?token=${userStore.token}`;
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
const { data, error, isLoading, size, setSize } = useSWRInfinite(
|
||||
|
@ -72,7 +79,11 @@ export function CollectionsFullPage(props: {
|
|||
}, [scrollPosition]);
|
||||
|
||||
useEffect(() => {
|
||||
if (userStore.state === "finished" && !userStore.token) {
|
||||
if (
|
||||
userStore.state === "finished" &&
|
||||
!userStore.token &&
|
||||
props.type == "favorites"
|
||||
) {
|
||||
router.push(`/login?redirect=/collections/favorites`);
|
||||
}
|
||||
}, [userStore.state, userStore.token]);
|
||||
|
|
|
@ -15,6 +15,7 @@ import { ReleaseInfoRating } from "#/components/ReleaseInfo/ReleaseInfo.Rating";
|
|||
import { ReleaseInfoRelated } from "#/components/ReleaseInfo/ReleaseInfo.Related";
|
||||
import { ReleaseInfoScreenshots } from "#/components/ReleaseInfo/ReleaseInfo.Screenshots";
|
||||
import { CommentsMain } from "#/components/Comments/Comments.Main";
|
||||
import { InfoLists } from "#/components/InfoLists/InfoLists";
|
||||
|
||||
export const ReleasePage = (props: any) => {
|
||||
const token = useUserStore((state) => state.token);
|
||||
|
@ -68,7 +69,7 @@ export const ReleasePage = (props: any) => {
|
|||
released: data.release.episodes_released,
|
||||
}}
|
||||
season={data.release.season}
|
||||
status={data.release.status.name}
|
||||
status={data.release.status ? data.release.status.name : "Анонс"}
|
||||
duration={data.release.duration}
|
||||
category={data.release.category.name}
|
||||
broadcast={data.release.broadcast}
|
||||
|
@ -86,14 +87,15 @@ export const ReleasePage = (props: any) => {
|
|||
token={token}
|
||||
setUserList={setUserList}
|
||||
setIsFavorite={setUserFavorite}
|
||||
collection_count={data.release.collection_count}
|
||||
/>
|
||||
</div>
|
||||
{data.release.status.name.toLowerCase() != "анонс" && (
|
||||
<div className="[grid-column:1] [grid-row:span_4]">
|
||||
{data.release.status && data.release.status.name.toLowerCase() != "анонс" && (
|
||||
<div className="[grid-column:1] [grid-row:span_12]">
|
||||
<ReleasePlayer id={props.id} />
|
||||
</div>
|
||||
)}
|
||||
{data.release.status.name.toLowerCase() != "анонс" && (
|
||||
{data.release.status && data.release.status.name.toLowerCase() != "анонс" && (
|
||||
<div className="[grid-column:2]">
|
||||
<ReleaseInfoRating
|
||||
release_id={props.id}
|
||||
|
@ -111,14 +113,24 @@ export const ReleasePage = (props: any) => {
|
|||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="[grid-column:2] [grid-row:span_4]">
|
||||
<InfoLists
|
||||
completed={data.release.completed_count}
|
||||
planned={data.release.plan_count}
|
||||
abandoned={data.release.dropped_count}
|
||||
delayed={data.release.hold_on_count}
|
||||
watching={data.release.watching_count}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{data.release.screenshot_images.length > 0 && (
|
||||
<div className="[grid-column:2]">
|
||||
<div className="[grid-column:2] [grid-row:span_11]">
|
||||
<ReleaseInfoScreenshots images={data.release.screenshot_images} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{data.release.related_releases.length > 0 && (
|
||||
<div className="[grid-column:2] [grid-row:span_4]">
|
||||
<div className="[grid-column:2] [grid-row:span_2]">
|
||||
<ReleaseInfoRelated
|
||||
release_id={props.id}
|
||||
related={data.release.related}
|
||||
|
@ -127,7 +139,7 @@ export const ReleasePage = (props: any) => {
|
|||
</div>
|
||||
)}
|
||||
|
||||
<div className="[grid-column:1] [grid-row:span_2]">
|
||||
<div className="[grid-column:1] [grid-row:span_32]">
|
||||
<CommentsMain
|
||||
release_id={props.id}
|
||||
token={token}
|
||||
|
|
|
@ -5,13 +5,12 @@ import { Spinner } from "#/components/Spinner/Spinner";
|
|||
import { useState, useEffect } from "react";
|
||||
import { useScrollPosition } from "#/hooks/useScrollPosition";
|
||||
import { useUserStore } from "../store/auth";
|
||||
import { Button, Card } from "flowbite-react";
|
||||
import { ENDPOINTS } from "#/api/config";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { ReleaseSection } from "#/components/ReleaseSection/ReleaseSection";
|
||||
|
||||
import { CollectionInfoBasics } from "#/components/CollectionInfo/CollectionInfo.Basics";
|
||||
import { CollectionInfoLists } from "#/components/CollectionInfo/CollectionInfoLists";
|
||||
import { InfoLists } from "#/components/InfoLists/InfoLists";
|
||||
import { CollectionInfoControls } from "#/components/CollectionInfo/CollectionInfoControls";
|
||||
|
||||
const fetcher = async (url: string) => {
|
||||
|
@ -101,7 +100,7 @@ export const ViewCollectionPage = (props: { id: number }) => {
|
|||
/>
|
||||
{userStore.token && !isLoading && (
|
||||
<div className="flex flex-col gap-4 w-full max-w-full lg:max-w-[48%]">
|
||||
<CollectionInfoLists
|
||||
<InfoLists
|
||||
completed={collectionInfo.completed_count}
|
||||
planned={collectionInfo.plan_count}
|
||||
abandoned={collectionInfo.dropped_count}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue