@subiz/widget-v4 4.0.61 → 4.0.66

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 (134) hide show
  1. package/assets/img/caret.svg +1 -0
  2. package/assets/img/done_green.svg +4 -0
  3. package/assets/img/empty_1.svg +11 -0
  4. package/assets/img/ghn.svg +17 -0
  5. package/assets/img/ghtk.svg +18 -0
  6. package/assets/img/home.svg +1 -0
  7. package/assets/img/info.svg +1 -0
  8. package/assets/img/loader.svg +1 -0
  9. package/assets/img/map-pin.svg +1 -0
  10. package/assets/img/not_found_search.png +0 -0
  11. package/assets/img/package.svg +5 -0
  12. package/assets/img/package_fade.svg +1 -0
  13. package/assets/img/phone.svg +1 -0
  14. package/assets/img/search.svg +1 -0
  15. package/assets/img/shop.svg +1 -0
  16. package/assets/img/shop_faded.svg +1 -0
  17. package/assets/img/user.svg +1 -0
  18. package/assets/img/x.svg +5 -0
  19. package/assets/less/chatbox.less +39 -1
  20. package/assets/less/dropdown_select.less +130 -0
  21. package/assets/less/form.less +7 -20
  22. package/assets/less/order.less +489 -0
  23. package/assets/less/rating.less +3 -8
  24. package/babel.config.js +2 -4
  25. package/compiled_src/bot.js +7 -1
  26. package/compiled_src/chatbox/ChatButton.js +3 -1
  27. package/compiled_src/chatbox/DropdownSelect.js +248 -0
  28. package/compiled_src/chatbox/Event.js +5 -2
  29. package/compiled_src/chatbox/Events.js +1 -0
  30. package/compiled_src/chatbox/Order.js +285 -0
  31. package/compiled_src/chatbox/OrderAttachments.js +2 -1
  32. package/compiled_src/chatbox/ProductAttachments.js +40 -4
  33. package/compiled_src/chatbox/TextMessage.js +9 -2
  34. package/compiled_src/chatbox/Typing.js +3 -1
  35. package/compiled_src/chatbox/Widget.js +44 -3
  36. package/compiled_src/chatbox/main.js +2 -0
  37. package/compiled_src/chatbox/spinner.js +1 -1
  38. package/compiled_src/chatbox/time.js +3 -1
  39. package/compiled_src/common.js +40 -1
  40. package/compiled_src/contact/contact.js +1 -3
  41. package/compiled_src/order/address_picker.js +249 -0
  42. package/compiled_src/order/icon.js +62 -0
  43. package/compiled_src/order/index.js +113 -0
  44. package/compiled_src/order/order.js +1234 -0
  45. package/compiled_src/plugin.js +9 -42
  46. package/compiled_src/store/api.js +20 -0
  47. package/compiled_src/store/store.js +67 -3
  48. package/compiled_src/util/common.js +36 -2
  49. package/dist/{74.js → 132.js} +2355 -271
  50. package/dist/178.js +1 -1
  51. package/dist/17fdfed03d1.132.js +1 -0
  52. package/dist/17fdfed03d1.178.js +1 -0
  53. package/dist/17fdfed03d1.213.js +1 -0
  54. package/dist/17fdfed03d1.335.js +1 -0
  55. package/dist/17fdfed03d1.362.js +1 -0
  56. package/dist/17fdfed03d1.441.js +1 -0
  57. package/dist/17fdfed03d1.605.js +1 -0
  58. package/dist/{17db8166252.678.js → 17fdfed03d1.678.js} +0 -0
  59. package/dist/17fdfed03d1.782.js +1 -0
  60. package/dist/17fdfed03d1.app.js +1 -0
  61. package/dist/{17db8166252.index.html → 17fdfed03d1.index.html} +1 -1
  62. package/dist/{17db8166252.library.html → 17fdfed03d1.library.html} +1 -1
  63. package/dist/17fdfed03d1.library.js +1 -0
  64. package/dist/{17db8166252.preview.html → 17fdfed03d1.preview.html} +1 -1
  65. package/dist/17fdfed03d1.preview.js +1 -0
  66. package/dist/17fdfed03d1.screenshoot.js +1 -0
  67. package/dist/213.js +5 -69
  68. package/dist/335.js +411 -0
  69. package/dist/362.js +1 -1
  70. package/dist/441.js +70 -44
  71. package/dist/605.js +1 -64
  72. package/dist/782.js +1 -1
  73. package/dist/HASH +1 -1
  74. package/dist/assets/img/caret.998eb8f.svg +1 -0
  75. package/dist/assets/img/done_green.b817fd4.svg +4 -0
  76. package/dist/assets/img/empty_1.0b98af0.svg +11 -0
  77. package/dist/assets/img/ghn.070f8e3.svg +17 -0
  78. package/dist/assets/img/ghtk.326eac1.svg +18 -0
  79. package/dist/assets/img/info.ebce7ea.svg +1 -0
  80. package/dist/assets/img/loader.37000a7.svg +1 -0
  81. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  82. package/dist/assets/img/package.8d37d0f.svg +5 -0
  83. package/dist/assets/img/package_fade.763c001.svg +1 -0
  84. package/dist/assets/img/search.f9705ff.svg +1 -0
  85. package/dist/assets/img/shop.f7dc7d8.svg +1 -0
  86. package/dist/assets/img/shop_faded.df7845a.svg +1 -0
  87. package/dist/assets/img/x.26fdfa3.svg +5 -0
  88. package/dist/screenshoot.html +1 -1
  89. package/dist/screenshoot.js +281 -98
  90. package/order.html +19 -771
  91. package/package.json +15 -16
  92. package/src/bot.js +2 -1
  93. package/src/chatbox/Buttons.js +8 -8
  94. package/src/chatbox/ChatButton.js +2 -2
  95. package/src/chatbox/DropdownSelect.js +229 -0
  96. package/src/chatbox/Event.js +3 -3
  97. package/src/chatbox/Events.js +43 -42
  98. package/src/chatbox/Order.js +232 -0
  99. package/src/chatbox/OrderAttachments.js +2 -1
  100. package/src/chatbox/ProductAttachments.js +41 -5
  101. package/src/chatbox/TextMessage.js +21 -12
  102. package/src/chatbox/Typing.js +5 -1
  103. package/src/chatbox/Widget.js +34 -4
  104. package/src/chatbox/main.js +4 -1
  105. package/src/chatbox/spinner.js +1 -1
  106. package/src/chatbox/time.js +1 -1
  107. package/src/common.js +52 -8
  108. package/src/contact/contact.js +1 -1
  109. package/src/order/address_picker.js +235 -0
  110. package/src/order/icon.js +32 -0
  111. package/src/order/index.js +86 -0
  112. package/src/order/order.js +1157 -0
  113. package/src/order/scratch +211 -0
  114. package/src/plugin.js +7 -52
  115. package/src/store/api.js +26 -1
  116. package/src/store/store.js +53 -3
  117. package/src/util/common.js +48 -2
  118. package/up +1 -1
  119. package/webpack.dev.js +2 -0
  120. package/dist/17db8166252.178.js +0 -1
  121. package/dist/17db8166252.213.js +0 -1
  122. package/dist/17db8166252.362.js +0 -1
  123. package/dist/17db8166252.441.js +0 -1
  124. package/dist/17db8166252.605.js +0 -1
  125. package/dist/17db8166252.619.js +0 -1
  126. package/dist/17db8166252.74.js +0 -1
  127. package/dist/17db8166252.782.js +0 -1
  128. package/dist/17db8166252.app.js +0 -1
  129. package/dist/17db8166252.library.js +0 -1
  130. package/dist/17db8166252.preview.js +0 -1
  131. package/dist/17db8166252.screenshoot.js +0 -1
  132. package/dist/619.js +0 -777
  133. package/order.js +0 -0
  134. package/test.js +0 -1
@@ -0,0 +1,1234 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _index = _interopRequireDefault(require("../util/index.js"));
9
+
10
+ var _time = _interopRequireDefault(require("../chatbox/time.js"));
11
+
12
+ var common = _interopRequireWildcard(require("../common.js"));
13
+
14
+ var _DropdownSelect = _interopRequireDefault(require("../chatbox/DropdownSelect.js"));
15
+
16
+ var _address_picker = _interopRequireDefault(require("./address_picker.js"));
17
+
18
+ var _preact = require("preact");
19
+
20
+ var _icon = _interopRequireDefault(require("./icon.js"));
21
+
22
+ var _spinner = _interopRequireDefault(require("../chatbox/spinner.js"));
23
+
24
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
+
26
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
+
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
+
32
+ var checkedimg = require('../../assets/img/done_green.svg');
33
+
34
+ var ximg = require('../../assets/img/x.svg');
35
+
36
+ class Order extends common.Com {
37
+ constructor(props) {
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
+
367
+ this.load();
368
+ }
369
+
370
+ async load() {
371
+ if (!this.props.order_id) return;
372
+ let orderout = await this.props.store.fetchOrder(this.props.order_id);
373
+ this.setState({
374
+ loading: false
375
+ });
376
+
377
+ if (!orderout.error) {
378
+ this.setState({
379
+ order: orderout.body
380
+ });
381
+ } else {
382
+ this.setState({
383
+ error: orderout.error
384
+ });
385
+ }
386
+
387
+ let user = this.props.store.matchUser();
388
+
389
+ let attributes = _index.default.get(this.props.store.matchUser(), 'attributes', []);
390
+
391
+ let fullname = _index.default.get(_index.default.find(attributes, att => att.key === 'fullname'), 'text');
392
+
393
+ let email = _index.default.get(_index.default.find(attributes, att => att.key === 'emails'), 'text');
394
+
395
+ let phone = _index.default.get(_index.default.find(attributes, att => att.key === 'phones'), 'text');
396
+
397
+ this.setState({
398
+ fullname,
399
+ email,
400
+ phone
401
+ });
402
+ await this.props.store.fetchShippingAddresses();
403
+ let out = await this.props.store.list_provinces();
404
+ this.setState({
405
+ loadProvince: false
406
+ });
407
+ if (!out.error) this.setState({
408
+ provinces: _index.default.get(out, 'body.addresses')
409
+ });
410
+ }
411
+
412
+ isMobile() {
413
+ if (this.props.cid) return true;
414
+ if (this.props.isMobile) return true;
415
+ return this.props.store.isMobile();
416
+ }
417
+
418
+ onChangeShippingAddress(id) {
419
+ this.setState({
420
+ shipping_address: id,
421
+ err: {},
422
+ g_err: ''
423
+ });
424
+ }
425
+
426
+ onChangeShipping(id) {
427
+ this.setState({
428
+ shipping: id,
429
+ err: {},
430
+ g_err: ''
431
+ });
432
+ }
433
+
434
+ renderDesktopPaymentMethod(order) {
435
+ return null;
436
+ let editmode = false;
437
+
438
+ if (!order.status || order.status == 'new') {
439
+ editmode = !order.user_confirmation;
440
+ }
441
+
442
+ if (editmode) {
443
+ let pms = this.props.store.matchPaymentMethods();
444
+
445
+ let $pms = _index.default.map(pms, pm => {
446
+ let $name = pm.description;
447
+
448
+ if (pm.method == 'bank_transfer') {
449
+ $name = pm.description + ' ' + pm.bank_name + ' ' + pm.bank_branch;
450
+ }
451
+
452
+ let cls = 'order__card';
453
+ let $desc = null;
454
+
455
+ if (this.state.pm === pm.id) {
456
+ cls += ' order__card__active';
457
+ $desc = (0, _preact.h)("div", {
458
+ class: "muted mt-1",
459
+ style: "margin-left: 26px !important;"
460
+ }, "Tr\u1EA3 ti\u1EC1n m\u1EB7t khi b\u1EA1n nh\u1EADn h\xE0ng");
461
+
462
+ if (pm.method == 'bank_transfer') {
463
+ $desc = (0, _preact.h)("div", {
464
+ class: "muted mt-1",
465
+ style: "margin-left: 26px !important;"
466
+ }, (0, _preact.h)("div", null, "STK: ", pm.bank_number), (0, _preact.h)("div", null, "Ch\u1EE7 t\xE0i kho\u1EA3n: ", pm.bank_owner));
467
+ }
468
+ }
469
+
470
+ return (0, _preact.h)("div", {
471
+ style: "width: 100% !important; margin-top: 10px !important;"
472
+ }, (0, _preact.h)("div", {
473
+ class: "radio"
474
+ }, (0, _preact.h)("input", {
475
+ type: "radio",
476
+ id: 'pm.' + pm.id,
477
+ onInput: e => this.onChangePaymentMethod(pm.id),
478
+ name: "pm",
479
+ checked: this.state.pm === pm.id
480
+ }), (0, _preact.h)("label", {
481
+ class: "radio--label",
482
+ style: `margin-left: 4px !important; font-weight: ${this.state.pm === pm.id ? 500 : 400} !important;`,
483
+ for: 'pm.' + pm.id
484
+ }, $name), (0, _preact.h)("div", {
485
+ class: "radio--check"
486
+ }, (0, _preact.h)("div", {
487
+ class: "inside"
488
+ })), $desc));
489
+ });
490
+
491
+ let seccls = 'card_section';
492
+ if (this.isMobile()) seccls = 'order_section';
493
+ return (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("div", {
494
+ class: "order_section__line"
495
+ }), (0, _preact.h)("div", {
496
+ class: seccls
497
+ }, (0, _preact.h)("div", {
498
+ class: "order_label"
499
+ }, this.props.t('payment')), (0, _preact.h)("div", {
500
+ class: "form",
501
+ style: "justify-content: space-between !important;"
502
+ }, $pms)));
503
+ }
504
+
505
+ let pm = order.payment_method || {
506
+ method: 'cod'
507
+ };
508
+ let $body = null;
509
+ if (pm.method === 'cash') $body = (0, _preact.h)("div", null, this.props.t('pm_cash'));
510
+ if (pm.method === 'cod') $body = (0, _preact.h)("div", null, this.props.t('pm_cod'));
511
+
512
+ if (pm.method === 'bank_transfer') {
513
+ let name = pm.bank_name;
514
+ if (pm.bank_branch) name += ' - ' + pm.bank_branch;
515
+ $body = (0, _preact.h)("div", null, (0, _preact.h)("div", null, "Ng\xE2n h\xE0ng: ", name), (0, _preact.h)("div", {
516
+ class: "mt-1"
517
+ }, "Ch\u1EE7 t\xE0i kho\u1EA3n: ", pm.bank_owner), (0, _preact.h)("div", {
518
+ class: "mt-1"
519
+ }, "S\u1ED1 t\xE0i kho\u1EA3n: ", pm.bank_number));
520
+ }
521
+
522
+ if (!$body) return null;
523
+ return (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("div", {
524
+ class: "order_label"
525
+ }, this.props.t('payment')), $body);
526
+ }
527
+
528
+ renderDesktopShipping(order) {
529
+ let editmode = false;
530
+
531
+ if (!order.status || order.status == 'new') {
532
+ editmode = !order.user_confirmation;
533
+ }
534
+
535
+ let user = this.props.store.matchUser();
536
+
537
+ if (editmode) {
538
+ let addresses = this.props.store.matchShippingAddresses();
539
+
540
+ let provinces = _index.default.map(this.state.provinces, province => ({
541
+ id: province.id,
542
+ name: province.province
543
+ }));
544
+
545
+ let districts = _index.default.map(this.state.districts, district => ({
546
+ id: district.id,
547
+ name: district.district
548
+ }));
549
+
550
+ let wards = _index.default.map(this.state.wards, ward => ({
551
+ id: ward.id,
552
+ name: ward.ward
553
+ }));
554
+
555
+ let cls = 'ship_card';
556
+ let $body = null;
557
+ let ship_icon_active = false;
558
+
559
+ if (this.state.shipping === 'ship') {
560
+ ship_icon_active = true;
561
+
562
+ let $preaddrs = _index.default.map(addresses, addr => {
563
+ let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
564
+ let $phone = null;
565
+
566
+ if (addr.phone) {
567
+ $phone = (0, _preact.h)(_preact.Fragment, null, "\xA0\xB7\xA0", this.props.t('phn'), " ", addr.phone);
568
+ }
569
+
570
+ return (0, _preact.h)("div", {
571
+ style: "margin-bottom: 15px !important"
572
+ }, (0, _preact.h)("div", {
573
+ class: "radio d-flex "
574
+ }, (0, _preact.h)("input", {
575
+ type: "radio",
576
+ id: 'shipping_addr.' + addr.id,
577
+ onInput: e => this.onChangeShippingAddress(addr.id),
578
+ name: "shipping_address",
579
+ checked: this.state.shipping_address === addr.id
580
+ }), (0, _preact.h)("label", {
581
+ class: "radio--label",
582
+ for: 'shipping_addr.' + addr.id,
583
+ style: `font-weight: ${this.state.shipping_address === addr.id ? 500 : 400} !important`
584
+ }, addr.fullname, $phone, (0, _preact.h)("div", {
585
+ class: "mt-1 muted"
586
+ }, "DC ", fulladdr)), (0, _preact.h)("div", {
587
+ class: "radio--check"
588
+ }, (0, _preact.h)("div", {
589
+ class: "inside"
590
+ }))));
591
+ });
592
+
593
+ $preaddrs.push((0, _preact.h)("div", {
594
+ style: ""
595
+ }, (0, _preact.h)("div", {
596
+ class: "radio d-flex "
597
+ }, (0, _preact.h)("input", {
598
+ type: "radio",
599
+ id: 'shipping_addr.new',
600
+ onInput: e => this.onChangeShippingAddress('new'),
601
+ name: "shipping_address",
602
+ checked: this.state.shipping_address === 'new'
603
+ }), (0, _preact.h)("label", {
604
+ class: "radio--label",
605
+ for: 'shipping_addr.new'
606
+ }, this.state.shipping_address === 'new' ? (0, _preact.h)("b", null, "T\u1EDBi \u0111\u1ECBa ch\u1EC9 kh\xE1c") : 'Tới địa chỉ khác'), (0, _preact.h)("div", {
607
+ class: "radio--check"
608
+ }, (0, _preact.h)("div", {
609
+ class: "inside"
610
+ })))));
611
+ let $new = (0, _preact.h)("div", {
612
+ style: "padding-left: 22px !important;"
613
+ }, (0, _preact.h)("div", {
614
+ class: "d-flex"
615
+ }, (0, _preact.h)("div", {
616
+ class: "mr-2",
617
+ style: "flex: 1 !important;"
618
+ }, (0, _preact.h)("div", {
619
+ class: "order_form_label"
620
+ }, this.props.t('fullname')), (0, _preact.h)("input", {
621
+ type: "text",
622
+ class: 'form-control ' + (this.state.err.name && 'err'),
623
+ onInput: this.onChangeFullname,
624
+ value: this.state.fullname
625
+ })), (0, _preact.h)("div", {
626
+ class: "ml-2",
627
+ style: "flex: 1 !important;"
628
+ }, (0, _preact.h)("div", {
629
+ class: "order_form_label"
630
+ }, this.props.t('phones')), (0, _preact.h)("input", {
631
+ type: "text",
632
+ class: 'form-control ' + (this.state.err.phone && 'err'),
633
+ onInput: this.onChangePhone,
634
+ value: this.state.phone
635
+ }))), (0, _preact.h)("div", {
636
+ class: "",
637
+ style: "width: 100% !important"
638
+ }, (0, _preact.h)("div", {
639
+ class: "order_form_label"
640
+ }, this.props.t('address')), (0, _preact.h)(_address_picker.default, {
641
+ initAddress: this.state.address,
642
+ store: this.props.store,
643
+ width: "100%",
644
+ onChangeAddress: this.onChangeAddress,
645
+ full: this.isMobile(),
646
+ onSelect: this.onSelectAddress,
647
+ extra_cls: this.state.err.address && 'err'
648
+ })), (0, _preact.h)("div", {
649
+ class: "d-flex",
650
+ style: "justify-content: space-between !important;"
651
+ }, (0, _preact.h)("div", {
652
+ style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
653
+ }, (0, _preact.h)("div", {
654
+ class: "order_form_label"
655
+ }, this.props.t('province')), (0, _preact.h)(_DropdownSelect.default, {
656
+ width: "194",
657
+ full: this.isMobile(),
658
+ has_search: true,
659
+ loading: this.state.loadProvince,
660
+ items: provinces,
661
+ selected: this.state.selectedProvince,
662
+ onSelect: this.onSelectProvince,
663
+ extra_cls: this.state.err.province && 'err'
664
+ })), (0, _preact.h)("div", {
665
+ style: "flex: 1 !important; overflow:hidden !important; margin-left: 7px !important;"
666
+ }, (0, _preact.h)("div", {
667
+ class: "order_form_label"
668
+ }, this.props.t('district')), (0, _preact.h)(_DropdownSelect.default, {
669
+ width: "194",
670
+ full: this.isMobile(),
671
+ selected: this.state.selectedDistrict,
672
+ has_search: true,
673
+ onSelect: this.onSelectDistrict,
674
+ loading: this.state.loadDistrict,
675
+ extra_cls: this.state.err.district && 'err',
676
+ items: districts
677
+ }))), (0, _preact.h)("div", {
678
+ class: "d-flex",
679
+ style: "justify-content: space-between !important;"
680
+ }, (0, _preact.h)("div", {
681
+ style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
682
+ }, (0, _preact.h)("div", {
683
+ class: "order_form_label"
684
+ }, this.props.t('ward')), (0, _preact.h)(_DropdownSelect.default, {
685
+ width: "194",
686
+ selected: this.state.selectedWard,
687
+ full: this.isMobile(),
688
+ has_search: true,
689
+ onSelect: this.onSelectWard,
690
+ extra_cls: this.state.err.ward && 'err',
691
+ loading: this.state.loadWard,
692
+ items: wards
693
+ })), (0, _preact.h)("div", {
694
+ style: "flex: 1 !important; margin-left: 7px !important;"
695
+ })));
696
+ cls += ' ship_card__active';
697
+
698
+ if (_index.default.size(addresses) == 0) {
699
+ $body = (0, _preact.h)("div", null, (0, _preact.h)("div", {
700
+ class: 'mt-3 mb-2 '
701
+ }, this.props.t('input_shipping_info')), $new);
702
+ } else {
703
+ if (this.state.shipping_address !== 'new') $new = null;
704
+ $body = (0, _preact.h)("div", null, (0, _preact.h)("div", {
705
+ class: "mt-3 mb-2",
706
+ style: "margin-bottom: 10px !important;"
707
+ }, "Vui l\xF2ng ch\u1ECDn \u0111\u1ECBa ch\u1EC9 giao h\xE0ng"), (0, _preact.h)("div", {
708
+ class: "form"
709
+ }, $preaddrs), $new);
710
+ }
711
+ }
712
+
713
+ let shopcls = 'ship_card';
714
+ let shop_icon_active = false;
715
+
716
+ if (this.state.shipping === 'shop') {
717
+ shop_icon_active = true;
718
+ shopcls += ' ship_card__active';
719
+ $body = (0, _preact.h)("div", null, (0, _preact.h)("div", {
720
+ class: "d-flex"
721
+ }, (0, _preact.h)("div", {
722
+ class: "mr-2",
723
+ style: "flex: 3 !important;"
724
+ }, (0, _preact.h)("div", {
725
+ class: "order_form_label"
726
+ }, this.props.t('fullname')), (0, _preact.h)("input", {
727
+ type: "text",
728
+ class: 'form-control ' + (this.state.err.name && 'err'),
729
+ onInput: this.onChangeFullname,
730
+ value: this.state.fullname
731
+ })), (0, _preact.h)("div", {
732
+ class: "ml-2",
733
+ style: "flex: 2 !important;"
734
+ }, (0, _preact.h)("div", {
735
+ class: "order_form_label"
736
+ }, this.props.t('phones')), (0, _preact.h)("input", {
737
+ type: "text",
738
+ class: 'form-control ' + (this.state.err.phone && 'err'),
739
+ onInput: this.onChangePhone,
740
+ value: this.state.phone
741
+ }))), (0, _preact.h)("div", null, (0, _preact.h)("div", {
742
+ class: "order_form_label"
743
+ }, this.props.t('email')), (0, _preact.h)("input", {
744
+ type: "text",
745
+ class: 'form-control ' + (this.state.err.email && 'err'),
746
+ onInput: this.onChangeEmail,
747
+ value: this.state.email
748
+ })));
749
+ }
750
+
751
+ let seccls = 'card_section';
752
+ if (this.isMobile()) seccls = 'order_section';
753
+ return (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("div", {
754
+ class: "order_section__line"
755
+ }), (0, _preact.h)("div", {
756
+ class: seccls
757
+ }, (0, _preact.h)("div", {
758
+ class: "order_label"
759
+ }, this.props.t('ship_to')), (0, _preact.h)("div", {
760
+ class: "d-flex"
761
+ }, (0, _preact.h)("div", {
762
+ class: shopcls + ' mr-3',
763
+ onClick: e => this.onChangeShipping('shop')
764
+ }, (0, _preact.h)(_icon.default, {
765
+ name: "shop",
766
+ active: shop_icon_active
767
+ }), " ", (0, _preact.h)("b", {
768
+ class: "ml-2"
769
+ }, "Nh\u1EADn h\xE0ng t\u1EA1i shop")), (0, _preact.h)("div", {
770
+ class: cls,
771
+ onClick: e => this.onChangeShipping('ship')
772
+ }, (0, _preact.h)(_icon.default, {
773
+ name: "package",
774
+ active: ship_icon_active
775
+ }), " ", (0, _preact.h)("b", {
776
+ class: "ml-2"
777
+ }, "Giao h\xE0ng cho t\xF4i"))), $body));
778
+ }
779
+
780
+ let addr = _index.default.get(order, 'shipping.address') || {};
781
+ let fulladdr = [addr.address, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
782
+ let $phone = null;
783
+ if (addr.phone) $phone = (0, _preact.h)("div", {
784
+ class: "mt-1 muted"
785
+ }, this.props.t('phn'), ":\xA0", addr.phone);
786
+
787
+ if (_index.default.get(order, 'shipping.pickup_at_shop')) {
788
+ fulladdr = 'Nhận hàng tại cửa hàng';
789
+ }
790
+
791
+ let $addr = fulladdr ? (0, _preact.h)("div", null, fulladdr) : (0, _preact.h)("i", {
792
+ class: "i muted"
793
+ }, "Ch\u01B0a c\xF3 \u0111\u1ECBa ch\u1EC9 giao h\xE0ng");
794
+ let seccls = 'card_section';
795
+ if (this.isMobile()) seccls = 'order_section';
796
+ return (0, _preact.h)("div", {
797
+ class: seccls
798
+ }, (0, _preact.h)("div", {
799
+ class: "order_label "
800
+ }, this.props.t('ship_to')), $addr, $phone);
801
+ }
802
+
803
+ renderDesktopSummary(order) {
804
+ let $deposit = null;
805
+
806
+ if (order.deposit > 0) {
807
+ $deposit = (0, _preact.h)("span", {
808
+ class: "muted"
809
+ }, "(c\u1ECDc ", _index.default.formatCurrency(order.deposit), ")");
810
+ }
811
+
812
+ let $discount = null;
813
+
814
+ if (order.total_discount > 0) {
815
+ $discount = (0, _preact.h)("div", {
816
+ class: "order_summary_line"
817
+ }, (0, _preact.h)("div", null, "Gi\u1EA3m gi\xE1"), (0, _preact.h)("div", null, _index.default.formatCurrency(order.total_discount)));
818
+ }
819
+
820
+ let $pay = null;
821
+
822
+ if ($deposit || order.payment_made) {
823
+ $pay = (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("div", {
824
+ class: "order_summary_line"
825
+ }, (0, _preact.h)("div", null, "B\u1EA1n \u0111\xE3 tr\u1EA3"), (0, _preact.h)("div", null, $deposit, " ", _index.default.formatCurrency(order.payment_made))), (0, _preact.h)("div", {
826
+ class: "order_summary_line"
827
+ }, (0, _preact.h)("div", null, "B\u1EA1n ch\u01B0a tr\u1EA3"), (0, _preact.h)("div", null, _index.default.formatCurrency((order.total || 0) - (order.payment_made || 0)))));
828
+ }
829
+
830
+ let $tax = (0, _preact.h)("div", {
831
+ class: "order_summary_line"
832
+ }, (0, _preact.h)("div", null, "Ti\u1EC1n thu\u1EBF"), (0, _preact.h)("div", null, _index.default.formatCurrency(order.total_tax)));
833
+ let $ship = (0, _preact.h)("div", {
834
+ class: "order_summary_line"
835
+ }, (0, _preact.h)("div", null, "Ph\xED v\u1EADn chuy\u1EC3n"), (0, _preact.h)("div", null, _index.default.get(order, 'shipping.fee', 0), " d"));
836
+ let editmode = false;
837
+
838
+ if (!order.status || order.status == 'new') {
839
+ editmode = !order.user_confirmation;
840
+ }
841
+
842
+ let $note = null;
843
+
844
+ if (editmode) {
845
+ $ship = null;
846
+ $tax = null;
847
+ $note = (0, _preact.h)("div", {
848
+ class: "muted"
849
+ }, (0, _preact.h)("img", {
850
+ class: "order_ship_icon",
851
+ src: require('../../assets/img/info.svg')
852
+ }), "\xA0 Ch\u01B0a bao g\u1ED3m thu\u1EBF v\xE0 ph\xED v\u1EADn chuy\u1EC3n");
853
+ }
854
+
855
+ let seccls = '';
856
+ if (this.isMobile()) seccls = 'order_section';
857
+ return (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("div", {
858
+ class: "order_section__line"
859
+ }), (0, _preact.h)("div", {
860
+ class: seccls
861
+ }, (0, _preact.h)("div", {
862
+ class: "order_label"
863
+ }, "T\xF3m t\u1EAFt"), (0, _preact.h)("div", {
864
+ class: "order_summary_line"
865
+ }, (0, _preact.h)("div", null, "T\u1ED5ng ti\u1EC1n h\xE0ng"), (0, _preact.h)("div", null, _index.default.formatCurrency(order.subtotal))), $tax, $discount, $ship, $note, (0, _preact.h)("div", {
866
+ class: "order_summary_line",
867
+ style: "margin-top: 10px !important; padding-top: 15px !important; border-top: 1px solid #eee !important"
868
+ }, (0, _preact.h)("div", null, "B\u1EA1n ph\u1EA3i tr\u1EA3"), (0, _preact.h)("div", {
869
+ class: "order__total"
870
+ }, _index.default.formatCurrency(order.total))), $pay));
871
+ }
872
+
873
+ renderStatusBadge(order) {
874
+ let status = order.status || 'new';
875
+ return (0, _preact.h)("div", {
876
+ style: "float: right !important;",
877
+ class: 'order_status order_status__' + status
878
+ }, status);
879
+ }
880
+
881
+ renderShippingInfo(order) {
882
+ if (order.status != 'new' || order.user_confirmation) {}
883
+
884
+ let shipping_provider = _index.default.get(order, 'shipping.shipping_provider');
885
+
886
+ if (!shipping_provider) return null;
887
+
888
+ let shipping_code = _index.default.get(order, 'shipping.shipping_code');
889
+
890
+ let $tracking_code = null;
891
+ if (shipping_code) $tracking_code = (0, _preact.h)("div", {
892
+ class: "muted",
893
+ style: "margin-top: 3px !important"
894
+ }, "V\u1EADn \u0111\u01A1n\xA0", (0, _preact.h)("a", {
895
+ class: "order_tracking_link",
896
+ target: "_blank",
897
+ href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
898
+ }, shipping_code, "\xA0", (0, _preact.h)("img", {
899
+ class: "order_tracking_link_icon",
900
+ src: require('../../assets/img/external-link.svg')
901
+ })));
902
+
903
+ if (shipping_provider == 'ghtk') {
904
+ return (0, _preact.h)("div", {
905
+ class: "order_section"
906
+ }, (0, _preact.h)("div", {
907
+ class: "order_section_label"
908
+ }, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0, _preact.h)("div", {
909
+ class: "d-flex align-items-center"
910
+ }, (0, _preact.h)("img", {
911
+ class: "order_shipping_provider_logo",
912
+ src: ShippingProvider.ghtk.logo
913
+ }), (0, _preact.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
914
+ }
915
+
916
+ return null;
917
+ }
918
+
919
+ renderDesktopShippingInfo(order) {
920
+ let shipping_provider = _index.default.get(order, 'shipping.shipping_provider');
921
+
922
+ if (!shipping_provider) return null;
923
+
924
+ let shipping_code = _index.default.get(order, 'shipping.shipping_code');
925
+
926
+ let $tracking_code = null;
927
+ if (shipping_code) $tracking_code = (0, _preact.h)("div", {
928
+ class: "muted",
929
+ style: "margin-top: 3px !important"
930
+ }, "V\u1EADn \u0111\u01A1n\xA0", (0, _preact.h)("a", {
931
+ class: "order_tracking_link",
932
+ target: "_blank",
933
+ href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
934
+ }, shipping_code, "\xA0", (0, _preact.h)("img", {
935
+ class: "order_tracking_link_icon",
936
+ src: require('../../assets/img/external-link.svg')
937
+ })));
938
+
939
+ if (shipping_provider == 'ghtk') {
940
+ return (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("div", {
941
+ class: "order_label"
942
+ }, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0, _preact.h)("div", {
943
+ class: "d-flex align-items-center"
944
+ }, (0, _preact.h)("img", {
945
+ class: "order_shipping_provider_logo",
946
+ src: ShippingProvider.ghtk.logo
947
+ }), (0, _preact.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
948
+ }
949
+
950
+ return null;
951
+ }
952
+
953
+ renderProducts(order) {
954
+ let $products = null;
955
+ $products = _index.default.map(order.items, item => {
956
+ if (!item || !item.product) return null;
957
+ let product = item.product;
958
+ return (0, _preact.h)("div", {
959
+ class: "order_attachment__product"
960
+ }, (0, _preact.h)("img", {
961
+ class: "order_attachment__product_img",
962
+ alt: '' + product.id,
963
+ src: _index.default.get(product, 'images.0') || require('../../assets/img/default.jpg')
964
+ }), (0, _preact.h)("div", {
965
+ style: "overflow: hidden !important;"
966
+ }, (0, _preact.h)("div", {
967
+ class: "order_attachment__product_name"
968
+ }, product.name), (0, _preact.h)("div", {
969
+ class: "order_attachment__product_desc"
970
+ }, product.description || product.long_description), (0, _preact.h)("div", {
971
+ class: "order_attachment__product_desc"
972
+ }, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", _index.default.formatCurrency(product.price))));
973
+ });
974
+ if (!this.isMobile()) return (0, _preact.h)("div", null, (0, _preact.h)("div", {
975
+ class: "order_label"
976
+ }, this.props.t('product')), $products);
977
+ return (0, _preact.h)("div", {
978
+ class: "order_section"
979
+ }, (0, _preact.h)("div", {
980
+ class: "order_section_label"
981
+ }, this.props.t('product')), $products);
982
+ }
983
+
984
+ renderDesktopProducts(order) {
985
+ let $products = null;
986
+ let editmode = false;
987
+
988
+ if (!order.status || order.status == 'new') {
989
+ editmode = !order.user_confirmation;
990
+ }
991
+
992
+ if (editmode) {
993
+ $products = _index.default.map(order.items, item => {
994
+ if (!item || !item.product) return null;
995
+ let product = item.product;
996
+ return (0, _preact.h)("div", {
997
+ class: "order_attachment__product"
998
+ }, (0, _preact.h)("img", {
999
+ class: "order_attachment__product_img",
1000
+ alt: '' + product.id,
1001
+ src: _index.default.get(product, 'images.0') || require('../../assets/img/default.jpg')
1002
+ }), (0, _preact.h)("div", {
1003
+ style: "overflow: hidden !important; flex: 1 !important"
1004
+ }, (0, _preact.h)("div", {
1005
+ class: "order_attachment__product_name"
1006
+ }, product.name), (0, _preact.h)("div", {
1007
+ class: "order_attachment__product_desc"
1008
+ }, product.description || product.long_description), (0, _preact.h)("div", {
1009
+ class: "order_attachment__product_desc"
1010
+ }, _index.default.formatCurrency(product.price))), (0, _preact.h)("input", {
1011
+ class: "form-control",
1012
+ style: "text-align: center !important; font-weight: 400 !important; width: 50px !important",
1013
+ value: item.quantity,
1014
+ onInput: e => this.onChangeQuantity(item, e.target.value),
1015
+ type: "text"
1016
+ }), (0, _preact.h)("div", {
1017
+ style: "width: 80px !important; text-align: right !important; "
1018
+ }, (0, _preact.h)("b", null, _index.default.formatCurrency(item.quantity * product.price))));
1019
+ });
1020
+ } else {
1021
+ $products = _index.default.map(order.items, item => {
1022
+ if (!item || !item.product) return null;
1023
+ let product = item.product;
1024
+ return (0, _preact.h)("div", {
1025
+ class: "order_attachment__product"
1026
+ }, (0, _preact.h)("img", {
1027
+ class: "order_attachment__product_img",
1028
+ alt: '' + product.id,
1029
+ src: _index.default.get(product, 'images.0') || require('../../assets/img/default.jpg')
1030
+ }), (0, _preact.h)("div", {
1031
+ style: "overflow: hidden !important; flex: 1 !important"
1032
+ }, (0, _preact.h)("div", {
1033
+ class: "order_attachment__product_name"
1034
+ }, product.name), (0, _preact.h)("div", {
1035
+ class: "order_attachment__product_desc"
1036
+ }, product.description || product.long_description), (0, _preact.h)("div", {
1037
+ class: "order_attachment__product_desc"
1038
+ }, _index.default.formatCurrency(product.price))), (0, _preact.h)("div", {
1039
+ style: "text-align: center !important; font-weight: 400 !important; width: 50px !important"
1040
+ }, item.quantity), (0, _preact.h)("div", {
1041
+ style: "width: 80px !important; text-align: right !important; "
1042
+ }, (0, _preact.h)("b", null, _index.default.formatCurrency(item.total))));
1043
+ });
1044
+ }
1045
+
1046
+ return (0, _preact.h)("div", {
1047
+ class: "card_section"
1048
+ }, (0, _preact.h)("div", {
1049
+ class: "desktop_order__heading"
1050
+ }, this.renderStatusBadge(order), (0, _preact.h)("b", {
1051
+ style: "font-size: 18px !important;"
1052
+ }, this.props.t('order'), " #", order.order_number || order.id), (0, _preact.h)("div", {
1053
+ class: "muted"
1054
+ }, (0, _preact.h)(_time.default, {
1055
+ style: "font-size: 13px !important;",
1056
+ time: order.issue_date || order.created
1057
+ }))), (0, _preact.h)("div", {
1058
+ class: "order_label d-flex",
1059
+ style: "margin-top: 20px !important;justify-content: space-between !important; align-items: flex-end !important;"
1060
+ }, (0, _preact.h)("div", {
1061
+ style: "flex: 1 !important;"
1062
+ }, this.props.t('product')), (0, _preact.h)("div", {
1063
+ style: "font-weight: 400 !important; text-align:center !important; width: 50px !important"
1064
+ }, this.props.t('qty')), (0, _preact.h)("div", {
1065
+ style: "font-weight: 400 !important; text-align: right !important; width: 80px !important;"
1066
+ }, this.props.t('total'))), $products);
1067
+ }
1068
+
1069
+ renderMobile(order) {
1070
+ if (this.state.step === 'success') return this.renderMobileSuccess(order);
1071
+ let $error = null;
1072
+
1073
+ if (this.state.g_err) {
1074
+ $error = (0, _preact.h)("div", {
1075
+ class: "mb-2 text__danger"
1076
+ }, (0, _preact.h)("img", {
1077
+ style: "margin-top: -4px !important; height: 15px !important;",
1078
+ src: ximg
1079
+ }), "\xA0", (0, _preact.h)("b", null, this.state.g_err));
1080
+ }
1081
+
1082
+ let $status = (0, _preact.h)("div", null, $error, (0, _preact.h)("div", {
1083
+ class: "btn-confirm-order",
1084
+ style: "margin-top: 0 !important;",
1085
+ onClick: this.confirm
1086
+ }, this.props.t('confirm_order')));
1087
+ let $close = (0, _preact.h)("div", {
1088
+ class: "order_btn order__btn__light mt-3",
1089
+ onClick: this.onCancel
1090
+ }, this.props.t('cancel_order'));
1091
+
1092
+ if (order.user_confirmation || order.status != 'new') {
1093
+ $status = null;
1094
+ if (this.props.cid) $close = (0, _preact.h)("div", {
1095
+ class: "order_btn order__btn__light mt-3",
1096
+ onClick: this.close
1097
+ }, this.props.t('close'));
1098
+ }
1099
+
1100
+ return (0, _preact.h)("div", {
1101
+ class: "order",
1102
+ style: "height: 100% !important"
1103
+ }, (0, _preact.h)("div", {
1104
+ class: "order--content"
1105
+ }, (0, _preact.h)("div", {
1106
+ class: "order--heading"
1107
+ }, this.renderStatusBadge(order), (0, _preact.h)("b", {
1108
+ style: "font-size: 16px !important;"
1109
+ }, this.props.t('order'), " #", order.order_number || order.id), (0, _preact.h)("div", {
1110
+ class: "muted"
1111
+ }, (0, _preact.h)(_time.default, {
1112
+ style: "font-size: 13px !important;",
1113
+ time: order.issue_date || order.created
1114
+ }))), this.renderProducts(order), this.renderDesktopShipping(order), this.renderShippingInfo(order), this.renderDesktopPaymentMethod(order), this.renderDesktopSummary(order), (0, _preact.h)("div", {
1115
+ class: "order_section pb-3",
1116
+ style: "padding-top: 0 !important;"
1117
+ }, $status, $close)));
1118
+ }
1119
+
1120
+ renderActions(order) {
1121
+ let $actions = null;
1122
+ let editmode = false;
1123
+
1124
+ if (!order.status || order.status == 'new') {
1125
+ editmode = !order.user_confirmation;
1126
+ }
1127
+
1128
+ if (this.state.step === 'success') return (0, _preact.h)("div", {
1129
+ class: "d-flex",
1130
+ style: "align-items: center !important; justify-content: flex-end !important"
1131
+ }, (0, _preact.h)("div", null, "Ghi nh\u1EADn th\xE0nh c\xF4ng"), "\xA0", (0, _preact.h)("img", {
1132
+ style: "width: 16px !important; height: 16px !important;",
1133
+ width: "16",
1134
+ height: "16",
1135
+ src: checkedimg
1136
+ }));
1137
+
1138
+ if (editmode) {
1139
+ let $error = null;
1140
+
1141
+ if (this.state.g_err) {
1142
+ $error = (0, _preact.h)("div", {
1143
+ class: "mb-2 text__danger"
1144
+ }, (0, _preact.h)("img", {
1145
+ style: "margin-top: -4px !important; height: 15px !important;",
1146
+ src: ximg
1147
+ }), "\xA0", (0, _preact.h)("b", null, this.state.g_err));
1148
+ }
1149
+
1150
+ $actions = (0, _preact.h)("div", null, $error, (0, _preact.h)("div", {
1151
+ class: "btn-confirm-order",
1152
+ onClick: this.confirm
1153
+ }, this.props.t('confirm_order')), (0, _preact.h)("div", {
1154
+ class: "btn-cancel-order",
1155
+ onClick: this.onCancel
1156
+ }, this.props.t('cancel_order')));
1157
+ }
1158
+
1159
+ return $actions;
1160
+ }
1161
+
1162
+ renderDesktop(order) {
1163
+ let acc = this.props.store.matchAccount();
1164
+
1165
+ var uri = acc.logo_url || require('../../assets/img/image_default.png');
1166
+
1167
+ return (0, _preact.h)("div", {
1168
+ class: "desktop order"
1169
+ }, (0, _preact.h)("div", {
1170
+ class: "order_acc_header"
1171
+ }, (0, _preact.h)("img", {
1172
+ class: "order_acc_logo",
1173
+ src: uri
1174
+ }), (0, _preact.h)("div", {
1175
+ class: "order_acc_name"
1176
+ }, acc.name)), (0, _preact.h)("div", {
1177
+ class: "desktop_order__content"
1178
+ }, (0, _preact.h)("div", {
1179
+ style: "flex: 1 !important; padding-right: 20px !important;"
1180
+ }, this.renderDesktopProducts(order), this.renderDesktopShipping(order), this.renderDesktopShippingInfo(order), this.renderDesktopPaymentMethod(order), (0, _preact.h)("div", {
1181
+ class: "order__footer"
1182
+ }, (0, _preact.h)("a", {
1183
+ target: "_blank",
1184
+ href: "https://subiz.com.vn",
1185
+ class: "order__footer_link"
1186
+ }, "Cung c\u1EA5p b\u1EDFi ", (0, _preact.h)("b", null, "Subiz")), (0, _preact.h)("div", {
1187
+ class: "order__footer_delimiter"
1188
+ }), (0, _preact.h)("a", {
1189
+ target: "_blank",
1190
+ href: "https://subiz.com.vn/vi/terms-of-service.html",
1191
+ class: "order__footer_link"
1192
+ }, "\u0110i\u1EC1u kho\u1EA3n"), (0, _preact.h)("a", {
1193
+ target: "_blank",
1194
+ href: "https://subiz.com.vn/vi/privacy-policy.html",
1195
+ class: "order__footer_link"
1196
+ }, "Quy\u1EC1n ri\xEAng t\u01B0"))), (0, _preact.h)("div", null, (0, _preact.h)("div", {
1197
+ class: "order_recap"
1198
+ }, this.renderDesktopSummary(order), this.renderActions(order)))));
1199
+ }
1200
+
1201
+ render() {
1202
+ if (this.state.loading) return (0, _preact.h)("div", {
1203
+ class: "order_error"
1204
+ }, (0, _preact.h)(_spinner.default, {
1205
+ class: "mt-4",
1206
+ size: "60",
1207
+ static: true
1208
+ }));
1209
+ if (this.state.error) return (0, _preact.h)("div", {
1210
+ class: "order_error"
1211
+ }, (0, _preact.h)("img", {
1212
+ class: "mt-3",
1213
+ src: require('../../assets/img/empty_1.svg')
1214
+ }), (0, _preact.h)("div", {
1215
+ class: "mt-3"
1216
+ }, this.props.t('order_load_error')));
1217
+ let order = this.state.order;
1218
+ if (this.isMobile()) return this.renderMobile(order);
1219
+ return this.renderDesktop(order);
1220
+ }
1221
+
1222
+ }
1223
+
1224
+ exports.default = Order;
1225
+ let ShippingProvider = {
1226
+ ghtk: {
1227
+ name: 'Giao hàng tiết kiệm',
1228
+ logo: require('../../assets/img/ghtk.svg')
1229
+ },
1230
+ ghn: {
1231
+ name: 'Giao hàng nhanh',
1232
+ logo: require('../../assets/img/ghn.svg')
1233
+ }
1234
+ };