diff --git a/src/features/Filters/filterApi.ts b/src/features/Filters/filterApi.ts index 58e8233..5cc4faf 100644 --- a/src/features/Filters/filterApi.ts +++ b/src/features/Filters/filterApi.ts @@ -1,6 +1,6 @@ import { createApi } from '@reduxjs/toolkit/query/react'; import { pokeApiBaseQuery } from '../../services/pokeapi/paginationBaseQuery'; -import { RegionListResponseData, TypeListResponseData } from './types/api'; +import { RegionListResponseData, TypeListResponseData } from 'types/api'; export const filterApi = createApi({ reducerPath: 'filterApi', diff --git a/src/features/Filters/types/api.ts b/src/features/Filters/types/api.ts deleted file mode 100644 index 8163df6..0000000 --- a/src/features/Filters/types/api.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { ListResponse } from 'types/api'; - -export type RegionListResponseData = ListResponse; -export type TypeListResponseData = ListResponse; diff --git a/src/features/Pokedex/pokedexSlice.ts b/src/features/Pokedex/pokedexSlice.ts index 18b4e29..fd3bb13 100644 --- a/src/features/Pokedex/pokedexSlice.ts +++ b/src/features/Pokedex/pokedexSlice.ts @@ -4,7 +4,7 @@ import type { Slice, PayloadAction } from '@reduxjs/toolkit'; import { PokedexState } from 'features/Pokedex/types/slice'; import { getStartAndEndIdsForRegion } from './utils'; -import { PokemonResponseData } from './types/api'; +import { PokemonResponseData } from 'types/api'; import { RootState } from 'app/store'; export const fetchPokemonsInTheRegion = createAsyncThunk< diff --git a/src/features/Pokedex/types/api.ts b/src/features/Pokedex/types/api.ts deleted file mode 100644 index 1a9cda6..0000000 --- a/src/features/Pokedex/types/api.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { ListResponse, nameUrlPair } from 'types/api'; - -export type PokemonListResponseData = ListResponse; - -export interface PokemonListItem { - name: string; - id: number; - type: string[]; - image: string; -} - -export interface PokemonList { - PokemonList: PokemonListItem[]; -} - -export interface RegionResponseData { - // many fields are ignored - id: number; - locations: nameUrlPair[]; - name: string; -} - -export interface TypeResponseData { - // many fields are ignored - id: number; - name: string; -} - -export interface AbilityItem { - ability: nameUrlPair; - is_hidden: boolean; - slot: number; -} - -export interface StatItem { - base_stat: number; - effort: number; - stat: nameUrlPair; -} - -export interface typeItem { - slot: number; - type: nameUrlPair; -} - -export interface PokemonResponseData { - // many fields are ignored - abilities: AbilityItem[]; - base_experience: number; - forms: nameUrlPair[]; - height: number; - held_items: any[]; - id: number; - is_default: boolean; - location_area_encounters: string; - name: string; - order: number; - species: nameUrlPair; - stats: StatItem[]; - types: typeItem[]; - weight: number; - sprites: { - back_default: string; - front_default: string; - other: { - dream_world: { - front_default: string; - }; - 'official-artwork': { - front_default: string; - }; - }; - }; -} - -export interface LocationResponseData { - // many fields are ignored - areas: nameUrlPair[]; - id: number; - name: string; - region: nameUrlPair; -} - -export interface PokemonEncounter { - // many fields are ignored - pokemon: nameUrlPair; -} -export interface AreaResponseData { - // many fields are ignored - id: number; - name: string; - pokemon_encounters: PokemonEncounter[]; -} diff --git a/src/features/Pokedex/types/slice.ts b/src/features/Pokedex/types/slice.ts index 849d0be..ef89c6e 100644 --- a/src/features/Pokedex/types/slice.ts +++ b/src/features/Pokedex/types/slice.ts @@ -1,4 +1,3 @@ -import { PokemonResponseData } from './api'; import { PokemonCardProps } from 'components/PokemonCard'; export type PokedexState = { diff --git a/src/types/api.ts b/src/types/api.ts index bef8f79..0ce80b3 100644 --- a/src/types/api.ts +++ b/src/types/api.ts @@ -1,3 +1,4 @@ +// API Base types export interface nameUrlPair { name: string; url: string; @@ -7,3 +8,55 @@ export interface ListResponse { count: number; results: nameUrlPair[]; } + +// Filter API +export type RegionListResponseData = ListResponse; +export type TypeListResponseData = ListResponse; + +// InfoDialog API +export interface AbilityItem { + ability: nameUrlPair; + is_hidden: boolean; + slot: number; +} + +export interface StatItem { + base_stat: number; + effort: number; + stat: nameUrlPair; +} + +export interface typeItem { + slot: number; + type: nameUrlPair; +} + +export interface PokemonResponseData { + // many fields are ignored + abilities: AbilityItem[]; + base_experience: number; + forms: nameUrlPair[]; + height: number; + held_items: any[]; + id: number; + is_default: boolean; + location_area_encounters: string; + name: string; + order: number; + species: nameUrlPair; + stats: StatItem[]; + types: typeItem[]; + weight: number; + sprites: { + back_default: string; + front_default: string; + other: { + dream_world: { + front_default: string; + }; + 'official-artwork': { + front_default: string; + }; + }; + }; +}