diff --git a/package.json b/package.json index fb74bb6..9805a3a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "express": "^4.16.4", "morgan": "^1.9.1", "vue": "^2.5.2", - "vue-router": "^3.0.1" + "vue-router": "^3.0.1", + "vuex": "^3.0.1" }, "devDependencies": { "autoprefixer": "^7.1.5", diff --git a/src/App.vue b/src/App.vue index 183f102..2971fd5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -17,7 +17,10 @@ diff --git a/src/components/Config.vue b/src/components/Config.vue index 32e7f3d..fd44095 100644 --- a/src/components/Config.vue +++ b/src/components/Config.vue @@ -1,65 +1,43 @@ diff --git a/src/main.js b/src/main.js index 5855b61..05a4306 100644 --- a/src/main.js +++ b/src/main.js @@ -1,6 +1,7 @@ // The Vue build version to load with the `import` command // (runtime-only or standalone) has been set in webpack.base.conf with an alias. import Vue from 'vue' +import store from './store' import App from './App' import router from './router' import BootstrapVue from 'bootstrap-vue' @@ -13,6 +14,7 @@ Vue.config.productionTip = false /* eslint-disable no-new */ new Vue({ el: '#app', + store, router, template: '', components: { App } diff --git a/src/store/index.js b/src/store/index.js new file mode 100644 index 0000000..4764e12 --- /dev/null +++ b/src/store/index.js @@ -0,0 +1,11 @@ +import Vue from 'vue' +import Vuex from 'vuex' +import user from './modules/user' + +Vue.use(Vuex) + +export default new Vuex.Store({ + modules: { + user + } +}) diff --git a/src/store/modules/user.js b/src/store/modules/user.js new file mode 100644 index 0000000..03be69c --- /dev/null +++ b/src/store/modules/user.js @@ -0,0 +1,33 @@ +// initial state +const state = { + name: null, + fee_percent: null, + minimum_contribution: null, + tezos_rpc_address: null, + baker_tz_address: null +} + +// actions +const actions = { + loadFromConfigFile ({ commit }) { + commit('setUserConfig', require('../../../static/config.json')) + } +} + +// mutations +const mutations = { + setUserConfig (state, { name, feePercent, minimumContribution, tezosRpcAddress, bakerTzAddress }) { + state.name = name + state.fee_percent = feePercent + state.minimum_contribution = minimumContribution + state.tezos_rpc_address = tezosRpcAddress + state.baker_tz_address = bakerTzAddress + } +} + +export default { + namespaced: true, + state, + actions, + mutations +}