mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-31 21:51:10 -04:00
init crater
This commit is contained in:
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user