import { INIT_PAYMENTS_CURRENCIES, RESET_CURRENCY } from '@/constants/actionTypes' import { SET_CURRENCIES, SET_LOADING_CURRENCIES } from '@/constants/mutationTypes' const initialState = { currency: [], loadingCurrency: false } const state = { currency: initialState.currency, loadingCurrency: initialState.loadingCurrency } const getters = { /** * [currency] * @param {[type]} state [description] * @return {[type]} [description] */ currency(state) { return state.currency }, /** * [loadingCurrency] * @param {[type]} state [description] * @return {[type]} [description] */ loadingCurrency(state) { return state.loadingCurrency } } const mutations = { /** * [currency] * @param {[type]} state [description] * @param {[type]} payload [description] */ [SET_CURRENCIES] (state, payload) { state.currency = payload }, /** * [loadingCurrency] * @param {[type]} state [description] * @param {[type]} payload [description] */ [SET_LOADING_CURRENCIES] (state, payload) { state.loadingCurrency = !!payload } } const actions = { /** * [INIT_CURRENCIES] * @param {*} param0 * @param {*} payload */ [INIT_PAYMENTS_CURRENCIES] ({commit}, payload) { commit(SET_CURRENCIES, payload) commit(SET_LOADING_CURRENCIES, payload) }, [RESET_CURRENCY] ({ commit }) { commit(SET_CURRENCIES, [] ) } } export default { state, getters, mutations, actions }