From 31bd239756383ba6f2fad5f3be232d427f7ba593 Mon Sep 17 00:00:00 2001 From: olexh Date: Wed, 28 Aug 2024 19:31:01 +0300 Subject: [PATCH] feat: open auth when user not signed in --- .../(pages)/(content)/anime/[slug]/layout.tsx | 1 + .../(pages)/(content)/anime/[slug]/page.tsx | 33 +++++++++++-------- src/components/comments/comment-vote.tsx | 16 +++++++-- src/components/comments/comment.tsx | 16 +++++++-- src/components/comments/global-comment.tsx | 2 +- .../collection-info/collection-vote.tsx | 16 +++++++-- 6 files changed, 63 insertions(+), 21 deletions(-) diff --git a/src/app/(pages)/(content)/anime/[slug]/layout.tsx b/src/app/(pages)/(content)/anime/[slug]/layout.tsx index 538a2212..048e7f7c 100644 --- a/src/app/(pages)/(content)/anime/[slug]/layout.tsx +++ b/src/app/(pages)/(content)/anime/[slug]/layout.tsx @@ -45,6 +45,7 @@ const AnimeLayout: FC = async ({ params: { slug }, children }) => { ]); if (!anime) { + console.log('Anime not found'); return permanentRedirect('/'); } diff --git a/src/app/(pages)/(content)/anime/[slug]/page.tsx b/src/app/(pages)/(content)/anime/[slug]/page.tsx index e8c1a9ec..3b5dad56 100644 --- a/src/app/(pages)/(content)/anime/[slug]/page.tsx +++ b/src/app/(pages)/(content)/anime/[slug]/page.tsx @@ -10,9 +10,8 @@ import WatchStats from '@/features/anime/anime-view/watch-stats/watch-stats.comp import Followings from '@/features/followings/followings.component'; import Franchise from '@/features/franchise/franchise.component'; -import getAnimeInfo, { - Response as AnimeResponse, -} from '@/services/api/anime/getAnimeInfo'; +import { prefetchAnimeInfo } from '@/services/hooks/anime/use-anime-info'; +import getQueryClient from '@/utils/get-query-client'; import jsonSchema from './anime.schema'; @@ -22,20 +21,26 @@ interface Props { }; } -const AnimePage: FC = async ({ params }) => { - const anime: AnimeResponse = await getAnimeInfo({ - params: { - slug: params.slug, - }, - }); - const jsonLd = jsonSchema({ anime }); +const AnimePage: FC = async ({ params: { slug } }) => { + const queryClient = getQueryClient(); + + await prefetchAnimeInfo({ slug }); + + const anime: API.AnimeInfo | undefined = queryClient.getQueryData([ + 'anime', + slug, + ]); return (
-