Merge all api types together
parent
1055a14457
commit
5317050679
|
@ -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',
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
import { ListResponse } from 'types/api';
|
||||
|
||||
export type RegionListResponseData = ListResponse;
|
||||
export type TypeListResponseData = ListResponse;
|
|
@ -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<
|
||||
|
|
|
@ -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[];
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
import { PokemonResponseData } from './api';
|
||||
import { PokemonCardProps } from 'components/PokemonCard';
|
||||
|
||||
export type PokedexState = {
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue