aboutsummaryrefslogtreecommitdiff
path: root/client/src/store
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2021-07-30 01:51:25 +0200
committerMateja <mail@matejamaric.com>2021-07-30 01:51:25 +0200
commit2376e26dc970e9bd90cd6cedb019860f5a5b1936 (patch)
tree3bd9c8b07b3a220e66c27630f8dba6574d495000 /client/src/store
parent6467c01cddf7333ff96de21b9ffe830c0d9bc7e4 (diff)
downloadmevn-ecommerce-2376e26dc970e9bd90cd6cedb019860f5a5b1936.tar.gz
mevn-ecommerce-2376e26dc970e9bd90cd6cedb019860f5a5b1936.zip
Added Orders page for users to see their purchases.
Diffstat (limited to 'client/src/store')
-rw-r--r--client/src/store/index.js19
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: {