From 40358e39006d225dcd061253b01f05d1a216cea8 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Wed, 5 Apr 2023 21:37:03 +1000 Subject: [PATCH] Created utils functions within Pokedex --- src/features/Pokedex/utils.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/features/Pokedex/utils.ts diff --git a/src/features/Pokedex/utils.ts b/src/features/Pokedex/utils.ts new file mode 100644 index 0000000..340eee8 --- /dev/null +++ b/src/features/Pokedex/utils.ts @@ -0,0 +1,11 @@ +import { RegionPokemonRange } from './types/slice'; + +export const getStartAndEndIdsForRegion = ( + region: string, + data: RegionPokemonRange[], +): { startId: number; endId: number } => { + const regionData = data.find(data => data.region === region); + return regionData + ? { startId: regionData.startId, endId: regionData.endId } + : { startId: 0, endId: 0 }; +};