diff --git a/src/market/acquisition/AcquisitionQuantilsTooltip.vue b/src/market/acquisition/AcquisitionQuantilsTooltip.vue index d496de3..17ee694 100644 --- a/src/market/acquisition/AcquisitionQuantilsTooltip.vue +++ b/src/market/acquisition/AcquisitionQuantilsTooltip.vue @@ -2,7 +2,7 @@ import { LoadingSpinner, Tooltip } from '@/components'; import { formatIsk } from '@/formaters'; import { getHistory, jitaId } from '@/market'; -import { getHistoryQuartils } from '@/market/scan'; +import { getHistoryQuartils } from '@/market/tracking'; import { ArrowTrendingDownIcon, ArrowTrendingUpIcon } from '@heroicons/vue/24/outline'; import { computedAsync } from '@vueuse/core'; import { ref, watchEffect } from 'vue'; @@ -85,4 +85,4 @@ watchEffect(async () => { @apply rounded-t-md bg-slate-600; } } - \ No newline at end of file +@/market/tracking \ No newline at end of file diff --git a/src/market/acquisition/acquisition.ts b/src/market/acquisition/acquisition.ts index 5409ebf..3c451fc 100644 --- a/src/market/acquisition/acquisition.ts +++ b/src/market/acquisition/acquisition.ts @@ -1,4 +1,3 @@ -import { useAuthStore } from "@/auth"; import { marbasAxiosInstance } from "@/service"; import { defineStore } from "pinia"; import { computed, ref } from "vue"; @@ -18,9 +17,8 @@ const endpoint = '/api/acquisitions'; export const useAcquiredItemStore = defineStore('market-acquisition', () => { const acquiredItems = ref([]); - const authStore = useAuthStore(); - const items = computed(() => acquiredItems.value); + const types = computed(() => acquiredItems.value); const addAcquiredItem = async (type: number, quantity: number, price: number) => { acquiredItems.value = [...acquiredItems.value, (await marbasAxiosInstance.post(endpoint, { type: type, @@ -29,7 +27,6 @@ export const useAcquiredItemStore = defineStore('market-acquisition', () => { price: price, date: new Date(), source: 'bo', - user: authStore.userId, })).data]; }; const removeAcquiredItem = async (type: number, quantity: number) => { @@ -62,5 +59,5 @@ export const useAcquiredItemStore = defineStore('market-acquisition', () => { marbasAxiosInstance.get(endpoint).then(res => acquiredItems.value = res.data.filter(item => item.remaining > 0)); - return { items, addAcquiredItem, removeAcquiredItem }; + return { types, addAcquiredItem, removeAcquiredItem }; }); \ No newline at end of file diff --git a/src/market/scan/index.ts b/src/market/scan/index.ts deleted file mode 100644 index 02cbf73..0000000 --- a/src/market/scan/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './HistoryQuartils'; -export * from './scan'; - -export { default as ScanResultTable } from './ScanResultTable.vue'; - diff --git a/src/market/scan/scan.ts b/src/market/scan/scan.ts deleted file mode 100644 index 289b32b..0000000 --- a/src/market/scan/scan.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { MarketOrderHistory, MarketType, MarketTypePrice, getHistory, jitaId } from "@/market"; -import { defineStore } from "pinia"; -import { computed, ref } from "vue"; - -export type ScanResult = { - type: MarketType; - history: MarketOrderHistory[]; - buy: number, - sell: number, - orderCount: number, -} - -type MarketScan = { - owner: string, - types: number[] -}; - -const marketScans = 'marketScans'; - -export const useMarketScanStore = defineStore(marketScans, () => { - const marketScan = ref(); - - const types = computed(() => marketScan.value?.types ?? []); - const setTypes = async (types: number[]) => { - - } - const addType = async (type: number) => { - if (!types.value.includes(type)) { - await setTypes([...types.value, type]); - } - } - const removeType = async (type: number) => { - if (types.value.includes(type)) { - await setTypes(types.value.filter(t => t !== type)); - } - } - return { types, setTypes, addType, removeType }; -}); - -export const createResult = async (id: number, price: MarketTypePrice): Promise => ({ history: await getHistory(jitaId, id), ...price }); \ No newline at end of file diff --git a/src/market/scan/HistoryQuartils.ts b/src/market/tracking/HistoryQuartils.ts similarity index 100% rename from src/market/scan/HistoryQuartils.ts rename to src/market/tracking/HistoryQuartils.ts diff --git a/src/market/scan/ScanResultTable.vue b/src/market/tracking/TrackingResultTable.vue similarity index 96% rename from src/market/scan/ScanResultTable.vue rename to src/market/tracking/TrackingResultTable.vue index b7eb875..e93318e 100644 --- a/src/market/scan/ScanResultTable.vue +++ b/src/market/tracking/TrackingResultTable.vue @@ -6,7 +6,7 @@ import { MarketType, MarketTypeLabel, TaxInput, useMarketTaxStore } from "@/mark import { BookmarkSlashIcon, ShoppingCartIcon } from '@heroicons/vue/24/outline'; import { useStorage } from '@vueuse/core'; import { computed, ref } from 'vue'; -import { ScanResult, getHistoryQuartils } from '.'; +import { TrackingResult, getHistoryQuartils } from '.'; type Result = { type: MarketType; @@ -22,7 +22,7 @@ type Result = { } interface Props { - items?: ScanResult[]; + items?: TrackingResult[]; infoOnly?: boolean; ignoredColums?: string[]; } @@ -45,8 +45,8 @@ defineEmits(); const marketTaxStore = useMarketTaxStore(); -const days = useStorage('market-scan-days', 365); -const threshold = useStorage('market-scan-threshold', 10); +const days = useStorage('market-tracking-days', 365); +const threshold = useStorage('market-tracking-threshold', 10); const filter = ref(""); const onlyCheap = ref(false); const columnsToIgnore = computed(() => { diff --git a/src/market/tracking/index.ts b/src/market/tracking/index.ts new file mode 100644 index 0000000..910e701 --- /dev/null +++ b/src/market/tracking/index.ts @@ -0,0 +1,5 @@ +export * from './HistoryQuartils'; +export * from './tracking'; + +export { default as TrackingResultTable } from './TrackingResultTable.vue'; + diff --git a/src/market/tracking/tracking.ts b/src/market/tracking/tracking.ts new file mode 100644 index 0000000..17de9c7 --- /dev/null +++ b/src/market/tracking/tracking.ts @@ -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([]); + + 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 => ({ history: await getHistory(jitaId, id), ...price }); \ No newline at end of file diff --git a/src/pages/Market.vue b/src/pages/Market.vue index 1c7a0f5..9f7ccbc 100644 --- a/src/pages/Market.vue +++ b/src/pages/Market.vue @@ -9,8 +9,8 @@ import { RouterLink, RouterView } from 'vue-router'; Item Info - - Scan + + Tracking Acquisitions diff --git a/src/pages/market/Acquisitions.vue b/src/pages/market/Acquisitions.vue index 93ead63..0f43fa3 100644 --- a/src/pages/market/Acquisitions.vue +++ b/src/pages/market/Acquisitions.vue @@ -11,7 +11,7 @@ const apraisalStore = useApraisalStore(); const acquiredItemStore = useAcquiredItemStore(); const items = ref([]); -watch(() => acquiredItemStore.items, async itms => { +watch(() => acquiredItemStore.types, async itms => { if (itms.length === 0) { return; } diff --git a/src/pages/market/Scan.vue b/src/pages/market/Tracking.vue similarity index 79% rename from src/pages/market/Scan.vue rename to src/pages/market/Tracking.vue index 3c35522..92514c2 100644 --- a/src/pages/market/Scan.vue +++ b/src/pages/market/Tracking.vue @@ -1,7 +1,7 @@