29 lines
830 B
TypeScript
29 lines
830 B
TypeScript
import { marbasAxiosInstance } from "@/marbas";
|
|
|
|
export type ReprocessItemValues = {
|
|
typeID: number;
|
|
name: string;
|
|
buy: number;
|
|
buy_reprocess: number;
|
|
sell: number;
|
|
sell_reprocess: number;
|
|
}
|
|
|
|
export const reprocess = async (items: string, minerals: string, efficiency?: number): Promise<ReprocessItemValues[]> => {
|
|
if (!items || !minerals || (efficiency && (efficiency < 0 || efficiency > 1))) {
|
|
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 response = await marbasAxiosInstance.post('/reprocess/', source, {params: {efficiency: efficiency ?? 0.55}});
|
|
|
|
return response.data;
|
|
};
|