123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- const initialState = {
- customers: [],
- filterCustomers: [],
- selectedCustomer: null,
- loadingCustomers: false,
- }
- const state = {
- customers: initialState.customers,
- loadingCustomers: !initialState.loadingCustomers,
- selectedCustomer: initialState.selectedCustomer,
- filterCustomers: initialState.filterCustomers
- }
- const getters = {
- /**
- * [customers description]
- */
- customers(state) {
- return state.customers
- },
- /**
- * [loadingcustomers description]
- */
- loadingCustomers(state) {
- return state.loadingCustomers
- },
- /**
- * [selectedCustomer description]
- */
- selectedCustomer(state) {
- return state.selectedCustomer
- },
- /**
- * [customerVisible description]
- */
- customerVisible (state) {
- return state.filterCustomers.length === 0 ? state.customers : state.filterCustomers
- }
- }
- const mutations = {
- /**
- * [actions description]
- */
- setCustomers (state, payload) {
- state.customers = payload
- },
- /**
- * [loadingcustomers description]
- */
- setLoadingCutomers (state, payload) {
- state.loadingCustomers = !payload
- },
- /**
- * [selectedCustomer description]
- */
- setSelectedCustomer (state, payload) {
- state.selectedCustomer = payload
- },
- /**
- * [filterCustomers description]
- */
- setFilterPaymentsCustomers (state, payload) {
- state.filterCustomers = payload
- }
- }
- const actions = {
- /**
- * [INIT_PAYMENTS_CUSTOMERS]
- */
- initPaymentsCustomers({commit}, payload) {
- commit('setCustomers', payload)
- commit('setLoadingCutomers', payload)
- },
- /**
- * [SELECT_PAYMENTS_CUSTOMER]
- */
- selectPaymentsCustomer ({ commit, dispatch }, payload ) {
- commit('setSelectedCustomer', payload)
- dispatch('selectCustomerInvoices', payload.invoices)
- },
- /**
- * [FILTER_PAYMENTS_CUSTOMERS]
- */
- filterPaymentsCustomers ({ commit }, payload) {
- commit('setFilterPaymentsCustomers', payload)
- },
- /**
- * [RESET_CUSTOMERS]
- */
- resetCustomers ({ commit }) {
- commit('setCustomers', [])
- commit('setSelectedCustomer', null)
- commit('setFilterPaymentsCustomers', [])
- commit('setLoadingCutomers', true)
- }
- }
- export default {
- state,
- getters,
- mutations,
- actions
- }
|