From f30edc970000b39ee957804eca0f1be37b3e3cf6 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Sun, 2 Apr 2023 23:51:23 +1000 Subject: [PATCH] Move types with pokedexSlice into types/slice.ts --- src/features/Pokedex/Filters/Filters.tsx | 35 ++++++++++-------------- src/features/Pokedex/pokedexSlice.ts | 12 +------- src/features/Pokedex/types/slice.ts | 15 ++++++++++ 3 files changed, 30 insertions(+), 32 deletions(-) create mode 100644 src/features/Pokedex/types/slice.ts diff --git a/src/features/Pokedex/Filters/Filters.tsx b/src/features/Pokedex/Filters/Filters.tsx index 33114b7..46d1ae3 100644 --- a/src/features/Pokedex/Filters/Filters.tsx +++ b/src/features/Pokedex/Filters/Filters.tsx @@ -4,8 +4,8 @@ import { setSelectedRegion, setSelectedType, setSelectedSort, - setFetchingRegionPokemonList, } from 'features/Pokedex/pokedexSlice'; +import { RegionPokemonRange } from 'features/Pokedex/types/slice'; import { useAppDispatch, useAppSelector } from 'app/hooks'; const useGetSortOptions = () => { @@ -17,34 +17,27 @@ const useGetSortOptions = () => { }; export const useGetRegionPokemons = () => { - return { - data: [ - { region: 'kanto', startid: 1, endid: 151 }, - { region: 'johto', startid: 152, endid: 251 }, - { region: 'hoenn', startid: 252, endid: 386 }, - { region: 'sinnoh', startid: 387, endid: 493 }, - { region: 'unova', startid: 494, endid: 649 }, - { region: 'kalos', startid: 650, endid: 721 }, - { region: 'alola', startid: 722, endid: 809 }, - { region: 'galar', startid: 810, endid: 898 }, - ], - }; -}; - -export type RegionPokemonRange = { - region: string; - startid: number; - endid: number; + const data: RegionPokemonRange[] = [ + { region: 'kanto', startId: 1, endId: 151 }, + { region: 'johto', startId: 152, endId: 251 }, + { region: 'hoenn', startId: 252, endId: 386 }, + { region: 'sinnoh', startId: 387, endId: 493 }, + { region: 'unova', startId: 494, endId: 649 }, + { region: 'kalos', startId: 650, endId: 721 }, + { region: 'alola', startId: 722, endId: 809 }, + { region: 'galar', startId: 810, endId: 898 }, + ]; + return { data: data }; }; export const createRegionPokemonListOptionElements = ( data: RegionPokemonRange[], ) => { - return data.map(({ region, startid, endid }) => { + return data.map(({ region, startId, endId }) => { const value = `${region}`; const label = `${ region.charAt(0).toUpperCase() + region.slice(1) - } (${startid}-${endid})`; + } (${startId}-${endId})`; return (