| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- import {
- INIT_PAYMENTS_CUSTOMERS,
- SELECT_PAYMENTS_CUSTOMER,
- SELECT_CUSTOMER_INVOICES,
- FILTER_PAYMENTS_CUSTOMERS,
- RESET_CUSTOMERS
- } from '@/constants/actionTypes'
- import {
- SET_CUSTOMERS,
- SET_LOADING_CUSTOMERS,
- SET_SELECTED_CUSTOMER,
- SET_FILTER_PAYMENTS_CUSTOMERS
- } from '@/constants/mutationTypes'
- 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]
- * @param {[type]} state [description]
- * @return {[type]} [description]
- */
- customers(state) {
- return state.customers
- },
- /**
- * [loadingcustomers description]
- * @param {[type]} state [description]
- * @return {[type]} [description]
- */
- loadingCustomers(state) {
- return state.loadingCustomers
- },
- /**
- * [selectedCustomer description]
- * @param {[type]} state [description]
- * @return {[type]} [description]
- */
- selectedCustomer(state) {
- return state.selectedCustomer
- },
- customerVisible (state) {
- return state.filterCustomers.length === 0 ? state.customers : state.filterCustomers
- }
- }
- const mutations = {
- /**
- * [actions description]
- * @param {[type]} state [description]
- * @param {[type]} payload [description]
- */
- [SET_CUSTOMERS] (state, payload) {
- state.customers = payload
- },
- /**
- * [loadingcustomers description]
- * @param {[type]} state [description]
- * @param {[type]} payload [description]
- */
- [SET_LOADING_CUSTOMERS] (state, payload) {
- state.loadingCustomers = !payload
- },
- /**
- * [selectedCustomer description]
- * @param {[type]} state [description]
- * @param {[type]} payload [description]
- */
- [SET_SELECTED_CUSTOMER] (state, payload) {
- state.selectedCustomer = payload
- },
- [SET_FILTER_PAYMENTS_CUSTOMERS] (state, payload) {
- state.filterCustomers = payload
- }
- }
- const actions = {
- /**
- *
- * @param {*} param0
- * @param {*} payload
- */
- [INIT_PAYMENTS_CUSTOMERS] ({commit}, payload) {
- commit(SET_CUSTOMERS, payload)
- commit(SET_LOADING_CUSTOMERS, payload)
- },
- /**
- * @param {*} param0
- * @param {*} payload
- */
- [SELECT_PAYMENTS_CUSTOMER] ({ commit, dispatch }, payload ) {
- commit(SET_SELECTED_CUSTOMER, payload)
- dispatch(SELECT_CUSTOMER_INVOICES, payload.invoices)
- },
- /**
- * @param {*} param0
- * @param {*} payload
- *
- */
- [FILTER_PAYMENTS_CUSTOMERS] ({ commit }, payload) {
- commit(SET_FILTER_PAYMENTS_CUSTOMERS, payload)
- },
- /**
- * [RESET_CUSTOMERS]
- * @param {*} param0
- */
- [RESET_CUSTOMERS] ({ commit }) {
- commit(SET_CUSTOMERS, [])
- commit(SET_SELECTED_CUSTOMER, null)
- commit(SET_FILTER_PAYMENTS_CUSTOMERS, [])
- commit(SET_LOADING_CUSTOMERS, true)
- }
- }
- export default {
- state,
- getters,
- mutations,
- actions
- }
|