mirror of
https://github.com/crater-invoice/crater.git
synced 2026-02-10 21:02:41 -05:00
build version 400
This commit is contained in:
16
resources/assets/js/store/modules/search/actions.js
Normal file
16
resources/assets/js/store/modules/search/actions.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export const searchUsers = ({ commit, dispatch, state }, params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get(`/api/v1/search`, { params })
|
||||
.then((response) => {
|
||||
commit(types.SET_CUSTOMER_LISTS, response.data.customers.data)
|
||||
commit(types.SET_USER_LISTS, response.data.users.data)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
4
resources/assets/js/store/modules/search/getters.js
Normal file
4
resources/assets/js/store/modules/search/getters.js
Normal file
@@ -0,0 +1,4 @@
|
||||
export const getCustomerList = (state) =>
|
||||
state.customerList ? state.customerList : []
|
||||
|
||||
export const getUserList = (state) => (state.userList ? state.userList : [])
|
||||
20
resources/assets/js/store/modules/search/index.js
Normal file
20
resources/assets/js/store/modules/search/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import mutations from './mutations'
|
||||
import * as actions from './actions'
|
||||
import * as getters from './getters'
|
||||
|
||||
const initialState = {
|
||||
userList: [],
|
||||
customerList: [],
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
||||
state: initialState,
|
||||
|
||||
getters: getters,
|
||||
|
||||
actions: actions,
|
||||
|
||||
mutations: mutations,
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export const SET_CUSTOMER_LISTS = 'SET_CUSTOMER_LISTS'
|
||||
export const SET_USER_LISTS = 'SET_USER_LISTS'
|
||||
11
resources/assets/js/store/modules/search/mutations.js
Normal file
11
resources/assets/js/store/modules/search/mutations.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export default {
|
||||
[types.SET_CUSTOMER_LISTS](state, customerList) {
|
||||
state.customerList = customerList
|
||||
},
|
||||
|
||||
[types.SET_USER_LISTS](state, userList) {
|
||||
state.userList = userList
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user