diff options
Diffstat (limited to 'client/src/store')
-rw-r--r-- | client/src/store/index.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/client/src/store/index.js b/client/src/store/index.js index 47f8f47..8d74c5a 100644 --- a/client/src/store/index.js +++ b/client/src/store/index.js @@ -7,7 +7,8 @@ export default createStore({ currentProduct: {}, cart: [], token: localStorage.getItem('token') || '', - isAdmin: localStorage.getItem('isAdmin') === 'true' + isAdmin: localStorage.getItem('isAdmin') === 'true', + userOrders: [] }, getters: { getProducts(state) { @@ -45,6 +46,9 @@ export default createStore({ }, isAdmin(state) { return state.isAdmin; + }, + getUserOrders(state) { + return state.userOrders; } }, mutations: { @@ -90,6 +94,9 @@ export default createStore({ localStorage.removeItem('token'); localStorage.removeItem('isAdmin'); delete axios.defaults.headers.common['Authorization']; + }, + setUserOrders(state, orders) { + state.userOrders = orders; } }, actions: { @@ -138,6 +145,16 @@ export default createStore({ }) .catch(error => reject(error)); }); + }, + pullUserOrders(context) { + return new Promise((resolve, reject) => { + axios.get(`${process.env.VUE_APP_ROOT_API}/transactions/personal`) + .then(response => { + context.commit('setUserOrders', response.data); + resolve(response); + }) + .catch(error => reject(error)); + }); } }, modules: { |