This commit is contained in:
2023-09-19 16:04:32 +02:00
parent 6587e4f522
commit 7c645b0d0b
15 changed files with 430 additions and 24 deletions

View File

@@ -1,7 +1,6 @@
<script setup lang="ts">
import { MarketOrderHistory, MarketType, getHistory, getMarketType, getMarketTypes, jitaId } from "@/market";
import { ScanResult, ScanResultTable } from '@/market/scan';
import { evepraisalAxiosInstance } from '@/service';
import { MarketOrderHistory, MarketType, MarketTypePrice, getHistory, getMarketType, getMarketTypes, getPrice, getPrices, jitaId } from "@/market";
import { BuyModal, ScanResult, ScanResultTable } from '@/market/scan';
import { useStorage } from '@vueuse/core';
import { onMounted, ref, watch } from 'vue';
@@ -10,6 +9,8 @@ type MarketItemStorage = {
history: MarketOrderHistory[];
}
const buyModal = ref<typeof BuyModal>();
const item = ref("");
/**
* @deprecated use itemsStorage instead
@@ -23,13 +24,13 @@ const addOrRelaod = async (type: MarketType) => {
const typeID = type.id;
const [history, price] = await Promise.all([
getHistory(jitaId, typeID),
evepraisalAxiosInstance.post(`/appraisal.json?market=jita&persist=no&raw_textarea=${type.name}`)
getPrice(type)
]);
const item = {
type,
history,
buy: price.data.appraisal.items[0].prices.buy.max,
sell: price.data.appraisal.items[0].prices.sell.min
buy: price.buy,
sell: price.sell
};
if (items.value.some(i => i.type.id === typeID)) {
@@ -61,21 +62,15 @@ onMounted(async () => {
return;
}
const types = await getMarketTypes(itemsStorage.value.map(i => i.typeID));
const prices: any = (await evepraisalAxiosInstance.post(`/appraisal.json?market=jita&persist=no&raw_textarea=${types.map(t => t.name).join("%0A")}`)).data;
const prices = await getPrices(await getMarketTypes(itemsStorage.value.map(i => i.typeID)));
items.value = itemsStorage.value.map(i => {
const type = types.find(t => t.id === i.typeID) as MarketType;
const price = prices.appraisal.items.find((p: any) => p.typeID === i.typeID);
const price = prices.find(p => p.type.id === i.typeID) as MarketTypePrice;
return {
...i,
type: type,
buy: price.prices.buy.max,
sell: price.prices.sell.min
};
return { ...i, ...price };
});
});
</script>
<template>
@@ -88,6 +83,7 @@ onMounted(async () => {
</div>
<template v-if="items.length > 0">
<hr />
<ScanResultTable :items="items" @relaod="type => addOrRelaod(type)" @relaodAll="reloadAll" />
<ScanResultTable :items="items" @relaod="type => addOrRelaod(type)" @relaodAll="reloadAll" @buy="(type, buy, sell) => buyModal?.open(type, { 'Buy': buy, 'Sell': sell })" />
<BuyModal ref="buyModal" />
</template>
</template>