@subiz/widget-v4 4.0.63 → 4.0.67

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.
Files changed (100) hide show
  1. package/assets/less/chatbox.less +6 -1
  2. package/babel.config.js +2 -4
  3. package/compiled_src/bot.js +7 -1
  4. package/compiled_src/call/call.js +15 -12
  5. package/compiled_src/chatbox/ChatButton.js +3 -1
  6. package/compiled_src/chatbox/DropdownSelect.js +75 -66
  7. package/compiled_src/chatbox/Event.js +1 -0
  8. package/compiled_src/chatbox/MessageInput.js +7 -4
  9. package/compiled_src/chatbox/Order.js +94 -90
  10. package/compiled_src/chatbox/ProductAttachments.js +40 -4
  11. package/compiled_src/chatbox/Rating.js +10 -7
  12. package/compiled_src/chatbox/Typing.js +3 -1
  13. package/compiled_src/chatbox/Widget.js +27 -23
  14. package/compiled_src/chatbox/main.js +2 -0
  15. package/compiled_src/contact/contact.js +9 -6
  16. package/compiled_src/lib.js +14 -9
  17. package/compiled_src/notif/notif.js +15 -12
  18. package/compiled_src/order/address_picker.js +71 -63
  19. package/compiled_src/order/order.js +330 -316
  20. package/compiled_src/popup/countdown.js +7 -4
  21. package/compiled_src/popup/popup.js +12 -9
  22. package/compiled_src/store/api.js +110 -80
  23. package/compiled_src/store/api_fake.js +82 -55
  24. package/compiled_src/store/store.js +194 -135
  25. package/compiled_src/util/common.js +1 -1
  26. package/dist/132.js +678 -591
  27. package/dist/178.js +174 -341
  28. package/dist/17ff367201e.132.js +1 -0
  29. package/dist/17ff367201e.178.js +1 -0
  30. package/dist/17ff367201e.213.js +1 -0
  31. package/dist/17ff367201e.335.js +1 -0
  32. package/dist/17ff367201e.362.js +1 -0
  33. package/dist/17ff367201e.441.js +1 -0
  34. package/dist/17ff367201e.605.js +1 -0
  35. package/dist/17ff367201e.678.js +1 -0
  36. package/dist/17ff367201e.782.js +1 -0
  37. package/dist/17ff367201e.app.js +1 -0
  38. package/dist/{17e757ccadd.index.html → 17ff367201e.index.html} +1 -1
  39. package/dist/{17e757ccadd.library.html → 17ff367201e.library.html} +1 -1
  40. package/dist/17ff367201e.library.js +1 -0
  41. package/dist/{17e757ccadd.preview.html → 17ff367201e.preview.html} +1 -1
  42. package/dist/17ff367201e.preview.js +1 -0
  43. package/dist/17ff367201e.screenshoot.js +1 -0
  44. package/dist/213.js +19 -13
  45. package/dist/335.js +11 -8
  46. package/dist/362.js +21 -71
  47. package/dist/441.js +2 -2
  48. package/dist/605.js +15 -12
  49. package/dist/678.js +20 -70
  50. package/dist/782.js +21 -118
  51. package/dist/HASH +1 -1
  52. package/dist/screenshoot.html +1 -1
  53. package/dist/screenshoot.js +453 -332
  54. package/package.json +14 -14
  55. package/src/bot.js +2 -1
  56. package/src/chatbox/Buttons.js +8 -8
  57. package/src/chatbox/ChatButton.js +2 -2
  58. package/src/chatbox/Event.js +1 -1
  59. package/src/chatbox/ProductAttachments.js +41 -5
  60. package/src/chatbox/Typing.js +5 -1
  61. package/src/chatbox/main.js +4 -1
  62. package/src/store/store.js +24 -11
  63. package/src/util/common.js +1 -1
  64. package/up +1 -1
  65. package/dist/0b82fa7e5c3b07b40a44.png +0 -1
  66. package/dist/0f4af006e38ee8b93633.png +0 -1
  67. package/dist/17e757ccadd.132.js +0 -1
  68. package/dist/17e757ccadd.178.js +0 -1
  69. package/dist/17e757ccadd.213.js +0 -1
  70. package/dist/17e757ccadd.335.js +0 -1
  71. package/dist/17e757ccadd.362.js +0 -1
  72. package/dist/17e757ccadd.441.js +0 -1
  73. package/dist/17e757ccadd.605.js +0 -1
  74. package/dist/17e757ccadd.678.js +0 -1
  75. package/dist/17e757ccadd.782.js +0 -1
  76. package/dist/17e757ccadd.app.js +0 -1
  77. package/dist/17e757ccadd.library.js +0 -1
  78. package/dist/17e757ccadd.preview.js +0 -1
  79. package/dist/17e757ccadd.screenshoot.js +0 -1
  80. package/dist/1ea1c6cd21d25176810c.png +0 -1
  81. package/dist/292d42404e1b03398f61.png +0 -1
  82. package/dist/312d376370831b7bea83.png +0 -1
  83. package/dist/313d1bfc1cf776d1aefe.png +0 -1
  84. package/dist/4aa58bb7a66bb44975aa.png +0 -1
  85. package/dist/56ce063bc6c81adb7322.png +0 -1
  86. package/dist/6a411166ef5cc79e0714.png +0 -1
  87. package/dist/6faf403782fefacc1649.png +0 -1
  88. package/dist/79dca33c68fab79c067f.png +0 -1
  89. package/dist/82da1578fa84f9debaeb.png +0 -1
  90. package/dist/8b8e0f0824743974b282.png +0 -1
  91. package/dist/8d551390d81e39130a3c.png +0 -1
  92. package/dist/9fc61b9479877ebdb6c7.png +0 -1
  93. package/dist/a165d31dcb3dc90f1057.png +0 -1
  94. package/dist/a98d4a5698812c4426b3.png +0 -1
  95. package/dist/c41606bf9d1b604e46d5.png +0 -1
  96. package/dist/ce1f7450ce6c1aacd330.png +0 -1
  97. package/dist/cf8c01e88f4770a6e3e5.png +0 -1
  98. package/dist/dfbcfeab1d5622a737e2.png +0 -1
  99. package/dist/e4893ed8c2f7b8329919.png +0 -1
  100. package/dist/ec2ab4eb4ef73d186186.png +0 -1
@@ -27,31 +27,343 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
27
27
 
28
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
29
 
30
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
+
30
32
  var checkedimg = require('../../assets/img/done_green.svg');
31
33
 
32
34
  var ximg = require('../../assets/img/x.svg');
33
35
 
34
36
  class Order extends common.Com {
35
- state = {
36
- loadProvince: true,
37
- g_err: '',
38
- fullname: '',
39
- email: '',
40
- phone: '',
41
- loading: true,
42
- order: {},
43
- err: {},
44
- selectedProvince: null,
45
- selectedDistrict: null,
46
- selectedWard: null,
47
- street: '',
48
- address: '',
49
- sending: false,
50
- step: ''
51
- };
52
-
53
37
  constructor(props) {
54
38
  super(props);
39
+
40
+ _defineProperty(this, "state", {
41
+ loadProvince: true,
42
+ g_err: '',
43
+ fullname: '',
44
+ email: '',
45
+ phone: '',
46
+ loading: true,
47
+ order: {},
48
+ err: {},
49
+ selectedProvince: null,
50
+ selectedDistrict: null,
51
+ selectedWard: null,
52
+ street: '',
53
+ address: '',
54
+ sending: false,
55
+ step: ''
56
+ });
57
+
58
+ _defineProperty(this, "renderMobileSuccess", order => {
59
+ return (0, _preact.h)("div", {
60
+ class: "order",
61
+ style: "height: 100% !important"
62
+ }, (0, _preact.h)("div", {
63
+ style: "display: flex !important; align-items: center !important; padding-top: 40px !important; padding-bottom: 20px !important; flex-direction: column !important; height: 100% !important"
64
+ }, (0, _preact.h)("img", {
65
+ style: "width: 60px !important; height: 60px !important;",
66
+ width: "60",
67
+ height: "60",
68
+ src: checkedimg
69
+ }), (0, _preact.h)("div", {
70
+ style: "margin-top: 20px !important; margin-bottom: 10px !important"
71
+ }, (0, _preact.h)("b", {
72
+ style: "font-size: 18px !important;"
73
+ }, "\u0110\u01A1n h\xE0ng c\u1EE7a b\u1EA1n \u0111\xE3 \u0111\u01B0\u1EE3c ghi nh\u1EADn")), (0, _preact.h)("div", {
74
+ class: "muted"
75
+ }, "T\xF4i s\u1EBD li\xEAn h\u1EC7 l\u1EA1i v\u1EDBi b\u1EA1n khi \u0111\u01A1n h\xE0ng \u0111\u01B0\u1EE3c x\u1EED l\xFD"), (0, _preact.h)("div", {
76
+ style: "flex:1 !important"
77
+ }), (0, _preact.h)("div", {
78
+ style: "margin-top: 20px !important; padding: 0px 20px 0 20px !important; width: 100% !important"
79
+ }, (0, _preact.h)("div", {
80
+ class: "order_btn order__btn__light",
81
+ onClick: this.close
82
+ }, this.props.t('close')))));
83
+ });
84
+
85
+ _defineProperty(this, "onSelectProvince", async item => {
86
+ this.setState({
87
+ selectedProvince: item,
88
+ err: {},
89
+ g_err: ''
90
+ });
91
+ this.setState({
92
+ loadDistrict: true
93
+ });
94
+ let out = await this.props.store.list_districts({
95
+ id: item.id
96
+ });
97
+ this.setState({
98
+ loadDistrict: false
99
+ });
100
+ if (!out.error) this.setState({
101
+ districts: _index.default.get(out, 'body.addresses')
102
+ });
103
+ });
104
+
105
+ _defineProperty(this, "onSelectDistrict", async item => {
106
+ this.setState({
107
+ selectedDistrict: item,
108
+ err: {},
109
+ g_err: ''
110
+ });
111
+ this.setState({
112
+ loadWard: true
113
+ });
114
+ let out = await this.props.store.list_wards({
115
+ id: item.id
116
+ });
117
+ this.setState({
118
+ loadWard: false
119
+ });
120
+ if (!out.error) this.setState({
121
+ wards: _index.default.get(out, 'body.addresses')
122
+ });
123
+ });
124
+
125
+ _defineProperty(this, "onSelectWard", item => this.setState({
126
+ selectedWard: item,
127
+ err: {},
128
+ g_err: ''
129
+ }));
130
+
131
+ _defineProperty(this, "onChangeFullname", e => this.setState({
132
+ fullname: e.target.value,
133
+ err: {},
134
+ g_err: ''
135
+ }));
136
+
137
+ _defineProperty(this, "onChangeAddress", e => this.setState({
138
+ address: e,
139
+ err: {},
140
+ g_err: ''
141
+ }));
142
+
143
+ _defineProperty(this, "onSelectAddress", addr => {
144
+ if (!addr) return;
145
+ this.setState({
146
+ address: [_index.default.trim(addr.address), _index.default.trim(addr.street)].join(' ').trim(),
147
+ street: addr.street,
148
+ err: {},
149
+ g_err: ''
150
+ });
151
+ this.onSelectWard({
152
+ id: addr.ward_id,
153
+ name: addr.ward
154
+ });
155
+ this.onSelectDistrict({
156
+ id: addr.district_id,
157
+ name: addr.district
158
+ });
159
+ this.onSelectProvince({
160
+ id: addr.province_id,
161
+ name: addr.province
162
+ });
163
+ });
164
+
165
+ _defineProperty(this, "onChangeEmail", e => this.setState({
166
+ email: e.target.value,
167
+ err: {},
168
+ g_err: ''
169
+ }));
170
+
171
+ _defineProperty(this, "onChangePhone", e => this.setState({
172
+ phone: e.target.value,
173
+ err: {},
174
+ g_err: ''
175
+ }));
176
+
177
+ _defineProperty(this, "onChangePaymentMethod", id => this.setState({
178
+ pm: id
179
+ }));
180
+
181
+ _defineProperty(this, "onChangeQuantity", (item, text) => {
182
+ let qty = parseInt(text) || 1;
183
+ item.quantity = qty;
184
+ this.forceUpdate();
185
+ });
186
+
187
+ _defineProperty(this, "confirm", async () => {
188
+ this.setState({
189
+ g_err: ''
190
+ });
191
+ let err = {};
192
+
193
+ if (!this.state.shipping) {
194
+ this.setState({
195
+ g_err: 'Mời bạn chọn địa chỉ giao hàng trước khi xác nhận'
196
+ });
197
+ }
198
+
199
+ if (this.state.shipping === 'shop') {
200
+ if (!_index.default.isPhone(this.state.phone)) {
201
+ err.phone = true;
202
+ }
203
+
204
+ if (!_index.default.trim(this.state.fullname)) {
205
+ err.name = true;
206
+ }
207
+
208
+ if (!_index.default.trim(this.state.email)) {
209
+ err.email = true;
210
+ }
211
+ } else if (this.state.shipping_address == 'new') {
212
+ if (!_index.default.isPhone(this.state.phone)) {
213
+ err.phone = true;
214
+ }
215
+
216
+ if (!_index.default.trim(this.state.fullname)) {
217
+ err.name = true;
218
+ }
219
+
220
+ if (!_index.default.trim(this.state.address)) {
221
+ err.address = true;
222
+ }
223
+
224
+ if (_index.default.size(this.state.selectedWard) == 0) {
225
+ err.ward = true;
226
+ }
227
+
228
+ if (_index.default.size(this.state.selectedDistrict) == 0) {
229
+ err.district = true;
230
+ }
231
+
232
+ if (_index.default.size(this.state.selectedProvince) == 0) {
233
+ err.province = true;
234
+ }
235
+ }
236
+
237
+ if (_index.default.size(err) > 0) {
238
+ this.setState({
239
+ err,
240
+ g_err: this.props.t('input_shipping_info_err')
241
+ });
242
+ return;
243
+ }
244
+
245
+ let user = this.props.store.matchUser();
246
+
247
+ let ufullname = _index.default.getUserAttr(user, 'fullname', 'text');
248
+
249
+ let uemail = _index.default.getUserAttr(user, 'emails', 'text');
250
+
251
+ let uphone = _index.default.getUserAttr(user, 'phones', 'text');
252
+
253
+ let order = _index.default.cloneDeep(this.state.order);
254
+
255
+ if (this.state.shipping === 'shop') {
256
+ _index.default.set(order, 'shipping.pickup_at_shop', true);
257
+
258
+ _index.default.set(order, 'shipping.address.phone', this.state.phone);
259
+
260
+ _index.default.set(order, 'shipping.address.fullname', this.state.fullname);
261
+
262
+ _index.default.set(order, 'shipping.address.email', this.state.email);
263
+ } else {
264
+ if (this.state.shipping_address == 'new') {
265
+ let out = await this.props.store.createShippingAddress({
266
+ address: this.state.address,
267
+ country: 'Việt Nam',
268
+ fullname: this.state.fullname,
269
+ email: this.state.email,
270
+ phone: this.state.phone,
271
+ district: this.state.selectedDistrict.name,
272
+ district_id: this.state.selectedDistrict.id,
273
+ province: this.state.selectedProvince.name,
274
+ province_id: this.state.selectedProvince.id,
275
+ ward: this.state.selectedWard.name,
276
+ street: this.state.street,
277
+ ward_id: this.state.selectedWard.id
278
+ });
279
+ if (out.error) return this.setState({
280
+ g_err: this.props.t('update_failed')
281
+ });
282
+
283
+ _index.default.set(order, 'shipping.address', out.body);
284
+ } else {
285
+ let addresses = this.props.store.matchShippingAddresses();
286
+
287
+ let sa = _index.default.find(addresses, addr => addr.id === this.state.shipping_address);
288
+
289
+ if (!sa) {
290
+ return this.setState({
291
+ err,
292
+ g_err: this.props.t('input_shipping_info_err')
293
+ });
294
+ }
295
+
296
+ _index.default.set(order, 'shipping.address', sa);
297
+ }
298
+ }
299
+
300
+ let changeduser = false;
301
+
302
+ if (!ufullname && this.state.fullname) {
303
+ changeduser = true;
304
+
305
+ _index.default.setUserAttr(user, {
306
+ key: 'fullname',
307
+ text: this.state.fullname
308
+ });
309
+ }
310
+
311
+ if (!uemail && this.state.email) {
312
+ changeduser = true;
313
+
314
+ _index.default.setUserAttr(user, {
315
+ key: 'emails',
316
+ text: this.state.email
317
+ });
318
+ }
319
+
320
+ if (!uphone && this.state.phone) {
321
+ changeduser = true;
322
+
323
+ _index.default.setUserAttr(user, {
324
+ key: 'phones',
325
+ text: this.state.phone
326
+ });
327
+ }
328
+
329
+ if (changeduser) this.props.store.setUser(user);
330
+ this.setState({
331
+ sending: true
332
+ });
333
+ order.user_confirmation = 'confirmed';
334
+ let out = await this.props.store.updateOrder(order);
335
+ this.setState({
336
+ sending: false
337
+ });
338
+
339
+ if (out.error) {
340
+ return this.setState({
341
+ g_err: this.props.t('update_failed')
342
+ });
343
+ }
344
+
345
+ this.setState({
346
+ step: 'success'
347
+ });
348
+ if (this.props.onResponse) this.props.onResponse('confirmed');
349
+ });
350
+
351
+ _defineProperty(this, "onCancel", () => {
352
+ if (this.props.onResponse) this.props.onResponse('rejected');
353
+ this.close();
354
+ });
355
+
356
+ _defineProperty(this, "close", () => {
357
+ if (this.props.cid && !this.state.order.user_confirmation) {
358
+ let order = _index.default.cloneDeep(this.state.order);
359
+
360
+ order.user_confirmation = 'rejected';
361
+ this.props.store.updateOrder(order);
362
+ }
363
+
364
+ if (this.props.onClose) this.props.onClose();
365
+ });
366
+
55
367
  this.load();
56
368
  }
57
369
 
@@ -111,33 +423,6 @@ class Order extends common.Com {
111
423
  });
112
424
  }
113
425
 
114
- renderMobileSuccess = order => {
115
- return (0, _preact.h)("div", {
116
- class: "order",
117
- style: "height: 100% !important"
118
- }, (0, _preact.h)("div", {
119
- style: "display: flex !important; align-items: center !important; padding-top: 40px !important; padding-bottom: 20px !important; flex-direction: column !important; height: 100% !important"
120
- }, (0, _preact.h)("img", {
121
- style: "width: 60px !important; height: 60px !important;",
122
- width: "60",
123
- height: "60",
124
- src: checkedimg
125
- }), (0, _preact.h)("div", {
126
- style: "margin-top: 20px !important; margin-bottom: 10px !important"
127
- }, (0, _preact.h)("b", {
128
- style: "font-size: 18px !important;"
129
- }, "\u0110\u01A1n h\xE0ng c\u1EE7a b\u1EA1n \u0111\xE3 \u0111\u01B0\u1EE3c ghi nh\u1EADn")), (0, _preact.h)("div", {
130
- class: "muted"
131
- }, "T\xF4i s\u1EBD li\xEAn h\u1EC7 l\u1EA1i v\u1EDBi b\u1EA1n khi \u0111\u01A1n h\xE0ng \u0111\u01B0\u1EE3c x\u1EED l\xFD"), (0, _preact.h)("div", {
132
- style: "flex:1 !important"
133
- }), (0, _preact.h)("div", {
134
- style: "margin-top: 20px !important; padding: 0px 20px 0 20px !important; width: 100% !important"
135
- }, (0, _preact.h)("div", {
136
- class: "order_btn order__btn__light",
137
- onClick: this.close
138
- }, this.props.t('close')))));
139
- };
140
-
141
426
  onChangeShipping(id) {
142
427
  this.setState({
143
428
  shipping: id,
@@ -146,94 +431,6 @@ class Order extends common.Com {
146
431
  });
147
432
  }
148
433
 
149
- onSelectProvince = async item => {
150
- this.setState({
151
- selectedProvince: item,
152
- err: {},
153
- g_err: ''
154
- });
155
- this.setState({
156
- loadDistrict: true
157
- });
158
- let out = await this.props.store.list_districts({
159
- id: item.id
160
- });
161
- this.setState({
162
- loadDistrict: false
163
- });
164
- if (!out.error) this.setState({
165
- districts: _index.default.get(out, 'body.addresses')
166
- });
167
- };
168
- onSelectDistrict = async item => {
169
- this.setState({
170
- selectedDistrict: item,
171
- err: {},
172
- g_err: ''
173
- });
174
- this.setState({
175
- loadWard: true
176
- });
177
- let out = await this.props.store.list_wards({
178
- id: item.id
179
- });
180
- this.setState({
181
- loadWard: false
182
- });
183
- if (!out.error) this.setState({
184
- wards: _index.default.get(out, 'body.addresses')
185
- });
186
- };
187
- onSelectWard = item => this.setState({
188
- selectedWard: item,
189
- err: {},
190
- g_err: ''
191
- });
192
- onChangeFullname = e => this.setState({
193
- fullname: e.target.value,
194
- err: {},
195
- g_err: ''
196
- });
197
- onChangeAddress = e => this.setState({
198
- address: e,
199
- err: {},
200
- g_err: ''
201
- });
202
- onSelectAddress = addr => {
203
- if (!addr) return;
204
- this.setState({
205
- address: [_index.default.trim(addr.address), _index.default.trim(addr.street)].join(' ').trim(),
206
- street: addr.street,
207
- err: {},
208
- g_err: ''
209
- });
210
- this.onSelectWard({
211
- id: addr.ward_id,
212
- name: addr.ward
213
- });
214
- this.onSelectDistrict({
215
- id: addr.district_id,
216
- name: addr.district
217
- });
218
- this.onSelectProvince({
219
- id: addr.province_id,
220
- name: addr.province
221
- });
222
- };
223
- onChangeEmail = e => this.setState({
224
- email: e.target.value,
225
- err: {},
226
- g_err: ''
227
- });
228
- onChangePhone = e => this.setState({
229
- phone: e.target.value,
230
- err: {},
231
- g_err: ''
232
- });
233
- onChangePaymentMethod = id => this.setState({
234
- pm: id
235
- });
236
-
237
434
  renderDesktopPaymentMethod(order) {
238
435
  return null;
239
436
  let editmode = false;
@@ -784,12 +981,6 @@ class Order extends common.Com {
784
981
  }, this.props.t('product')), $products);
785
982
  }
786
983
 
787
- onChangeQuantity = (item, text) => {
788
- let qty = parseInt(text) || 1;
789
- item.quantity = qty;
790
- this.forceUpdate();
791
- };
792
-
793
984
  renderDesktopProducts(order) {
794
985
  let $products = null;
795
986
  let editmode = false;
@@ -1028,183 +1219,6 @@ class Order extends common.Com {
1028
1219
  return this.renderDesktop(order);
1029
1220
  }
1030
1221
 
1031
- confirm = async () => {
1032
- this.setState({
1033
- g_err: ''
1034
- });
1035
- let err = {};
1036
-
1037
- if (!this.state.shipping) {
1038
- this.setState({
1039
- g_err: 'Mời bạn chọn địa chỉ giao hàng trước khi xác nhận'
1040
- });
1041
- }
1042
-
1043
- if (this.state.shipping === 'shop') {
1044
- if (!_index.default.isPhone(this.state.phone)) {
1045
- err.phone = true;
1046
- }
1047
-
1048
- if (!_index.default.trim(this.state.fullname)) {
1049
- err.name = true;
1050
- }
1051
-
1052
- if (!_index.default.trim(this.state.email)) {
1053
- err.email = true;
1054
- }
1055
- } else if (this.state.shipping_address == 'new') {
1056
- if (!_index.default.isPhone(this.state.phone)) {
1057
- err.phone = true;
1058
- }
1059
-
1060
- if (!_index.default.trim(this.state.fullname)) {
1061
- err.name = true;
1062
- }
1063
-
1064
- if (!_index.default.trim(this.state.address)) {
1065
- err.address = true;
1066
- }
1067
-
1068
- if (_index.default.size(this.state.selectedWard) == 0) {
1069
- err.ward = true;
1070
- }
1071
-
1072
- if (_index.default.size(this.state.selectedDistrict) == 0) {
1073
- err.district = true;
1074
- }
1075
-
1076
- if (_index.default.size(this.state.selectedProvince) == 0) {
1077
- err.province = true;
1078
- }
1079
- }
1080
-
1081
- if (_index.default.size(err) > 0) {
1082
- this.setState({
1083
- err,
1084
- g_err: this.props.t('input_shipping_info_err')
1085
- });
1086
- return;
1087
- }
1088
-
1089
- let user = this.props.store.matchUser();
1090
-
1091
- let ufullname = _index.default.getUserAttr(user, 'fullname', 'text');
1092
-
1093
- let uemail = _index.default.getUserAttr(user, 'emails', 'text');
1094
-
1095
- let uphone = _index.default.getUserAttr(user, 'phones', 'text');
1096
-
1097
- let order = _index.default.cloneDeep(this.state.order);
1098
-
1099
- if (this.state.shipping === 'shop') {
1100
- _index.default.set(order, 'shipping.pickup_at_shop', true);
1101
-
1102
- _index.default.set(order, 'shipping.address.phone', this.state.phone);
1103
-
1104
- _index.default.set(order, 'shipping.address.fullname', this.state.fullname);
1105
-
1106
- _index.default.set(order, 'shipping.address.email', this.state.email);
1107
- } else {
1108
- if (this.state.shipping_address == 'new') {
1109
- let out = await this.props.store.createShippingAddress({
1110
- address: this.state.address,
1111
- country: 'Việt Nam',
1112
- fullname: this.state.fullname,
1113
- email: this.state.email,
1114
- phone: this.state.phone,
1115
- district: this.state.selectedDistrict.name,
1116
- district_id: this.state.selectedDistrict.id,
1117
- province: this.state.selectedProvince.name,
1118
- province_id: this.state.selectedProvince.id,
1119
- ward: this.state.selectedWard.name,
1120
- street: this.state.street,
1121
- ward_id: this.state.selectedWard.id
1122
- });
1123
- if (out.error) return this.setState({
1124
- g_err: this.props.t('update_failed')
1125
- });
1126
-
1127
- _index.default.set(order, 'shipping.address', out.body);
1128
- } else {
1129
- let addresses = this.props.store.matchShippingAddresses();
1130
-
1131
- let sa = _index.default.find(addresses, addr => addr.id === this.state.shipping_address);
1132
-
1133
- if (!sa) {
1134
- return this.setState({
1135
- err,
1136
- g_err: this.props.t('input_shipping_info_err')
1137
- });
1138
- }
1139
-
1140
- _index.default.set(order, 'shipping.address', sa);
1141
- }
1142
- }
1143
-
1144
- let changeduser = false;
1145
-
1146
- if (!ufullname && this.state.fullname) {
1147
- changeduser = true;
1148
-
1149
- _index.default.setUserAttr(user, {
1150
- key: 'fullname',
1151
- text: this.state.fullname
1152
- });
1153
- }
1154
-
1155
- if (!uemail && this.state.email) {
1156
- changeduser = true;
1157
-
1158
- _index.default.setUserAttr(user, {
1159
- key: 'emails',
1160
- text: this.state.email
1161
- });
1162
- }
1163
-
1164
- if (!uphone && this.state.phone) {
1165
- changeduser = true;
1166
-
1167
- _index.default.setUserAttr(user, {
1168
- key: 'phones',
1169
- text: this.state.phone
1170
- });
1171
- }
1172
-
1173
- if (changeduser) this.props.store.setUser(user);
1174
- this.setState({
1175
- sending: true
1176
- });
1177
- order.user_confirmation = 'confirmed';
1178
- let out = await this.props.store.updateOrder(order);
1179
- this.setState({
1180
- sending: false
1181
- });
1182
-
1183
- if (out.error) {
1184
- return this.setState({
1185
- g_err: this.props.t('update_failed')
1186
- });
1187
- }
1188
-
1189
- this.setState({
1190
- step: 'success'
1191
- });
1192
- if (this.props.onResponse) this.props.onResponse('confirmed');
1193
- };
1194
- onCancel = () => {
1195
- if (this.props.onResponse) this.props.onResponse('rejected');
1196
- this.close();
1197
- };
1198
- close = () => {
1199
- if (this.props.cid && !this.state.order.user_confirmation) {
1200
- let order = _index.default.cloneDeep(this.state.order);
1201
-
1202
- order.user_confirmation = 'rejected';
1203
- this.props.store.updateOrder(order);
1204
- }
1205
-
1206
- if (this.props.onClose) this.props.onClose();
1207
- };
1208
1222
  }
1209
1223
 
1210
1224
  exports.default = Order;
@@ -17,15 +17,18 @@ var _preact = require("preact");
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
+
20
22
  _tickCoreCommonjs.default.plugin.add(_tickViewFlipCommonjs.default);
21
23
 
22
24
  class Countdown extends _common.Com {
23
- state = {
24
- flipKey: '43'
25
- };
26
-
27
25
  constructor(props) {
28
26
  super(props);
27
+
28
+ _defineProperty(this, "state", {
29
+ flipKey: '43'
30
+ });
31
+
29
32
  this.timer = setInterval(() => {
30
33
  if (this.props._destroy) return this.componentWillUnmount();
31
34
  let cd = this.props.com.countdown || {};