diff --git a/src/components/Tanks/components/Item.tsx b/src/components/Tanks/components/Item.tsx index 181379f18..b37b49a68 100644 --- a/src/components/Tanks/components/Item.tsx +++ b/src/components/Tanks/components/Item.tsx @@ -1,8 +1,8 @@ -import { TANK_ICONS, TankType } from '../../../core/blitz/tankopedia.js'; +import { TANK_ICONS } from '../../../core/blitz/tankopedia.js'; export interface ItemProps { icon?: string; - type?: TankType; + type?: string; name: string; } diff --git a/src/core/blitz/tankopedia.ts b/src/core/blitz/tankopedia.ts index 4452a611d..54174548c 100644 --- a/src/core/blitz/tankopedia.ts +++ b/src/core/blitz/tankopedia.ts @@ -1,15 +1,13 @@ -export type TankType = 'AT-SPG' | 'lightTank' | 'mediumTank' | 'heavyTank'; +import { WARGAMING_APPLICATION_ID } from '../node/arguments.js'; +import getWargamingResponse from './getWargamingResponse.js'; export interface TankopediaEntry { - name: string; - nation: string; - is_premium: boolean; - tier: number; - cost: { price_credit: number; price_gold: number }; - images: { preview: string; normal: string }; tank_id: number; - type: TankType; - description: string; + name: string; + tier: number; + type: string; + is_premium: boolean; + images: { preview: string; normal: string }; } export interface Tankopedia { @@ -17,12 +15,9 @@ export interface Tankopedia { } console.log('Caching tankopedia...'); -export const tankopedia = fetch('https://www.blitzstars.com/bs-tankopedia.json') - .then((response) => response.json()) - .then((wrapperTankopedia) => { - console.log('Tankopedia cached'); - return (wrapperTankopedia as { data: Tankopedia }).data; - }); +export const tankopedia = getWargamingResponse( + `https://api.wotblitz.com/wotb/encyclopedia/vehicles/?application_id=${WARGAMING_APPLICATION_ID}&fields=name,tier,images,tank_id,type,is_premium`, +); const entries = new Promise(async (resolve) => { resolve(Object.entries(await tankopedia).map(([, entry]) => entry)); }); @@ -33,7 +28,7 @@ export const TANK_NAMES = new Promise(async (resolve) => { resolve((await entries).map(({ name }) => name)); }); -export const TANK_ICONS: Record = { +export const TANK_ICONS: Record = { 'AT-SPG': 'https://i.imgur.com/BIHSEH0.png', lightTank: 'https://i.imgur.com/CSNha5V.png', mediumTank: 'https://i.imgur.com/wvf3ltm.png',