household address: init vue component for household address

This commit is contained in:
nobohan
2021-06-04 14:50:51 +02:00
parent 878ee5d9c7
commit 7e1b7b7e9f
7 changed files with 147 additions and 36 deletions

View File

@@ -0,0 +1,41 @@
import 'es6-promise/auto';
import { createStore } from 'vuex';
import { postAddress } from 'ChillMainAssets/vuejs/_api/AddAddress'
const debug = process.env.NODE_ENV !== 'production';
const store = createStore({
strict: debug,
state: {
address: {},
errorMsg: []
},
getters: {
},
mutations: {
catchError(state, error) {
state.errorMsg.push(error);
},
addAddress(state, address) {
console.log('@M addAddress address', address);
state.address = address;
}
},
actions: {
addAddress({ commit }, payload) {
console.log('@A addAddress payload', payload);
postAddress(payload)
.then(address => new Promise((resolve, reject) => {
commit('addAddress', address);
resolve();
}))
.catch((error) => {
commit('catchError', error);
});
}
}
});
export { store };