fix: correct catalog purchase field name and swap api method mappings
- Rename saleline_set to catalogsaleline_set in catalog purchase payload - Fix swapped createPurchase/createCatalogPurchase method calls in Api class - Format http.js (indentation, quotes, trailing commas)
This commit is contained in:
@@ -388,7 +388,7 @@ export default {
|
|||||||
customer: 1,
|
customer: 1,
|
||||||
notes: "",
|
notes: "",
|
||||||
payment_method: "CASH",
|
payment_method: "CASH",
|
||||||
saleline_set: this.cartItems.map((item) => ({
|
catalogsaleline_set: this.cartItems.map((item) => ({
|
||||||
product: item.id,
|
product: item.id,
|
||||||
unit_price: item.price,
|
unit_price: item.price,
|
||||||
quantity: item.quantity,
|
quantity: item.quantity,
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ class Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createPurchase(purchase) {
|
createPurchase(purchase) {
|
||||||
return this.apiImplementation.createCatalogPurchase(purchase);
|
return this.apiImplementation.createPurchase(purchase);
|
||||||
}
|
}
|
||||||
|
|
||||||
createCatalogPurchase(purchase) {
|
createCatalogPurchase(purchase) {
|
||||||
return this.apiImplementation.createPurchase(purchase);
|
return this.apiImplementation.createCatalogPurchase(purchase);
|
||||||
}
|
}
|
||||||
|
|
||||||
createReconciliationJar(reconciliation) {
|
createReconciliationJar(reconciliation) {
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
import axios from 'axios';
|
import axios from "axios";
|
||||||
import AuthService from '@/services/auth';
|
import AuthService from "@/services/auth";
|
||||||
import router from '@/router';
|
import router from "@/router";
|
||||||
|
|
||||||
const http = axios.create({
|
const http = axios.create({
|
||||||
baseURL: import.meta.env.VITE_DJANGO_BASE_URL,
|
baseURL: import.meta.env.VITE_DJANGO_BASE_URL,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
http.interceptors.request.use(
|
http.interceptors.request.use(
|
||||||
config => {
|
(config) => {
|
||||||
const token = AuthService.getAccessToken();
|
const token = AuthService.getAccessToken();
|
||||||
if (token) {
|
if (token) {
|
||||||
config.headers.Authorization = `Bearer ${token}`;
|
config.headers.Authorization = `Bearer ${token}`;
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
error => Promise.reject(error)
|
(error) => Promise.reject(error),
|
||||||
);
|
);
|
||||||
|
|
||||||
http.interceptors.response.use(
|
http.interceptors.response.use(
|
||||||
response => response,
|
(response) => response,
|
||||||
async error => {
|
async (error) => {
|
||||||
const originalRequest = error.config;
|
const originalRequest = error.config;
|
||||||
|
|
||||||
if (error.response?.status === 401 && !originalRequest._retry) {
|
if (error.response?.status === 401 && !originalRequest._retry) {
|
||||||
@@ -33,13 +33,13 @@ http.interceptors.response.use(
|
|||||||
return http.request(originalRequest);
|
return http.request(originalRequest);
|
||||||
} catch (refreshError) {
|
} catch (refreshError) {
|
||||||
AuthService.logout();
|
AuthService.logout();
|
||||||
router.push('/autenticarse');
|
router.push("/autenticarse");
|
||||||
return Promise.reject(refreshError);
|
return Promise.reject(refreshError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export default http;
|
export default http;
|
||||||
|
|||||||
Reference in New Issue
Block a user