|
@@ -1,9 +1,9 @@
|
1
|
1
|
/* eslint-disable guard-for-in */
|
2
|
2
|
/* eslint-disable no-restricted-syntax */
|
3
|
|
-import axios from 'axios';
|
4
|
|
-import _ from 'lodash';
|
5
|
|
-import MyData from '../../../assets/myData';
|
6
|
|
-import MaritalStatus from '../../../assets/staticData/maritalStatus';
|
|
3
|
+import axios from "axios";
|
|
4
|
+import _ from "lodash";
|
|
5
|
+import MyData from "../../../assets/myData";
|
|
6
|
+import MaritalStatus from "../../../assets/staticData/maritalStatus";
|
7
|
7
|
|
8
|
8
|
export default {
|
9
|
9
|
namespaced: true,
|
|
@@ -50,9 +50,9 @@ export default {
|
50
|
50
|
status: undefined,
|
51
|
51
|
owner: {
|
52
|
52
|
address: {},
|
53
|
|
- bankingDetails: {},
|
54
|
|
- },
|
55
|
|
- },
|
|
53
|
+ bankingDetails: {}
|
|
54
|
+ }
|
|
55
|
+ }
|
56
|
56
|
},
|
57
|
57
|
mutations: {
|
58
|
58
|
setUnitConfigurationList(state, list) {
|
|
@@ -97,138 +97,133 @@ export default {
|
97
|
97
|
state.sellItem.resortName = resort.resortName;
|
98
|
98
|
},
|
99
|
99
|
displayResult(state) {
|
100
|
|
- state.result = 'Week has been added ^-^';
|
|
100
|
+ state.result = "Week has been added ^-^";
|
101
|
101
|
},
|
102
|
102
|
setWeekDetail(state, week) {
|
103
|
103
|
state.sellItem = week;
|
104
|
|
- },
|
|
104
|
+ }
|
105
|
105
|
},
|
106
|
106
|
getters: {
|
107
|
107
|
getRegionCode(state) {
|
108
|
|
- return (value) => {
|
109
|
|
- const reg = state.detailedRegion.find(region => region.children.some(resort => resort
|
110
|
|
- .resortCode === value));
|
|
108
|
+ return value => {
|
|
109
|
+ const reg = state.detailedRegion.find(region =>
|
|
110
|
+ region.children.some(resort => resort.resortCode === value)
|
|
111
|
+ );
|
111
|
112
|
if (reg && reg.region) {
|
112
|
113
|
return reg.region.regionCode;
|
113
|
114
|
}
|
114
|
|
- return '';
|
|
115
|
+ return "";
|
115
|
116
|
};
|
116
|
117
|
},
|
117
|
118
|
getResortName(state) {
|
118
|
|
- return (value) => {
|
|
119
|
+ return value => {
|
119
|
120
|
const res = state.resorts.find(resort => resort.resortCode === value);
|
120
|
121
|
if (res) {
|
121
|
122
|
return res.resortName;
|
122
|
123
|
}
|
123
|
124
|
};
|
124
|
|
- },
|
|
125
|
+ }
|
125
|
126
|
},
|
126
|
127
|
actions: {
|
127
|
|
- initTimeshare({
|
128
|
|
- commit,
|
129
|
|
- dispatch,
|
130
|
|
- }, timeshareId) {
|
131
|
|
- commit('setResortBedrooms', MyData.resortBedrooms);
|
132
|
|
- commit('setMaxSleep', MyData.maxBedrooms);
|
133
|
|
- commit('setBankedEntities', MyData.bankedEntities);
|
134
|
|
- dispatch('getSeasons');
|
135
|
|
- dispatch('getAgents');
|
136
|
|
- dispatch('getAgencies');
|
137
|
|
- dispatch('getResorts');
|
138
|
|
- dispatch('getRegions');
|
|
128
|
+ initTimeshare({ commit, dispatch }, timeshareId) {
|
|
129
|
+ commit("setResortBedrooms", MyData.resortBedrooms);
|
|
130
|
+ commit("setMaxSleep", MyData.maxBedrooms);
|
|
131
|
+ commit("setBankedEntities", MyData.bankedEntities);
|
|
132
|
+ dispatch("getSeasons");
|
|
133
|
+ dispatch("getAgents");
|
|
134
|
+ dispatch("getAgencies");
|
|
135
|
+ dispatch("getResorts");
|
|
136
|
+ dispatch("getRegions");
|
139
|
137
|
if (timeshareId && timeshareId !== 0) {
|
140
|
|
- dispatch('getWeekDetail', timeshareId);
|
|
138
|
+ dispatch("getWeekDetail", timeshareId);
|
141
|
139
|
}
|
142
|
140
|
},
|
143
|
|
- getWeekDetail({
|
144
|
|
- commit,
|
145
|
|
- }, timeshareId) {
|
|
141
|
+ getWeekDetail({ commit }, timeshareId) {
|
146
|
142
|
axios
|
147
|
143
|
.get(`api/timeshareweek/${timeshareId}`)
|
148
|
|
- .then((result) => {
|
|
144
|
+ .then(result => {
|
149
|
145
|
console.log(result.data);
|
150
|
|
- commit('setWeekDetail', result.data);
|
|
146
|
+ commit("setWeekDetail", result.data);
|
151
|
147
|
})
|
152
|
148
|
.catch(console.error);
|
153
|
149
|
},
|
154
|
|
- getSeasons({
|
155
|
|
- commit,
|
156
|
|
- }) {
|
|
150
|
+ getSeasons({ commit }) {
|
157
|
151
|
axios
|
158
|
|
- .get('/api/season')
|
159
|
|
- .then(result => commit('setSeason', result.data))
|
|
152
|
+ .get("/api/season")
|
|
153
|
+ .then(result => commit("setSeason", result.data))
|
160
|
154
|
.catch(console.error);
|
161
|
155
|
},
|
162
|
|
- getAgencies({
|
163
|
|
- commit,
|
164
|
|
- }) {
|
|
156
|
+ getAgencies({ commit }) {
|
165
|
157
|
axios
|
166
|
|
- .get('/api/agency')
|
167
|
|
- .then(result => commit('setAgency', result.data))
|
|
158
|
+ .get("/api/agency")
|
|
159
|
+ .then(result => commit("setAgency", result.data))
|
168
|
160
|
.catch(console.error);
|
169
|
161
|
},
|
170
|
|
- getAgents({
|
171
|
|
- commit,
|
172
|
|
- }) {
|
|
162
|
+ getAgents({ commit }) {
|
173
|
163
|
axios
|
174
|
|
- .get('/api/agent')
|
175
|
|
- .then(result => commit('setAgent', result.data))
|
|
164
|
+ .get("/api/agent")
|
|
165
|
+ .then(result => commit("setAgent", result.data))
|
176
|
166
|
.catch(console.error);
|
177
|
167
|
},
|
178
|
|
- getResorts({
|
179
|
|
- commit,
|
180
|
|
- }) {
|
|
168
|
+ getResorts({ commit }) {
|
181
|
169
|
axios
|
182
|
|
- .get('https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list/')
|
183
|
|
- .then(result => commit('addResort', result.data))
|
|
170
|
+ .get("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list/")
|
|
171
|
+ .then(result => commit("addResort", result.data))
|
184
|
172
|
.catch(console.error);
|
185
|
173
|
},
|
186
|
|
- getRegions({
|
187
|
|
- dispatch,
|
188
|
|
- commit,
|
189
|
|
- }) {
|
|
174
|
+ getRegions({ dispatch, commit }) {
|
190
|
175
|
axios
|
191
|
|
- .get('https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/regions/list/ZA')
|
192
|
|
- .then((result) => {
|
193
|
|
- commit('addRegion', result.data);
|
194
|
|
- dispatch('getDetailedRegion', result.data);
|
|
176
|
+ .get("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/regions/list/ZA")
|
|
177
|
+ .then(result => {
|
|
178
|
+ commit("addRegion", result.data);
|
|
179
|
+ dispatch("getDetailedRegion", result.data);
|
195
|
180
|
})
|
196
|
181
|
.catch(console.error);
|
197
|
182
|
},
|
198
|
|
- getDetailedRegion({
|
199
|
|
- commit,
|
200
|
|
- }, data) {
|
|
183
|
+ getDetailedRegion({ commit }, data) {
|
201
|
184
|
if (data) {
|
202
|
185
|
for (const r in Object.keys(data)) {
|
203
|
186
|
const region = data[r];
|
204
|
187
|
if (region !== undefined) {
|
205
|
188
|
axios
|
206
|
189
|
.get(
|
207
|
|
- `https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/${
|
208
|
|
- region.regionCode
|
209
|
|
- }/`,
|
|
190
|
+ `https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/${region.regionCode}/`
|
|
191
|
+ )
|
|
192
|
+ .then(result =>
|
|
193
|
+ commit("addDetailedRegion", {
|
|
194
|
+ region,
|
|
195
|
+ children: result.data
|
|
196
|
+ })
|
210
|
197
|
)
|
211
|
|
- .then(result => commit('addDetailedRegion', {
|
212
|
|
- region,
|
213
|
|
- children: result.data,
|
214
|
|
- }))
|
215
|
198
|
.catch(console.error);
|
216
|
199
|
}
|
217
|
200
|
}
|
218
|
201
|
}
|
219
|
202
|
},
|
220
|
|
- onResortChange({
|
221
|
|
- commit,
|
222
|
|
- }, resort) {
|
223
|
|
- commit('changeResort', resort);
|
|
203
|
+ onResortChange({ commit }, resort) {
|
|
204
|
+ commit("changeResort", resort);
|
|
205
|
+ },
|
|
206
|
+ saveWeek({ commit }, week) {
|
|
207
|
+ return new Promise((resolve, reject) => {
|
|
208
|
+ axios
|
|
209
|
+ .post("/api/timeshareweek", week)
|
|
210
|
+ .then(result => {
|
|
211
|
+ commit("setWeekDetail", result.data);
|
|
212
|
+ resolve();
|
|
213
|
+ })
|
|
214
|
+ .catch(error => reject(new Error(error.message)));
|
|
215
|
+ });
|
|
216
|
+
|
|
217
|
+ // axios
|
|
218
|
+ // .post('/api/timeshareweek', week)
|
|
219
|
+ // .then(result => commit('displayResult'))
|
|
220
|
+ // .catch(console.error);
|
224
|
221
|
},
|
225
|
|
- saveWeek({
|
226
|
|
- commit,
|
227
|
|
- }, week) {
|
|
222
|
+ getBlankWeek({ commit }) {
|
228
|
223
|
axios
|
229
|
|
- .post('/api/timeshareweek', week)
|
230
|
|
- .then(result => commit('displayResult'))
|
|
224
|
+ .get("/api/timeshareweek/gettemplate")
|
|
225
|
+ .then(result => commit("setWeekDetail", result.data))
|
231
|
226
|
.catch(console.error);
|
232
|
|
- },
|
233
|
|
- },
|
|
227
|
+ }
|
|
228
|
+ }
|
234
|
229
|
};
|