const state = { search: '', totalOf0: 0, totalOf1: 0, totalOf2: 0 } const getters = { searchValue (state) { return state.search }, totalOf0 (state) { return state.totalOf0 }, totalOf1 (state) { return state.totalOf1 }, totalOf2 (state) { return state.totalOf2 } } const actions = { setSearchValue ({ commit }, value) { commit('UPDATE_SEARCH_VALUE', value) }, setTotal ({ commit }, value) { commit('UPDATE_TOTAL_VALUE', value) } } const mutations = { UPDATE_SEARCH_VALUE (state, value) { state.search = value }, UPDATE_TOTAL_VALUE (state, obj) { state[`totalOf${obj.status}`] = obj.value } } export default { namespaced: true, state, getters, actions, mutations }