acquisition ui
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {logResource} from "@/service";
|
||||
import axios from "axios";
|
||||
import {
|
||||
AcquisitionApi,
|
||||
ActivityApi,
|
||||
CharacterApi,
|
||||
CharacterRuleBookApi,
|
||||
@@ -29,3 +30,4 @@ export const ruleBookApi = new RuleBookApi(undefined, mammonUrl, mammonAxiosInst
|
||||
export const characterRuleBookApi = new CharacterRuleBookApi(undefined, mammonUrl, mammonAxiosInstance);
|
||||
export const activityApi = new ActivityApi(undefined, mammonUrl, mammonAxiosInstance);
|
||||
export const processingApi = new ProcessingApi(undefined, mammonUrl, mammonAxiosInstance);
|
||||
export const acquisitionApi = new AcquisitionApi(undefined, mammonUrl, mammonAxiosInstance);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { MarketType } from "..";
|
||||
import { MarbasAcquiredType } from "./acquisition";
|
||||
import { RawAcquiredType } from "./acquisition";
|
||||
|
||||
export type AcquiredType = Omit<MarbasAcquiredType, 'type'> & {
|
||||
export type AcquiredType = Omit<RawAcquiredType, 'type'> & {
|
||||
type: MarketType,
|
||||
buy: number,
|
||||
sell: number
|
||||
|
||||
@@ -6,9 +6,10 @@ import {useStorage} from '@vueuse/core';
|
||||
import {computed, ref} from 'vue';
|
||||
import {AcquiredType} from './AcquiredType';
|
||||
import AcquisitionQuantilsTooltip from './AcquisitionQuantilsTooltip.vue';
|
||||
import {formatEveDate, formatIsk, percentFormater} from "@/formaters.ts";
|
||||
|
||||
type Result = {
|
||||
id: number;
|
||||
id: string;
|
||||
type: MarketType;
|
||||
name: string;
|
||||
buy: number;
|
||||
@@ -97,7 +98,7 @@ const { sortedArray, headerProps, showColumn } = useSort<Result>(computed(() =>
|
||||
const precentProfit = marketTaxStore.calculateProfit(price, first.sell);
|
||||
|
||||
list.push({
|
||||
id: typeID,
|
||||
id: typeID.toString(),
|
||||
type: first.type,
|
||||
name: first.type.name,
|
||||
buy: first.buy,
|
||||
|
||||
@@ -1,39 +1,41 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {computed, ref} from "vue";
|
||||
import {acquisitionApi} from "@/mammon";
|
||||
import {AcquisitionResponse, AcquisitionResponseSourceEnum} from "@/generated/mammon";
|
||||
|
||||
export type AcquiredTypeSource = 'bo' | 'so' | 'prod' | 'misc';
|
||||
|
||||
export type RawAcquiredType = {
|
||||
id: string;
|
||||
type: number;
|
||||
quantity: number;
|
||||
remaining: number;
|
||||
price: number;
|
||||
date: Date;
|
||||
source: AcquisitionResponseSourceEnum;
|
||||
}
|
||||
|
||||
const toAcquiredType = (a: AcquisitionResponse): RawAcquiredType => ({
|
||||
id: a.acquisitionId,
|
||||
type: a.marketTypeId,
|
||||
quantity: a.quantity,
|
||||
remaining: a.remaining,
|
||||
price: a.unitCost,
|
||||
date: new Date(a.datetime),
|
||||
source: a.source,
|
||||
});
|
||||
|
||||
export const useAcquiredTypesStore = defineStore('market-acquisition', () => {
|
||||
const acquiredTypes = ref<any[]>([]); // TODO
|
||||
const acquiredTypes = ref<RawAcquiredType[]>([]);
|
||||
|
||||
const types = computed(() => acquiredTypes.value.filter(item => item.remaining > 0));
|
||||
const addAcquiredType = async (type: number, quantity: number, price: number, source?: AcquiredTypeSource) => {
|
||||
const newItem = [];
|
||||
|
||||
acquiredTypes.value = [...acquiredTypes.value, newItem];
|
||||
};
|
||||
const removeAcquiredType = async (id: number, quantity: number) => {
|
||||
const found = acquiredTypes.value.find(t => t.id === id);
|
||||
// Display-only: the backend exposes no write endpoint yet, so buy/sell are no-ops.
|
||||
const addAcquiredType = async (_type: number, _quantity: number, _price: number, _source?: AcquiredTypeSource) => {};
|
||||
const removeAcquiredType = async (_id: string, _quantity: number) => {};
|
||||
|
||||
if (!found) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const item = {
|
||||
...found,
|
||||
remaining: Math.max(0, found.remaining - quantity)
|
||||
};
|
||||
|
||||
acquiredTypes.value = acquiredTypes.value.map(i => {
|
||||
if (i.id === item.id) {
|
||||
return item;
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const refresh = () => {}
|
||||
const refresh = () => acquisitionApi.findAllAcquisitions()
|
||||
.then(response => acquiredTypes.value = response.data.map(toAcquiredType));
|
||||
|
||||
refresh();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {esiAxiosInstance} from '@/service';
|
||||
|
||||
export type MarketType = {
|
||||
type_id: number;
|
||||
id: number;
|
||||
group_id: number;
|
||||
market_group_id: number;
|
||||
name: string;
|
||||
@@ -19,9 +19,11 @@ const fetchType = (id: number): Promise<MarketType> => {
|
||||
if (cache.has(id)) {
|
||||
return Promise.resolve(cache.get(id)!);
|
||||
}
|
||||
return esiAxiosInstance.get<MarketType>(`/universe/types/${id}/`).then(r => {
|
||||
cache.set(id, r.data);
|
||||
return r.data;
|
||||
return esiAxiosInstance.get<Omit<MarketType, 'id'> & { type_id: number }>(`/universe/types/${id}/`).then(r => {
|
||||
const { type_id, ...rest } = r.data;
|
||||
const marketType: MarketType = { id: type_id, ...rest };
|
||||
cache.set(id, marketType);
|
||||
return marketType;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ watchEffect(async () => {
|
||||
<template>
|
||||
<div @click="() => isOpen = true" v-on-click-outside="() => isOpen = false">
|
||||
<div class="fake-input">
|
||||
<img v-if="modelValue?.id" :src="`https://images.evetech.net/types/${modelValue.id}/icon?size=32`" alt="" />
|
||||
<img v-if="modelValue?.type_id" :src="`https://images.evetech.net/types/${modelValue.type_id}/icon?size=32`" alt="" />
|
||||
<input type="text" v-model="name" @keyup.enter="submit" @keyup.down="moveDown" @keyup.up="moveUp" />
|
||||
</div>
|
||||
<div v-if="suggestions.length > 1" class="z-20 absolute w-96">
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { MarketTypePrice, getMarketTypes, useApraisalStore } from "@/market";
|
||||
import {getMarketTypes, MarketTypePrice, useApraisalStore} from "@/market";
|
||||
import {AcquiredType, AcquisitionResultTable, BuyModal, SellModal, useAcquiredTypesStore} from '@/market/acquisition';
|
||||
import {ref, watch} from 'vue';
|
||||
import {activityApi, processingApi} from "@/mammon";
|
||||
|
||||
const buyModal = ref<typeof BuyModal>();
|
||||
const sellModal = ref<typeof SellModal>();
|
||||
@@ -10,7 +11,11 @@ const apraisalStore = useApraisalStore();
|
||||
const acquiredTypesStore = useAcquiredTypesStore();
|
||||
const items = ref<AcquiredType[]>([]);
|
||||
|
||||
const refresh = async () => await acquiredTypesStore.refresh();
|
||||
const refresh = async () => {
|
||||
await activityApi.fetchAllNewActivities();
|
||||
await processingApi.processNewActivities();
|
||||
await acquiredTypesStore.refresh();
|
||||
}
|
||||
|
||||
watch(() => acquiredTypesStore.acquiredTypes, async itms => {
|
||||
if (itms.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user