type tracking
This commit is contained in:
31
src/market/tracking/tracking.ts
Normal file
31
src/market/tracking/tracking.ts
Normal 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 });
|
||||
Reference in New Issue
Block a user