currency.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const state = {
  2. currencies: {
  3. default: [],
  4. values: this.default
  5. },
  6. loadingCurrencies: {
  7. default: false,
  8. value: true
  9. }
  10. }
  11. const getters = {
  12. /**
  13. *
  14. * @param {*} state
  15. */
  16. currencies(state) {
  17. return state.currencies.values
  18. },
  19. /**
  20. *
  21. * @param {*} state
  22. */
  23. loadingCurrencies(state) {
  24. return state.loadingCurrencies.value
  25. }
  26. }
  27. const mutations = {
  28. /**
  29. *
  30. * @param {*} state
  31. * @param {*} payload
  32. */
  33. setCurrencies(state, payload) {
  34. state.currencies.values = [...payload]
  35. },
  36. /**
  37. *
  38. * @param {*} state
  39. * @param {*} payload
  40. */
  41. setLoadingCurrencies(state, payload) {
  42. state.loadingCurrencies.value = !!payload
  43. }
  44. }
  45. const actions = {
  46. /**
  47. *
  48. * @param {*} param0
  49. * @param {*} payload
  50. */
  51. initCurrencies({ commit }, payload) {
  52. commit('setCurrencies', payload)
  53. commit('setLoadingCurrencies', false)
  54. },
  55. /**
  56. *
  57. * @param {*} param0
  58. */
  59. setCurrencies({ commit }, payload) {
  60. commit('setCurrencies', payload)
  61. }
  62. }
  63. export default {
  64. state,
  65. getters,
  66. mutations,
  67. actions
  68. }