|
@@ -1,11 +1,11 @@
|
1
|
1
|
/* eslint-disable no-restricted-syntax */
|
2
|
2
|
/* eslint-disable guard-for-in */
|
3
|
|
-import axios from 'axios';
|
|
3
|
+import axios from "axios";
|
4
|
4
|
|
5
|
5
|
export default {
|
6
|
6
|
namespaced: true,
|
7
|
7
|
state: {
|
8
|
|
- items: [],
|
|
8
|
+ items: []
|
9
|
9
|
},
|
10
|
10
|
mutations: {
|
11
|
11
|
setItems(state, list) {
|
|
@@ -15,38 +15,34 @@ export default {
|
15
|
15
|
state.week = item;
|
16
|
16
|
},
|
17
|
17
|
updateItem(state, item) {
|
18
|
|
- var index
|
19
|
|
- var count = 0
|
20
|
|
- state.items.forEach((el) => {
|
21
|
|
- if (el.id === item.id) {
|
22
|
|
- index = count
|
23
|
|
- }
|
24
|
|
- count++
|
25
|
|
- })
|
|
18
|
+ var index;
|
|
19
|
+ var count = 0;
|
|
20
|
+ state.items.forEach(el => {
|
|
21
|
+ if (el.id === item.id) {
|
|
22
|
+ index = count;
|
|
23
|
+ }
|
|
24
|
+ count++;
|
|
25
|
+ });
|
26
|
26
|
|
27
|
|
- Object.assign(state.items[index], item)
|
28
|
|
- },
|
|
27
|
+ Object.assign(state.items[index], item);
|
|
28
|
+ }
|
29
|
29
|
},
|
30
|
30
|
getters: {
|
31
|
31
|
getNeedsVerify(state) {
|
32
|
|
- return _.filter(state.items, x => x.status && x.status.code === 'A1');
|
33
|
|
- },
|
|
32
|
+ return _.filter(state.items, x => x.status && x.status.code === "A1");
|
|
33
|
+ }
|
34
|
34
|
// removeListing(state, id) {
|
35
|
35
|
// state.myWeeks.pop(state.myWeeks.find(w => w.id === id));
|
36
|
36
|
// },
|
37
|
37
|
},
|
38
|
38
|
actions: {
|
39
|
|
- getItems({
|
40
|
|
- commit,
|
41
|
|
- }, id) {
|
42
|
|
- axios.get(`/api/timeshareweek/getMyWeek/${id}`).then(r => commit('setItems', r.data)).catch(
|
43
|
|
- console
|
44
|
|
- .error,
|
45
|
|
- );
|
|
39
|
+ getItems({ commit }, id) {
|
|
40
|
+ axios
|
|
41
|
+ .get(`/api/timeshareweek/getMyWeek/${id}`)
|
|
42
|
+ .then(r => commit("setItems", r.data))
|
|
43
|
+ .catch(console.error);
|
46
|
44
|
},
|
47
|
|
- verifyWeek({
|
48
|
|
- commit,
|
49
|
|
- }, id) {
|
|
45
|
+ verifyWeek({ commit }, id) {
|
50
|
46
|
try {
|
51
|
47
|
axios.post(`/api/timeshareweek/verifyweek/${id}`).catch(console.error);
|
52
|
48
|
} catch (err) {
|
|
@@ -62,22 +58,22 @@ export default {
|
62
|
58
|
// .then(result => commit('removeListing', id))
|
63
|
59
|
// .catch(console.error);
|
64
|
60
|
// }
|
65
|
|
- getWeek({ commit }, id) {
|
66
|
|
- axios
|
67
|
|
- .get(`/api/timeshareweek/${id}`)
|
68
|
|
- .then(r => {
|
69
|
|
- console.log(JSON.stringify(r));
|
70
|
|
- commit('setItem', r.data);
|
71
|
|
- })
|
72
|
|
- .catch(console.error);
|
|
61
|
+ async getWeek({ commit }, id) {
|
|
62
|
+ await axios
|
|
63
|
+ .get(`/api/timeshareweek/${id}`)
|
|
64
|
+ .then(r => {
|
|
65
|
+ console.log(JSON.stringify(r));
|
|
66
|
+ commit("setItem", r.data);
|
|
67
|
+ })
|
|
68
|
+ .catch(console.error);
|
73
|
69
|
},
|
74
|
70
|
editSave({ commit }, week) {
|
75
|
71
|
axios
|
76
|
|
- .put(`/api/timeshareweek`, week)
|
77
|
|
- .then(r => {
|
78
|
|
- commit('updateItem', r.data);
|
79
|
|
- })
|
80
|
|
- .catch(console.error);
|
|
72
|
+ .put(`/api/timeshareweek`, week)
|
|
73
|
+ .then(r => {
|
|
74
|
+ commit("updateItem", r.data);
|
|
75
|
+ })
|
|
76
|
+ .catch(console.error);
|
81
|
77
|
}
|
82
|
|
- },
|
|
78
|
+ }
|
83
|
79
|
};
|