From 5f0e7120025b6001bf42613d60f4ee93c77b5d57 Mon Sep 17 00:00:00 2001 From: alfaruqii Date: Thu, 7 Nov 2024 17:05:28 +0700 Subject: [PATCH 1/5] feat(api): remove unecessary api route(anime-episodes) --- app/api/anime-episodes/route.ts | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 app/api/anime-episodes/route.ts diff --git a/app/api/anime-episodes/route.ts b/app/api/anime-episodes/route.ts deleted file mode 100644 index 6be5a8d..0000000 --- a/app/api/anime-episodes/route.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { NextRequest, NextResponse } from 'next/server' -import { AnimeServiceV2 } from '@/services' - -export async function GET(request: NextRequest) { - const searchParams = request.nextUrl.searchParams - const query = searchParams.get('query') - - if (!query) { - return NextResponse.json({ error: 'Query parameter is required' }, { status: 400 }) - } - - try { - const { data } = await AnimeServiceV2.searchAnimeV2(query) - return NextResponse.json(data) - } catch (error) { - console.error('Error searching anime:', error) - return NextResponse.json({ error: 'Failed to search anime' }, { status: 500 }) - } -} From 2641942f4efcb532968b8e97c1e877072916d116 Mon Sep 17 00:00:00 2001 From: alfaruqii Date: Thu, 7 Nov 2024 17:06:33 +0700 Subject: [PATCH 2/5] =?UTF-8?q?feat(api):=20update=20api's=20error=20messa?= =?UTF-8?q?ge(for=20descriptive=20purpose)=20=F0=9F=94=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/anime-infov1/route.ts | 4 ++-- app/api/anime-infov2/route.ts | 4 ++-- app/api/anime-search/route.ts | 24 +++++++++++++++--------- app/api/animestream/route.ts | 5 ++--- app/api/movie-search/route.ts | 25 +++++++++++++++---------- 5 files changed, 36 insertions(+), 26 deletions(-) diff --git a/app/api/anime-infov1/route.ts b/app/api/anime-infov1/route.ts index a7ededd..6487b31 100644 --- a/app/api/anime-infov1/route.ts +++ b/app/api/anime-infov1/route.ts @@ -16,9 +16,9 @@ export async function GET(request: NextRequest) { const { data } = await AnimeServiceV1.getAnimeInfoV1Gogo(query); return NextResponse.json(data); } catch (error) { - console.error("Error searching anime:", error); + console.error("Error to give animev1 info:", error); return NextResponse.json( - { error: "Failed to search anime" }, + { error: "Failed to give animev1 info" }, { status: 500 } ); } diff --git a/app/api/anime-infov2/route.ts b/app/api/anime-infov2/route.ts index f1094e5..8625719 100644 --- a/app/api/anime-infov2/route.ts +++ b/app/api/anime-infov2/route.ts @@ -16,9 +16,9 @@ export async function GET(request: NextRequest) { const { data } = await AnimeServiceV2.getAnimeInfoV2(query); return NextResponse.json(data); } catch (error) { - console.error("Error searching anime:", error); + console.error("Failed to give animev2 info", error); return NextResponse.json( - { error: "Failed to search anime" }, + { error: "Failed to give animev2 info" }, { status: 500 } ); } diff --git a/app/api/anime-search/route.ts b/app/api/anime-search/route.ts index 6be5a8d..719587e 100644 --- a/app/api/anime-search/route.ts +++ b/app/api/anime-search/route.ts @@ -1,19 +1,25 @@ -import { NextRequest, NextResponse } from 'next/server' -import { AnimeServiceV2 } from '@/services' +import { NextRequest, NextResponse } from "next/server"; +import { AnimeServiceV2 } from "@/services"; export async function GET(request: NextRequest) { - const searchParams = request.nextUrl.searchParams - const query = searchParams.get('query') + const searchParams = request.nextUrl.searchParams; + const query = searchParams.get("query"); if (!query) { - return NextResponse.json({ error: 'Query parameter is required' }, { status: 400 }) + return NextResponse.json( + { error: "Query parameter is required" }, + { status: 400 } + ); } try { - const { data } = await AnimeServiceV2.searchAnimeV2(query) - return NextResponse.json(data) + const { data } = await AnimeServiceV2.searchAnimeV2(query); + return NextResponse.json(data); } catch (error) { - console.error('Error searching anime:', error) - return NextResponse.json({ error: 'Failed to search anime' }, { status: 500 }) + console.error("Error searching animev2:", error); + return NextResponse.json( + { error: "Failed to search animev2" }, + { status: 500 } + ); } } diff --git a/app/api/animestream/route.ts b/app/api/animestream/route.ts index e8f4e1b..80be683 100644 --- a/app/api/animestream/route.ts +++ b/app/api/animestream/route.ts @@ -16,11 +16,10 @@ export async function GET(request: NextRequest) { const { data } = await AnimeServiceV1.getAnimeStreamGogo(query); return NextResponse.json(data); } catch (error) { - console.error("Error searching anime:", error); + console.error("Failed to give animev1 stream", error); return NextResponse.json( - { error: "Failed to search anime" }, + { error: "Failed to give animev1 stream" }, { status: 500 } ); } } - diff --git a/app/api/movie-search/route.ts b/app/api/movie-search/route.ts index 2f08691..0f39890 100644 --- a/app/api/movie-search/route.ts +++ b/app/api/movie-search/route.ts @@ -1,20 +1,25 @@ -import { NextRequest, NextResponse } from 'next/server' -import { MovieService } from '@/services' +import { NextRequest, NextResponse } from "next/server"; +import { MovieService } from "@/services"; export async function GET(request: NextRequest) { - const searchParams = request.nextUrl.searchParams - const query = searchParams.get('query') + const searchParams = request.nextUrl.searchParams; + const query = searchParams.get("query"); if (!query) { - return NextResponse.json({ error: 'Query parameter is required' }, { status: 400 }) + return NextResponse.json( + { error: "Query parameter is required" }, + { status: 400 } + ); } try { - const { data } = await MovieService.searchMovie(query) - return NextResponse.json(data) + const { data } = await MovieService.searchMovie(query); + return NextResponse.json(data); } catch (error) { - console.error('Error searching anime:', error) - return NextResponse.json({ error: 'Failed to search anime' }, { status: 500 }) + console.error("Failed to search movie", error); + return NextResponse.json( + { error: "Failed to search movie" }, + { status: 500 } + ); } } - From e90a46e60887e42949c511b90001cb152136f4ae Mon Sep 17 00:00:00 2001 From: alfaruqii Date: Thu, 7 Nov 2024 17:06:59 +0700 Subject: [PATCH 3/5] feat(component): update AnimeCard(add fallback for seasonYear) --- app/components/card/animecard/AnimeCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/card/animecard/AnimeCard.tsx b/app/components/card/animecard/AnimeCard.tsx index 52ef1f8..5d412e7 100644 --- a/app/components/card/animecard/AnimeCard.tsx +++ b/app/components/card/animecard/AnimeCard.tsx @@ -62,7 +62,7 @@ const AnimeCard = ({ anime }: AnimeCardProps) => { {isPopularAnime(anime) && ( From 4321648afda10310c71161650c539fac462da290 Mon Sep 17 00:00:00 2001 From: alfaruqii Date: Thu, 7 Nov 2024 17:07:55 +0700 Subject: [PATCH 4/5] feat(component): update CardBanner(desc: styling purpose[slice 2 -> mobile, slice 3 -> not mobile[genre]]) --- app/components/detail/cardbanner/CardBanner.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/components/detail/cardbanner/CardBanner.tsx b/app/components/detail/cardbanner/CardBanner.tsx index 33be47a..b218353 100644 --- a/app/components/detail/cardbanner/CardBanner.tsx +++ b/app/components/detail/cardbanner/CardBanner.tsx @@ -1,5 +1,5 @@ "use client"; -import { useState, useMemo } from "react"; +import { useState, useMemo, useEffect } from "react"; import Image from "next/image"; import { AnimeInfo } from "@/types/anime.type"; import { MovieInfo, TVInfo } from "@/types/movies.type"; @@ -13,6 +13,14 @@ function CardBanner({ item }: CardBannerProps) { const pathName = usePathname(); const fallbackCard = "/fallback-card.webp"; const [isImageLoading, setImageLoading] = useState(true); + const [isMobile, setIsMobile] = useState(false); + + useEffect(() => { + const handleResize = () => setIsMobile(window.innerWidth < 640); // Tailwind's mobile breakpoint (sm: 640px) + handleResize(); + window.addEventListener("resize", handleResize); + return () => window.removeEventListener("resize", handleResize); + }, []); const isAnime = useMemo(() => pathName.split("/")[1] === "anime", [pathName]); @@ -69,6 +77,8 @@ function CardBanner({ item }: CardBannerProps) { return []; }, [item]); + const genreSlice = isMobile ? genres.slice(0, 2) : genres.slice(0, 3); + return (
- {genres.slice(0, 3).map((genre: string, i: number) => ( + {genreSlice.map((genre: string, i: number) => (
Date: Thu, 7 Nov 2024 17:10:25 +0700 Subject: [PATCH 5/5] feat(type): update type(desc: add format on Anime for relation/recommendation card[fallback for seasonYear]) --- app/types/anime.type.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/types/anime.type.ts b/app/types/anime.type.ts index 308f391..0afb882 100644 --- a/app/types/anime.type.ts +++ b/app/types/anime.type.ts @@ -98,6 +98,7 @@ export type Anime = { coverImage?: CoverImage; episodes: number | null; meanScore?: number; + format?: string; duration: number; season: string; seasonYear?: number;