|
@@ -1,11 +1,12 @@
|
|
|
const state = {
|
|
|
customers: [],
|
|
|
+ filtered: [],
|
|
|
selectedCustomer: null
|
|
|
}
|
|
|
|
|
|
const getters = {
|
|
|
getCustomers(state) {
|
|
|
- return state.customers
|
|
|
+ return state.filtered.length === 0 ? state.customers : state.filtered
|
|
|
},
|
|
|
hasSelectedCustomer(state) {
|
|
|
return !!state.selectedCustomer
|
|
@@ -18,6 +19,9 @@ const mutations = {
|
|
|
},
|
|
|
selectCustomer(state, payload) {
|
|
|
state.selectedCustomer = payload.customer
|
|
|
+ },
|
|
|
+ applyCustomersFilter(state, payload) {
|
|
|
+ state.filtered = payload
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -43,6 +47,9 @@ const actions = {
|
|
|
},
|
|
|
selectCustomer({ commit }, payload) {
|
|
|
commit('selectCustomer', payload)
|
|
|
+ },
|
|
|
+ filterCustomers({ commit }, payload) {
|
|
|
+ commit('applyCustomersFilter', payload)
|
|
|
}
|
|
|
}
|
|
|
|