reprocess rework

This commit is contained in:
Sirttas
2026-06-19 23:05:42 +02:00
parent 981045da2f
commit 6dac42bbbe
6 changed files with 43 additions and 65 deletions
+17 -11
View File
@@ -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<ReprocessItemValues[]> => {
if (!items || !minerals || (efficiency && (efficiency < 0 || efficiency > 1))) {
export const reprocess = async (characterId?: number, items?: string, locationId?: number): Promise<ReprocessItemValues[]> => {
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),
}));
};