get orders
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { evepraisalAxiosInstance } from '@/service';
|
||||
import { useStorage } from '@vueuse/core';
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { MarketOrderHistory, MarketResult, getHistory, jitaId } from ".";
|
||||
@@ -15,8 +16,16 @@ const itemsStorage = useStorage<MarketItemStorage[]>('market-items', []);
|
||||
const items = ref<MarketResult[]>([]);
|
||||
const addOrRelaod = async (type: MarketType) => {
|
||||
const typeID = type.id;
|
||||
const history = await getHistory(jitaId, typeID);
|
||||
const item = { type, history };
|
||||
const [history, price] = await Promise.all([
|
||||
getHistory(jitaId, typeID),
|
||||
evepraisalAxiosInstance.post('/appraisal.json?market=jita&persist=no', type.name)
|
||||
]);
|
||||
const item = {
|
||||
type,
|
||||
history,
|
||||
buy: price.data.appraisal.items[0].prices.buy.max,
|
||||
sell: price.data.appraisal.items[0].prices.sell.min
|
||||
};
|
||||
|
||||
if (items.value.some(i => i.type.id === typeID)) {
|
||||
items.value = items.value.map(i => i.type.id === typeID ? item : i);
|
||||
@@ -37,9 +46,20 @@ const addItem = async () => {
|
||||
watch(items, itms => itemsStorage.value = itms.map(i => ({ typeID: i.type.id, history: i.history })));
|
||||
onMounted(async () => {
|
||||
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;
|
||||
|
||||
items.value = itemsStorage.value.map(i => ({ ...i, type: types.find(t => t.id === i.typeID) as MarketType }));
|
||||
})
|
||||
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);
|
||||
|
||||
return {
|
||||
...i,
|
||||
type: type,
|
||||
buy: price.prices.buy.max,
|
||||
sell: price.prices.sell.min
|
||||
};
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user