27 lines
769 B
TypeScript
27 lines
769 B
TypeScript
import { esiAxiosInstance } from "@/service";
|
|
|
|
|
|
export type EsiMarketOrderHistory = {
|
|
average: number;
|
|
date: string;
|
|
highest: number;
|
|
lowest: number;
|
|
order_count: number;
|
|
volume: number;
|
|
}
|
|
|
|
// TODO use pinia store
|
|
const historyCache: { [key: number]: { [key: number]: EsiMarketOrderHistory[] } } = {};
|
|
|
|
export const getHistory = async (regionId: number, tyeId: number): Promise<EsiMarketOrderHistory[]> => {
|
|
if (historyCache[regionId]?.[tyeId]) {
|
|
return historyCache[regionId][tyeId];
|
|
}
|
|
|
|
const value = (await esiAxiosInstance.get(`/markets/${regionId}/history/`, { params: { type_id: tyeId } })).data;
|
|
|
|
historyCache[regionId] = historyCache[regionId] ?? {};
|
|
historyCache[regionId][tyeId] = value;
|
|
return value;
|
|
}
|