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,
|
||||
notes: "",
|
||||
payment_method: "CASH",
|
||||
saleline_set: this.cartItems.map((item) => ({
|
||||
catalogsaleline_set: this.cartItems.map((item) => ({
|
||||
product: item.id,
|
||||
unit_price: item.price,
|
||||
quantity: item.quantity,
|
||||
|
||||
@@ -32,11 +32,11 @@ class Api {
|
||||
}
|
||||
|
||||
createPurchase(purchase) {
|
||||
return this.apiImplementation.createCatalogPurchase(purchase);
|
||||
return this.apiImplementation.createPurchase(purchase);
|
||||
}
|
||||
|
||||
createCatalogPurchase(purchase) {
|
||||
return this.apiImplementation.createPurchase(purchase);
|
||||
return this.apiImplementation.createCatalogPurchase(purchase);
|
||||
}
|
||||
|
||||
createReconciliationJar(reconciliation) {
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
import axios from 'axios';
|
||||
import AuthService from '@/services/auth';
|
||||
import router from '@/router';
|
||||
import axios from "axios";
|
||||
import AuthService from "@/services/auth";
|
||||
import router from "@/router";
|
||||
|
||||
const http = axios.create({
|
||||
baseURL: import.meta.env.VITE_DJANGO_BASE_URL,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
baseURL: import.meta.env.VITE_DJANGO_BASE_URL,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
http.interceptors.request.use(
|
||||
config => {
|
||||
const token = AuthService.getAccessToken();
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
error => Promise.reject(error)
|
||||
(config) => {
|
||||
const token = AuthService.getAccessToken();
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error) => Promise.reject(error),
|
||||
);
|
||||
|
||||
http.interceptors.response.use(
|
||||
response => response,
|
||||
async error => {
|
||||
const originalRequest = error.config;
|
||||
(response) => response,
|
||||
async (error) => {
|
||||
const originalRequest = error.config;
|
||||
|
||||
if (error.response?.status === 401 && !originalRequest._retry) {
|
||||
originalRequest._retry = true;
|
||||
try {
|
||||
const newAccess = await AuthService.refresh();
|
||||
originalRequest.headers.Authorization = `Bearer ${newAccess}`;
|
||||
return http.request(originalRequest);
|
||||
} catch (refreshError) {
|
||||
AuthService.logout();
|
||||
router.push('/autenticarse');
|
||||
return Promise.reject(refreshError);
|
||||
}
|
||||
}
|
||||
if (error.response?.status === 401 && !originalRequest._retry) {
|
||||
originalRequest._retry = true;
|
||||
try {
|
||||
const newAccess = await AuthService.refresh();
|
||||
originalRequest.headers.Authorization = `Bearer ${newAccess}`;
|
||||
return http.request(originalRequest);
|
||||
} catch (refreshError) {
|
||||
AuthService.logout();
|
||||
router.push("/autenticarse");
|
||||
return Promise.reject(refreshError);
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
}
|
||||
return Promise.reject(error);
|
||||
},
|
||||
);
|
||||
|
||||
export default http;
|
||||
|
||||
Reference in New Issue
Block a user