diff --git a/src/modules/anilist/anilistApi.ts b/src/modules/anilist/anilistApi.ts index b4fe261f..e28d1fbb 100644 --- a/src/modules/anilist/anilistApi.ts +++ b/src/modules/anilist/anilistApi.ts @@ -1,4 +1,4 @@ -import { TrendingAnime } from '../../types/anilistAPITypes'; +import { AnimeData, MostPopularAnime, TrendingAnime } from '../../types/anilistAPITypes'; import { ClientData } from '../../types/types'; import { clientData } from '../clientData'; import { getOptions, makeRequest } from '../requests'; @@ -310,7 +310,7 @@ export const getTrendingAnime = async (viewerId: number): Promise * @param {*} viewerId * @returns object with most popular animes */ -export const getMostPopularAnimes = async (viewerId: any) => { +export const getMostPopularAnime = async (viewerId: number): Promise => { var query = ` { Page(page: 1, perPage: ${PAGES}) { diff --git a/src/types/anilistAPITypes.tsx b/src/types/anilistAPITypes.tsx index ac20f635..af2077a4 100644 --- a/src/types/anilistAPITypes.tsx +++ b/src/types/anilistAPITypes.tsx @@ -1,6 +1,9 @@ import { Media, PageInfo } from "./anilistGraphQLTypes" -export type TrendingAnime = { - media?: [Media] +export type AnimeData = { + media?: Media[] pageInfo?: PageInfo } + +export type TrendingAnime = AnimeData +export type MostPopularAnime = AnimeData diff --git a/src/types/anilistGraphQLTypes.tsx b/src/types/anilistGraphQLTypes.tsx index e636794e..dd5b8553 100644 --- a/src/types/anilistGraphQLTypes.tsx +++ b/src/types/anilistGraphQLTypes.tsx @@ -1,4 +1,3 @@ - export type MediaTitle = { romaji?: string; english?: string; @@ -41,14 +40,30 @@ export type MediaCoverImage = { }; export type AiringSchedule = { - id?: number; - airingAt?: number; - timeUntilAiring?: number; - episode?: number; - mediaId?: number; + id: number; + airingAt: number; + timeUntilAiring: number; + episode: number; + mediaId: number; media?: Media; }; +export type MediaListStatus = + | 'CURRENT' + | 'PLANNING' + | 'COMPLETED' + | 'DROPPED' + | 'PAUSED' + | 'REPEATING'; + +export type MediaList = { + id: number; + mediaId: number; + status?: MediaListStatus; + score?: number; + progress?: number; +}; + export type MediaTrailer = { id?: string; site?: string; @@ -62,7 +77,7 @@ export type PageInfo = { }; export type Media = { - id: number; + id?: number; title?: MediaTitle; format?: MediaFormat; status?: MediaStatus; @@ -75,8 +90,8 @@ export type Media = { duration?: number; coverImage?: MediaCoverImage; bannerImage?: string; - genres?: [string]; - synonyms?: [string]; + genres?: string[]; + synonyms?: string[]; averageScore?: number; meanScore?: number; popularity?: number;