Rework to use marbas and authentik instead of poketbase (#1)

Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2024-05-17 23:00:52 +02:00
parent 9fb78329cc
commit 717eaa6ed8
47 changed files with 2306 additions and 1049 deletions

View File

@@ -0,0 +1,41 @@
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,
}
type MarketTracking = {
id: number,
type: number
};
const endpoint = '/api/types_tracking/';
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(endpoint, { type });
}
}
const removeType = async (type: number) => {
if (trackedTypes.value.includes(type)) {
await marbasAxiosInstance.delete(`${endpoint}${type}`);
}
}
marbasAxiosInstance.get<MarketTracking[]>(endpoint).then(res => trackedTypes.value = res.data.map(item => item.type));
return { types, addType, removeType };
});
export const createResult = async (id: number, price: MarketTypePrice): Promise<TrackingResult> => ({ history: await getHistory(jitaId, id), ...price });