type tracking

This commit is contained in:
2024-05-17 19:15:15 +02:00
parent 719dc60027
commit 08b28a83be
13 changed files with 63 additions and 75 deletions

View File

@@ -0,0 +1,31 @@
import { MarketOrderHistory, MarketType, MarketTypePrice, getHistory, jitaId } from "@/market";
import { marbasAxiosInstance } from "@/service";
import { defineStore } from "pinia";
import { computed, ref } from "vue";
export type TrackingResult = {
type: MarketType;
history: MarketOrderHistory[];
buy: number,
sell: number,
orderCount: number,
}
export const useMarketTrackingStore = defineStore('marketTracking', () => {
const trackedTypes = ref<number[]>([]);
const types = computed(() => trackedTypes.value ?? []);
const addType = async (type: number) => {
if (!trackedTypes.value.includes(type)) {
await marbasAxiosInstance.post(`/api/types_tracked`, { type });
}
}
const removeType = async (type: number) => {
if (trackedTypes.value.includes(type)) {
await marbasAxiosInstance.delete(`/api/types_tracked/${type}`);
}
}
return { types, addType, removeType };
});
export const createResult = async (id: number, price: MarketTypePrice): Promise<TrackingResult> => ({ history: await getHistory(jitaId, id), ...price });