import { INIT_PAYMENTS_USER, INIT_PAYMENTS_COMPANY, RESET_USER} from '@/constants/actionTypes' import { SET_USER, SET_LOADING_USER } from '@/constants/mutationTypes' const initialState ={ user: null, loadingUser: false, } const state = { user: initialState.user, loadingUser: initialState.loadingUser, } const getters = { /** * [user] * @param {[type]} state [description] * @return {[type]} [description] */ user(state) { return state.user }, /** * [loadingUser] * @param {[type]} state [description] * @return {[type]} [description] */ loadingUser(state) { return state.loadingUser } } const mutations = { /** * [actions description] * @param {[type]} state [description] * @param {[type]} payload [description] */ [SET_USER] (state, payload) { state.user = payload }, /** * [actions description] * @param {[type]} state [description] * @param {[type]} payload [description] */ [SET_LOADING_USER] (state, payload) { state.loadingUser = !!payload } } const actions ={ /** * @param {*} param0 * @param {*} payload */ [INIT_PAYMENTS_USER] ({commit, dispatch}, payload) { commit(SET_USER, payload) commit(SET_LOADING_USER, payload) dispatch(INIT_PAYMENTS_COMPANY, payload) }, /** * */ [RESET_USER] ({ commit }) { commit(SET_USER, []) } } export default { state, getters, mutations, actions }