household address: add a button for posting to household

This commit is contained in:
nobohan
2021-06-04 15:38:28 +02:00
parent 7e1b7b7e9f
commit aff140230c
4 changed files with 88 additions and 2 deletions

View File

@@ -1,7 +1,8 @@
import 'es6-promise/auto';
import { createStore } from 'vuex';
import { postAddress } from 'ChillMainAssets/vuejs/_api/AddAddress'
import { postAddress } from 'ChillMainAssets/vuejs/_api/AddAddress';
import { postAddressToHousehold } from '../api';
const debug = process.env.NODE_ENV !== 'production';
@@ -9,6 +10,7 @@ const store = createStore({
strict: debug,
state: {
address: {},
household: {},
errorMsg: []
},
getters: {
@@ -20,6 +22,10 @@ const store = createStore({
addAddress(state, address) {
console.log('@M addAddress address', address);
state.address = address;
},
addAddressToHousehold(state, household) {
console.log('@M addAddress address', household);
state.household = household;
}
},
actions: {
@@ -34,6 +40,18 @@ const store = createStore({
.catch((error) => {
commit('catchError', error);
});
},
addAddressToHousehold({ commit }, payload) {
console.log('@A addAddressToHousehold payload', payload);
postAddressToHousehold(payload)
.then(household => new Promise((resolve, reject) => {
commit('addAddressToHousehold', household);
resolve();
}))
.catch((error) => {
commit('catchError', error);
});
}
}
});