Fix marbas integration
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { MarketOrderHistory, MarketType, MarketTypePrice, getHistory, jitaId } from "@/market";
|
||||
import { marbasAxiosInstance } from "@/service";
|
||||
import { marbasAxiosInstance, MarbasObject } from "@/marbas";
|
||||
import { getHistory, jitaId, MarketOrderHistory, MarketType, MarketTypePrice } from "@/market";
|
||||
import log from "loglevel";
|
||||
import { defineStore } from "pinia";
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
@@ -11,22 +12,22 @@ export type TrackingResult = {
|
||||
orderCount: number,
|
||||
}
|
||||
|
||||
type MarketTracking = {
|
||||
id: number,
|
||||
export type MarbasTrackedType = MarbasObject & {
|
||||
type: number
|
||||
};
|
||||
|
||||
const endpoint = '/api/types_tracking/';
|
||||
|
||||
export const useMarketTrackingStore = defineStore('marketTracking', () => {
|
||||
const trackedTypes = ref<MarketTracking[]>([]);
|
||||
const trackedTypes = ref<MarbasTrackedType[]>([]);
|
||||
|
||||
const types = computed(() => trackedTypes.value.map(item => item.type) ?? []);
|
||||
const addType = async (type: number) => {
|
||||
const found = trackedTypes.value.find(item => item.type === type);
|
||||
|
||||
if (!found) {
|
||||
trackedTypes.value = [...trackedTypes.value, (await marbasAxiosInstance.post<MarketTracking>(endpoint, { type })).data];
|
||||
trackedTypes.value = [...trackedTypes.value, (await marbasAxiosInstance.post<MarbasTrackedType>(endpoint, { type })).data];
|
||||
log.info(`Tracking type ${type}`);
|
||||
}
|
||||
}
|
||||
const removeType = async (type: number) => {
|
||||
@@ -38,9 +39,10 @@ export const useMarketTrackingStore = defineStore('marketTracking', () => {
|
||||
|
||||
trackedTypes.value = trackedTypes.value.filter(t => t.id !== found.id);
|
||||
await marbasAxiosInstance.delete(`${endpoint}${found.id}`);
|
||||
log.info(`Stopped tracking type ${type}`);
|
||||
}
|
||||
|
||||
marbasAxiosInstance.get<MarketTracking[]>(endpoint).then(res => trackedTypes.value = res.data);
|
||||
marbasAxiosInstance.get<MarbasTrackedType[]>(endpoint).then(res => trackedTypes.value = res.data);
|
||||
|
||||
return { types, addType, removeType };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user