feat: session tracker list

This commit is contained in:
TrèsAbhi committed 2023-09-24 15:58:42 -05:00
1 parent 6ff2a23ff7
commit 8c041d4eef
6 files changed
+145 -29

No files matched your search

+5 -2
View File
@@ -1,5 +1,6 @@
import { deburr } from 'lodash';
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
import { context } from '../blitzkrieg/context';
import getWargamingResponse from './getWargamingResponse';
export type TankType = 'AT-SPG' | 'lightTank' | 'mediumTank' | 'heavyTank';
@@ -23,14 +24,16 @@ export interface Tankopedia {
console.log('Caching tankopedia...');
export const tankopedia = fetch(
typeof window === 'undefined'
context === 'bot'
? 'https://www.blitzstars.com/bs-tankopedia.json'
: '/api/tankopedia',
)
.then(async (response) => response.json())
.then((wrapperTankopedia) => {
console.log('Tankopedia cached');
return (wrapperTankopedia as { data: Tankopedia }).data;
return context === 'bot'
? (wrapperTankopedia as { data: Tankopedia }).data
: (wrapperTankopedia as Tankopedia);
});
const entries = new Promise<TankopediaEntry[]>(async (resolve) => {
resolve(Object.entries(await tankopedia).map(([, entry]) => entry));