orderiom-api-package 0.2.45 → 0.2.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/modules/auth.js +16 -8
- package/src/modules/order.js +2 -0
package/package.json
CHANGED
package/src/modules/auth.js
CHANGED
|
@@ -22,6 +22,12 @@ const mutations = {
|
|
|
22
22
|
storeUser(state, userData) {
|
|
23
23
|
state.user = userData
|
|
24
24
|
},
|
|
25
|
+
updateUser(state, userData){
|
|
26
|
+
state.user = {
|
|
27
|
+
...state.user,
|
|
28
|
+
...userData
|
|
29
|
+
};
|
|
30
|
+
},
|
|
25
31
|
clearAuthData(state) {
|
|
26
32
|
state.privateToken = null;
|
|
27
33
|
state.expires_at = null;
|
|
@@ -544,29 +550,31 @@ const actions = {
|
|
|
544
550
|
});
|
|
545
551
|
|
|
546
552
|
},
|
|
547
|
-
update({ }, userData) {
|
|
553
|
+
update({ commit }, userData) {
|
|
548
554
|
return axios.post('api/auth/user/update', null, {
|
|
549
555
|
params: userData
|
|
550
|
-
}).then(
|
|
556
|
+
}).then(result => {
|
|
557
|
+
commit('updateUser', {
|
|
558
|
+
...userData,
|
|
559
|
+
updated_at: new Date().toISOString() // has a little difference with server
|
|
560
|
+
});
|
|
551
561
|
return {
|
|
552
562
|
type: 'success',
|
|
553
563
|
msg: result.data.message.body
|
|
554
564
|
}
|
|
555
|
-
}).catch(
|
|
565
|
+
}).catch(error => {
|
|
556
566
|
if (error.response) {
|
|
557
|
-
|
|
567
|
+
const status = error.response.status;
|
|
568
|
+
if (status === 422) {
|
|
558
569
|
return {
|
|
559
570
|
type: 'error',
|
|
560
571
|
msg: Object.values(error.response.data.error.validation).map(m => { return m[0] }).toString()
|
|
561
|
-
|
|
562
572
|
}
|
|
563
573
|
}
|
|
564
|
-
if (
|
|
565
|
-
|
|
574
|
+
if ([401, 403, 404, 400].includes(status)) {
|
|
566
575
|
return {
|
|
567
576
|
type: 'error',
|
|
568
577
|
msg: error.response.data.message.body
|
|
569
|
-
|
|
570
578
|
}
|
|
571
579
|
}
|
|
572
580
|
|