diff options
Diffstat (limited to 'lib/anilist')
| -rw-r--r-- | lib/anilist/aniAdvanceSearch.ts (renamed from lib/anilist/aniAdvanceSearch.js) | 34 | ||||
| -rw-r--r-- | lib/anilist/getUpcomingAnime.js | 2 | ||||
| -rw-r--r-- | lib/anilist/useAnilist.js | 3 |
3 files changed, 33 insertions, 6 deletions
diff --git a/lib/anilist/aniAdvanceSearch.js b/lib/anilist/aniAdvanceSearch.ts index ccfbd27..5251815 100644 --- a/lib/anilist/aniAdvanceSearch.js +++ b/lib/anilist/aniAdvanceSearch.ts @@ -1,8 +1,32 @@ +import { AnifySearchAdvanceTypes } from "types/info/AnifySearchAdvanceTypes"; import { advanceSearchQuery } from "../graphql/query"; +export type AniAdvanceSearch = { + search?: string; + type?: string; + genres?: any[]; + page?: number; + sort?: string; + format?: + | "TV" + | "TV_SHORT" + | "MOVIE" + | "SPECIAL" + | "OVA" + | "ONA" + | "MUSIC" + | "MANGA" + | "NOVEL" + | "ONE_SHOT" + | undefined; + season?: string; + seasonYear?: number; + perPage?: number; +}; + export async function aniAdvanceSearch({ search, - type, + type = "ANIME", genres, page, sort, @@ -10,7 +34,7 @@ export async function aniAdvanceSearch({ season, seasonYear, perPage, -}) { +}: AniAdvanceSearch) { const categorizedGenres = genres?.reduce((result, item) => { const existingEntry = result[item.type]; @@ -43,10 +67,10 @@ export async function aniAdvanceSearch({ }), }); - const data = await response.json(); + const data: AnifySearchAdvanceTypes = await response.json(); return { pageInfo: { - hasNextPage: page < data.total, + hasNextPage: page ?? 0 < data.total, currentPage: page, lastPage: Math.ceil(data.lastPage), perPage: perPage ?? 20, @@ -62,7 +86,7 @@ export async function aniAdvanceSearch({ large: item.coverImage, }, description: item.description, - duration: item.duration ?? null, + duration: item?.duration ?? null, endDate: { day: null, month: null, diff --git a/lib/anilist/getUpcomingAnime.js b/lib/anilist/getUpcomingAnime.js index 2ab9315..d5249f1 100644 --- a/lib/anilist/getUpcomingAnime.js +++ b/lib/anilist/getUpcomingAnime.js @@ -59,7 +59,7 @@ const getUpcomingAnime = async () => { `; const variables = { - season: "FALL", + season: currentSeason, year: currentYear, format: "TV", }; diff --git a/lib/anilist/useAnilist.js b/lib/anilist/useAnilist.js index 20c1964..323dd29 100644 --- a/lib/anilist/useAnilist.js +++ b/lib/anilist/useAnilist.js @@ -225,6 +225,9 @@ export const useAniList = (session) => { // if (lists.length > 0) { await fetchGraphQL(progressWatched, variables); console.log(`Progress Updated: ${progress}`, status); + toast.success(`Progress Updated: ${progress}`, { + position: "bottom-right", + }); // } } else if (media && media.type === "MANGA") { let variables = { |