Add HTTP client wrapper and upgrade Axios to v1 (#594)

* refactor: add HTTP client wrapper and upgrade axios to v1

Introduce a thin HTTP wrapper (resources/scripts/http) that centralizes
axios configuration, interceptors, and auth header injection. All 43
files now import from the wrapper instead of axios directly, making
future library swaps a single-file change. Upgrade axios from 0.30.0
to 1.14.0.

* fix: restore window.Ls assignment removed during axios refactor

company.js uses window.Ls.set() to persist selected company,
which broke after the axios plugin (that set window.Ls) was deleted.
This commit is contained in:
Darko Gjorgjijoski
2026-04-02 15:08:23 +02:00
committed by GitHub
parent a38f09cf7b
commit 691178857f
46 changed files with 637 additions and 394 deletions

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import moment from 'moment'
import { defineStore } from 'pinia'
import { useRoute } from 'vue-router'
@@ -99,7 +99,7 @@ export const usePaymentStore = (useWindow = false) => {
fetchPayments(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/payments`, { params })
.then((response) => {
this.payments = response.data.data
@@ -115,7 +115,7 @@ export const usePaymentStore = (useWindow = false) => {
fetchPayment(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/payments/${id}`)
.then((response) => {
Object.assign(this.currentPayment, response.data.data)
@@ -130,7 +130,7 @@ export const usePaymentStore = (useWindow = false) => {
addPayment(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/payments', data)
.then((response) => {
this.payments.push(response.data)
@@ -150,7 +150,7 @@ export const usePaymentStore = (useWindow = false) => {
updatePayment(data) {
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/payments/${data.id}`, data)
.then((response) => {
if (response.data) {
@@ -179,7 +179,7 @@ export const usePaymentStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/payments/delete`, id)
.then((response) => {
let index = this.payments.findIndex(
@@ -203,7 +203,7 @@ export const usePaymentStore = (useWindow = false) => {
deleteMultiplePayments() {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/payments/delete`, { ids: this.selectedPayments })
.then((response) => {
this.selectedPayments.forEach((payment) => {
@@ -260,7 +260,7 @@ export const usePaymentStore = (useWindow = false) => {
searchPayment(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/payments`, { params })
.then((response) => {
this.payments = response.data
@@ -275,7 +275,7 @@ export const usePaymentStore = (useWindow = false) => {
previewPayment(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/payments/${params.id}/send/preview`, { params })
.then((response) => {
resolve(response)
@@ -289,7 +289,7 @@ export const usePaymentStore = (useWindow = false) => {
sendEmail(data) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/payments/${data.id}/send`, data)
.then((response) => {
const notificationStore = useNotificationStore()
@@ -308,7 +308,7 @@ export const usePaymentStore = (useWindow = false) => {
getNextNumber(params, setState = false) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/next-number?key=payment`, { params })
.then((response) => {
if (setState) {
@@ -331,7 +331,7 @@ export const usePaymentStore = (useWindow = false) => {
fetchPaymentModes(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/payment-methods`, { params })
.then((response) => {
this.paymentModes = response.data.data
@@ -346,7 +346,7 @@ export const usePaymentStore = (useWindow = false) => {
fetchPaymentMode(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/payment-methods/${id}`)
.then((response) => {
this.currentPaymentMode = response.data.data
@@ -362,7 +362,7 @@ export const usePaymentStore = (useWindow = false) => {
addPaymentMode(data) {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/payment-methods`, data)
.then((response) => {
this.paymentModes.push(response.data.data)
@@ -382,7 +382,7 @@ export const usePaymentStore = (useWindow = false) => {
updatePaymentMode(data) {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/payment-methods/${data.id}`, data)
.then((response) => {
if (response.data) {
@@ -410,7 +410,7 @@ export const usePaymentStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.delete(`/api/v1/payment-methods/${id}`)
.then((response) => {
let index = this.paymentModes.findIndex(