fix marbas proxy
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { apiAxiosInstance } from "@/service";
|
||||
import { marbasAxiosInstance } from "@/service";
|
||||
|
||||
export type MarketType = {
|
||||
id: number;
|
||||
@@ -18,9 +18,9 @@ export const getMarketTypes = async (types: (string | number)[]): Promise<Market
|
||||
if (types.length === 0) {
|
||||
return [];
|
||||
} else if (types.length === 1 && typeof types[0] === "number") {
|
||||
return [(await apiAxiosInstance.get<MarketType>(`/sde/types/${types[0]}/`)).data];
|
||||
return [(await marbasAxiosInstance.get<MarketType>(`/sde/types/${types[0]}/`)).data];
|
||||
}
|
||||
return (await apiAxiosInstance.post<MarketType[]>("/api/types/search", types.map(t => {
|
||||
return (await marbasAxiosInstance.post<MarketType[]>("/api/types/search", types.map(t => {
|
||||
if (typeof t === "number") {
|
||||
return { id: t };
|
||||
} else {
|
||||
@@ -49,7 +49,7 @@ const blueprintMarketGrous = [ // TODO add all groups
|
||||
]
|
||||
|
||||
export const searchMarketTypes = async (search: string): Promise<MarketType[]> => {
|
||||
return (await apiAxiosInstance.post<MarketType[]>("/api/types/search", [{
|
||||
return (await marbasAxiosInstance.post<MarketType[]>("/api/types/search", [{
|
||||
name__icontains: search,
|
||||
marketgroup_id___not: null,
|
||||
marketgroup_id__in___not: blueprintMarketGrous,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { apiAxiosInstance } from "@/service";
|
||||
import { marbasAxiosInstance } from "@/service";
|
||||
|
||||
export type ReprocessItemValues = {
|
||||
typeID: number;
|
||||
@@ -22,7 +22,7 @@ export const reprocess = async (items: string, minerals: string, efficiency?: nu
|
||||
};
|
||||
const source = JSON.stringify(sourceJson);
|
||||
|
||||
const response = await apiAxiosInstance.post('/reprocess/', source, {params: {efficiency: efficiency ?? 0.55}});
|
||||
const response = await marbasAxiosInstance.post('/reprocess/', source, {params: {efficiency: efficiency ?? 0.55}});
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
@@ -12,20 +12,26 @@ const logResource = (a: AxiosInstance) => {
|
||||
});
|
||||
}
|
||||
|
||||
export const apiAxiosInstance = axios.create({
|
||||
baseURL: '/api/',
|
||||
export const marbasAxiosInstance = axios.create({
|
||||
baseURL: '/marbas/',
|
||||
headers: {
|
||||
'accept': 'application/json',
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
})
|
||||
logResource(apiAxiosInstance)
|
||||
apiAxiosInstance.interceptors.response.use(async r => {
|
||||
marbasAxiosInstance.interceptors.request.use(r => {
|
||||
if (!r.params?.page_size) {
|
||||
r.params = { ...r.params, page_size: 250 };
|
||||
}
|
||||
return r;
|
||||
})
|
||||
logResource(marbasAxiosInstance)
|
||||
marbasAxiosInstance.interceptors.response.use(async r => {
|
||||
const next = r.data?.next;
|
||||
let results = r.data?.results;
|
||||
|
||||
if (next) {
|
||||
results = results.concat((await apiAxiosInstance.request({
|
||||
results = results.concat((await marbasAxiosInstance.request({
|
||||
...r.config,
|
||||
url: next,
|
||||
baseURL: '',
|
||||
|
||||
Reference in New Issue
Block a user