mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-31 05:31:10 -04:00 
			
		
		
		
	init crater
This commit is contained in:
		
							
								
								
									
										77
									
								
								resources/assets/js/store/modules/auth/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								resources/assets/js/store/modules/auth/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,77 @@ | ||||
| import Ls from '@/services/ls' | ||||
| import * as types from './mutation-types' | ||||
| import * as userTypes from '../user/mutation-types' | ||||
| import * as rootTypes from '../../mutation-types' | ||||
| import router from '@/router.js' | ||||
|  | ||||
| export const login = ({ commit, dispatch, state }, data) => { | ||||
|   let loginData = { | ||||
|     username: data.email, | ||||
|     password: data.password | ||||
|   } | ||||
|   return new Promise((resolve, reject) => { | ||||
|     axios.post('/api/auth/login', loginData).then((response) => { | ||||
|       let token = response.data.access_token | ||||
|       Ls.set('auth.token', token) | ||||
|  | ||||
|       commit('user/' + userTypes.RESET_CURRENT_USER, null, { root: true }) | ||||
|       commit(rootTypes.UPDATE_APP_LOADING_STATUS, false, { root: true }) | ||||
|  | ||||
|       commit(types.AUTH_SUCCESS, token) | ||||
|       window.toastr['success']('Login Successful') | ||||
|       resolve(response) | ||||
|     }).catch(err => { | ||||
|       if (err.response.data.error === 'invalid_credentials') { | ||||
|         window.toastr['error']('Invalid Credentials') | ||||
|       } else { | ||||
|         // Something happened in setting up the request that triggered an Error | ||||
|         console.log('Error', err.message) | ||||
|       } | ||||
|  | ||||
|       commit(types.AUTH_ERROR, err.response) | ||||
|       Ls.remove('auth.token') | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const refreshToken = ({ commit, dispatch, state }) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     let data = { | ||||
|       token: Ls.get('auth.token') | ||||
|     } | ||||
|     console.log('REFRESH ACTION') | ||||
|     axios.post('/api/auth/refresh_token', data).then((response) => { | ||||
|       let token = response.data.data.token | ||||
|       Ls.set('auth.token', token) | ||||
|       commit(types.REFRESH_SUCCESS, token) | ||||
|       resolve(response) | ||||
|     }).catch(err => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const logout = ({ commit, dispatch, state }, noRequest = false) => { | ||||
|   if (noRequest) { | ||||
|     commit(types.AUTH_LOGOUT) | ||||
|     Ls.remove('auth.token') | ||||
|     router.push('/login') | ||||
|  | ||||
|     return true | ||||
|   } | ||||
|  | ||||
|   return new Promise((resolve, reject) => { | ||||
|     axios.get('/api/auth/logout').then((response) => { | ||||
|       commit(types.AUTH_LOGOUT) | ||||
|       Ls.remove('auth.token') | ||||
|       router.push('/login') | ||||
|       window.toastr['success']('Logged out!', 'Success') | ||||
|     }).catch(err => { | ||||
|       reject(err) | ||||
|       commit(types.AUTH_LOGOUT) | ||||
|       Ls.remove('auth.token') | ||||
|       router.push('/login') | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
							
								
								
									
										2
									
								
								resources/assets/js/store/modules/auth/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								resources/assets/js/store/modules/auth/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| export const isAuthenticated = (state) => !!state.token | ||||
| export const authStatus = (state) => state.status | ||||
							
								
								
									
										23
									
								
								resources/assets/js/store/modules/auth/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								resources/assets/js/store/modules/auth/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
| import Ls from '@/services/ls' | ||||
|  | ||||
| const initialState = { | ||||
|   token: Ls.get('auth.token'), | ||||
|   status: '', | ||||
|   validateTokenError: '', | ||||
|   validateTokenSuccess: '' | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
							
								
								
									
										4
									
								
								resources/assets/js/store/modules/auth/mutation-types.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								resources/assets/js/store/modules/auth/mutation-types.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| export const AUTH_SUCCESS = 'AUTH_SUCCESS' | ||||
| export const AUTH_LOGOUT = 'AUTH_LOGOUT' | ||||
| export const AUTH_ERROR = 'AUTH_ERROR' | ||||
| export const REFRESH_SUCCESS = 'REFRESH_SUCCESS' | ||||
							
								
								
									
										22
									
								
								resources/assets/js/store/modules/auth/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								resources/assets/js/store/modules/auth/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.AUTH_SUCCESS] (state, token) { | ||||
|     state.token = token | ||||
|     state.status = 'success' | ||||
|   }, | ||||
|  | ||||
|   [types.AUTH_LOGOUT] (state) { | ||||
|     state.token = null | ||||
|   }, | ||||
|  | ||||
|   [types.AUTH_ERROR] (state, errorResponse) { | ||||
|     state.token = null | ||||
|     state.status = 'error' | ||||
|   }, | ||||
|  | ||||
|   [types.REFRESH_SUCCESS] (state, token) { | ||||
|     state.token = token | ||||
|     state.status = 'success' | ||||
|   } | ||||
| } | ||||
							
								
								
									
										57
									
								
								resources/assets/js/store/modules/category/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								resources/assets/js/store/modules/category/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const fetchCategories = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/categories/`).then((response) => { | ||||
|       commit(types.SET_CATEGORIES, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const fetchCategory = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/categories/${id}/edit`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const addCategory = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post('/api/categories', data).then((response) => { | ||||
|       commit(types.ADD_CATEGORY, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const updateCategory = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.put(`/api/categories/${data.id}`, data).then((response) => { | ||||
|       commit(types.UPDATE_CATEGORY, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const deleteCategory = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.delete(`/api/categories/${id}`).then((response) => { | ||||
|       if (response.data.success) { | ||||
|         commit(types.DELETE_CATEGORY, id) | ||||
|       } | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
							
								
								
									
										5
									
								
								resources/assets/js/store/modules/category/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								resources/assets/js/store/modules/category/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| export const categories = (state) => state.categories | ||||
|  | ||||
| export const getCategoryById = (state) => (id) => { | ||||
|   return state.categories.find(category => category.id === id) | ||||
| } | ||||
							
								
								
									
										19
									
								
								resources/assets/js/store/modules/category/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								resources/assets/js/store/modules/category/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   categories: [] | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,4 @@ | ||||
| export const SET_CATEGORIES = 'SET_CATEGORIES' | ||||
| export const ADD_CATEGORY = 'ADD_CATEGORY' | ||||
| export const UPDATE_CATEGORY = 'UPDATE_CATEGORY' | ||||
| export const DELETE_CATEGORY = 'DELETE_CATEGORY' | ||||
							
								
								
									
										21
									
								
								resources/assets/js/store/modules/category/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								resources/assets/js/store/modules/category/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.SET_CATEGORIES] (state, data) { | ||||
|     state.categories = data.categories | ||||
|   }, | ||||
|  | ||||
|   [types.ADD_CATEGORY] (state, data) { | ||||
|     state.categories.push(data.category) | ||||
|   }, | ||||
|  | ||||
|   [types.UPDATE_CATEGORY] (state, data) { | ||||
|     let pos = state.categories.findIndex(category => category.id === data.category.id) | ||||
|     Object.assign(state.categories[pos], {...data.category}) | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_CATEGORY] (state, id) { | ||||
|     let pos = state.categories.findIndex(category => category.id === id) | ||||
|     state.categories.splice(pos, 1) | ||||
|   } | ||||
| } | ||||
							
								
								
									
										7
									
								
								resources/assets/js/store/modules/company/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								resources/assets/js/store/modules/company/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| import * as types from './mutation-types' | ||||
| import Ls from '@/services/ls' | ||||
|  | ||||
| export const setSelectedCompany = ({ commit, dispatch, state }, data) => { | ||||
|   Ls.set('selectedCompany', data.id) | ||||
|   commit(types.SET_SELECTED_COMPANY, data) | ||||
| } | ||||
							
								
								
									
										2
									
								
								resources/assets/js/store/modules/company/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								resources/assets/js/store/modules/company/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| export const getSelectedCompany = (state) => state.selectedCompany | ||||
| export const getCompanies = (state) => state.companies | ||||
							
								
								
									
										20
									
								
								resources/assets/js/store/modules/company/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								resources/assets/js/store/modules/company/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   selectedCompany: null, | ||||
|   companies: [] | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,2 @@ | ||||
| export const BOOTSTRAP_COMPANIES = 'BOOTSTRAP_COMPANIES' | ||||
| export const SET_SELECTED_COMPANY = 'SET_SELECTED_COMPANY' | ||||
							
								
								
									
										11
									
								
								resources/assets/js/store/modules/company/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								resources/assets/js/store/modules/company/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.BOOTSTRAP_COMPANIES] (state, companies) { | ||||
|     state.companies = companies | ||||
|     state.selectedCompany = companies[0] | ||||
|   }, | ||||
|   [types.SET_SELECTED_COMPANY] (state, company) { | ||||
|     state.selectedCompany = company | ||||
|   } | ||||
| } | ||||
							
								
								
									
										70
									
								
								resources/assets/js/store/modules/currency/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								resources/assets/js/store/modules/currency/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,70 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| // export const indexLoadData = ({ commit, dispatch, state }) => { | ||||
| //   return new Promise((resolve, reject) => { | ||||
| //     window.axios.get('/api/settings/currencies').then((response) => { | ||||
| //       commit(types.BOOTSTRAP_CURRENCIES, response.data) | ||||
| //       resolve(response) | ||||
| //     }).catch((err) => { | ||||
| //       reject(err) | ||||
| //     }) | ||||
| //   }) | ||||
| // } | ||||
|  | ||||
| // export const loadData = ({ commit, dispatch, state }, id) => { | ||||
| //   return new Promise((resolve, reject) => { | ||||
| //     window.axios.get(`/api/settings/currencies/${id}/edit`).then((response) => { | ||||
| //       resolve(response) | ||||
| //     }).catch((err) => { | ||||
| //       reject(err) | ||||
| //     }) | ||||
| //   }) | ||||
| // } | ||||
|  | ||||
| // export const addCurrency = ({ commit, dispatch, state }, data) => { | ||||
| //   return new Promise((resolve, reject) => { | ||||
| //     window.axios.post('/api/settings/currencies', data).then((response) => { | ||||
| //       commit(types.ADD_CURRENCY, response.data) | ||||
| //       resolve(response) | ||||
| //     }).catch((err) => { | ||||
| //       reject(err) | ||||
| //     }) | ||||
| //   }) | ||||
| // } | ||||
|  | ||||
| // export const editCurrency = ({ commit, dispatch, state }, data) => { | ||||
| //   return new Promise((resolve, reject) => { | ||||
| //     window.axios.put('/api/settings/currency_setting', data).then((response) => { | ||||
| //       resolve(response) | ||||
| //     }).catch((err) => { | ||||
| //       reject(err) | ||||
| //     }) | ||||
| //   }) | ||||
| // } | ||||
|  | ||||
| // export const removeItem = ({ commit, dispatch, state }, id) => { | ||||
| //   return new Promise((resolve, reject) => { | ||||
| //     window.axios.delete(`/api/settings/currencies/${id}`).then((response) => { | ||||
| //       resolve(response) | ||||
| //     }).catch((err) => { | ||||
| //       reject(err) | ||||
| //     }) | ||||
| //   }) | ||||
| // } | ||||
|  | ||||
| // export const selectCurrency = ({ commit, dispatch, state }) => { | ||||
| //   return new Promise((resolve, reject) => { | ||||
| //     let data = { | ||||
| //       currency: state.currencyId | ||||
| //     } | ||||
| //     window.axios.delete(`/api/settings/currency_setting`, data).then((response) => { | ||||
| //       resolve(response) | ||||
| //     }).catch((err) => { | ||||
| //       reject(err) | ||||
| //     }) | ||||
| //   }) | ||||
| // } | ||||
|  | ||||
| export const setDefaultCurrency = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_DEFAULT_CURRENCY, { default_currency: data }) | ||||
| } | ||||
							
								
								
									
										21
									
								
								resources/assets/js/store/modules/currency/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								resources/assets/js/store/modules/currency/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | ||||
| export const currencies = (state) => state.currencies | ||||
| export const defaultCurrency = (state) => state.defaultCurrency | ||||
| export const defaultCurrencyForInput = (state) => { | ||||
|   if (state.defaultCurrency) { | ||||
|     return { | ||||
|       decimal: state.defaultCurrency.decimal_separator, | ||||
|       thousands: state.defaultCurrency.thousand_separator, | ||||
|       prefix: state.defaultCurrency.symbol + ' ', | ||||
|       precision: state.defaultCurrency.precision, | ||||
|       masked: false | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   return { | ||||
|     decimal: '.', | ||||
|     thousands: ',', | ||||
|     prefix: '$ ', | ||||
|     precision: 2, | ||||
|     masked: false | ||||
|   } | ||||
| } | ||||
							
								
								
									
										20
									
								
								resources/assets/js/store/modules/currency/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								resources/assets/js/store/modules/currency/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   currencies: [], | ||||
|   defaultCurrency: null | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,5 @@ | ||||
| export const BOOTSTRAP_CURRENCIES = 'BOOTSTRAP_CURRENCIES' | ||||
| export const SET_DEFAULT_CURRENCY = 'SET_DEFAULT_CURRENCY' | ||||
| export const ADD_CURRENCY = 'ADD_CURRENCY' | ||||
| export const UPDATE_CURRENCY = 'UPDATE_CURRENCY' | ||||
| export const DELETE_CURRENCY = 'DELETE_CURRENCY' | ||||
							
								
								
									
										16
									
								
								resources/assets/js/store/modules/currency/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								resources/assets/js/store/modules/currency/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.BOOTSTRAP_CURRENCIES] (state, data) { | ||||
|     state.currencies = data.currencies | ||||
|     state.currencyId = data.currencyId | ||||
|   }, | ||||
|  | ||||
|   [types.SET_DEFAULT_CURRENCY] (state, data) { | ||||
|     state.defaultCurrency = data.default_currency | ||||
|   }, | ||||
|  | ||||
|   [types.ADD_CURRENCY] (state, data) { | ||||
|     state.currencies.push(data) | ||||
|   } | ||||
| } | ||||
							
								
								
									
										95
									
								
								resources/assets/js/store/modules/customer/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								resources/assets/js/store/modules/customer/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,95 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const fetchCustomers = ({ commit, dispatch, state }, params) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/customers`, {params}).then((response) => { | ||||
|       commit(types.BOOTSTRAP_CUSTOMERS, response.data.customers.data) | ||||
|       commit(types.SET_TOTAL_CUSTOMERS, response.data.customers.total) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const fetchCustomer = ({ commit, dispatch }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/customers/${id}/edit`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const addCustomer = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post('/api/customers', data).then((response) => { | ||||
|       commit(types.ADD_CUSTOMER, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const updateCustomer = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.put(`/api/customers/${data.id}`, data).then((response) => { | ||||
|       commit(types.UPDATE_CUSTOMER, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const deleteCustomer = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.delete(`/api/customers/${id}`).then((response) => { | ||||
|       commit(types.DELETE_CUSTOMER, id) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const deleteMultipleCustomers = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/customers/delete`, {'id': state.selectedCustomers}).then((response) => { | ||||
|       commit(types.DELETE_MULTIPLE_CUSTOMERS, state.selectedCustomers) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const setSelectAllState = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_SELECT_ALL_STATE, data) | ||||
| } | ||||
|  | ||||
| export const selectAllCustomers = ({ commit, dispatch, state }) => { | ||||
|   if (state.selectedCustomers.length === state.customers.length) { | ||||
|     commit(types.SET_SELECTED_CUSTOMERS, []) | ||||
|     commit(types.SET_SELECT_ALL_STATE, false) | ||||
|   } else { | ||||
|     let allCustomerIds = state.customers.map(cust => cust.id) | ||||
|     commit(types.SET_SELECTED_CUSTOMERS, allCustomerIds) | ||||
|     commit(types.SET_SELECT_ALL_STATE, true) | ||||
|   } | ||||
| } | ||||
|  | ||||
| export const selectCustomer = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_SELECTED_CUSTOMERS, data) | ||||
|   if (state.selectedCustomers.length === state.customers.length) { | ||||
|     commit(types.SET_SELECT_ALL_STATE, true) | ||||
|   } else { | ||||
|     commit(types.SET_SELECT_ALL_STATE, false) | ||||
|   } | ||||
| } | ||||
|  | ||||
| export const resetSelectedCustomer = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.RESET_SELECTED_CUSTOMER) | ||||
| } | ||||
							
								
								
									
										4
									
								
								resources/assets/js/store/modules/customer/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								resources/assets/js/store/modules/customer/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| export const customers = (state) => state.customers | ||||
| export const selectAllField = (state) => state.selectAllField | ||||
| export const selectedCustomers = (state) => state.selectedCustomers | ||||
| export const totalCustomers = (state) => state.totalCustomers | ||||
							
								
								
									
										22
									
								
								resources/assets/js/store/modules/customer/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								resources/assets/js/store/modules/customer/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   customers: [], | ||||
|   totalCustomers: 0, | ||||
|   selectAllField: false, | ||||
|   selectedCustomers: [] | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,9 @@ | ||||
| export const BOOTSTRAP_CUSTOMERS = 'BOOTSTRAP_CUSTOMERS' | ||||
| export const ADD_CUSTOMER = 'ADD_CUSTOMER' | ||||
| export const UPDATE_CUSTOMER = 'UPDATE_CUSTOMER' | ||||
| export const DELETE_CUSTOMER = 'DELETE_CUSTOMER' | ||||
| export const DELETE_MULTIPLE_CUSTOMERS = 'DELETE_MULTIPLE_CUSTOMERS' | ||||
| export const SET_SELECTED_CUSTOMERS = 'SET_SELECTED_CUSTOMERS' | ||||
| export const SET_TOTAL_CUSTOMERS = 'SET_TOTAL_CUSTOMERS' | ||||
| export const RESET_SELECTED_CUSTOMER = 'RESET_SELECTED_CUSTOMER' | ||||
| export const SET_SELECT_ALL_STATE = 'SET_SELECT_ALL_STATE' | ||||
							
								
								
									
										48
									
								
								resources/assets/js/store/modules/customer/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								resources/assets/js/store/modules/customer/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.BOOTSTRAP_CUSTOMERS] (state, customers) { | ||||
|     state.customers = customers | ||||
|   }, | ||||
|  | ||||
|   [types.SET_TOTAL_CUSTOMERS] (state, totalCustomers) { | ||||
|     state.totalCustomers = totalCustomers | ||||
|   }, | ||||
|  | ||||
|   [types.ADD_CUSTOMER] (state, data) { | ||||
|     state.customers.push(data.customer) | ||||
|   }, | ||||
|  | ||||
|   [types.UPDATE_CUSTOMER] (state, data) { | ||||
|     let pos = state.customers.findIndex(customer => customer.id === data.customer.id) | ||||
|  | ||||
|     state.customers[pos] = data.customer | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_CUSTOMER] (state, id) { | ||||
|     let index = state.customers.findIndex(customer => customer.id === id) | ||||
|     state.customers.splice(index, 1) | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_MULTIPLE_CUSTOMERS] (state, selectedCustomers) { | ||||
|     selectedCustomers.forEach((customer) => { | ||||
|       let index = state.customers.findIndex(_cust => _cust.id === customer.id) | ||||
|       state.customers.splice(index, 1) | ||||
|     }) | ||||
|  | ||||
|     state.selectedCustomers = [] | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SELECTED_CUSTOMERS] (state, data) { | ||||
|     state.selectedCustomers = data | ||||
|   }, | ||||
|  | ||||
|   [types.RESET_SELECTED_CUSTOMER] (state, data) { | ||||
|     state.selectedCustomer = null | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SELECT_ALL_STATE] (state, data) { | ||||
|     state.selectAllField = data | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										25
									
								
								resources/assets/js/store/modules/dashboard/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								resources/assets/js/store/modules/dashboard/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | ||||
|  | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const loadData = ({ commit, dispatch, state }, params) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/dashboard`, {params}).then((response) => { | ||||
|       commit(types.SET_INITIAL_DATA, response.data) | ||||
|       commit(types.GET_INITIAL_DATA, true) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const getChart = ({ commit, dispatch, state }) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/dashboard/expense/chart`).then((response) => { | ||||
|       commit(types.SET_INITIAL_DATA, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
							
								
								
									
										26
									
								
								resources/assets/js/store/modules/dashboard/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								resources/assets/js/store/modules/dashboard/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| export const getContacts = (state) => state.contacts | ||||
| export const getInvoices = (state) => state.invoices | ||||
| export const getEstimates = (state) => state.estimates | ||||
| export const getExpenses = (state) => state.expenses | ||||
| export const getRecentInvoices = (state) => state.recentInvoices | ||||
| export const getNewContacts = (state) => state.newContacts | ||||
| export const getTotalDueAmount = (state) => state.totalDueAmount | ||||
|  | ||||
| export const getDueInvoices = (state) => state.dueInvoices | ||||
| export const getRecentEstimates = (state) => state.recentEstimates | ||||
|  | ||||
| export const getLoadedData = (state) => state.isDataLoaded | ||||
|  | ||||
| export const getWeeklyInvoicesCounter = (state) => state.weeklyInvoices.counter | ||||
| export const getWeeklyInvoicesDays = (state) => state.weeklyInvoices.days | ||||
|  | ||||
| export const getChartMonths = (state) => state.chartData.months | ||||
| export const getChartInvoices = (state) => state.chartData.invoiceTotals | ||||
| export const getChartExpenses = (state) => state.chartData.expenseTotals | ||||
| export const getNetProfits = (state) => state.chartData.netProfits | ||||
| export const getReceiptTotals = (state) => state.chartData.receiptTotals | ||||
|  | ||||
| export const getTotalSales = (state) => state.salesTotal | ||||
| export const getTotalReceipts = (state) => state.totalReceipts | ||||
| export const getTotalExpenses = (state) => state.totalExpenses | ||||
| export const getNetProfit = (state) => state.netProfit | ||||
							
								
								
									
										46
									
								
								resources/assets/js/store/modules/dashboard/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								resources/assets/js/store/modules/dashboard/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,46 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   contacts: 0, | ||||
|   invoices: 0, | ||||
|   estimates: 0, | ||||
|   expenses: 0, | ||||
|   totalDueAmount: [], | ||||
|   isDataLoaded: false, | ||||
|  | ||||
|   weeklyInvoices: { | ||||
|     days: [], | ||||
|     counter: [] | ||||
|   }, | ||||
|  | ||||
|   chartData: { | ||||
|     months: [], | ||||
|     invoiceTotals: [], | ||||
|     expenseTotals: [], | ||||
|     netProfits: [], | ||||
|     receiptTotals: [] | ||||
|   }, | ||||
|  | ||||
|   salesTotal: null, | ||||
|   totalReceipts: null, | ||||
|   totalExpenses: null, | ||||
|   netProfit: null, | ||||
|  | ||||
|   dueInvoices: [], | ||||
|   recentEstimates: [], | ||||
|   newContacts: [] | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,2 @@ | ||||
| export const SET_INITIAL_DATA = 'SET_INITIAL_DATA' | ||||
| export const GET_INITIAL_DATA = 'GET_INITIAL_DATA' | ||||
							
								
								
									
										36
									
								
								resources/assets/js/store/modules/dashboard/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								resources/assets/js/store/modules/dashboard/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.SET_INITIAL_DATA] (state, data) { | ||||
|     state.contacts = data.customersCount | ||||
|     state.invoices = data.invoicesCount | ||||
|     state.estimates = data.estimatesCount | ||||
|     state.expenses = data.expenses | ||||
|     state.recentInvoices = data.invoices | ||||
|     state.newContacts = data.contacts | ||||
|     state.totalDueAmount = data.totalDueAmount | ||||
|  | ||||
|     state.dueInvoices = data.dueInvoices | ||||
|     state.recentEstimates = data.estimates | ||||
|  | ||||
|     state.weeklyInvoices.days = data.weekDays | ||||
|     state.weeklyInvoices.counter = data.counters | ||||
|  | ||||
|     if (state.chartData && data.chartData) { | ||||
|       state.chartData.months = data.chartData.months | ||||
|       state.chartData.invoiceTotals = data.chartData.invoiceTotals | ||||
|       state.chartData.expenseTotals = data.chartData.expenseTotals | ||||
|       state.chartData.netProfits = data.chartData.netProfits | ||||
|       state.chartData.receiptTotals = data.chartData.receiptTotals | ||||
|     } | ||||
|  | ||||
|     state.salesTotal = data.salesTotal | ||||
|     state.totalReceipts = data.totalReceipts | ||||
|     state.totalExpenses = data.totalExpenses | ||||
|     state.netProfit = data.netProfit | ||||
|   }, | ||||
|  | ||||
|   [types.GET_INITIAL_DATA] (state, data) { | ||||
|     state.isDataLoaded = data | ||||
|   } | ||||
| } | ||||
							
								
								
									
										231
									
								
								resources/assets/js/store/modules/estimate/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										231
									
								
								resources/assets/js/store/modules/estimate/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,231 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const fetchEstimates = ({ commit, dispatch, state }, params) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/estimates`, {params}).then((response) => { | ||||
|       commit(types.SET_ESTIMATES, response.data.estimates.data) | ||||
|       commit(types.SET_TOTAL_ESTIMATES, response.data.estimateTotalCount) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const getRecord = ({ commit, dispatch, state }, record) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/estimates/records?record=${record}`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const fetchCreateEstimate = ({ commit, dispatch, state }) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/estimates/create`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const fetchEstimate = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/estimates/${id}/edit`).then((response) => { | ||||
|       commit(types.SET_TEMPLATE_ID, response.data.estimate.estimate_template_id) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const fetchViewEstimate = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/estimates/${id}`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const sendEmail = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/estimates/send`, data).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const addEstimate = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post('/api/estimates', data).then((response) => { | ||||
|       commit(types.ADD_ESTIMATE, response.data.estimate) | ||||
|  | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const deleteEstimate = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.delete(`/api/estimates/${id}`).then((response) => { | ||||
|       commit(types.DELETE_ESTIMATE, id) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const deleteMultipleEstimates = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/estimates/delete`, {'id': state.selectedEstimates}).then((response) => { | ||||
|       commit(types.DELETE_MULTIPLE_ESTIMATES, state.selectedEstimates) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const updateEstimate = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.put(`/api/estimates/${data.id}`, data).then((response) => { | ||||
|       commit(types.UPDATE_ESTIMATE, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const markAsAccepted = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/estimates/accept`, data).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const markAsRejected = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/estimates/reject`, data).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const markAsSent = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/estimates/sent`, data).then((response) => { | ||||
|       // commit(types.UPDATE_INVOICE, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const convertToInvoice = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/estimates/${id}/convert-to-invoice`).then((response) => { | ||||
|       // commit(types.UPDATE_INVOICE, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const searchEstimate = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/estimates?${data}`).then((response) => { | ||||
|       // commit(types.UPDATE_INVOICE, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const selectEstimate = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_SELECTED_ESTIMATES, data) | ||||
|   if (state.selectedEstimates.length === state.estimates.length) { | ||||
|     commit(types.SET_SELECT_ALL_STATE, true) | ||||
|   } else { | ||||
|     commit(types.SET_SELECT_ALL_STATE, false) | ||||
|   } | ||||
| } | ||||
|  | ||||
| export const setSelectAllState = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_SELECT_ALL_STATE, data) | ||||
| } | ||||
|  | ||||
| export const selectAllEstimates = ({ commit, dispatch, state }) => { | ||||
|   if (state.selectedEstimates.length === state.estimates.length) { | ||||
|     commit(types.SET_SELECTED_ESTIMATES, []) | ||||
|     commit(types.SET_SELECT_ALL_STATE, false) | ||||
|   } else { | ||||
|     let allEstimateIds = state.estimates.map(estimt => estimt.id) | ||||
|     commit(types.SET_SELECTED_ESTIMATES, allEstimateIds) | ||||
|     commit(types.SET_SELECT_ALL_STATE, true) | ||||
|   } | ||||
| } | ||||
|  | ||||
| export const resetSelectedEstimates = ({ commit, dispatch, state }) => { | ||||
|   commit(types.RESET_SELECTED_ESTIMATES) | ||||
| } | ||||
|  | ||||
| export const setCustomer = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.RESET_CUSTOMER) | ||||
|   commit(types.SET_CUSTOMER, data) | ||||
| } | ||||
|  | ||||
| export const setItem = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.RESET_ITEM) | ||||
|   commit(types.SET_ITEM, data) | ||||
| } | ||||
|  | ||||
| export const resetCustomer = ({ commit, dispatch, state }) => { | ||||
|   commit(types.RESET_CUSTOMER) | ||||
| } | ||||
|  | ||||
| export const resetItem = ({ commit, dispatch, state }) => { | ||||
|   commit(types.RESET_ITEM) | ||||
| } | ||||
|  | ||||
| export const setTemplate = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     commit(types.SET_TEMPLATE_ID, data) | ||||
|     resolve({}) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const selectCustomer = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/customers/${id}`).then((response) => { | ||||
|       commit(types.RESET_SELECTED_CUSTOMER) | ||||
|       commit(types.SELECT_CUSTOMER, response.data.customer) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const resetSelectedCustomer = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.RESET_SELECTED_CUSTOMER) | ||||
| } | ||||
							
								
								
									
										6
									
								
								resources/assets/js/store/modules/estimate/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								resources/assets/js/store/modules/estimate/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| export const estimates = (state) => state.estimates | ||||
| export const selectAllField = (state) => state.selectAllField | ||||
| export const getTemplateId = (state) => state.estimateTemplateId | ||||
| export const selectedEstimates = (state) => state.selectedEstimates | ||||
| export const totalEstimates = (state) => state.totalEstimates | ||||
| export const selectedCustomer = (state) => state.selectedCustomer | ||||
							
								
								
									
										24
									
								
								resources/assets/js/store/modules/estimate/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								resources/assets/js/store/modules/estimate/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   estimates: [], | ||||
|   estimateTemplateId: 1, | ||||
|   selectAllField: false, | ||||
|   selectedEstimates: [], | ||||
|   totalEstimates: 0, | ||||
|   selectedCustomer: null | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
							
								
								
									
										16
									
								
								resources/assets/js/store/modules/estimate/mutation-types.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								resources/assets/js/store/modules/estimate/mutation-types.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | ||||
| export const SET_ESTIMATES = 'SET_ESTIMATES' | ||||
| export const ADD_ESTIMATE = 'ADD_ESTIMATE' | ||||
| export const UPDATE_ESTIMATE = 'UPDATE_ESTIMATE' | ||||
| export const DELETE_ESTIMATE = 'DELETE_ESTIMATE' | ||||
| export const DELETE_MULTIPLE_ESTIMATES = 'DELETE_MULTIPLE_ESTIMATES' | ||||
| export const SET_SELECTED_ESTIMATES = 'SET_SELECTED_ESTIMATES' | ||||
| export const SET_TOTAL_ESTIMATES = 'SET_TOTAL_ESTIMATES' | ||||
| export const RESET_CUSTOMER = 'RESET_CUSTOMER' | ||||
| export const RESET_ITEM = 'RESET_ITEM' | ||||
| export const SET_CUSTOMER = 'SET_CUSTOMER' | ||||
| export const SET_ITEM = 'SET_ITEM' | ||||
| export const SET_TEMPLATE_ID = 'SET_TEMPLATE_ID' | ||||
| export const SELECT_CUSTOMER = 'SELECT_CUSTOMER' | ||||
| export const RESET_SELECTED_CUSTOMER = 'RESET_SELECTED_CUSTOMER' | ||||
| export const SET_SELECT_ALL_STATE = 'SET_SELECT_ALL_STATE' | ||||
| export const RESET_SELECTED_ESTIMATES = 'RESET_SELECTED_ESTIMATES' | ||||
							
								
								
									
										60
									
								
								resources/assets/js/store/modules/estimate/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								resources/assets/js/store/modules/estimate/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,60 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.SET_ESTIMATES] (state, data) { | ||||
|     state.estimates = data | ||||
|   }, | ||||
|  | ||||
|   [types.SET_TOTAL_ESTIMATES] (state, totalEstimates) { | ||||
|     state.totalEstimates = totalEstimates | ||||
|   }, | ||||
|  | ||||
|   [types.ADD_ESTIMATE] (state, data) { | ||||
|     state.estimates = [...state.estimates, data] | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_ESTIMATE] (state, id) { | ||||
|     let index = state.estimates.findIndex(estimate => estimate.id === id) | ||||
|     state.estimates.splice(index, 1) | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SELECTED_ESTIMATES] (state, data) { | ||||
|     state.selectedEstimates = data | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_MULTIPLE_ESTIMATES] (state, selectedEstimates) { | ||||
|     selectedEstimates.forEach((estimate) => { | ||||
|       let index = state.estimates.findIndex(_est => _est.id === estimate.id) | ||||
|       state.estimates.splice(index, 1) | ||||
|     }) | ||||
|  | ||||
|     state.selectedEstimates = [] | ||||
|   }, | ||||
|  | ||||
|   [types.UPDATE_ESTIMATE] (state, data) { | ||||
|     let pos = state.estimates.findIndex(estimate => estimate.id === data.estimate.id) | ||||
|  | ||||
|     state.estimates[pos] = data.estimate | ||||
|   }, | ||||
|  | ||||
|   [types.RESET_SELECTED_ESTIMATES] (state, data) { | ||||
|     state.selectedEstimates = [] | ||||
|     state.selectAllField = false | ||||
|   }, | ||||
|  | ||||
|   [types.SET_TEMPLATE_ID] (state, templateId) { | ||||
|     state.estimateTemplateId = templateId | ||||
|   }, | ||||
|  | ||||
|   [types.SELECT_CUSTOMER] (state, data) { | ||||
|     state.selectedCustomer = data | ||||
|   }, | ||||
|  | ||||
|   [types.RESET_SELECTED_CUSTOMER] (state, data) { | ||||
|     state.selectedCustomer = null | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SELECT_ALL_STATE] (state, data) { | ||||
|     state.selectAllField = data | ||||
|   } | ||||
| } | ||||
							
								
								
									
										101
									
								
								resources/assets/js/store/modules/expense/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								resources/assets/js/store/modules/expense/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,101 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const fetchExpenses = ({ commit, dispatch, state }, params) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/expenses`, {params}).then((response) => { | ||||
|       commit(types.SET_EXPENSES, response.data.expenses.data) | ||||
|       commit(types.SET_TOTAL_EXPENSES, response.data.expenses.total) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const fetchCreateExpense = ({ commit, dispatch, state }) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/expenses/create`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const fetchExpense = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/expenses/${id}/edit`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const addExpense = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post('/api/expenses', data).then((response) => { | ||||
|       // commit(types.ADD_EXPENSE, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const updateExpense = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/expenses/${data.id}`, data.editData).then((response) => { | ||||
|       commit(types.UPDATE_EXPENSE, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const deleteExpense = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.delete(`/api/expenses/${id}`).then((response) => { | ||||
|       commit(types.DELETE_EXPENSE, id) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const deleteMultipleExpenses = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/expenses/delete`, {'id': state.selectedExpenses}).then((response) => { | ||||
|       commit(types.DELETE_MULTIPLE_EXPENSES, state.selectedExpenses) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const setSelectAllState = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_SELECT_ALL_STATE, data) | ||||
| } | ||||
|  | ||||
| export const selectAllExpenses = ({ commit, dispatch, state }) => { | ||||
|   if (state.selectedExpenses.length === state.expenses.length) { | ||||
|     commit(types.SET_SELECTED_EXPENSES, []) | ||||
|     commit(types.SET_SELECT_ALL_STATE, false) | ||||
|   } else { | ||||
|     let allExpenseIds = state.expenses.map(cust => cust.id) | ||||
|     commit(types.SET_SELECTED_EXPENSES, allExpenseIds) | ||||
|     commit(types.SET_SELECT_ALL_STATE, true) | ||||
|   } | ||||
| } | ||||
|  | ||||
| export const selectExpense = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_SELECTED_EXPENSES, data) | ||||
|   if (state.selectedExpenses.length === state.expenses.length) { | ||||
|     commit(types.SET_SELECT_ALL_STATE, true) | ||||
|   } else { | ||||
|     commit(types.SET_SELECT_ALL_STATE, false) | ||||
|   } | ||||
| } | ||||
							
								
								
									
										4
									
								
								resources/assets/js/store/modules/expense/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								resources/assets/js/store/modules/expense/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| export const expenses = (state) => state.expenses | ||||
| export const selectAllField = (state) => state.selectAllField | ||||
| export const selectedExpenses = (state) => state.selectedExpenses | ||||
| export const totalExpenses = (state) => state.totalExpenses | ||||
							
								
								
									
										22
									
								
								resources/assets/js/store/modules/expense/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								resources/assets/js/store/modules/expense/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   expenses: [], | ||||
|   totalExpenses: 0, | ||||
|   selectAllField: false, | ||||
|   selectedExpenses: [] | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,9 @@ | ||||
| export const SET_EXPENSES = 'SET_EXPENSES' | ||||
| export const ADD_EXPENSE = 'ADD_EXPENSE' | ||||
| export const UPDATE_EXPENSE = 'UPDATE_EXPENSE' | ||||
| export const SET_SELECT_ALL = 'SET_SELECT_ALL' | ||||
| export const DELETE_EXPENSE = 'DELETE_EXPENSE' | ||||
| export const DELETE_MULTIPLE_EXPENSES = 'DELETE_MULTIPLE_EXPENSES' | ||||
| export const SET_SELECTED_EXPENSES = 'SET_SELECTED_EXPENSES' | ||||
| export const SET_TOTAL_EXPENSES = 'SET_TOTAL_EXPENSES' | ||||
| export const SET_SELECT_ALL_STATE = 'SET_SELECT_ALL_STATE' | ||||
							
								
								
									
										58
									
								
								resources/assets/js/store/modules/expense/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								resources/assets/js/store/modules/expense/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,58 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.SET_EXPENSES] (state, expenses) { | ||||
|     state.expenses = expenses | ||||
|   }, | ||||
|  | ||||
|   [types.ADD_EXPENSE] (state, expense) { | ||||
|     state.expenses.push(expense) | ||||
|   }, | ||||
|  | ||||
|   [types.UPDATE_EXPENSE] (state, data) { | ||||
|     let pos = state.expenses.findIndex(expense => expense.id === data.expense.id) | ||||
|  | ||||
|     state.expenses[pos] = data.expense | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_EXPENSE] (state, id) { | ||||
|     let index = state.expenses.findIndex(expense => expense.id === id) | ||||
|     state.expenses.splice(index, 1) | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SELECT_ALL] (state, selectAll) { | ||||
|     if (selectAll) { | ||||
|       state.expenses.filter(expense => { | ||||
|         state.selectedRow.push(expense.id) | ||||
|       }) | ||||
|     } else { | ||||
|       state.selectedRow = [] | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|   [types.SET_TOTAL_EXPENSES] (state, totalExpenses) { | ||||
|     state.totalExpenses = totalExpenses | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_EXPENSE] (state, id) { | ||||
|     let index = state.expenses.findIndex(expense => expense.id === id) | ||||
|     state.expenses.splice(index, 1) | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_MULTIPLE_EXPENSES] (state, selectedExpenses) { | ||||
|     selectedExpenses.forEach((expense) => { | ||||
|       let index = state.expenses.findIndex(_exp => _exp.id === expense.id) | ||||
|       state.expenses.splice(index, 1) | ||||
|     }) | ||||
|  | ||||
|     state.selectedExpenses = [] | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SELECTED_EXPENSES] (state, data) { | ||||
|     state.selectedExpenses = data | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SELECT_ALL_STATE] (state, data) { | ||||
|     state.selectAllField = data | ||||
|   } | ||||
| } | ||||
							
								
								
									
										196
									
								
								resources/assets/js/store/modules/invoice/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										196
									
								
								resources/assets/js/store/modules/invoice/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,196 @@ | ||||
| import * as types from './mutation-types' | ||||
| // import moment from 'moment' | ||||
|  | ||||
| export const fetchInvoices = ({ commit, dispatch, state }, params) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/invoices`, {params}).then((response) => { | ||||
|       commit(types.SET_INVOICES, response.data.invoices.data) | ||||
|       commit(types.SET_TOTAL_INVOICES, response.data.invoiceTotalCount) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const fetchCreateInvoice = ({ commit, dispatch, state }) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/invoices/create`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const fetchInvoice = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/invoices/${id}/edit`).then((response) => { | ||||
|       commit(types.SET_TEMPLATE_ID, response.data.invoice.invoice_template_id) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const fetchViewInvoice = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/invoices/${id}`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const sendEmail = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/invoices/send`, data).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| // export const SentEmail = ({ commit, dispatch, state }, invoiceId) => { | ||||
| //   return new Promise((resolve, reject) => { | ||||
| //     window.axios.post(`/api/invoices/sent/${invoiceId}`).then((response) => { | ||||
| //       resolve(response) | ||||
| //     }).catch((err) => { | ||||
| //       reject(err) | ||||
| //     }) | ||||
| //   }) | ||||
| // } | ||||
|  | ||||
| export const addInvoice = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post('/api/invoices', data).then((response) => { | ||||
|       commit(types.ADD_INVOICE, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const deleteInvoice = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.delete(`/api/invoices/${id}`).then((response) => { | ||||
|       commit(types.DELETE_INVOICE, id) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const deleteMultipleInvoices = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/invoices/delete`, {'id': state.selectedInvoices}).then((response) => { | ||||
|       if (response.data.error) { | ||||
|         resolve(response) | ||||
|       } else { | ||||
|         commit(types.DELETE_MULTIPLE_INVOICES, state.selectedInvoices) | ||||
|         resolve(response) | ||||
|       } | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const updateInvoice = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.put(`/api/invoices/${data.id}`, data).then((response) => { | ||||
|       if (response.data.invoice) { | ||||
|         commit(types.UPDATE_INVOICE, response.data) | ||||
|       } | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const markAsSent = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/invoices/mark-as-sent`, data).then((response) => { | ||||
|       // commit(types.UPDATE_INVOICE, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const searchInvoice = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/invoices?${data}`).then((response) => { | ||||
|       // commit(types.UPDATE_INVOICE, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const selectInvoice = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_SELECTED_INVOICES, data) | ||||
|   if (state.selectedInvoices.length === state.invoices.length) { | ||||
|     commit(types.SET_SELECT_ALL_STATE, true) | ||||
|   } else { | ||||
|     commit(types.SET_SELECT_ALL_STATE, false) | ||||
|   } | ||||
| } | ||||
|  | ||||
| export const setSelectAllState = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_SELECT_ALL_STATE, data) | ||||
| } | ||||
|  | ||||
| export const selectAllInvoices = ({ commit, dispatch, state }) => { | ||||
|   if (state.selectedInvoices.length === state.invoices.length) { | ||||
|     commit(types.SET_SELECTED_INVOICES, []) | ||||
|     commit(types.SET_SELECT_ALL_STATE, false) | ||||
|   } else { | ||||
|     let allInvoiceIds = state.invoices.map(inv => inv.id) | ||||
|     commit(types.SET_SELECTED_INVOICES, allInvoiceIds) | ||||
|     commit(types.SET_SELECT_ALL_STATE, true) | ||||
|   } | ||||
| } | ||||
|  | ||||
| export const resetSelectedInvoices = ({ commit, dispatch, state }) => { | ||||
|   commit(types.RESET_SELECTED_INVOICES) | ||||
| } | ||||
| export const setCustomer = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.RESET_CUSTOMER) | ||||
|   commit(types.SET_CUSTOMER, data) | ||||
| } | ||||
|  | ||||
| export const resetCustomer = ({ commit, dispatch, state }) => { | ||||
|   commit(types.RESET_CUSTOMER) | ||||
| } | ||||
|  | ||||
| export const setTemplate = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     commit(types.SET_TEMPLATE_ID, data) | ||||
|     resolve({}) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const selectCustomer = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/customers/${id}`).then((response) => { | ||||
|       commit(types.RESET_SELECTED_CUSTOMER) | ||||
|       commit(types.SELECT_CUSTOMER, response.data.customer) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const resetSelectedCustomer = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.RESET_SELECTED_CUSTOMER) | ||||
| } | ||||
							
								
								
									
										6
									
								
								resources/assets/js/store/modules/invoice/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								resources/assets/js/store/modules/invoice/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| export const invoices = (state) => state.invoices | ||||
| export const selectAllField = (state) => state.selectAllField | ||||
| export const getTemplateId = (state) => state.invoiceTemplateId | ||||
| export const selectedInvoices = (state) => state.selectedInvoices | ||||
| export const totalInvoices = (state) => state.totalInvoices | ||||
| export const selectedCustomer = (state) => state.selectedCustomer | ||||
							
								
								
									
										24
									
								
								resources/assets/js/store/modules/invoice/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								resources/assets/js/store/modules/invoice/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   invoices: [], | ||||
|   invoiceTemplateId: 1, | ||||
|   selectedInvoices: [], | ||||
|   selectAllField: false, | ||||
|   totalInvoices: 0, | ||||
|   selectedCustomer: null | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
							
								
								
									
										16
									
								
								resources/assets/js/store/modules/invoice/mutation-types.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								resources/assets/js/store/modules/invoice/mutation-types.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | ||||
| export const SET_INVOICES = 'SET_INVOICES' | ||||
| export const ADD_INVOICE = 'ADD_INVOICE' | ||||
| export const UPDATE_INVOICE = 'UPDATE_INVOICE' | ||||
| export const DELETE_INVOICE = 'DELETE_INVOICE' | ||||
| export const DELETE_MULTIPLE_INVOICES = 'DELETE_MULTIPLE_INVOICES' | ||||
| export const SET_SELECTED_INVOICES = 'SET_SELECTED_INVOICES' | ||||
| export const SET_TOTAL_INVOICES = 'SET_TOTAL_INVOICES' | ||||
| export const RESET_CUSTOMER = 'RESET_CUSTOMER' | ||||
| export const RESET_ITEM = 'RESET_ITEM' | ||||
| export const SET_CUSTOMER = 'SET_CUSTOMER' | ||||
| export const SET_ITEM = 'SET_ITEM' | ||||
| export const SET_TEMPLATE_ID = 'SET_TEMPLATE_ID' | ||||
| export const SELECT_CUSTOMER = 'SELECT_CUSTOMER' | ||||
| export const RESET_SELECTED_CUSTOMER = 'RESET_SELECTED_CUSTOMER' | ||||
| export const SET_SELECT_ALL_STATE = 'SET_SELECT_ALL_STATE' | ||||
| export const RESET_SELECTED_INVOICES = 'RESET_SELECTED_INVOICES' | ||||
							
								
								
									
										59
									
								
								resources/assets/js/store/modules/invoice/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								resources/assets/js/store/modules/invoice/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,59 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.SET_INVOICES] (state, invoices) { | ||||
|     state.invoices = invoices | ||||
|   }, | ||||
|  | ||||
|   [types.SET_TOTAL_INVOICES] (state, totalInvoices) { | ||||
|     state.totalInvoices = totalInvoices | ||||
|   }, | ||||
|  | ||||
|   [types.ADD_INVOICE] (state, data) { | ||||
|     state.invoices.push(data) | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_INVOICE] (state, id) { | ||||
|     let index = state.invoices.findIndex(invoice => invoice.id === id) | ||||
|     state.invoices.splice(index, 1) | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SELECTED_INVOICES] (state, data) { | ||||
|     state.selectedInvoices = data | ||||
|   }, | ||||
|  | ||||
|   [types.UPDATE_INVOICE] (state, data) { | ||||
|     let pos = state.invoices.findIndex(invoice => invoice.id === data.invoice.id) | ||||
|  | ||||
|     state.invoices[pos] = data.invoice | ||||
|   }, | ||||
|  | ||||
|   [types.RESET_SELECTED_INVOICES] (state, data) { | ||||
|     state.selectedInvoices = [] | ||||
|     state.selectAllField = false | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_MULTIPLE_INVOICES] (state, selectedInvoices) { | ||||
|     selectedInvoices.forEach((invoice) => { | ||||
|       let index = state.invoices.findIndex(_inv => _inv.id === invoice.id) | ||||
|       state.invoices.splice(index, 1) | ||||
|     }) | ||||
|     state.selectedInvoices = [] | ||||
|   }, | ||||
|  | ||||
|   [types.SET_TEMPLATE_ID] (state, templateId) { | ||||
|     state.invoiceTemplateId = templateId | ||||
|   }, | ||||
|  | ||||
|   [types.SELECT_CUSTOMER] (state, data) { | ||||
|     state.selectedCustomer = data | ||||
|   }, | ||||
|  | ||||
|   [types.RESET_SELECTED_CUSTOMER] (state, data) { | ||||
|     state.selectedCustomer = null | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SELECT_ALL_STATE] (state, data) { | ||||
|     state.selectAllField = data | ||||
|   } | ||||
| } | ||||
							
								
								
									
										92
									
								
								resources/assets/js/store/modules/item/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								resources/assets/js/store/modules/item/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,92 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const fetchItems = ({ commit, dispatch, state }, params) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/items`, {params}).then((response) => { | ||||
|       commit(types.BOOTSTRAP_ITEMS, response.data.items.data) | ||||
|       commit(types.SET_TOTAL_ITEMS, response.data.items.total) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const fetchItem = ({ commit, dispatch }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/items/${id}/edit`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const addItem = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post('/api/items', data).then((response) => { | ||||
|       commit(types.ADD_ITEM, response.data) | ||||
|  | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const updateItem = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.put(`/api/items/${data.id}`, data).then((response) => { | ||||
|       commit(types.UPDATE_ITEM, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const deleteItem = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.delete(`/api/items/${id}`).then((response) => { | ||||
|       commit(types.DELETE_ITEM, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const deleteMultipleItems = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/items/delete`, {'id': state.selectedItems}).then((response) => { | ||||
|       commit(types.DELETE_MULTIPLE_ITEMS, state.selectedItems) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const setSelectAllState = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_SELECT_ALL_STATE, data) | ||||
| } | ||||
|  | ||||
| export const selectAllItems = ({ commit, dispatch, state }) => { | ||||
|   if (state.selectedItems.length === state.items.length) { | ||||
|     commit(types.SET_SELECTED_ITEMS, []) | ||||
|     commit(types.SET_SELECT_ALL_STATE, false) | ||||
|   } else { | ||||
|     let allItemIds = state.items.map(item => item.id) | ||||
|     commit(types.SET_SELECTED_ITEMS, allItemIds) | ||||
|     commit(types.SET_SELECT_ALL_STATE, true) | ||||
|   } | ||||
| } | ||||
|  | ||||
| export const selectItem = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_SELECTED_ITEMS, data) | ||||
|   if (state.selectedItems.length === state.items.length) { | ||||
|     commit(types.SET_SELECT_ALL_STATE, true) | ||||
|   } else { | ||||
|     commit(types.SET_SELECT_ALL_STATE, false) | ||||
|   } | ||||
| } | ||||
							
								
								
									
										4
									
								
								resources/assets/js/store/modules/item/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								resources/assets/js/store/modules/item/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| export const items = (state) => state.items | ||||
| export const selectAllField = (state) => state.selectAllField | ||||
| export const selectedItems = (state) => state.selectedItems | ||||
| export const totalItems = (state) => state.totalItems | ||||
							
								
								
									
										22
									
								
								resources/assets/js/store/modules/item/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								resources/assets/js/store/modules/item/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   items: [], | ||||
|   totalItems: 0, | ||||
|   selectAllField: false, | ||||
|   selectedItems: [] | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
							
								
								
									
										8
									
								
								resources/assets/js/store/modules/item/mutation-types.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								resources/assets/js/store/modules/item/mutation-types.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| export const BOOTSTRAP_ITEMS = 'BOOTSTRAP_ITEMS' | ||||
| export const ADD_ITEM = 'ADD_ITEM' | ||||
| export const UPDATE_ITEM = 'UPDATE_ITEM' | ||||
| export const DELETE_ITEM = 'DELETE_ITEM' | ||||
| export const DELETE_MULTIPLE_ITEMS = 'DELETE_MULTIPLE_ITEMS' | ||||
| export const SET_SELECTED_ITEMS = 'SET_SELECTED_ITEMS' | ||||
| export const SET_TOTAL_ITEMS = 'SET_TOTAL_ITEMS' | ||||
| export const SET_SELECT_ALL_STATE = 'SET_SELECT_ALL_STATE' | ||||
							
								
								
									
										44
									
								
								resources/assets/js/store/modules/item/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								resources/assets/js/store/modules/item/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,44 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.BOOTSTRAP_ITEMS] (state, items) { | ||||
|     state.items = items | ||||
|   }, | ||||
|  | ||||
|   [types.SET_TOTAL_ITEMS] (state, totalItems) { | ||||
|     state.totalItems = totalItems | ||||
|   }, | ||||
|  | ||||
|   [types.ADD_ITEM] (state, data) { | ||||
|     state.items.push(data.item) | ||||
|   }, | ||||
|  | ||||
|   [types.UPDATE_ITEM] (state, data) { | ||||
|     let pos = state.items.findIndex(item => item.id === data.item.id) | ||||
|  | ||||
|     state.items[pos] = data.item | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_ITEM] (state, id) { | ||||
|     let index = state.items.findIndex(item => item.id === id) | ||||
|     state.items.splice(index, 1) | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_MULTIPLE_ITEMS] (state, selectedItems) { | ||||
|     selectedItems.forEach((item) => { | ||||
|       let index = state.items.findIndex(_item => _item.id === item.id) | ||||
|       state.items.splice(index, 1) | ||||
|     }) | ||||
|  | ||||
|     state.selectedItems = [] | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SELECTED_ITEMS] (state, data) { | ||||
|     state.selectedItems = data | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SELECT_ALL_STATE] (state, data) { | ||||
|     state.selectAllField = data | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										28
									
								
								resources/assets/js/store/modules/modal/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								resources/assets/js/store/modules/modal/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const openModal = ({ commit, dispatch, state }, payload) => { | ||||
|   commit(types.SET_COMPONENT_NAME, payload.componentName) | ||||
|   commit(types.SHOW_MODAL, true) | ||||
|  | ||||
|   if (payload.id) { | ||||
|     commit(types.SET_ID, payload.id) | ||||
|   } | ||||
|   commit(types.SET_TITLE, payload.title) | ||||
|  | ||||
|   if (payload.data) { | ||||
|     commit(types.SET_DATA, payload.data) | ||||
|   } | ||||
|  | ||||
|   if (payload.size) { | ||||
|     commit(types.SET_SIZE, payload.size) | ||||
|   } | ||||
| } | ||||
|  | ||||
| export const closeModal = ({ commit, dispatch, state }) => { | ||||
|   commit(types.RESET_DATA) | ||||
|   commit(types.HIDE_MODAL, false) | ||||
| } | ||||
|  | ||||
| export const resetModalData = ({ commit, dispatch, state }) => { | ||||
|   commit(types.RESET_DATA) | ||||
| } | ||||
							
								
								
									
										6
									
								
								resources/assets/js/store/modules/modal/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								resources/assets/js/store/modules/modal/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| export const modalActive = state => state.active | ||||
| export const modalTitle = state => state.title | ||||
| export const componentName = state => state.componentName | ||||
| export const modalDataID = state => state.id | ||||
| export const modalData = state => state.data | ||||
| export const modalSize = state => state.size | ||||
							
								
								
									
										25
									
								
								resources/assets/js/store/modules/modal/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								resources/assets/js/store/modules/modal/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   active: false, | ||||
|   content: '', | ||||
|   title: '', | ||||
|   componentName: '', | ||||
|   id: '', | ||||
|   size: 'md', | ||||
|   data: null | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,8 @@ | ||||
| export const SHOW_MODAL = 'SHOW_MODAL' | ||||
| export const SET_TITLE = 'SET_TITLE' | ||||
| export const SET_COMPONENT_NAME = 'SET_COMPONENT_NAME' | ||||
| export const HIDE_MODAL = 'HIDE_MODAL' | ||||
| export const SET_ID = 'SET_ID' | ||||
| export const SET_SIZE = 'SET_SIZE' | ||||
| export const SET_DATA = 'SET_DATA' | ||||
| export const RESET_DATA = 'RESET_DATA' | ||||
							
								
								
									
										40
									
								
								resources/assets/js/store/modules/modal/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								resources/assets/js/store/modules/modal/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.SHOW_MODAL] (state, data) { | ||||
|     state.active = data | ||||
|   }, | ||||
|  | ||||
|   [types.HIDE_MODAL] (state, data) { | ||||
|     state.active = data | ||||
|   }, | ||||
|  | ||||
|   [types.SET_TITLE] (state, data) { | ||||
|     state.title = data | ||||
|   }, | ||||
|  | ||||
|   [types.SET_COMPONENT_NAME] (state, data) { | ||||
|     state.componentName = data | ||||
|   }, | ||||
|  | ||||
|   [types.SET_ID] (state, data) { | ||||
|     state.id = data | ||||
|   }, | ||||
|  | ||||
|   [types.SET_DATA] (state, data) { | ||||
|     state.data = data | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SIZE] (state, size) { | ||||
|     state.size = size | ||||
|   }, | ||||
|  | ||||
|   [types.RESET_DATA] (state) { | ||||
|     state.active = false | ||||
|     state.content = '' | ||||
|     state.title = '' | ||||
|     state.componentName = '' | ||||
|     state.id = '' | ||||
|     state.data = null | ||||
|   } | ||||
| } | ||||
							
								
								
									
										99
									
								
								resources/assets/js/store/modules/payment/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								resources/assets/js/store/modules/payment/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,99 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const fetchPayments = ({ commit, dispatch, state }, params) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/payments`, {params}).then((response) => { | ||||
|       commit(types.SET_PAYMENTS, response.data.payments.data) | ||||
|       commit(types.SET_TOTAL_PAYMENTS, response.data.payments.total) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const fetchCreatePayment = ({ commit, dispatch }, page) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/payments/create`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const fetchPayment = ({ commit, dispatch }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/payments/${id}/edit`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const addPayment = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post('/api/payments', data).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const setSelectAllState = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_SELECT_ALL_STATE, data) | ||||
| } | ||||
|  | ||||
| export const selectPayment = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_SELECTED_PAYMENTS, data) | ||||
|   if (state.selectedPayments.length === state.payments.length) { | ||||
|     commit(types.SET_SELECT_ALL_STATE, true) | ||||
|   } else { | ||||
|     commit(types.SET_SELECT_ALL_STATE, false) | ||||
|   } | ||||
| } | ||||
|  | ||||
| export const updatePayment = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.put(`/api/payments/${data.id}`, data.editData).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const deletePayment = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.delete(`/api/payments/${id}`).then((response) => { | ||||
|       commit(types.DELETE_PAYMENT, id) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const deleteMultiplePayments = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post(`/api/payments/delete`, {'id': state.selectedPayments}).then((response) => { | ||||
|       commit(types.DELETE_MULTIPLE_PAYMENTS, state.selectedPayments) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const selectAllPayments = ({ commit, dispatch, state }) => { | ||||
|   if (state.selectedPayments.length === state.payments.length) { | ||||
|     commit(types.SET_SELECTED_PAYMENTS, []) | ||||
|     commit(types.SET_SELECT_ALL_STATE, false) | ||||
|   } else { | ||||
|     let allPaymentIds = state.payments.map(pay => pay.id) | ||||
|     commit(types.SET_SELECTED_PAYMENTS, allPaymentIds) | ||||
|     commit(types.SET_SELECT_ALL_STATE, true) | ||||
|   } | ||||
| } | ||||
							
								
								
									
										4
									
								
								resources/assets/js/store/modules/payment/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								resources/assets/js/store/modules/payment/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| export const payments = (state) => state.payments | ||||
| export const selectedPayments = (state) => state.selectedPayments | ||||
| export const selectAllField = (state) => state.selectAllField | ||||
| export const totalPayments = (state) => state.totalPayments | ||||
							
								
								
									
										22
									
								
								resources/assets/js/store/modules/payment/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								resources/assets/js/store/modules/payment/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   payments: [], | ||||
|   totalPayments: 0, | ||||
|   selectAllField: false, | ||||
|   selectedPayments: [] | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,8 @@ | ||||
| export const SET_PAYMENTS = 'SET_PAYMENTS' | ||||
| export const ADD_PAYMENT = 'ADD_PAYMENT' | ||||
| export const UPDATE_PAYMENT = 'UPDATE_PAYMENT' | ||||
| export const DELETE_PAYMENT = 'DELETE_PAYMENT' | ||||
| export const DELETE_MULTIPLE_PAYMENTS = 'DELETE_MULTIPLE_PAYMENTS' | ||||
| export const SET_SELECTED_PAYMENTS = 'SET_SELECTED_PAYMENTS' | ||||
| export const SET_TOTAL_PAYMENTS = 'SET_TOTAL_PAYMENTS' | ||||
| export const SET_SELECT_ALL_STATE = 'SET_SELECT_ALL_STATE' | ||||
							
								
								
									
										37
									
								
								resources/assets/js/store/modules/payment/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								resources/assets/js/store/modules/payment/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.SET_PAYMENTS] (state, payments) { | ||||
|     state.payments = payments | ||||
|   }, | ||||
|  | ||||
|   [types.SET_TOTAL_PAYMENTS] (state, totalPayments) { | ||||
|     state.totalPayments = totalPayments | ||||
|   }, | ||||
|  | ||||
|   [types.ADD_PAYMENT] (state, data) { | ||||
|     state.payments.push(data) | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_PAYMENT] (state, id) { | ||||
|     let index = state.payments.findIndex(payment => payment.id === id) | ||||
|     state.payments.splice(index, 1) | ||||
|   }, | ||||
|  | ||||
|   [types.DELETE_MULTIPLE_PAYMENTS] (state, selectedPayments) { | ||||
|     selectedPayments.forEach((payment) => { | ||||
|       let index = state.payments.findIndex(_inv => _inv.id === payment.id) | ||||
|       state.payments.splice(index, 1) | ||||
|     }) | ||||
|  | ||||
|     state.selectedPayments = [] | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SELECTED_PAYMENTS] (state, data) { | ||||
|     state.selectedPayments = data | ||||
|   }, | ||||
|  | ||||
|   [types.SET_SELECT_ALL_STATE] (state, data) { | ||||
|     state.selectAllField = data | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,12 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const loadEstimateData = ({ commit, dispatch, state }) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get('/api/report/estimate').then((response) => { | ||||
|       commit(types.SET_ESTIMATES, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
| export const estimates = (state) => state.estimates | ||||
							
								
								
									
										19
									
								
								resources/assets/js/store/modules/reports/estimate/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								resources/assets/js/store/modules/reports/estimate/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   estimates: [] | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
| export const SET_ESTIMATES = 'SET_ESTIMATES' | ||||
| @ -0,0 +1,7 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.SET_ESTIMATES] (state, data) { | ||||
|     state.estimates = data.estimates | ||||
|   } | ||||
| } | ||||
							
								
								
									
										11
									
								
								resources/assets/js/store/modules/reports/expense/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								resources/assets/js/store/modules/reports/expense/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const loadExpensesLink = ({ commit, dispatch, state }, url) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/reports/expenses/link`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
							
								
								
									
										19
									
								
								resources/assets/js/store/modules/reports/expense/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								resources/assets/js/store/modules/reports/expense/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   report: [] | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,5 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|  | ||||
| } | ||||
							
								
								
									
										12
									
								
								resources/assets/js/store/modules/reports/invoice/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								resources/assets/js/store/modules/reports/invoice/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const loadInvoiceData = ({ commit, dispatch, state },data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post('/api/report/invoice', data).then((response) => { | ||||
|       commit(types.SET_INVOICES, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
| export const invoices = (state) => state.invoices | ||||
							
								
								
									
										19
									
								
								resources/assets/js/store/modules/reports/invoice/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								resources/assets/js/store/modules/reports/invoice/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   invoices: [] | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
| export const SET_INVOICES = 'SET_INVOICES' | ||||
| @ -0,0 +1,7 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.SET_INVOICES] (state, data) { | ||||
|     state.invoices = data.invoices | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,11 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const loadProfitLossLink = ({ commit, dispatch, state }, url) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/reports/profit-loss/link`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
| @ -0,0 +1,19 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   report: null | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
|  | ||||
| @ -0,0 +1,5 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|  | ||||
| } | ||||
							
								
								
									
										21
									
								
								resources/assets/js/store/modules/reports/sales/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								resources/assets/js/store/modules/reports/sales/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const loadLinkByCustomer = ({ commit, dispatch, state }, url) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/reports/sales/customers/link`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const loadLinkByItems = ({ commit, dispatch, state }, url) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/reports/sales/items/link`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
							
								
								
									
										19
									
								
								resources/assets/js/store/modules/reports/sales/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								resources/assets/js/store/modules/reports/sales/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   report: null | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
|  | ||||
| @ -0,0 +1,5 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|  | ||||
| } | ||||
							
								
								
									
										11
									
								
								resources/assets/js/store/modules/reports/tax/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								resources/assets/js/store/modules/reports/tax/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const loadTaxesReportLink = ({ commit, dispatch, state }, url) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/reports/tax-summary/link`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
							
								
								
									
										19
									
								
								resources/assets/js/store/modules/reports/tax/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								resources/assets/js/store/modules/reports/tax/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   report: [] | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,5 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,26 @@ | ||||
| // import * as types from './mutation-types' | ||||
|  | ||||
| export const loadData = ({ commit, dispatch, state }, id) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/settings/company`).then((response) => { | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const editCompany = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post('/api/settings/company', data, { | ||||
|       headers: { | ||||
|         'Content-Type': 'multipart/form-data' | ||||
|       } | ||||
|     }).then((response) => { | ||||
|       // commit(types.UPDATE_ITEM, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
| export const company = (state) => state.company | ||||
| @ -0,0 +1,19 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   company: null | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,2 @@ | ||||
| export const SET_COMPANY = 'SET_COMPANY' | ||||
| export const UPDATE_COMPANY = 'UPDATE_COMPANY' | ||||
| @ -0,0 +1,11 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.SET_COMPANY] (state, data) { | ||||
|     state.company = data.company | ||||
|   }, | ||||
|  | ||||
|   [types.UPDATE_COMPANY] (state, data) { | ||||
|     state.company = data | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,27 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export const submitData = ({ commit, dispatch, state }, data) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.post('/api/settings/general', data).then((response) => { | ||||
|       // commit(types.SET_CATEGORIES, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const loadData = ({ commit, dispatch, state }) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get('/api/settings/general').then((response) => { | ||||
|       commit(types.SET_INITIAL_DATA, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const setItemDiscount = ({ commit, dispatch, state }) => { | ||||
|   commit(types.SET_ITEM_DISCOUNT) | ||||
| } | ||||
| @ -0,0 +1,2 @@ | ||||
| export const items = (state) => state.items | ||||
| export const itemDiscount = (state) => state.item_discount | ||||
							
								
								
									
										23
									
								
								resources/assets/js/store/modules/settings/general/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								resources/assets/js/store/modules/settings/general/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   currencies: null, | ||||
|   time_zones: null, | ||||
|   languages: null, | ||||
|   date_formats: null, | ||||
|   item_discount: false | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,2 @@ | ||||
| export const SET_INITIAL_DATA = 'SET_INITIAL_DATA' | ||||
| export const SET_ITEM_DISCOUNT = 'SET_ITEM_DISCOUNT' | ||||
| @ -0,0 +1,14 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.SET_INITIAL_DATA] (state, data) { | ||||
|     state.currencies = data.currencies | ||||
|     state.time_zones = data.time_zones | ||||
|     state.languages = data.languages | ||||
|     state.date_formats = data.date_formats | ||||
|   }, | ||||
|  | ||||
|   [types.SET_ITEM_DISCOUNT] (state) { | ||||
|     state.item_discount = true | ||||
|   } | ||||
| } | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user