1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import {
- SET_CURRENCIES,
- SET_LOADING_CURRENCIES
- } from '@/constants/mutationTypes'
- import {
- INIT_CURRENCIES,
- RESET_CURRENCY
- } from '@/constants/actionTypes'
- const initialState = {
- currencies: [],
- loadingCurrencies: false
- }
- const state = {
- currencies: initialState.currencies,
- loadingCurrencies: !initialState.currencies
- }
- const getters = {
- /**
- *
- * @param {*} state
- */
- currencies(state) {
- return state.currencies
- },
- /**
- *
- * @param {*} state
- */
- loadingCurrencies(state) {
- return state.loadingCurrencies
- }
- }
- const mutations = {
- /**
- *
- * @param {*} state
- * @param {*} payload
- */
- [SET_CURRENCIES] (state, payload) {
- state.currencies = payload
- },
- /**
- *
- * @param {*} state
- * @param {*} payload
- */
- [SET_LOADING_CURRENCIES] (state, payload) {
- state.loadingCurrencies = !!payload
- }
- }
- const actions = {
- /**
- *
- * @param {*} param0
- * @param {*} payload
- */
- [INIT_CURRENCIES] ({ commit }, payload) {
- commit(SET_CURRENCIES, payload)
- commit(SET_LOADING_CURRENCIES)
- },
- /**
- *
- * @param {*} param0
- * @param {*} payload
- */
- [RESET_CURRENCY] ({ commit }) {
- commit(SET_LOADING_CURRENCIES, true)
- commit(SET_CURRENCIES, [])
- }
- }
- export default {
- state,
- getters,
- mutations,
- actions
- }
|