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

@@ -116,7 +116,6 @@
<script setup>
import { computed, onMounted, reactive, ref } from 'vue'
import axios from 'axios'
import { useModalStore } from '@/scripts/stores/modal'
import { useTaxTypeStore } from '@/scripts/admin/stores/tax-type'
import { useGlobalStore } from '@/scripts/admin/stores/global'

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useNotificationStore } from '@/scripts/stores/notification'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -22,9 +22,9 @@ export const useAuthStore = (useWindow = false) => {
actions: {
login(data) {
return new Promise((resolve, reject) => {
axios.get('/sanctum/csrf-cookie').then((response) => {
http.get('/sanctum/csrf-cookie').then((response) => {
if (response) {
axios
http
.post('/login', data)
.then((response) => {
resolve(response)
@@ -45,7 +45,7 @@ export const useAuthStore = (useWindow = false) => {
logout() {
return new Promise((resolve, reject) => {
axios
http
.post('/auth/logout')
.then((response) => {
const notificationStore = useNotificationStore()

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useNotificationStore } from '@/scripts/stores/notification'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -21,7 +21,7 @@ export const useBackupStore = (useWindow = false) => {
actions: {
fetchBackups(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/backups`, { params })
.then((response) => {
this.backups = response.data.data
@@ -36,7 +36,7 @@ export const useBackupStore = (useWindow = false) => {
createBackup(data) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/backups`, data)
.then((response) => {
const notificationStore = useNotificationStore()
@@ -55,7 +55,7 @@ export const useBackupStore = (useWindow = false) => {
removeBackup(params) {
return new Promise((resolve, reject) => {
axios
http
.delete(`/api/v1/backups/${params.disk}`, { params })
.then((response) => {
const notificationStore = useNotificationStore()

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useNotificationStore } from '@/scripts/stores/notification'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -27,7 +27,7 @@ export const useCategoryStore = (useWindow = false) => {
actions: {
fetchCategories(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/categories`, { params })
.then((response) => {
this.categories = response.data.data
@@ -42,7 +42,7 @@ export const useCategoryStore = (useWindow = false) => {
fetchCategory(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/categories/${id}`)
.then((response) => {
this.currentCategory = response.data.data
@@ -57,7 +57,7 @@ export const useCategoryStore = (useWindow = false) => {
addCategory(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/categories', data)
.then((response) => {
this.categories.push(response.data.data)
@@ -77,7 +77,7 @@ export const useCategoryStore = (useWindow = false) => {
updateCategory(data) {
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/categories/${data.id}`, data)
.then((response) => {
if (response.data) {
@@ -104,7 +104,7 @@ export const useCategoryStore = (useWindow = false) => {
deleteCategory(id) {
return new Promise((resolve) => {
axios
http
.delete(`/api/v1/categories/${id}`)
.then((response) => {
let index = this.categories.findIndex(

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useNotificationStore } from '@/scripts/stores/notification'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -26,7 +26,7 @@ export const useCompanyStore = (useWindow = false) => {
fetchBasicMailConfig() {
return new Promise((resolve, reject) => {
axios
http
.get('/api/v1/company/mail/config')
.then((response) => {
resolve(response)
@@ -40,7 +40,7 @@ export const useCompanyStore = (useWindow = false) => {
updateCompany(data) {
return new Promise((resolve, reject) => {
axios
http
.put('/api/v1/company', data)
.then((response) => {
const notificationStore = useNotificationStore()
@@ -66,7 +66,7 @@ export const useCompanyStore = (useWindow = false) => {
updateCompanyLogo(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/company/upload-logo', data)
.then((response) => {
resolve(response)
@@ -80,7 +80,7 @@ export const useCompanyStore = (useWindow = false) => {
addNewCompany(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/companies', data)
.then((response) => {
const notificationStore = useNotificationStore()
@@ -99,7 +99,7 @@ export const useCompanyStore = (useWindow = false) => {
fetchCompany(params) {
return new Promise((resolve, reject) => {
axios
http
.get('/api/v1/current-company', params)
.then((response) => {
Object.assign(this.companyForm, response.data.data.address)
@@ -115,7 +115,7 @@ export const useCompanyStore = (useWindow = false) => {
fetchUserCompanies() {
return new Promise((resolve, reject) => {
axios
http
.get('/api/v1/companies')
.then((response) => {
resolve(response)
@@ -129,7 +129,7 @@ export const useCompanyStore = (useWindow = false) => {
fetchCompanySettings(settings) {
return new Promise((resolve, reject) => {
axios
http
.get('/api/v1/company/settings', {
params: {
settings,
@@ -147,7 +147,7 @@ export const useCompanyStore = (useWindow = false) => {
updateCompanySettings({ data, message }) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/company/settings', data)
.then((response) => {
Object.assign(this.selectedCompanySettings, data.settings)
@@ -172,7 +172,7 @@ export const useCompanyStore = (useWindow = false) => {
deleteCompany(data) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/companies/delete`, data)
.then((response) => {
resolve(response)

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useNotificationStore } from '@/scripts/stores/notification'
import customFieldStub from '@/scripts/admin/stub/custom-field'
@@ -41,7 +41,7 @@ export const useCustomFieldStore = (useWindow = false) => {
fetchCustomFields(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/custom-fields`, { params })
.then((response) => {
this.customFields = response.data.data
@@ -63,7 +63,7 @@ export const useCustomFieldStore = (useWindow = false) => {
this.isRequestOngoing = true
axios
http
.get(`/api/v1/custom-fields`, { params })
.then((response) => {
this.customFields = response.data.data
@@ -80,7 +80,7 @@ export const useCustomFieldStore = (useWindow = false) => {
fetchCustomField(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/custom-fields/${id}`)
.then((response) => {
this.currentCustomField = response.data.data
@@ -107,7 +107,7 @@ export const useCustomFieldStore = (useWindow = false) => {
addCustomField(params) {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/custom-fields`, params)
.then((response) => {
let data = {
@@ -139,7 +139,7 @@ export const useCustomFieldStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/custom-fields/${params.id}`, params)
.then((response) => {
let data = {
@@ -174,7 +174,7 @@ export const useCustomFieldStore = (useWindow = false) => {
deleteCustomFields(id) {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.delete(`/api/v1/custom-fields/${id}`)
.then((response) => {
let index = this.customFields.findIndex(

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useRoute } from 'vue-router'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -75,7 +75,7 @@ export const useCustomerStore = (useWindow = false) => {
fetchCustomers(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/customers`, { params })
.then((response) => {
this.customers = response.data.data
@@ -92,7 +92,7 @@ export const useCustomerStore = (useWindow = false) => {
fetchViewCustomer(params) {
return new Promise((resolve, reject) => {
this.isFetchingViewData = true
axios
http
.get(`/api/v1/customers/${params.id}/stats`, { params })
.then((response) => {
@@ -112,7 +112,7 @@ export const useCustomerStore = (useWindow = false) => {
fetchCustomer(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/customers/${id}`)
.then((response) => {
Object.assign(this.currentCustomer, response.data.data)
@@ -129,7 +129,7 @@ export const useCustomerStore = (useWindow = false) => {
addCustomer(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/customers', data)
.then((response) => {
this.customers.push(response.data.data)
@@ -151,7 +151,7 @@ export const useCustomerStore = (useWindow = false) => {
updateCustomer(data) {
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/customers/${data.id}`, data)
.then((response) => {
if (response.data) {
@@ -177,7 +177,7 @@ export const useCustomerStore = (useWindow = false) => {
deleteCustomer(id) {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/customers/delete`, id)
.then((response) => {
let index = this.customers.findIndex(
@@ -201,7 +201,7 @@ export const useCustomerStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/customers/delete`, { ids: this.selectedCustomers })
.then((response) => {
this.selectedCustomers.forEach((customer) => {

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useGlobalStore } from '@/scripts/admin/stores/global'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -40,7 +40,7 @@ export const useDashboardStore = (useWindow = false) => {
actions: {
loadData(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/dashboard`, { params })
.then((response) => {
// Stats

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useNotificationStore } from '@/scripts/stores/notification'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -71,7 +71,7 @@ export const useDiskStore = (useWindow = false) => {
actions: {
fetchDiskEnv(data) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/disks/${data.disk}`)
.then((response) => {
resolve(response)
@@ -85,7 +85,7 @@ export const useDiskStore = (useWindow = false) => {
fetchDisks(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/disks`, { params })
.then((response) => {
this.disks = response.data.data
@@ -100,7 +100,7 @@ export const useDiskStore = (useWindow = false) => {
fetchDiskDrivers() {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/disk/drivers`)
.then((response) => {
this.diskConfigData = response.data
@@ -116,7 +116,7 @@ export const useDiskStore = (useWindow = false) => {
deleteFileDisk(id) {
return new Promise((resolve, reject) => {
axios
http
.delete(`/api/v1/disks/${id}`)
.then((response) => {
if (response.data.success) {
@@ -141,7 +141,7 @@ export const useDiskStore = (useWindow = false) => {
updateDisk(data) {
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/disks/${data.id}`, data)
.then((response) => {
if (response.data) {
@@ -166,7 +166,7 @@ export const useDiskStore = (useWindow = false) => {
createDisk(data) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/disks`, data)
.then((response) => {
if (response.data) {

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import moment from 'moment'
import Guid from 'guid'
import _ from 'lodash'
@@ -100,7 +100,7 @@ export const useEstimateStore = (useWindow = false) => {
previewEstimate(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/estimates/${params.id}/send/preview`, { params })
.then((response) => {
resolve(response)
@@ -114,7 +114,7 @@ export const useEstimateStore = (useWindow = false) => {
fetchEstimates(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/estimates`, { params })
.then((response) => {
this.estimates = response.data.data
@@ -130,7 +130,7 @@ export const useEstimateStore = (useWindow = false) => {
getNextNumber(params, setState = false) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/next-number?key=estimate`, { params })
.then((response) => {
if (setState) {
@@ -147,7 +147,7 @@ export const useEstimateStore = (useWindow = false) => {
fetchEstimate(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/estimates/${id}`)
.then((response) => {
this.setEstimateData(response.data.data)
@@ -222,7 +222,7 @@ export const useEstimateStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/estimates/${data.id}/send`, data)
.then((response) => {
if (!data.is_preview) {
@@ -242,7 +242,7 @@ export const useEstimateStore = (useWindow = false) => {
addEstimate(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/estimates', data)
.then((response) => {
this.estimates = [...this.estimates, response.data.estimate]
@@ -266,7 +266,7 @@ export const useEstimateStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/estimates/delete`, id)
.then((response) => {
let index = this.estimates.findIndex(
@@ -292,7 +292,7 @@ export const useEstimateStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/estimates/delete`, { ids: this.selectedEstimates })
.then((response) => {
this.selectedEstimates.forEach((estimate) => {
@@ -318,7 +318,7 @@ export const useEstimateStore = (useWindow = false) => {
updateEstimate(data) {
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/estimates/${data.id}`, data)
.then((response) => {
let pos = this.estimates.findIndex(
@@ -341,7 +341,7 @@ export const useEstimateStore = (useWindow = false) => {
cloneEstimate(data) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/estimates/${data.id}/clone`, data)
.then((response) => {
const notificationStore = useNotificationStore()
@@ -360,7 +360,7 @@ export const useEstimateStore = (useWindow = false) => {
markAsAccepted(data) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/estimates/${data.id}/status`, data)
.then((response) => {
let pos = this.estimates.findIndex(
@@ -387,7 +387,7 @@ export const useEstimateStore = (useWindow = false) => {
markAsRejected(data) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/estimates/${data.id}/status`, data)
.then((response) => {
const notificationStore = useNotificationStore()
@@ -407,7 +407,7 @@ export const useEstimateStore = (useWindow = false) => {
markAsSent(data) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/estimates/${data.id}/status`, data)
.then((response) => {
let pos = this.estimates.findIndex(
@@ -435,7 +435,7 @@ export const useEstimateStore = (useWindow = false) => {
convertToInvoice(id) {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/estimates/${id}/convert-to-invoice`)
.then((response) => {
notificationStore.showNotification({
@@ -453,7 +453,7 @@ export const useEstimateStore = (useWindow = false) => {
searchEstimate(data) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/estimates?${data}`)
.then((response) => {
resolve(response)
@@ -487,7 +487,7 @@ export const useEstimateStore = (useWindow = false) => {
selectCustomer(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/customers/${id}`)
.then((response) => {
this.newEstimate.customer = response.data.data
@@ -502,7 +502,7 @@ export const useEstimateStore = (useWindow = false) => {
},
fetchEstimateTemplates(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/estimates/templates`, { params })
.then((response) => {
this.templates = response.data.estimateTemplates

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useNotificationStore } from '@/scripts/stores/notification'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -37,7 +37,7 @@ export const useExchangeRateStore = (useWindow = false) => {
actions: {
fetchProviders(params) {
return new Promise((resolve, reject) => {
axios
http
.get('/api/v1/exchange-rate-providers', { params })
.then((response) => {
this.providers = response.data.data
@@ -52,7 +52,7 @@ export const useExchangeRateStore = (useWindow = false) => {
fetchDefaultProviders() {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/config?key=exchange_rate_drivers`)
.then((response) => {
this.drivers = response.data.exchange_rate_drivers
@@ -68,7 +68,7 @@ export const useExchangeRateStore = (useWindow = false) => {
fetchProvider(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/exchange-rate-providers/${id}`)
.then((response) => {
this.currentExchangeRate = response.data.data
@@ -84,7 +84,7 @@ export const useExchangeRateStore = (useWindow = false) => {
addProvider(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/exchange-rate-providers', data)
.then((response) => {
notificationStore.showNotification({
@@ -104,7 +104,7 @@ export const useExchangeRateStore = (useWindow = false) => {
updateProvider(data) {
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/exchange-rate-providers/${data.id}`, data)
.then((response) => {
notificationStore.showNotification({
@@ -122,7 +122,7 @@ export const useExchangeRateStore = (useWindow = false) => {
deleteExchangeRate(id) {
return new Promise((resolve, reject) => {
axios
http
.delete(`/api/v1/exchange-rate-providers/${id}`)
.then((response) => {
let index = this.drivers.findIndex((driver) => driver.id === id)
@@ -148,7 +148,7 @@ export const useExchangeRateStore = (useWindow = false) => {
},
fetchCurrencies(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/supported-currencies`, { params })
.then((response) => {
this.supportedCurrencies = response.data.supportedCurrencies
@@ -163,7 +163,7 @@ export const useExchangeRateStore = (useWindow = false) => {
},
fetchActiveCurrency(params) {
return new Promise((resolve, reject) => {
axios
http
.get('/api/v1/used-currencies', { params })
.then((response) => {
this.activeUsedCurrencies = response.data.activeUsedCurrencies
@@ -178,7 +178,7 @@ export const useExchangeRateStore = (useWindow = false) => {
},
fetchBulkCurrencies() {
return new Promise((resolve, reject) => {
axios
http
.get('/api/v1/currencies/used')
.then((response) => {
this.bulkCurrencies = response.data.currencies.map((_m) => {
@@ -196,7 +196,7 @@ export const useExchangeRateStore = (useWindow = false) => {
},
updateBulkExchangeRate(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/currencies/bulk-update-exchange-rate', data)
.then((response) => {
resolve(response)
@@ -209,7 +209,7 @@ export const useExchangeRateStore = (useWindow = false) => {
},
getCurrentExchangeRate(currencyId) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/currencies/${currencyId}/exchange-rate`)
.then((response) => {
resolve(response)
@@ -221,7 +221,7 @@ export const useExchangeRateStore = (useWindow = false) => {
},
getCurrencyConverterServers() {
return new Promise((resolve, reject) => {
axios
http
.get('/api/v1/config?key=currency_converter_servers')
.then((response) => {
resolve(response)
@@ -234,7 +234,7 @@ export const useExchangeRateStore = (useWindow = false) => {
},
checkForActiveProvider(currency_id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/currencies/${currency_id}/active-provider`)
.then((response) => {
resolve(response)

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { handleError } from '@/scripts/helpers/error-handling'
import { useNotificationStore } from '@/scripts/stores/notification'
@@ -38,7 +38,7 @@ export const useExpenseStore = (useWindow = false) => {
fetchExpenses(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/expenses`, { params })
.then((response) => {
this.expenses = response.data.data
@@ -54,7 +54,7 @@ export const useExpenseStore = (useWindow = false) => {
fetchExpense(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/expenses/${id}`)
.then((response) => {
if (response.data) {
@@ -97,7 +97,7 @@ export const useExpenseStore = (useWindow = false) => {
const formData = utils.toFormData(data)
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/expenses', formData)
.then((response) => {
this.expenses.push(response.data)
@@ -127,7 +127,7 @@ export const useExpenseStore = (useWindow = false) => {
formData.append('is_attachment_receipt_removed', isAttachmentReceiptRemoved)
return new Promise((resolve) => {
axios.post(`/api/v1/expenses/${id}`, formData).then((response) => {
http.post(`/api/v1/expenses/${id}`, formData).then((response) => {
let pos = this.expenses.findIndex(
(expense) => expense.id === response.data.id
)
@@ -175,7 +175,7 @@ export const useExpenseStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/expenses/delete`, id)
.then((response) => {
let index = this.expenses.findIndex(
@@ -200,7 +200,7 @@ export const useExpenseStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/expenses/delete`, { ids: this.selectedExpenses })
.then((response) => {
this.selectedExpenses.forEach((expense) => {
@@ -223,7 +223,7 @@ export const useExpenseStore = (useWindow = false) => {
},
fetchPaymentModes(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/payment-methods`, { params })
.then((response) => {
this.paymentModes = response.data.data

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useCompanyStore } from './company'
import { useUserStore } from './user'
@@ -48,7 +48,7 @@ export const useGlobalStore = (useWindow = false) => {
actions: {
bootstrap() {
return new Promise((resolve, reject) => {
axios
http
.get('/api/v1/bootstrap')
.then(async (response) => {
const companyStore = useCompanyStore()
@@ -123,7 +123,7 @@ export const useGlobalStore = (useWindow = false) => {
resolve(this.currencies)
} else {
this.areCurrenciesLoading = true
axios
http
.get('/api/v1/currencies')
.then((response) => {
this.currencies = response.data.data.filter((currency) => {
@@ -143,7 +143,7 @@ export const useGlobalStore = (useWindow = false) => {
fetchConfig(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/config`, { params })
.then((response) => {
if (response.data.languages) {
@@ -165,7 +165,7 @@ export const useGlobalStore = (useWindow = false) => {
if (this.dateFormats.length) {
resolve(this.dateFormats)
} else {
axios
http
.get('/api/v1/date/formats')
.then((response) => {
this.dateFormats = response.data.date_formats
@@ -184,7 +184,7 @@ export const useGlobalStore = (useWindow = false) => {
if (this.timeFormats.length) {
resolve(this.timeFormats)
} else {
axios
http
.get('/api/v1/time/formats')
.then((response) => {
this.timeFormats = response.data.time_formats
@@ -203,7 +203,7 @@ export const useGlobalStore = (useWindow = false) => {
if (this.timeZones.length) {
resolve(this.timeZones)
} else {
axios
http
.get('/api/v1/timezones')
.then((response) => {
this.timeZones = response.data.time_zones
@@ -222,7 +222,7 @@ export const useGlobalStore = (useWindow = false) => {
if (this.countries.length) {
resolve(this.countries)
} else {
axios
http
.get('/api/v1/countries')
.then((response) => {
this.countries = response.data.data
@@ -238,7 +238,7 @@ export const useGlobalStore = (useWindow = false) => {
fetchPlaceholders(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/number-placeholders`, { params })
.then((response) => {
resolve(response)
@@ -260,7 +260,7 @@ export const useGlobalStore = (useWindow = false) => {
updateGlobalSettings({ data, message }) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/settings', data)
.then((response) => {
Object.assign(this.globalSettings, data.settings)

View File

@@ -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)

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import moment from 'moment'
import Guid from 'guid'
import _ from 'lodash'
@@ -108,7 +108,7 @@ export const useInvoiceStore = (useWindow = false) => {
previewInvoice(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/invoices/${params.id}/send/preview`, { params })
.then((response) => {
resolve(response)
@@ -122,7 +122,7 @@ export const useInvoiceStore = (useWindow = false) => {
fetchInvoices(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/invoices`, { params })
.then((response) => {
this.invoices = response.data.data
@@ -138,7 +138,7 @@ export const useInvoiceStore = (useWindow = false) => {
fetchInvoice(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/invoices/${id}`)
.then((response) => {
this.setInvoiceData(response.data.data)
@@ -204,7 +204,7 @@ export const useInvoiceStore = (useWindow = false) => {
sendInvoice(data) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/invoices/${data.id}/send`, data)
.then((response) => {
notificationStore.showNotification({
@@ -222,7 +222,7 @@ export const useInvoiceStore = (useWindow = false) => {
addInvoice(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/invoices', data)
.then((response) => {
this.invoices = [...this.invoices, response.data.invoice]
@@ -243,7 +243,7 @@ export const useInvoiceStore = (useWindow = false) => {
deleteInvoice(id) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/invoices/delete`, id)
.then((response) => {
let index = this.invoices.findIndex(
@@ -266,7 +266,7 @@ export const useInvoiceStore = (useWindow = false) => {
deleteMultipleInvoices(id) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/invoices/delete`, { ids: this.selectedInvoices })
.then((response) => {
this.selectedInvoices.forEach((invoice) => {
@@ -292,7 +292,7 @@ export const useInvoiceStore = (useWindow = false) => {
updateInvoice(data) {
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/invoices/${data.id}`, data)
.then((response) => {
let pos = this.invoices.findIndex(
@@ -316,7 +316,7 @@ export const useInvoiceStore = (useWindow = false) => {
cloneInvoice(data) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/invoices/${data.id}/clone`, data)
.then((response) => {
notificationStore.showNotification({
@@ -334,7 +334,7 @@ export const useInvoiceStore = (useWindow = false) => {
markAsSent(data) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/invoices/${data.id}/status`, data)
.then((response) => {
let pos = this.invoices.findIndex(
@@ -360,7 +360,7 @@ export const useInvoiceStore = (useWindow = false) => {
getNextNumber(params, setState = false) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/next-number?key=invoice`, { params })
.then((response) => {
if (setState) {
@@ -377,7 +377,7 @@ export const useInvoiceStore = (useWindow = false) => {
searchInvoice(data) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/invoices?${data}`)
.then((response) => {
resolve(response)
@@ -411,7 +411,7 @@ export const useInvoiceStore = (useWindow = false) => {
selectCustomer(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/customers/${id}`)
.then((response) => {
this.newInvoice.customer = response.data.data
@@ -427,7 +427,7 @@ export const useInvoiceStore = (useWindow = false) => {
fetchInvoiceTemplates(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/invoices/templates`, { params })
.then((response) => {
this.templates = response.data.invoiceTemplates

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useNotificationStore } from '@/scripts/stores/notification'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -45,7 +45,7 @@ export const useItemStore = (useWindow = false) => {
},
fetchItems(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/items`, { params })
.then((response) => {
this.items = response.data.data
@@ -62,7 +62,7 @@ export const useItemStore = (useWindow = false) => {
fetchItem(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/items/${id}`)
.then((response) => {
if (response.data) {
@@ -79,7 +79,7 @@ export const useItemStore = (useWindow = false) => {
addItem(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/items', data)
.then((response) => {
const notificationStore = useNotificationStore()
@@ -102,7 +102,7 @@ export const useItemStore = (useWindow = false) => {
updateItem(data) {
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/items/${data.id}`, data)
.then((response) => {
if (response.data) {
@@ -133,7 +133,7 @@ export const useItemStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/items/delete`, id)
.then((response) => {
let index = this.items.findIndex((item) => item.id === id)
@@ -157,7 +157,7 @@ export const useItemStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/items/delete`, { ids: this.selectedItems })
.then((response) => {
this.selectedItems.forEach((item) => {
@@ -205,7 +205,7 @@ export const useItemStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/units`, data)
.then((response) => {
this.itemUnits.push(response.data.data)
@@ -239,7 +239,7 @@ export const useItemStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/units/${data.id}`, data)
.then((response) => {
let pos = this.itemUnits.findIndex(
@@ -274,7 +274,7 @@ export const useItemStore = (useWindow = false) => {
fetchItemUnits(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/units`, { params })
.then((response) => {
this.itemUnits = response.data.data
@@ -289,7 +289,7 @@ export const useItemStore = (useWindow = false) => {
fetchItemUnit(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/units/${id}`)
.then((response) => {
this.currentItemUnit = response.data.data
@@ -306,7 +306,7 @@ export const useItemStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.delete(`/api/v1/units/${id}`)
.then((response) => {
if (!response.data.error) {

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useNotificationStore } from '@/scripts/stores/notification'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -57,7 +57,7 @@ export const useMailDriverStore = (useWindow = false) => {
actions: {
fetchMailDrivers() {
return new Promise((resolve, reject) => {
axios
http
.get('/api/v1/mail/drivers')
.then((response) => {
if (response.data) {
@@ -74,7 +74,7 @@ export const useMailDriverStore = (useWindow = false) => {
fetchMailConfig() {
return new Promise((resolve, reject) => {
axios
http
.get('/api/v1/mail/config')
.then((response) => {
if (response.data) {
@@ -92,7 +92,7 @@ export const useMailDriverStore = (useWindow = false) => {
updateMailConfig(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/mail/config', data)
.then((response) => {
const notificationStore = useNotificationStore()
@@ -118,7 +118,7 @@ export const useMailDriverStore = (useWindow = false) => {
sendTestMail(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/mail/test', data)
.then((response) => {
const notificationStore = useNotificationStore()

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { handleError } from '@/scripts/helpers/error-handling'
import { useNotificationStore } from '@/scripts/stores/notification'
@@ -27,7 +27,7 @@ export const useModuleStore = (useWindow = false) => {
actions: {
fetchModules(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/modules`)
.then((response) => {
this.modules = response.data.data
@@ -43,7 +43,7 @@ export const useModuleStore = (useWindow = false) => {
fetchModule(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/modules/${id}`)
.then((response) => {
if (response.data.error === 'invalid_token') {
@@ -67,7 +67,7 @@ export const useModuleStore = (useWindow = false) => {
checkApiToken(token) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/modules/check?api_token=${token}`)
.then((response) => {
const notificationStore = useNotificationStore()
@@ -88,7 +88,7 @@ export const useModuleStore = (useWindow = false) => {
disableModule(module) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/modules/${module}/disable`)
.then((response) => {
const notificationStore = useNotificationStore()
@@ -109,7 +109,7 @@ export const useModuleStore = (useWindow = false) => {
enableModule(module) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/modules/${module}/enable`)
.then((response) => {
const notificationStore = useNotificationStore()

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -40,7 +40,7 @@ export const useNotesStore = (useWindow = false) => {
fetchNotes(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/notes`, { params })
.then((response) => {
this.notes = response.data.data
@@ -55,7 +55,7 @@ export const useNotesStore = (useWindow = false) => {
fetchNote(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/notes/${id}`)
.then((response) => {
this.currentNote = response.data.data
@@ -70,7 +70,7 @@ export const useNotesStore = (useWindow = false) => {
addNote(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/notes', data)
.then((response) => {
this.notes.push(response.data)
@@ -85,7 +85,7 @@ export const useNotesStore = (useWindow = false) => {
updateNote(data) {
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/notes/${data.id}`, data)
.then((response) => {
if (response.data) {
@@ -105,7 +105,7 @@ export const useNotesStore = (useWindow = false) => {
deleteNote(id) {
return new Promise((resolve, reject) => {
axios
http
.delete(`/api/v1/notes/${id}`)
.then((response) => {
let index = this.notes.findIndex((note) => note.id === id)

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(

View File

@@ -1,7 +1,7 @@
const { defineStore } = window.pinia
import { handleError } from '@/scripts/helpers/error-handling'
import { useNotificationStore } from '@/scripts/stores/notification'
import axios from 'axios'
import http from '@/scripts/http'
export const usePDFDriverStore = (useWindow = false) => {
const defineStoreFunc = useWindow ? window.pinia.defineStore : defineStore
@@ -28,7 +28,7 @@ export const usePDFDriverStore = (useWindow = false) => {
actions: {
async fetchDrivers() {
try {
const response = await axios.get('/api/v1/pdf/drivers')
const response = await http.get('/api/v1/pdf/drivers')
this.pdf_drivers = response.data
} catch (err) {
handleError(err)
@@ -37,7 +37,7 @@ export const usePDFDriverStore = (useWindow = false) => {
},
async fetchConfig() {
try {
const response = await axios.get('/api/v1/pdf/config')
const response = await http.get('/api/v1/pdf/config')
this.pdfDriverConfig = response.data
this.pdf_driver = response.data.pdf_driver
} catch (err) {
@@ -47,7 +47,7 @@ export const usePDFDriverStore = (useWindow = false) => {
},
async updateConfig(data) {
try {
const response = await axios.post('/api/v1/pdf/config', data)
const response = await http.post('/api/v1/pdf/config', data)
const notificationStore = useNotificationStore()
if (response.data.success) {
notificationStore.showNotification({

View File

@@ -1,5 +1,5 @@
import { defineStore } from 'pinia'
import axios from 'axios'
import http from '@/scripts/http'
import recurringInvoiceStub from '@/scripts/admin/stub/recurring-invoice'
import recurringInvoiceItemStub from '@/scripts/admin/stub/recurring-invoice-item'
import TaxStub from '../stub/tax'
@@ -162,7 +162,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
addRecurringInvoice(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/recurring-invoices', data)
.then((response) => {
this.recurringInvoices = [
@@ -187,7 +187,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
fetchRecurringInvoice(id) {
return new Promise((resolve, reject) => {
this.isFetchingViewData = true
axios
http
.get(`/api/v1/recurring-invoices/${id}`)
.then((response) => {
Object.assign(this.newRecurringInvoice, response.data.data)
@@ -207,7 +207,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
updateRecurringInvoice(data) {
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/recurring-invoices/${data.id}`, data)
.then((response) => {
resolve(response)
@@ -234,7 +234,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
selectCustomer(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/customers/${id}`)
.then((response) => {
this.newRecurringInvoice.customer = response.data.data
@@ -250,7 +250,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
searchRecurringInvoice(data) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/recurring-invoices?${data}`)
.then((response) => {
resolve(response)
@@ -264,7 +264,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
fetchRecurringInvoices(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/recurring-invoices`, { params })
.then((response) => {
this.recurringInvoices = response.data.data
@@ -282,7 +282,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
deleteRecurringInvoice(id) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/recurring-invoices/delete`, id)
.then((response) => {
let index = this.recurringInvoices.findIndex(
@@ -304,7 +304,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
if (id) {
ids = [id]
}
axios
http
.post(`/api/v1/recurring-invoices/delete`, {
ids: ids,
})
@@ -492,7 +492,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
fetchRecurringInvoiceFrequencyDate(params) {
return new Promise((resolve, reject) => {
axios
http
.get('/api/v1/recurring-invoice-frequency', { params })
.then((response) => {
this.newRecurringInvoice.next_invoice_at =

View File

@@ -1,4 +1,3 @@
import axios from 'axios'
import { defineStore } from 'pinia'
import { useBackupStore } from './backup'
import { useCategoryStore } from './category'

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useNotificationStore } from '@/scripts/stores/notification'
import _ from 'lodash'
@@ -38,7 +38,7 @@ export const useRoleStore = (useWindow = false) => {
actions: {
fetchRoles(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/roles`, { params })
.then((response) => {
this.roles = response.data.data
@@ -53,7 +53,7 @@ export const useRoleStore = (useWindow = false) => {
fetchRole(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/roles/${id}`)
.then((response) => {
this.currentRole.name = response.data.data.name
@@ -81,7 +81,7 @@ export const useRoleStore = (useWindow = false) => {
addRole(data) {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/roles', data)
.then((response) => {
this.roles.push(response.data.role)
@@ -101,7 +101,7 @@ export const useRoleStore = (useWindow = false) => {
updateRole(data) {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/roles/${data.id}`, data)
.then((response) => {
if (response.data) {
@@ -128,7 +128,7 @@ export const useRoleStore = (useWindow = false) => {
if (this.allAbilities.length) {
resolve(this.allAbilities)
} else {
axios
http
.get(`/api/v1/abilities`, { params })
.then((response) => {
this.allAbilities = response.data.abilities
@@ -146,7 +146,7 @@ export const useRoleStore = (useWindow = false) => {
deleteRole(id) {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.delete(`/api/v1/roles/${id}`)
.then((response) => {
let index = this.roles.findIndex((role) => role.id === id)

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useNotificationStore } from '@/scripts/stores/notification'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -44,7 +44,7 @@ export const useTaxTypeStore = (useWindow = false) => {
fetchTaxTypes(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/tax-types`, { params })
.then((response) => {
this.taxTypes = response.data.data
@@ -59,7 +59,7 @@ export const useTaxTypeStore = (useWindow = false) => {
fetchTaxType(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/tax-types/${id}`)
.then((response) => {
this.currentTaxType = response.data.data
@@ -75,7 +75,7 @@ export const useTaxTypeStore = (useWindow = false) => {
addTaxType(data) {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/tax-types', data)
.then((response) => {
this.taxTypes.push(response.data.data)
@@ -95,7 +95,7 @@ export const useTaxTypeStore = (useWindow = false) => {
updateTaxType(data) {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/tax-types/${data.id}`, data)
.then((response) => {
if (response.data) {
@@ -119,7 +119,7 @@ export const useTaxTypeStore = (useWindow = false) => {
fetchSalesTax(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/m/sales-tax-us/current-tax', data)
.then((response) => {
if (response.data) {
@@ -141,7 +141,7 @@ export const useTaxTypeStore = (useWindow = false) => {
deleteTaxType(id) {
return new Promise((resolve, reject) => {
axios
http
.delete(`/api/v1/tax-types/${id}`)
.then((response) => {
if (response.data.success) {

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useNotificationStore } from '@/scripts/stores/notification'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -31,7 +31,7 @@ export const useUserStore = (useWindow = false) => {
actions: {
updateCurrentUser(data) {
return new Promise((resolve, reject) => {
axios
http
.put('/api/v1/me', data)
.then((response) => {
this.currentUser = response.data.data
@@ -52,7 +52,7 @@ export const useUserStore = (useWindow = false) => {
fetchCurrentUser(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/me`, params)
.then((response) => {
this.currentUser = response.data.data
@@ -68,7 +68,7 @@ export const useUserStore = (useWindow = false) => {
uploadAvatar(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/me/upload-avatar', data)
.then((response) => {
this.currentUser.avatar = response.data.data.avatar
@@ -83,7 +83,7 @@ export const useUserStore = (useWindow = false) => {
fetchUserSettings(settings) {
return new Promise((resolve, reject) => {
axios
http
.get('/api/v1/me/settings', {
params: {
settings,
@@ -101,7 +101,7 @@ export const useUserStore = (useWindow = false) => {
updateUserSettings(data) {
return new Promise((resolve, reject) => {
axios
http
.put('/api/v1/me/settings', data)
.then((response) => {
if (data.settings.language) {

View File

@@ -1,4 +1,4 @@
import axios from 'axios'
import http from '@/scripts/http'
import { defineStore } from 'pinia'
import { useNotificationStore } from '@/scripts/stores/notification'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -42,7 +42,7 @@ export const useUsersStore = (useWindow = false) => {
fetchUsers(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/users`, { params })
.then((response) => {
this.users = response.data.data
@@ -58,7 +58,7 @@ export const useUsersStore = (useWindow = false) => {
fetchUser(id) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/users/${id}`)
.then((response) => {
this.userData = response.data.data
@@ -82,7 +82,7 @@ export const useUsersStore = (useWindow = false) => {
fetchRoles(state) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/roles`)
.then((response) => {
this.roles = response.data.data
@@ -97,7 +97,7 @@ export const useUsersStore = (useWindow = false) => {
addUser(data) {
return new Promise((resolve, reject) => {
axios
http
.post('/api/v1/users', data)
.then((response) => {
this.users.push(response.data)
@@ -118,7 +118,7 @@ export const useUsersStore = (useWindow = false) => {
updateUser(data) {
return new Promise((resolve, reject) => {
axios
http
.put(`/api/v1/users/${data.id}`, data)
.then((response) => {
if (response) {
@@ -145,7 +145,7 @@ export const useUsersStore = (useWindow = false) => {
const notificationStore = useNotificationStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/users/delete`, { users: id.ids })
.then((response) => {
let index = this.users.findIndex((user) => user.id === id)
@@ -165,7 +165,7 @@ export const useUsersStore = (useWindow = false) => {
deleteMultipleUsers() {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/users/delete`, { users: this.selectedUsers })
.then((response) => {
this.selectedUsers.forEach((user) => {
@@ -190,7 +190,7 @@ export const useUsersStore = (useWindow = false) => {
searchUsers(params) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/search`, { params })
.then((response) => {
this.userList = response.data.users.data

View File

@@ -41,7 +41,7 @@
</template>
<script type="text/babel" setup>
import axios from 'axios'
import http from '@/scripts/http'
import { reactive, ref, computed } from 'vue'
import { required, email, helpers } from '@vuelidate/validators'
import { useVuelidate } from '@vuelidate/core'
@@ -74,7 +74,7 @@ async function onSubmit(e) {
if (!v$.value.$invalid) {
try {
isLoading.value = true
let res = await axios.post('/api/v1/auth/password/email', formData)
let res = await http.post('/api/v1/auth/password/email', formData)
if (res.data) {
notificationStore.showNotification({
type: 'success',

View File

@@ -56,7 +56,7 @@
</template>
<script setup>
import axios from 'axios'
import http from '@/scripts/http'
import { ref, computed, onMounted } from 'vue'
import { useNotificationStore } from '@/scripts/stores/notification'
import { useRouter } from 'vue-router'
@@ -96,8 +96,6 @@ const getInputType = computed(() => {
})
async function onSubmit() {
axios.defaults.withCredentials = true
v$.value.$touch()
if (v$.value.$invalid) {

View File

@@ -58,7 +58,7 @@ import useVuelidate from '@vuelidate/core'
import { required, email, minLength, sameAs } from '@vuelidate/validators'
import { useNotificationStore } from '@/scripts/stores/notification'
import { useRoute, useRouter } from 'vue-router'
import axios from 'axios'
import http from '@/scripts/http'
import { useI18n } from 'vue-i18n'
import { handleError } from '@/scripts/helpers/error-handling'
@@ -141,7 +141,7 @@ async function onSubmit(e) {
token: route.params.token,
}
isLoading.value = true
let res = await axios.post('/api/v1/auth/reset/password', data)
let res = await http.post('/api/v1/auth/reset/password', data)
isLoading.value = false
if (res.data) {
notificationStore.showNotification({

View File

@@ -673,7 +673,7 @@ import { useRoute } from 'vue-router'
import { useDialogStore } from '@/scripts/stores/dialog'
import { useI18n } from 'vue-i18n'
import moment from 'moment'
import axios from 'axios'
import http from '@/scripts/http'
import ModulePlaceholder from './partials/ModulePlaceholder.vue'
import RecentModuleCard from './partials/RecentModuleCard.vue'
import { useNotificationStore } from '@/scripts/stores/notification'
@@ -853,7 +853,7 @@ async function installModule() {
module: moduleData.value.module_name,
}
let requestResponse = await axios.post(currentStep.stepUrl, updateParams)
let requestResponse = await http.post(currentStep.stepUrl, updateParams)
currentStep.completed = true
if (requestResponse.data) {

View File

@@ -214,7 +214,7 @@
<script setup>
import { useNotificationStore } from '@/scripts/stores/notification'
import axios from 'axios'
import http from '@/scripts/http'
import LoadingIcon from '@/scripts/components/icons/LoadingIcon.vue'
import { reactive, ref, onMounted, computed } from 'vue'
import { useI18n } from 'vue-i18n'
@@ -301,7 +301,7 @@ window.addEventListener('beforeunload', (event) => {
// Created
axios.get('/api/v1/app/version').then((res) => {
http.get('/api/v1/app/version').then((res) => {
currentVersion.value = res.data.version
insiderChannel.value = res.data.channel === 'insider'
})
@@ -344,7 +344,7 @@ function statusClass(step) {
async function checkUpdate() {
try {
isCheckingforUpdate.value = true
let response = await axios.get('/api/v1/check/update', {
let response = await http.get('/api/v1/check/update', {
params: {
channel: insiderChannel ? 'insider' : ''
}
@@ -409,7 +409,7 @@ function onUpdateApp() {
path: path || null,
}
let requestResponse = await axios.post(
let requestResponse = await http.post(
currentStep.stepUrl,
updateParams
)

View File

@@ -73,7 +73,7 @@ I
</template>
<script setup>
import axios from 'axios'
import http from '@/scripts/http'
import { ref, reactive, computed, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import InvoiceInformationCard from '@/scripts/components/InvoiceInformationCard.vue'
@@ -85,7 +85,7 @@ const router = useRouter()
loadInvoice()
async function loadInvoice() {
let res = await axios.get(`/customer/invoices/${route.params.hash}`)
let res = await http.get(`/customer/invoices/${route.params.hash}`)
invoiceData.value = res.data.data
}

View File

@@ -379,7 +379,7 @@
<script setup>
import { ref, onMounted, watch } from 'vue'
import axios from 'axios'
import http from '@/scripts/http'
import utils from '@/scripts/helpers/utilities'
const props = defineProps({
@@ -456,7 +456,7 @@ function reset() {
function upload(formData) {
return (
axios
http
.post(props.uploadUrl, formData)
// get data
.then((x) => x.data)

View File

@@ -1,5 +1,5 @@
const { defineStore } = window.pinia
import axios from 'axios'
import http from '@/scripts/http'
import { useNotificationStore } from '@/scripts/stores/notification'
import router from '@/scripts/customer/customer-router'
import { handleError } from '@/scripts/customer/helpers/error-handling'
@@ -20,9 +20,9 @@ export const useAuthStore = defineStore({
login(data) {
const notificationStore = useNotificationStore(true)
return new Promise((resolve, reject) => {
axios.get('/sanctum/csrf-cookie').then((response) => {
http.get('/sanctum/csrf-cookie').then((response) => {
if (response) {
axios
http
.post(`/${data.company}/customer/login`, data)
.then((response) => {
notificationStore.showNotification({
@@ -47,7 +47,7 @@ export const useAuthStore = defineStore({
forgotPassword(data) {
const notificationStore = useNotificationStore(true)
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/${data.company}/customer/auth/password/email`, data)
.then((response) => {
@@ -75,7 +75,7 @@ export const useAuthStore = defineStore({
resetPassword(data, company) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/${company}/customer/auth/reset/password`, data)
.then((response) => {
@@ -102,7 +102,7 @@ export const useAuthStore = defineStore({
logout(data) {
return new Promise((resolve, reject) => {
axios
http
.post(`/${data}/customer/logout`)
.then((response) => {
const notificationStore = useNotificationStore()

View File

@@ -1,6 +1,6 @@
const { defineStore } = window.pinia
import { useGlobalStore } from '@/scripts/customer/stores/global'
import axios from 'axios'
import http from '@/scripts/http'
import { handleError } from '@/scripts/customer/helpers/error-handling'
export const useDashboardStore = defineStore({
@@ -19,7 +19,7 @@ export const useDashboardStore = defineStore({
loadData(data) {
const globalStore = useGlobalStore()
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/${globalStore.companySlug}/customer/dashboard`, {
data,
})

View File

@@ -1,6 +1,6 @@
const { defineStore } = window.pinia
import { useNotificationStore } from '@/scripts/stores/notification'
import axios from 'axios'
import http from '@/scripts/http'
import { handleError } from '@/scripts/customer/helpers/error-handling'
export const useEstimateStore = defineStore({
@@ -13,7 +13,7 @@ export const useEstimateStore = defineStore({
actions: {
fetchEstimate(params, slug) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/${slug}/customer/estimates`, { params })
.then((response) => {
this.estimates = response.data.data
@@ -29,7 +29,7 @@ export const useEstimateStore = defineStore({
fetchViewEstimate(params, slug) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/${slug}/customer/estimates/${params.id}`, {
params,
})
@@ -47,7 +47,7 @@ export const useEstimateStore = defineStore({
searchEstimate(params, slug) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/${slug}/customer/estimates`, { params })
.then((response) => {
this.estimates = response.data
@@ -62,7 +62,7 @@ export const useEstimateStore = defineStore({
acceptEstimate({ slug, id, status }) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/${slug}/customer/estimate/${id}/status`, { status })
.then((response) => {
let pos = this.estimates.findIndex(
@@ -89,7 +89,7 @@ export const useEstimateStore = defineStore({
rejectEstimate({ slug, id, status }) {
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/${slug}/customer/estimate/${id}/status`, { status })
.then((response) => {
let pos = this.estimates.findIndex(

View File

@@ -1,7 +1,7 @@
import { handleError } from '@/scripts/customer/helpers/error-handling'
import { useUserStore } from './user'
const { defineStore } = window.pinia
import axios from 'axios'
import http from '@/scripts/http'
const { global } = window.i18n
export const useGlobalStore = defineStore({
id: 'CustomerPortalGlobalStore',
@@ -22,7 +22,7 @@ export const useGlobalStore = defineStore({
this.companySlug = data
const userStore = useUserStore()
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/${data}/customer/bootstrap`)
.then((response) => {
this.currentUser = response.data.data
@@ -51,7 +51,7 @@ export const useGlobalStore = defineStore({
if (this.countries.length) {
resolve(this.countries)
} else {
axios
http
.get(`/api/v1/${this.companySlug}/customer/countries`)
.then((response) => {
this.countries = response.data.data

View File

@@ -1,6 +1,6 @@
import { handleError } from '@/scripts/customer/helpers/error-handling'
const { defineStore } = window.pinia
import axios from 'axios'
import http from '@/scripts/http'
export const useInvoiceStore = defineStore({
id: 'customerInvoiceStore',
state: () => ({
@@ -12,7 +12,7 @@ export const useInvoiceStore = defineStore({
actions: {
fetchInvoices(params, slug) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/${slug}/customer/invoices`, { params })
.then((response) => {
this.invoices = response.data.data
@@ -28,7 +28,7 @@ export const useInvoiceStore = defineStore({
fetchViewInvoice(params, slug) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/${slug}/customer/invoices/${params.id}`, {
params,
})
@@ -46,7 +46,7 @@ export const useInvoiceStore = defineStore({
searchInvoice(params, slug) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/${slug}/customer/invoices`, { params })
.then((response) => {
this.invoices = response.data

View File

@@ -1,6 +1,6 @@
import { handleError } from '@/scripts/customer/helpers/error-handling'
const { defineStore } = window.pinia
import axios from 'axios'
import http from '@/scripts/http'
export const usePaymentStore = defineStore({
id: 'customerPaymentStore',
@@ -13,7 +13,7 @@ export const usePaymentStore = defineStore({
actions: {
fetchPayments(params, slug) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/${slug}/customer/payments`, { params })
.then((response) => {
this.payments = response.data.data
@@ -29,7 +29,7 @@ export const usePaymentStore = defineStore({
fetchViewPayment(params, slug) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/${slug}/customer/payments/${params.id}`)
.then((response) => {
@@ -45,7 +45,7 @@ export const usePaymentStore = defineStore({
searchPayment(params, slug) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/${slug}/customer/payments`, { params })
.then((response) => {
this.payments = response.data
@@ -60,7 +60,7 @@ export const usePaymentStore = defineStore({
fetchPaymentModes(params, slug) {
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/${slug}/customer/payment-method`, { params })
.then((response) => {
resolve(response)

View File

@@ -2,7 +2,7 @@ import { handleError } from '@/scripts/customer/helpers/error-handling'
const { defineStore } = window.pinia
import { useNotificationStore } from '@/scripts/stores/notification'
import stubs from '@/scripts/customer/stubs/address'
import axios from 'axios'
import http from '@/scripts/http'
import { useGlobalStore } from '@/scripts/customer/stores/global'
export const useUserStore = defineStore({
@@ -37,7 +37,7 @@ export const useUserStore = defineStore({
fetchCurrentUser() {
const globalStore = useGlobalStore()
return new Promise((resolve, reject) => {
axios
http
.get(`/api/v1/${globalStore.companySlug}/customer/me`)
.then((response) => {
Object.assign(this.userForm, response.data.data)
@@ -53,7 +53,7 @@ export const useUserStore = defineStore({
updateCurrentUser({ data, message }) {
const globalStore = useGlobalStore()
return new Promise((resolve, reject) => {
axios
http
.post(`/api/v1/${globalStore.companySlug}/customer/profile`, data)
.then((response) => {
this.userForm = response.data.data

40
resources/scripts/http/index.js vendored Normal file
View File

@@ -0,0 +1,40 @@
import axios from 'axios'
import Ls from '@/scripts/services/ls.js'
window.Ls = Ls
const instance = axios.create({
withCredentials: true,
headers: {
common: {
'X-Requested-With': 'XMLHttpRequest',
},
},
})
instance.interceptors.request.use(function (config) {
const companyId = Ls.get('selectedCompany')
const authToken = Ls.get('auth.token')
if (authToken) {
config.headers.Authorization = authToken
}
if (companyId) {
config.headers.company = companyId
}
return config
})
function http(config) {
return instance(config)
}
http.get = instance.get.bind(instance)
http.post = instance.post.bind(instance)
http.put = instance.put.bind(instance)
http.delete = instance.delete.bind(instance)
http.patch = instance.patch.bind(instance)
export default http

View File

@@ -1,6 +1,6 @@
import '../sass/invoiceshelf.scss'
import 'v-tooltip/dist/v-tooltip.css'
import '@/scripts/plugins/axios.js'
import '@/scripts/http'
import * as VueRouter from 'vue-router'
import router from '@/scripts/router/index'
import * as pinia from 'pinia'

View File

@@ -1,31 +0,0 @@
import axios from 'axios'
import Ls from '@/scripts/services/ls.js'
window.Ls = Ls
window.axios = axios
axios.defaults.withCredentials = true
axios.defaults.headers.common = {
'X-Requested-With': 'XMLHttpRequest',
}
/**
* Interceptors
*/
axios.interceptors.request.use(function (config) {
// Pass selected company to header on all requests
const companyId = Ls.get('selectedCompany')
const authToken = Ls.get('auth.token')
if (authToken) {
config.headers.Authorization = authToken
}
if (companyId) {
config.headers.company = companyId
}
return config
})