mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 11:03:50 +00:00
household address: add a button for posting to household
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user