mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-19 03:04:05 +00:00
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:
committed by
GitHub
parent
a38f09cf7b
commit
691178857f
28
resources/scripts/admin/stores/installation.js
vendored
28
resources/scripts/admin/stores/installation.js
vendored
@@ -1,4 +1,4 @@
|
||||
import axios from 'axios'
|
||||
import http from '@/scripts/http'
|
||||
import { defineStore } from 'pinia'
|
||||
import { useCompanyStore } from './company'
|
||||
import { handleError } from '@/scripts/helpers/error-handling'
|
||||
@@ -28,7 +28,7 @@ export const useInstallationStore = (useWindow = false) => {
|
||||
actions: {
|
||||
fetchInstallationLanguages() {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.get(`/api/v1/installation/languages`)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
@@ -42,7 +42,7 @@ export const useInstallationStore = (useWindow = false) => {
|
||||
|
||||
fetchInstallationRequirements() {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.get(`/api/v1/installation/requirements`)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
@@ -56,7 +56,7 @@ export const useInstallationStore = (useWindow = false) => {
|
||||
|
||||
fetchInstallationStep() {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.get(`/api/v1/installation/wizard-step`)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
@@ -70,7 +70,7 @@ export const useInstallationStore = (useWindow = false) => {
|
||||
|
||||
addInstallationStep(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.post(`/api/v1/installation/wizard-step`, data)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
@@ -84,7 +84,7 @@ export const useInstallationStore = (useWindow = false) => {
|
||||
|
||||
addInstallationLanguage(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.post(`/api/v1/installation/wizard-language`, data)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
@@ -98,7 +98,7 @@ export const useInstallationStore = (useWindow = false) => {
|
||||
|
||||
fetchInstallationPermissions() {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.get(`/api/v1/installation/permissions`)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
@@ -112,7 +112,7 @@ export const useInstallationStore = (useWindow = false) => {
|
||||
|
||||
fetchInstallationDatabase(params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.get(`/api/v1/installation/database/config`, { params })
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
@@ -126,7 +126,7 @@ export const useInstallationStore = (useWindow = false) => {
|
||||
|
||||
addInstallationDatabase(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.post(`/api/v1/installation/database/config`, data)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
@@ -140,7 +140,7 @@ export const useInstallationStore = (useWindow = false) => {
|
||||
|
||||
addInstallationFinish() {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.post(`/api/v1/installation/finish`)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
@@ -154,7 +154,7 @@ export const useInstallationStore = (useWindow = false) => {
|
||||
|
||||
setInstallationDomain(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.put(`/api/v1/installation/set-domain`, data)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
@@ -168,9 +168,9 @@ export const useInstallationStore = (useWindow = false) => {
|
||||
|
||||
installationLogin() {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get('/sanctum/csrf-cookie').then((response) => {
|
||||
http.get('/sanctum/csrf-cookie').then((response) => {
|
||||
if (response) {
|
||||
axios
|
||||
http
|
||||
.post('/api/v1/installation/login')
|
||||
.then((response) => {
|
||||
companyStore.setSelectedCompany(response.data.company)
|
||||
@@ -187,7 +187,7 @@ export const useInstallationStore = (useWindow = false) => {
|
||||
|
||||
checkAuthenticated() {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.get(`/api/v1/auth/check`)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
|
||||
Reference in New Issue
Block a user