integration with marbas
This commit is contained in:
@@ -11,20 +11,30 @@ export type TrackingResult = {
|
||||
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(`/api/types_tracked`, { type });
|
||||
await marbasAxiosInstance.post(endpoint, { type });
|
||||
}
|
||||
}
|
||||
const removeType = async (type: number) => {
|
||||
if (trackedTypes.value.includes(type)) {
|
||||
await marbasAxiosInstance.delete(`/api/types_tracked/${type}`);
|
||||
await marbasAxiosInstance.delete(`${endpoint}${type}`);
|
||||
}
|
||||
}
|
||||
|
||||
marbasAxiosInstance.get<MarketTracking[]>(endpoint).then(res => trackedTypes.value = res.data.map(item => item.type));
|
||||
|
||||
return { types, addType, removeType };
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user