Files
vuefilemanager/resources/js/store/modules/oasisInvoices
T
2021-04-22 10:06:31 +02:00

123 lines
2.7 KiB
Plaintext

import {events} from '@/bus'
import axios from "axios"
import Vue from "vue"
const defaultState = {}
const actions = {
getRegularInvoices: ({commit, getters}) => {
commit('LOADING_STATE', {loading: true, data: []})
commit('STORE_CURRENT_FOLDER', {
name: 'Invoices',
id: undefined,
location: 'regular-invoice',
})
axios
.get('/api/oasis/invoices/regular')
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
})
.catch(() => {
Vue.prototype.$isSomethingWrong()
})
.finally(() => {
events.$emit('scrollTop')
})
},
getAdvanceInvoices: ({commit, getters}) => {
commit('LOADING_STATE', {loading: true, data: []})
commit('STORE_CURRENT_FOLDER', {
name: 'Advance Invoices',
id: undefined,
location: 'advance-invoice',
})
axios
.get('/api/oasis/invoices/advance')
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
})
.catch(() => {
Vue.prototype.$isSomethingWrong()
})
.finally(() => {
events.$emit('scrollTop')
})
},
getClients: ({commit, getters}) => {
commit('LOADING_STATE', {loading: true, data: []})
commit('STORE_CURRENT_FOLDER', {
name: 'Clients',
id: undefined,
location: 'clients',
})
axios
.get('/api/oasis/clients')
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
})
.catch(() => {
Vue.prototype.$isSomethingWrong()
})
.finally(() => {
events.$emit('scrollTop')
})
},
getSearchResultForInvoices: ({commit, getters}, query) => {
commit('LOADING_STATE', {loading: true, data: []})
commit('CHANGE_SEARCHING_STATE', true)
axios
.get('/api/oasis/invoices/search', {
params: {
query: query,
type: getters.currentFolder.location,
}
})
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
})
.catch(() => Vue.prototype.$isSomethingWrong())
},
getSearchResultForClients: ({commit, getters}, query) => {
commit('LOADING_STATE', {loading: true, data: []})
commit('CHANGE_SEARCHING_STATE', true)
axios
.get('/api/oasis/clients/search', {
params: {query: query}
})
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
})
.catch(() => Vue.prototype.$isSomethingWrong())
},
deleteClient: ({commit, getters}, payload) => {
//
},
deleteInvoice: ({commit, getters}, payload) => {
//
},
deleteAdvanceInvoice: ({commit, getters}, payload) => {
//
},
sendInvoice: ({commit, getters}, payload) => {
//
},
}
const mutations = {}
const getters = {}
export default {
state: defaultState,
getters,
actions,
mutations
}