diff --git a/src/mammon/mammonService.ts b/src/mammon/mammonService.ts index 5701e47..adee236 100644 --- a/src/mammon/mammonService.ts +++ b/src/mammon/mammonService.ts @@ -7,6 +7,7 @@ import { CharacterRuleBookApi, LedgerApi, MarketApi, + ReprocessingApi, RuleBookApi, TransactionApi } from "@/generated/mammon"; @@ -31,3 +32,4 @@ export const characterRuleBookApi = new CharacterRuleBookApi(undefined, mammonUr export const activityApi = new ActivityApi(undefined, mammonUrl, mammonAxiosInstance); export const acquisitionApi = new AcquisitionApi(undefined, mammonUrl, mammonAxiosInstance); export const marketApi = new MarketApi(undefined, mammonUrl, mammonAxiosInstance); +export const reprocessingApi = new ReprocessingApi(undefined, mammonUrl, mammonAxiosInstance); diff --git a/src/pages/Reprocess.vue b/src/pages/Reprocess.vue index 75a7fc5..920daa6 100644 --- a/src/pages/Reprocess.vue +++ b/src/pages/Reprocess.vue @@ -1,31 +1,36 @@ - Reprocess efficiency: - + Character: + + {{ character.name }} + - - + + Items + + - Send + Send diff --git a/src/reprocess/ReprocessInput.vue b/src/reprocess/ReprocessInput.vue deleted file mode 100644 index 0120b98..0000000 --- a/src/reprocess/ReprocessInput.vue +++ /dev/null @@ -1,34 +0,0 @@ - - - - - {{ name }} - - - \ No newline at end of file diff --git a/src/reprocess/ReprocessResultTable.vue b/src/reprocess/ReprocessResultTable.vue index fc8d262..8cdf67d 100644 --- a/src/reprocess/ReprocessResultTable.vue +++ b/src/reprocess/ReprocessResultTable.vue @@ -1,11 +1,11 @@ diff --git a/src/reprocess/index.ts b/src/reprocess/index.ts index 7248998..02eb6af 100644 --- a/src/reprocess/index.ts +++ b/src/reprocess/index.ts @@ -1,5 +1,4 @@ export * from './reprocess'; -export { default as ReprocessInput } from './ReprocessInput.vue'; export { default as ReprocessResultTable } from './ReprocessResultTable.vue'; diff --git a/src/reprocess/reprocess.ts b/src/reprocess/reprocess.ts index a00cd9c..2fe9623 100644 --- a/src/reprocess/reprocess.ts +++ b/src/reprocess/reprocess.ts @@ -1,3 +1,6 @@ +import { reprocessingApi } from '@/mammon'; +import { getMarketTypes } from '@/market'; + export type ReprocessItemValues = { typeID: number; name: string; @@ -7,18 +10,21 @@ export type ReprocessItemValues = { sell_reprocess: number; } -export const reprocess = async (items: string, minerals: string, efficiency?: number): Promise => { - if (!items || !minerals || (efficiency && (efficiency < 0 || efficiency > 1))) { +export const reprocess = async (characterId?: number, items?: string, locationId?: number): Promise => { + if (!characterId || !items?.trim()) { return []; } - const itemsJson = JSON.parse(items); - const mineralsJson = JSON.parse(minerals); - const sourceJson = { - "ep_items": itemsJson, - "ep_mat": mineralsJson - }; - const source = JSON.stringify(sourceJson); + const results = await reprocessingApi.reprocessRawItems(characterId, items, locationId).then(r => r.data); + const names = await getMarketTypes(results.map(r => r.input.marketTypeId)) + .then(types => new Map(types.map(t => [t.id, t.name]))); - return [] -}; + return results.map(({ input, output }) => ({ + typeID: input.marketTypeId, + name: names.get(input.marketTypeId) ?? '', + buy: input.buy, + sell: input.sell, + buy_reprocess: output.reduce((sum, o) => sum + o.buy, 0), + sell_reprocess: output.reduce((sum, o) => sum + o.sell, 0), + })); +}; \ No newline at end of file