@subiz/widget-v4 4.1.111 → 4.1.113

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 (56) hide show
  1. package/assets/less/message_input.less +8 -0
  2. package/assets/less/widget.less +2 -1
  3. package/compiled_src/chatbox/MessageInput.js +13 -9
  4. package/compiled_src/store/store.js +4 -1
  5. package/dist/127.js +273 -0
  6. package/dist/132.js +2575 -6434
  7. package/dist/185.js +1885 -0
  8. package/dist/19565267fde.127.js +1 -0
  9. package/dist/19565267fde.132.js +1 -0
  10. package/dist/19565267fde.185.js +1 -0
  11. package/dist/19565267fde.27.js +1 -0
  12. package/dist/19565267fde.278.js +1 -0
  13. package/dist/19565267fde.459.js +1 -0
  14. package/dist/19565267fde.490.js +1 -0
  15. package/dist/19565267fde.74.js +1 -0
  16. package/dist/19565267fde.997.js +1 -0
  17. package/dist/19565267fde.app.js +1 -0
  18. package/dist/{18a02a9c54e.index.html → 19565267fde.index.html} +28 -4
  19. package/dist/{18a02a9c54e.library.html → 19565267fde.library.html} +28 -4
  20. package/dist/19565267fde.library.js +1 -0
  21. package/dist/{18a02a9c54e.preview.html → 19565267fde.preview.html} +1 -1
  22. package/dist/19565267fde.preview.js +1 -0
  23. package/dist/19565267fde.webview.js +1 -0
  24. package/dist/27.js +107 -0
  25. package/dist/278.js +406 -0
  26. package/dist/459.js +107 -0
  27. package/dist/{605.js → 490.js} +82 -82
  28. package/dist/{335.js → 74.js} +35 -35
  29. package/dist/{678.js → 997.js} +6 -6
  30. package/dist/HASH +1 -1
  31. package/dist/assets/img/{subiz-mono.877e9f5.svg → subiz-mono.8fbc067.svg} +1 -1
  32. package/dist/malicious-app.js +6 -4
  33. package/dist/screenshoot.html +1 -1
  34. package/dist/screenshoot.js +9231 -4896
  35. package/package.json +13 -13
  36. package/src/chatbox/MessageInput.js +8 -7
  37. package/src/store/store.js +4 -1
  38. package/dist/178.js +0 -406
  39. package/dist/18a02a9c54e.132.js +0 -1
  40. package/dist/18a02a9c54e.178.js +0 -1
  41. package/dist/18a02a9c54e.213.js +0 -1
  42. package/dist/18a02a9c54e.335.js +0 -1
  43. package/dist/18a02a9c54e.362.js +0 -1
  44. package/dist/18a02a9c54e.441.js +0 -1
  45. package/dist/18a02a9c54e.605.js +0 -1
  46. package/dist/18a02a9c54e.678.js +0 -1
  47. package/dist/18a02a9c54e.782.js +0 -1
  48. package/dist/18a02a9c54e.app.js +0 -1
  49. package/dist/18a02a9c54e.library.js +0 -1
  50. package/dist/18a02a9c54e.preview.js +0 -1
  51. package/dist/18a02a9c54e.screenshoot.js +0 -1
  52. package/dist/18a02a9c54e.webview.js +0 -1
  53. package/dist/213.js +0 -2780
  54. package/dist/362.js +0 -107
  55. package/dist/441.js +0 -2855
  56. package/dist/782.js +0 -107
package/dist/185.js ADDED
@@ -0,0 +1,1885 @@
1
+ (self["webpackChunk_subiz_widget_v4"] = self["webpackChunk_subiz_widget_v4"] || []).push([[185],{
2
+
3
+ /***/ 185:
4
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5
+
6
+ module.exports = __webpack_require__.p + "assets/img/loader.37000a7.svg";
7
+
8
+ /***/ }),
9
+
10
+ /***/ 1113:
11
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
12
+
13
+ module.exports = __webpack_require__.p + "assets/img/ghn.070f8e3.svg";
14
+
15
+ /***/ }),
16
+
17
+ /***/ 2523:
18
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
19
+
20
+ module.exports = __webpack_require__.p + "assets/img/shop_faded.df7845a.svg";
21
+
22
+ /***/ }),
23
+
24
+ /***/ 3080:
25
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
26
+
27
+ module.exports = __webpack_require__.p + "assets/img/x.26fdfa3.svg";
28
+
29
+ /***/ }),
30
+
31
+ /***/ 3142:
32
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
33
+
34
+ module.exports = __webpack_require__.p + "assets/img/not_found_search.2ddb8d1.png";
35
+
36
+ /***/ }),
37
+
38
+ /***/ 4185:
39
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
40
+
41
+ "use strict";
42
+ // ESM COMPAT FLAG
43
+ __webpack_require__.r(__webpack_exports__);
44
+
45
+ // EXPORTS
46
+ __webpack_require__.d(__webpack_exports__, {
47
+ "default": () => (/* binding */ Order)
48
+ });
49
+
50
+ // EXTERNAL MODULE: ./src/util/index.js + 1 modules
51
+ var util = __webpack_require__(8150);
52
+ // EXTERNAL MODULE: ./src/chatbox/releaseAnimation.js
53
+ var releaseAnimation = __webpack_require__(2988);
54
+ // EXTERNAL MODULE: ./src/chatbox/time.js
55
+ var time = __webpack_require__(1620);
56
+ // EXTERNAL MODULE: ./src/common.js
57
+ var common = __webpack_require__(2840);
58
+ // EXTERNAL MODULE: ./node_modules/preact/dist/preact.module.js
59
+ var preact_module = __webpack_require__(172);
60
+ // EXTERNAL MODULE: ./src/chatbox/spinner.js
61
+ var spinner = __webpack_require__(4188);
62
+ ;// ./src/chatbox/DropdownSelect.js
63
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
64
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
65
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
66
+
67
+
68
+
69
+
70
+ class DropdownSelect extends common/* Com */.Mw {
71
+ constructor(props) {
72
+ super(props);
73
+ _defineProperty(this, "state", {
74
+ show: false,
75
+ searchValue: ''
76
+ });
77
+ _defineProperty(this, "filterRef", (0,preact_module/* createRef */._3)());
78
+ _defineProperty(this, "overlayRef", (0,preact_module/* createRef */._3)());
79
+ _defineProperty(this, "onTouchMove", e => {
80
+ if (e.target === this.overlayRef.current) {
81
+ e.preventDefault();
82
+ e.stopPropagation();
83
+ }
84
+ });
85
+ _defineProperty(this, "hideDropdown", () => {
86
+ this.setState({
87
+ show: false,
88
+ searchValue: ''
89
+ });
90
+ });
91
+ _defineProperty(this, "onKeydown", e => {
92
+ if (e.key === 'Escape') {
93
+ if (!this.state.show) return;
94
+ if (this.state.searchValue) this.setState({
95
+ searchValue: ''
96
+ });else this.hideDropdown();
97
+ e.preventDefault();
98
+ e.stopPropagation();
99
+ }
100
+ });
101
+ _defineProperty(this, "hasSearch", () => {
102
+ if (this.props.has_search) return true;
103
+ return util/* default */.A.size(this.props.items) >= 10;
104
+ });
105
+ _defineProperty(this, "getFilteredOptions", () => {
106
+ let items = this.props.items;
107
+ if (this.state.searchValue && this.hasSearch()) {
108
+ items = util/* default */.A.filter(items, item => {
109
+ let optionName = util/* default */.A.unicodeToAscii(item.name).toLowerCase().replace(/ /g, '');
110
+ let optionDesc = util/* default */.A.unicodeToAscii(item.desc).toLowerCase().replace(/ /g, '');
111
+ let searchValue = util/* default */.A.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g, '');
112
+ return optionName.indexOf(searchValue) != -1 || optionDesc.indexOf(searchValue) != -1;
113
+ });
114
+ }
115
+ return items;
116
+ });
117
+ _defineProperty(this, "onChangeSearchValue", e => {
118
+ this.setState({
119
+ searchValue: e.target.value
120
+ });
121
+ });
122
+ _defineProperty(this, "toogleDropdown", async () => {
123
+ await this.setState({
124
+ show: true,
125
+ searchValue: ''
126
+ });
127
+ this.focusFilter();
128
+ });
129
+ _defineProperty(this, "onSelect", item => {
130
+ this.props.onSelect(item);
131
+ this.hideDropdown();
132
+ });
133
+ _defineProperty(this, "onBackgroundScroll", e => {
134
+ console.log('EEEEEEE', e);
135
+ alert('y');
136
+ });
137
+ document.addEventListener('touchmove', function (e) {});
138
+ }
139
+ componentDidMount() {
140
+ window.addEventListener('keydown', this.onKeydown);
141
+ }
142
+ componentWillUnmount() {
143
+ window.removeEventListener('keydown', this.onKeydown);
144
+ }
145
+ renderEmpty() {
146
+ return (0,preact_module.h)("div", {
147
+ class: "dropdown_select_filter__empty"
148
+ }, (0,preact_module.h)("img", {
149
+ class: "dropdown_select_filter__empty_img",
150
+ src: __webpack_require__(3142)
151
+ }), (0,preact_module.h)("div", {
152
+ class: "muted",
153
+ style: "text-align: center !important;"
154
+ }, "Kh\xF4ng c\xF3 k\u1EBFt qu\u1EA3"));
155
+ }
156
+ renderLoading() {
157
+ return (0,preact_module.h)("div", {
158
+ class: "dropdown_select_filter__empty pt-3"
159
+ }, (0,preact_module.h)(spinner/* default */.A, {
160
+ size: "40",
161
+ static: true
162
+ }), (0,preact_module.h)("div", {
163
+ class: "muted mt-2",
164
+ style: "text-align: center !important;"
165
+ }, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
166
+ }
167
+ focusFilter() {
168
+ if (!this.filterRef.current) return;
169
+ this.filterRef.current.focus();
170
+ util/* default */.A.setTimeout(() => {
171
+ if (!this.filterRef.current) return;
172
+ this.filterRef.current.focus();
173
+ }, 100);
174
+ }
175
+ renderDropdown() {
176
+ if (!this.state.show) return null;
177
+ let items = this.getFilteredOptions();
178
+ let $items = util/* default */.A.map(items, item => {
179
+ return (0,preact_module.h)("div", {
180
+ class: "dropdown_select__item",
181
+ onClick: _ => this.onSelect(item)
182
+ }, item.name);
183
+ });
184
+ let $filter = null;
185
+ if (this.hasSearch()) {
186
+ let $img = (0,preact_module.h)("img", {
187
+ class: "dropdown_select_filter__icon",
188
+ src: __webpack_require__(5452)
189
+ });
190
+ if (this.props.loading) {
191
+ $img = (0,preact_module.h)("img", {
192
+ class: "dropdown_select_filter__icon",
193
+ src: __webpack_require__(185)
194
+ });
195
+ }
196
+ $filter = (0,preact_module.h)("div", {
197
+ class: "dropdown_select_filter"
198
+ }, $img, (0,preact_module.h)("input", {
199
+ ref: this.filterRef,
200
+ value: this.state.searchValue,
201
+ onInput: this.onChangeSearchValue,
202
+ type: "text",
203
+ class: "dropdown_select_filter_input "
204
+ }));
205
+ }
206
+ if ($items.length == 0) $items = this.renderEmpty();
207
+ if (this.props.loading) $items = this.renderLoading();
208
+ let style = `width: ${this.props.width || '150px'} !important;`;
209
+ if (this.props.full) {
210
+ style = ` top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; `;
211
+ return (0,preact_module.h)("div", {
212
+ class: "dropdown_select__overlay",
213
+ ref: this.overlayRef,
214
+ onClick: this.hideDropdown,
215
+ onTouchMove: this.onTouchMove
216
+ }, (0,preact_module.h)("div", {
217
+ class: "dropdown_select",
218
+ style: style,
219
+ onClick: e => {
220
+ e.preventDefault();
221
+ e.stopPropagation();
222
+ }
223
+ }, $filter, (0,preact_module.h)("div", {
224
+ class: "dropdown_select__items"
225
+ }, $items)));
226
+ }
227
+ return (0,preact_module.h)("div", {
228
+ class: "dropdown_select",
229
+ style: style
230
+ }, $filter, (0,preact_module.h)("div", {
231
+ class: "dropdown_select__items"
232
+ }, $items));
233
+ }
234
+ render() {
235
+ let $name = (0,preact_module.h)("div", {
236
+ class: "muted text-truncate",
237
+ style: "flex: 1 !important;"
238
+ }, "Ch\u1ECDn m\u1ED9t ph\u1EA7n t\u1EED");
239
+ if (util/* default */.A.get(this.props, 'selected.name')) $name = (0,preact_module.h)("div", {
240
+ class: "text-truncate",
241
+ style: "flex: 1 !important;"
242
+ }, util/* default */.A.get(this.props, 'selected.name'));
243
+ let style = 'position: relative !important;';
244
+ if (this.props.full) {
245
+ style = '';
246
+ }
247
+ return (0,preact_module.h)("div", {
248
+ style: style
249
+ }, (0,preact_module.h)(common/* Clickaway */.tW, {
250
+ onClickaway: this.hideDropdown
251
+ }, (0,preact_module.h)("div", {
252
+ type: "text",
253
+ class: 'dropdown_select_input ' + this.props.extra_cls,
254
+ onClick: this.toogleDropdown
255
+ }, $name, "\xA0", (0,preact_module.h)("img", {
256
+ class: "dropdown_select__caret",
257
+ src: __webpack_require__(7741)
258
+ })), this.renderDropdown()));
259
+ }
260
+ }
261
+ ;// ./src/order/address_picker.js
262
+ function address_picker_defineProperty(e, r, t) { return (r = address_picker_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
263
+ function address_picker_toPropertyKey(t) { var i = address_picker_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
264
+ function address_picker_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
265
+
266
+
267
+
268
+
269
+ class AddressPicker extends common/* Com */.Mw {
270
+ constructor(props) {
271
+ super(props);
272
+ address_picker_defineProperty(this, "state", {
273
+ show: false,
274
+ searchValue: '',
275
+ addresses: []
276
+ });
277
+ address_picker_defineProperty(this, "filterRef", (0,preact_module/* createRef */._3)());
278
+ address_picker_defineProperty(this, "overlayRef", (0,preact_module/* createRef */._3)());
279
+ address_picker_defineProperty(this, "onTouchMove", e => {
280
+ if (e.target === this.overlayRef.current) {
281
+ e.preventDefault();
282
+ e.stopPropagation();
283
+ }
284
+ });
285
+ address_picker_defineProperty(this, "hideDropdown", () => {
286
+ this.setState({
287
+ show: false,
288
+ searchValue: ''
289
+ });
290
+ });
291
+ address_picker_defineProperty(this, "onKeydown", e => {
292
+ if (e.key === 'Escape') {
293
+ if (!this.state.show) return;
294
+ if (this.state.searchValue) this.setState({
295
+ searchValue: ''
296
+ });else this.hideDropdown();
297
+ e.preventDefault();
298
+ e.stopPropagation();
299
+ }
300
+ if (e.key == 'Enter') {}
301
+ });
302
+ address_picker_defineProperty(this, "doSearch", util/* default */.A.throttle(async () => {
303
+ let requestId = Date.now();
304
+ this.requestId = requestId;
305
+ let res = await this.props.store.suggest_addresses(this.state.searchValue);
306
+ if (this.requestId !== requestId) return;
307
+ this.setState({
308
+ addresses: util/* default */.A.get(res, 'body.addresses', [])
309
+ });
310
+ }, 100));
311
+ address_picker_defineProperty(this, "onChangeSearchValue", e => {
312
+ this.setState({
313
+ searchValue: e.target.value
314
+ });
315
+ this.props.onChangeAddress(e.target.value);
316
+ this.doSearch();
317
+ });
318
+ address_picker_defineProperty(this, "toogleDropdown", async () => {
319
+ await this.setState({
320
+ show: true,
321
+ searchValue: this.props.initAddress || ''
322
+ });
323
+ this.focusFilter();
324
+ });
325
+ address_picker_defineProperty(this, "onSelect", item => {
326
+ this.props.onSelect(item);
327
+ this.hideDropdown();
328
+ });
329
+ address_picker_defineProperty(this, "onBackgroundScroll", e => {
330
+ console.log('EEEEEEE', e);
331
+ });
332
+ document.addEventListener('touchmove', function (e) {});
333
+ }
334
+ componentDidMount() {
335
+ window.addEventListener('keydown', this.onKeydown);
336
+ }
337
+ componentWillUnmount() {
338
+ window.removeEventListener('keydown', this.onKeydown);
339
+ }
340
+ renderEmpty() {
341
+ return (0,preact_module.h)("div", {
342
+ class: "dropdown_select_filter__empty"
343
+ }, (0,preact_module.h)("img", {
344
+ class: "dropdown_select_filter__empty_img",
345
+ src: __webpack_require__(3142)
346
+ }), (0,preact_module.h)("div", {
347
+ class: "muted",
348
+ style: "text-align: center !important;"
349
+ }, "Kh\xF4ng c\xF3 k\u1EBFt qu\u1EA3"));
350
+ }
351
+ renderLoading() {
352
+ return (0,preact_module.h)("div", {
353
+ class: "dropdown_select_filter__empty pt-3"
354
+ }, (0,preact_module.h)(spinner/* default */.A, {
355
+ size: "40",
356
+ static: true
357
+ }), (0,preact_module.h)("div", {
358
+ class: "muted mt-2",
359
+ style: "text-align: center !important;"
360
+ }, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
361
+ }
362
+ focusFilter() {
363
+ if (!this.filterRef.current) return;
364
+ this.filterRef.current.focus();
365
+ util/* default */.A.setTimeout(() => {
366
+ if (!this.filterRef.current) return;
367
+ this.filterRef.current.focus();
368
+ }, 100);
369
+ }
370
+ renderDropdown() {
371
+ if (!this.state.show) return null;
372
+ let $items = util/* default */.A.map(this.state.addresses, (addr, i) => {
373
+ let label = [((addr.address || '') + ' ' + normalize(addr.street)).trim()].join(', ');
374
+ let desc = [normalize(addr.ward), normalize(addr.district), normalize(addr.province)].join(', ');
375
+ return (0,preact_module.h)("div", {
376
+ class: "dropdown_select__item",
377
+ onClick: _ => this.onSelect(addr),
378
+ key: i
379
+ }, (0,preact_module.h)("div", null, (0,preact_module.h)("b", null, label)), (0,preact_module.h)("div", {
380
+ style: "opacity: 0.7 !important;"
381
+ }, desc));
382
+ });
383
+ let $filter = null;
384
+ let $img = (0,preact_module.h)("img", {
385
+ class: "dropdown_select_filter__icon",
386
+ src: __webpack_require__(5452)
387
+ });
388
+ if (this.props.loading) {
389
+ $img = (0,preact_module.h)("img", {
390
+ class: "dropdown_select_filter__icon",
391
+ src: __webpack_require__(185)
392
+ });
393
+ }
394
+ $filter = (0,preact_module.h)("div", {
395
+ class: "dropdown_select_filter"
396
+ }, $img, (0,preact_module.h)("input", {
397
+ ref: this.filterRef,
398
+ value: this.state.searchValue,
399
+ onInput: this.onChangeSearchValue,
400
+ type: "text",
401
+ class: "dropdown_select_filter_input "
402
+ }));
403
+ if ($items.length == 0) $items = this.renderEmpty();
404
+ if (this.props.loading) $items = this.renderLoading();
405
+ let style = `width: ${this.props.width || '150px'} !important;`;
406
+ if (this.props.full) {
407
+ style = ` top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; `;
408
+ return (0,preact_module.h)("div", {
409
+ class: "dropdown_select__overlay",
410
+ ref: this.overlayRef,
411
+ onClick: this.hideDropdown,
412
+ onTouchMove: this.onTouchMove
413
+ }, (0,preact_module.h)("div", {
414
+ class: "dropdown_select",
415
+ style: style,
416
+ onClick: e => {
417
+ e.preventDefault();
418
+ e.stopPropagation();
419
+ }
420
+ }, $filter, (0,preact_module.h)("div", {
421
+ class: "dropdown_select__items"
422
+ }, $items)));
423
+ }
424
+ return (0,preact_module.h)("div", {
425
+ class: "dropdown_select",
426
+ style: style
427
+ }, $filter, (0,preact_module.h)("div", {
428
+ class: "dropdown_select__items"
429
+ }, $items));
430
+ }
431
+ render() {
432
+ let $name = (0,preact_module.h)("div", {
433
+ class: "text-truncate",
434
+ style: "flex: 1 !important;"
435
+ }, this.props.initAddress);
436
+ let style = 'position: relative !important;';
437
+ if (this.props.full) {
438
+ style = '';
439
+ }
440
+ return (0,preact_module.h)("div", {
441
+ style: style
442
+ }, (0,preact_module.h)(common/* Clickaway */.tW, {
443
+ onClickaway: this.hideDropdown
444
+ }, (0,preact_module.h)("div", {
445
+ type: "text",
446
+ class: 'dropdown_select_input ' + this.props.extra_cls,
447
+ onClick: this.toogleDropdown
448
+ }, $name), this.renderDropdown()));
449
+ }
450
+ }
451
+ function normalize(s) {
452
+ let ls = (s + '').toLowerCase();
453
+ if (ls.startsWith('tp ')) return s.substr(3);
454
+ if (ls.startsWith('thanh pho ')) return s.substr('thanh pho '.length);
455
+ if (ls.startsWith('thành phố ')) return s.substr('thành phố '.length);
456
+ if (ls.startsWith('tỉnh ')) return s.substr('tỉnh '.length);
457
+ if (ls.startsWith('huyện ')) return s.substr('huyện '.length);
458
+ if (ls.startsWith('tỉnh ')) return s.substr('tỉnh '.length);
459
+ if (ls.startsWith('xã ')) return s.substr('xã '.length);
460
+ if (ls.startsWith('thị trấn ')) return s.substr('thị trấn '.length);
461
+ if (ls.startsWith('thị xã ')) return s.substr('thị xã '.length);
462
+ if (ls.startsWith('đường ') && (s[7] < '0' || s[7] > '9')) return s.substr('đường '.length);
463
+ if (ls.startsWith('phường ') && (s[7] < '0' || s[7] > '9')) return s.substr('phường '.length);
464
+ if (ls.startsWith('quận ') && (s[7] < '0' || s[7] > '9')) return s.substr('quận '.length);
465
+ return s;
466
+ }
467
+ ;// ./src/order/icon.js
468
+
469
+ let promiseMainCSS = (() => __webpack_require__.e(/* import() */ 278).then(__webpack_require__.bind(__webpack_require__, 9278)))();
470
+ var $link = document.createElement('link');
471
+ $link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';
472
+ $link.rel = 'stylesheet';
473
+ document.head.append($link);
474
+ util/* default */.A.preloadWebfonts(['Inter'], [400, 500]);
475
+
476
+ let defaultAvatar = __webpack_require__(2538);
477
+
478
+
479
+
480
+ class Icon extends common/* Com */.Mw {
481
+ render() {
482
+ if (this.props.name == 'package') {
483
+ if (this.props.active) return (0,preact_module.h)("img", {
484
+ style: "width: 18px !important;",
485
+ src: __webpack_require__(8512)
486
+ });
487
+ return (0,preact_module.h)("img", {
488
+ style: "width: 18px !important;",
489
+ src: __webpack_require__(6857)
490
+ });
491
+ }
492
+ if (this.props.name === 'shop') {
493
+ if (this.props.active) return (0,preact_module.h)("img", {
494
+ style: "width: 18px !important;",
495
+ src: __webpack_require__(5244)
496
+ });
497
+ return (0,preact_module.h)("img", {
498
+ style: "width: 18px !important;",
499
+ src: __webpack_require__(2523)
500
+ });
501
+ }
502
+ }
503
+ }
504
+ ;// ./src/order/order.js
505
+ function order_defineProperty(e, r, t) { return (r = order_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
506
+ function order_toPropertyKey(t) { var i = order_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
507
+ function order_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
508
+
509
+
510
+
511
+
512
+
513
+
514
+
515
+
516
+ var checkedimg = __webpack_require__(5860);
517
+ var ximg = __webpack_require__(3080);
518
+ class order_Order extends common/* Com */.Mw {
519
+ constructor(props) {
520
+ super(props);
521
+ order_defineProperty(this, "state", {
522
+ loadProvince: true,
523
+ g_err: '',
524
+ fullname: '',
525
+ email: '',
526
+ phone: '',
527
+ loading: true,
528
+ order: {},
529
+ err: {},
530
+ shipping_address: 'new',
531
+ selectedProvince: null,
532
+ selectedDistrict: null,
533
+ selectedWard: null,
534
+ street: '',
535
+ address: '',
536
+ sending: false,
537
+ step: ''
538
+ });
539
+ order_defineProperty(this, "renderMobileSuccess", order => {
540
+ return (0,preact_module.h)("div", {
541
+ class: "order",
542
+ style: "height: 100% !important"
543
+ }, (0,preact_module.h)("div", {
544
+ style: "display: flex !important; align-items: center !important; padding-top: 40px !important; padding-bottom: 20px !important; flex-direction: column !important; height: 100% !important"
545
+ }, (0,preact_module.h)("img", {
546
+ style: "width: 60px !important; height: 60px !important;",
547
+ width: "60",
548
+ height: "60",
549
+ src: checkedimg
550
+ }), (0,preact_module.h)("div", {
551
+ style: "margin-top: 20px !important; margin-bottom: 10px !important"
552
+ }, (0,preact_module.h)("b", {
553
+ style: "font-size: 18px !important;"
554
+ }, "\u0110\u01A1n h\xE0ng c\u1EE7a b\u1EA1n \u0111\xE3 \u0111\u01B0\u1EE3c ghi nh\u1EADn")), (0,preact_module.h)("div", {
555
+ class: "muted"
556
+ }, "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_module.h)("div", {
557
+ style: "flex:1 !important"
558
+ }), (0,preact_module.h)("div", {
559
+ style: "margin-top: 20px !important; padding: 0px 20px 0 20px !important; width: 100% !important"
560
+ }, (0,preact_module.h)("div", {
561
+ class: "order_btn order__btn__light",
562
+ onClick: this.close
563
+ }, this.props.t('close')))));
564
+ });
565
+ order_defineProperty(this, "onSelectProvince", async item => {
566
+ this.setState({
567
+ selectedProvince: item,
568
+ err: {},
569
+ g_err: ''
570
+ });
571
+ this.setState({
572
+ loadDistrict: true
573
+ });
574
+ let out = await this.props.store.list_districts({
575
+ id: item.id
576
+ });
577
+ this.setState({
578
+ loadDistrict: false
579
+ });
580
+ if (!out.error) this.setState({
581
+ districts: util/* default */.A.get(out, 'body.addresses')
582
+ });
583
+ });
584
+ order_defineProperty(this, "onSelectDistrict", async item => {
585
+ this.setState({
586
+ selectedDistrict: item,
587
+ err: {},
588
+ g_err: ''
589
+ });
590
+ this.setState({
591
+ loadWard: true
592
+ });
593
+ let out = await this.props.store.list_wards({
594
+ id: item.id
595
+ });
596
+ this.setState({
597
+ loadWard: false
598
+ });
599
+ if (!out.error) this.setState({
600
+ wards: util/* default */.A.get(out, 'body.addresses')
601
+ });
602
+ });
603
+ order_defineProperty(this, "onSelectWard", item => this.setState({
604
+ selectedWard: item,
605
+ err: {},
606
+ g_err: ''
607
+ }));
608
+ order_defineProperty(this, "onChangeFullname", e => this.setState({
609
+ fullname: e.target.value,
610
+ err: {},
611
+ g_err: ''
612
+ }));
613
+ order_defineProperty(this, "onChangeAddress", e => this.setState({
614
+ address: e,
615
+ err: {},
616
+ g_err: ''
617
+ }));
618
+ order_defineProperty(this, "onSelectAddress", addr => {
619
+ if (!addr) return;
620
+ this.setState({
621
+ address: [util/* default */.A.trim(addr.address), util/* default */.A.trim(addr.street)].join(' ').trim(),
622
+ street: addr.street,
623
+ err: {},
624
+ g_err: ''
625
+ });
626
+ this.onSelectWard({
627
+ id: addr.ward_id,
628
+ name: addr.ward
629
+ });
630
+ this.onSelectDistrict({
631
+ id: addr.district_id,
632
+ name: addr.district
633
+ });
634
+ this.onSelectProvince({
635
+ id: addr.province_id,
636
+ name: addr.province
637
+ });
638
+ });
639
+ order_defineProperty(this, "onChangeEmail", e => this.setState({
640
+ email: e.target.value,
641
+ err: {},
642
+ g_err: ''
643
+ }));
644
+ order_defineProperty(this, "onChangePhone", e => this.setState({
645
+ phone: e.target.value,
646
+ err: {},
647
+ g_err: ''
648
+ }));
649
+ order_defineProperty(this, "onChangePaymentMethod", id => this.setState({
650
+ pm: id
651
+ }));
652
+ order_defineProperty(this, "onChangeQuantity", (item, text) => {
653
+ let qty = parseInt(text) || 1;
654
+ item.quantity = qty;
655
+ this.forceUpdate();
656
+ });
657
+ order_defineProperty(this, "confirm", async () => {
658
+ this.setState({
659
+ g_err: ''
660
+ });
661
+ let err = {};
662
+ if (!this.state.shipping) {
663
+ this.setState({
664
+ g_err: 'Mời bạn chọn địa chỉ giao hàng trước khi xác nhận'
665
+ });
666
+ }
667
+ if (this.state.shipping === 'shop') {
668
+ if (!util/* default */.A.isPhone(this.state.phone)) {
669
+ err.phone = true;
670
+ }
671
+ if (!util/* default */.A.trim(this.state.fullname)) {
672
+ err.name = true;
673
+ }
674
+ if (!util/* default */.A.trim(this.state.email)) {
675
+ err.email = true;
676
+ }
677
+ } else if (this.state.shipping_address == 'new') {
678
+ if (!util/* default */.A.isPhone(this.state.phone)) {
679
+ err.phone = true;
680
+ }
681
+ if (!util/* default */.A.trim(this.state.fullname)) {
682
+ err.name = true;
683
+ }
684
+ if (!util/* default */.A.trim(this.state.address)) {
685
+ err.address = true;
686
+ }
687
+ if (util/* default */.A.size(this.state.selectedWard) == 0) {
688
+ err.ward = true;
689
+ }
690
+ if (util/* default */.A.size(this.state.selectedDistrict) == 0) {
691
+ err.district = true;
692
+ }
693
+ if (util/* default */.A.size(this.state.selectedProvince) == 0) {
694
+ err.province = true;
695
+ }
696
+ }
697
+ if (util/* default */.A.size(err) > 0) {
698
+ this.setState({
699
+ err,
700
+ g_err: this.props.t('input_shipping_info_err')
701
+ });
702
+ return;
703
+ }
704
+ let user = this.props.store.matchUser();
705
+ let ufullname = util/* default */.A.getUserAttr(user, 'fullname', 'text');
706
+ let uemail = util/* default */.A.getUserAttr(user, 'emails', 'text');
707
+ let uphone = util/* default */.A.getUserAttr(user, 'phones', 'text');
708
+ let order = util/* default */.A.cloneDeep(this.state.order);
709
+ if (this.state.shipping === 'shop') {
710
+ util/* default */.A.set(order, 'shipping.pickup_at_shop', true);
711
+ util/* default */.A.set(order, 'shipping.address.phone', this.state.phone);
712
+ util/* default */.A.set(order, 'shipping.address.fullname', this.state.fullname);
713
+ util/* default */.A.set(order, 'shipping.address.email', this.state.email);
714
+ } else {
715
+ if (this.state.shipping_address == 'new') {
716
+ let out = await this.props.store.createShippingAddress({
717
+ address: this.state.address,
718
+ country: 'Việt Nam',
719
+ fullname: this.state.fullname,
720
+ email: this.state.email,
721
+ phone: this.state.phone,
722
+ district: this.state.selectedDistrict.name,
723
+ district_id: this.state.selectedDistrict.id,
724
+ province: this.state.selectedProvince.name,
725
+ province_id: this.state.selectedProvince.id,
726
+ ward: this.state.selectedWard.name,
727
+ street: this.state.street,
728
+ ward_id: this.state.selectedWard.id
729
+ });
730
+ if (out.error) return this.setState({
731
+ g_err: this.props.t('update_failed')
732
+ });
733
+ util/* default */.A.set(order, 'shipping.address', out.body);
734
+ } else {
735
+ let addresses = this.props.store.matchShippingAddresses();
736
+ let sa = util/* default */.A.find(addresses, addr => addr.id === this.state.shipping_address);
737
+ if (!sa) {
738
+ return this.setState({
739
+ err,
740
+ g_err: this.props.t('input_shipping_info_err')
741
+ });
742
+ }
743
+ util/* default */.A.set(order, 'shipping.address', sa);
744
+ }
745
+ }
746
+ let changeduser = false;
747
+ if (!ufullname && this.state.fullname) {
748
+ changeduser = true;
749
+ util/* default */.A.setUserAttr(user, {
750
+ key: 'fullname',
751
+ text: this.state.fullname
752
+ });
753
+ }
754
+ if (!uemail && this.state.email) {
755
+ changeduser = true;
756
+ util/* default */.A.setUserAttr(user, {
757
+ key: 'emails',
758
+ text: this.state.email
759
+ });
760
+ }
761
+ if (!uphone && this.state.phone) {
762
+ changeduser = true;
763
+ util/* default */.A.setUserAttr(user, {
764
+ key: 'phones',
765
+ text: this.state.phone
766
+ });
767
+ }
768
+ if (changeduser) this.props.store.setUser(user);
769
+ this.setState({
770
+ sending: true
771
+ });
772
+ order.user_confirmation = 'confirmed';
773
+ let out = await this.props.store.updateOrder(order);
774
+ this.setState({
775
+ sending: false
776
+ });
777
+ if (out.error) {
778
+ return this.setState({
779
+ g_err: this.props.t('update_failed')
780
+ });
781
+ }
782
+ this.setState({
783
+ step: 'success'
784
+ });
785
+ if (this.props.onResponse) this.props.onResponse('confirmed');
786
+ });
787
+ order_defineProperty(this, "onCancel", () => {
788
+ if (this.props.onResponse) this.props.onResponse('rejected');
789
+ if (this.props.cid && !this.state.order.user_confirmation) {
790
+ let order = util/* default */.A.cloneDeep(this.state.order);
791
+ order.user_confirmation = 'rejected';
792
+ this.props.store.updateOrder(order);
793
+ }
794
+ this.close();
795
+ });
796
+ order_defineProperty(this, "close", () => {
797
+ if (this.props.onClose) this.props.onClose();
798
+ });
799
+ this.load();
800
+ }
801
+ async load() {
802
+ if (!this.props.order_id) return;
803
+ let orderout = await this.props.store.fetchOrder(this.props.order_id);
804
+ this.setState({
805
+ loading: false
806
+ });
807
+ if (!orderout.error) {
808
+ this.setState({
809
+ order: orderout.body
810
+ });
811
+ } else {
812
+ this.setState({
813
+ error: orderout.error
814
+ });
815
+ }
816
+ let user = this.props.store.matchUser();
817
+ let attributes = util/* default */.A.get(this.props.store.matchUser(), 'attributes', []);
818
+ let fullname = util/* default */.A.get(util/* default */.A.find(attributes, att => att.key === 'fullname'), 'text');
819
+ let email = util/* default */.A.get(util/* default */.A.find(attributes, att => att.key === 'emails'), 'text');
820
+ let phone = util/* default */.A.get(util/* default */.A.find(attributes, att => att.key === 'phones'), 'text');
821
+ this.setState({
822
+ fullname,
823
+ email,
824
+ phone
825
+ });
826
+ await this.props.store.fetchShippingAddresses();
827
+ let out = await this.props.store.list_provinces();
828
+ this.setState({
829
+ loadProvince: false
830
+ });
831
+ if (!out.error) this.setState({
832
+ provinces: util/* default */.A.get(out, 'body.addresses')
833
+ });
834
+ }
835
+ isMobile() {
836
+ if (this.props.cid) return true;
837
+ if (this.props.isMobile) return true;
838
+ return this.props.store.isMobile();
839
+ }
840
+ onChangeShippingAddress(id) {
841
+ this.setState({
842
+ shipping_address: id,
843
+ err: {},
844
+ g_err: ''
845
+ });
846
+ }
847
+ onChangeShipping(id) {
848
+ this.setState({
849
+ shipping: id,
850
+ err: {},
851
+ g_err: ''
852
+ });
853
+ }
854
+ renderDesktopPaymentMethod(order) {
855
+ return null;
856
+ let editmode = false;
857
+ if (!order.status || order.status == 'open') {
858
+ editmode = !order.user_confirmation;
859
+ }
860
+ if (editmode) {
861
+ let pms = this.props.store.matchPaymentMethods();
862
+ let $pms = util/* default */.A.map(pms, pm => {
863
+ let $name = pm.description;
864
+ if (pm.method == 'bank_transfer') {
865
+ $name = pm.description + ' ' + pm.bank_name + ' ' + pm.bank_branch;
866
+ }
867
+ let cls = 'order__card';
868
+ let $desc = null;
869
+ if (this.state.pm === pm.id) {
870
+ cls += ' order__card__active';
871
+ $desc = (0,preact_module.h)("div", {
872
+ class: "muted mt-1",
873
+ style: "margin-left: 26px !important;"
874
+ }, "Tr\u1EA3 ti\u1EC1n m\u1EB7t khi b\u1EA1n nh\u1EADn h\xE0ng");
875
+ if (pm.method == 'bank_transfer') {
876
+ $desc = (0,preact_module.h)("div", {
877
+ class: "muted mt-1",
878
+ style: "margin-left: 26px !important;"
879
+ }, (0,preact_module.h)("div", null, "STK: ", pm.bank_number), (0,preact_module.h)("div", null, "Ch\u1EE7 t\xE0i kho\u1EA3n: ", pm.bank_owner));
880
+ }
881
+ }
882
+ return (0,preact_module.h)("div", {
883
+ style: "width: 100% !important; margin-top: 10px !important;"
884
+ }, (0,preact_module.h)("div", {
885
+ class: "radio"
886
+ }, (0,preact_module.h)("input", {
887
+ type: "radio",
888
+ id: 'pm.' + pm.id,
889
+ onInput: e => this.onChangePaymentMethod(pm.id),
890
+ name: "pm",
891
+ checked: this.state.pm === pm.id
892
+ }), (0,preact_module.h)("label", {
893
+ class: "radio--label",
894
+ style: `margin-left: 4px !important; font-weight: ${this.state.pm === pm.id ? 500 : 400} !important;`,
895
+ for: 'pm.' + pm.id
896
+ }, $name), (0,preact_module.h)("div", {
897
+ class: "radio--check"
898
+ }, (0,preact_module.h)("div", {
899
+ class: "inside"
900
+ })), $desc));
901
+ });
902
+ let seccls = 'card_section';
903
+ if (this.isMobile()) seccls = 'order_section';
904
+ return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
905
+ class: "order_section__line"
906
+ }), (0,preact_module.h)("div", {
907
+ class: seccls
908
+ }, (0,preact_module.h)("div", {
909
+ class: "order_label"
910
+ }, this.props.t('payment')), (0,preact_module.h)("div", {
911
+ class: "form",
912
+ style: "justify-content: space-between !important;"
913
+ }, $pms)));
914
+ }
915
+ let pm = order.payment_method || {
916
+ method: 'cod'
917
+ };
918
+ let $body = null;
919
+ if (pm.method === 'cash') $body = (0,preact_module.h)("div", null, this.props.t('pm_cash'));
920
+ if (pm.method === 'cod') $body = (0,preact_module.h)("div", null, this.props.t('pm_cod'));
921
+ if (pm.method === 'bank_transfer') {
922
+ let name = pm.bank_name;
923
+ if (pm.bank_branch) name += ' - ' + pm.bank_branch;
924
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", null, "Ng\xE2n h\xE0ng: ", name), (0,preact_module.h)("div", {
925
+ class: "mt-1"
926
+ }, "Ch\u1EE7 t\xE0i kho\u1EA3n: ", pm.bank_owner), (0,preact_module.h)("div", {
927
+ class: "mt-1"
928
+ }, "S\u1ED1 t\xE0i kho\u1EA3n: ", pm.bank_number));
929
+ }
930
+ if (!$body) return null;
931
+ return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
932
+ class: "order_label"
933
+ }, this.props.t('payment')), $body);
934
+ }
935
+ renderDesktopShipping(order) {
936
+ let editmode = false;
937
+ if (!order.status || order.status == 'open') {
938
+ editmode = !order.user_confirmation;
939
+ }
940
+ let user = this.props.store.matchUser();
941
+ if (editmode) {
942
+ let addresses = this.props.store.matchShippingAddresses();
943
+ let provinces = util/* default */.A.map(this.state.provinces, province => ({
944
+ id: province.id,
945
+ name: province.province
946
+ }));
947
+ let districts = util/* default */.A.map(this.state.districts, district => ({
948
+ id: district.id,
949
+ name: district.district
950
+ }));
951
+ let wards = util/* default */.A.map(this.state.wards, ward => ({
952
+ id: ward.id,
953
+ name: ward.ward
954
+ }));
955
+ let cls = 'ship_card';
956
+ let $body = null;
957
+ let ship_icon_active = false;
958
+ if (this.state.shipping === 'ship') {
959
+ ship_icon_active = true;
960
+ let $preaddrs = util/* default */.A.map(addresses, addr => {
961
+ let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
962
+ let $phone = null;
963
+ if (addr.phone) {
964
+ $phone = (0,preact_module.h)(preact_module/* Fragment */.FK, null, "\xA0\xB7\xA0", this.props.t('phn'), " ", addr.phone);
965
+ }
966
+ return (0,preact_module.h)("div", {
967
+ style: "margin-bottom: 15px !important"
968
+ }, (0,preact_module.h)("div", {
969
+ class: "radio d-flex "
970
+ }, (0,preact_module.h)("input", {
971
+ type: "radio",
972
+ id: 'shipping_addr.' + addr.id,
973
+ onInput: e => this.onChangeShippingAddress(addr.id),
974
+ name: "shipping_address",
975
+ checked: this.state.shipping_address === addr.id
976
+ }), (0,preact_module.h)("label", {
977
+ class: "radio--label",
978
+ for: 'shipping_addr.' + addr.id,
979
+ style: `font-weight: ${this.state.shipping_address === addr.id ? 500 : 400} !important`
980
+ }, addr.fullname, $phone, (0,preact_module.h)("div", {
981
+ class: "mt-1 muted"
982
+ }, "DC ", fulladdr)), (0,preact_module.h)("div", {
983
+ class: "radio--check"
984
+ }, (0,preact_module.h)("div", {
985
+ class: "inside"
986
+ }))));
987
+ });
988
+ $preaddrs.push((0,preact_module.h)("div", {
989
+ style: ""
990
+ }, (0,preact_module.h)("div", {
991
+ class: "radio d-flex "
992
+ }, (0,preact_module.h)("input", {
993
+ type: "radio",
994
+ id: 'shipping_addr.new',
995
+ onInput: e => this.onChangeShippingAddress('new'),
996
+ name: "shipping_address",
997
+ checked: this.state.shipping_address === 'new'
998
+ }), (0,preact_module.h)("label", {
999
+ class: "radio--label",
1000
+ for: 'shipping_addr.new'
1001
+ }, this.state.shipping_address === 'new' ? (0,preact_module.h)("b", null, "T\u1EDBi \u0111\u1ECBa ch\u1EC9 kh\xE1c") : 'Tới địa chỉ khác'), (0,preact_module.h)("div", {
1002
+ class: "radio--check"
1003
+ }, (0,preact_module.h)("div", {
1004
+ class: "inside"
1005
+ })))));
1006
+ let $new = (0,preact_module.h)("div", {
1007
+ style: "padding-left: 22px !important;"
1008
+ }, (0,preact_module.h)("div", {
1009
+ class: "d-flex"
1010
+ }, (0,preact_module.h)("div", {
1011
+ class: "mr-2",
1012
+ style: "flex: 1 !important;"
1013
+ }, (0,preact_module.h)("div", {
1014
+ class: "order_form_label"
1015
+ }, this.props.t('fullname')), (0,preact_module.h)("input", {
1016
+ type: "text",
1017
+ class: 'form-control ' + (this.state.err.name && 'err'),
1018
+ onInput: this.onChangeFullname,
1019
+ value: this.state.fullname
1020
+ })), (0,preact_module.h)("div", {
1021
+ class: "ml-2",
1022
+ style: "flex: 1 !important;"
1023
+ }, (0,preact_module.h)("div", {
1024
+ class: "order_form_label"
1025
+ }, this.props.t('phones')), (0,preact_module.h)("input", {
1026
+ type: "text",
1027
+ class: 'form-control ' + (this.state.err.phone && 'err'),
1028
+ onInput: this.onChangePhone,
1029
+ value: this.state.phone
1030
+ }))), (0,preact_module.h)("div", {
1031
+ class: "",
1032
+ style: "width: 100% !important"
1033
+ }, (0,preact_module.h)("div", {
1034
+ class: "order_form_label"
1035
+ }, this.props.t('address')), (0,preact_module.h)(AddressPicker, {
1036
+ initAddress: this.state.address,
1037
+ store: this.props.store,
1038
+ width: "100%",
1039
+ onChangeAddress: this.onChangeAddress,
1040
+ full: this.isMobile(),
1041
+ onSelect: this.onSelectAddress,
1042
+ extra_cls: this.state.err.address && 'err'
1043
+ })), (0,preact_module.h)("div", {
1044
+ class: "d-flex",
1045
+ style: "justify-content: space-between !important;"
1046
+ }, (0,preact_module.h)("div", {
1047
+ style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
1048
+ }, (0,preact_module.h)("div", {
1049
+ class: "order_form_label"
1050
+ }, this.props.t('province')), (0,preact_module.h)(DropdownSelect, {
1051
+ width: "194",
1052
+ full: this.isMobile(),
1053
+ has_search: true,
1054
+ loading: this.state.loadProvince,
1055
+ items: provinces,
1056
+ selected: this.state.selectedProvince,
1057
+ onSelect: this.onSelectProvince,
1058
+ extra_cls: this.state.err.province && 'err'
1059
+ })), (0,preact_module.h)("div", {
1060
+ style: "flex: 1 !important; overflow:hidden !important; margin-left: 7px !important;"
1061
+ }, (0,preact_module.h)("div", {
1062
+ class: "order_form_label"
1063
+ }, this.props.t('district')), (0,preact_module.h)(DropdownSelect, {
1064
+ width: "194",
1065
+ full: this.isMobile(),
1066
+ selected: this.state.selectedDistrict,
1067
+ has_search: true,
1068
+ onSelect: this.onSelectDistrict,
1069
+ loading: this.state.loadDistrict,
1070
+ extra_cls: this.state.err.district && 'err',
1071
+ items: districts
1072
+ }))), (0,preact_module.h)("div", {
1073
+ class: "d-flex",
1074
+ style: "justify-content: space-between !important;"
1075
+ }, (0,preact_module.h)("div", {
1076
+ style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
1077
+ }, (0,preact_module.h)("div", {
1078
+ class: "order_form_label"
1079
+ }, this.props.t('ward')), (0,preact_module.h)(DropdownSelect, {
1080
+ width: "194",
1081
+ selected: this.state.selectedWard,
1082
+ full: this.isMobile(),
1083
+ has_search: true,
1084
+ onSelect: this.onSelectWard,
1085
+ extra_cls: this.state.err.ward && 'err',
1086
+ loading: this.state.loadWard,
1087
+ items: wards
1088
+ })), (0,preact_module.h)("div", {
1089
+ style: "flex: 1 !important; margin-left: 7px !important;"
1090
+ })));
1091
+ cls += ' ship_card__active';
1092
+ if (util/* default */.A.size(addresses) == 0) {
1093
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
1094
+ class: 'mt-3 mb-2 '
1095
+ }, this.props.t('input_shipping_info')), $new);
1096
+ } else {
1097
+ if (this.state.shipping_address !== 'new') $new = null;
1098
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
1099
+ class: "mt-3 mb-2",
1100
+ style: "margin-bottom: 10px !important;"
1101
+ }, "Vui l\xF2ng ch\u1ECDn \u0111\u1ECBa ch\u1EC9 giao h\xE0ng"), (0,preact_module.h)("div", {
1102
+ class: "form"
1103
+ }, $preaddrs), $new);
1104
+ }
1105
+ }
1106
+ let shopcls = 'ship_card';
1107
+ let shop_icon_active = false;
1108
+ if (this.state.shipping === 'shop') {
1109
+ shop_icon_active = true;
1110
+ shopcls += ' ship_card__active';
1111
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
1112
+ class: "d-flex"
1113
+ }, (0,preact_module.h)("div", {
1114
+ class: "mr-2",
1115
+ style: "flex: 3 !important;"
1116
+ }, (0,preact_module.h)("div", {
1117
+ class: "order_form_label"
1118
+ }, this.props.t('fullname')), (0,preact_module.h)("input", {
1119
+ type: "text",
1120
+ class: 'form-control ' + (this.state.err.name && 'err'),
1121
+ onInput: this.onChangeFullname,
1122
+ value: this.state.fullname
1123
+ })), (0,preact_module.h)("div", {
1124
+ class: "ml-2",
1125
+ style: "flex: 2 !important;"
1126
+ }, (0,preact_module.h)("div", {
1127
+ class: "order_form_label"
1128
+ }, this.props.t('phones')), (0,preact_module.h)("input", {
1129
+ type: "text",
1130
+ class: 'form-control ' + (this.state.err.phone && 'err'),
1131
+ onInput: this.onChangePhone,
1132
+ value: this.state.phone
1133
+ }))), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
1134
+ class: "order_form_label"
1135
+ }, this.props.t('email')), (0,preact_module.h)("input", {
1136
+ type: "text",
1137
+ class: 'form-control ' + (this.state.err.email && 'err'),
1138
+ onInput: this.onChangeEmail,
1139
+ value: this.state.email
1140
+ })));
1141
+ }
1142
+ let seccls = 'card_section';
1143
+ if (this.isMobile()) seccls = 'order_section';
1144
+ return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
1145
+ class: "order_section__line"
1146
+ }), (0,preact_module.h)("div", {
1147
+ class: seccls
1148
+ }, (0,preact_module.h)("div", {
1149
+ class: "order_label"
1150
+ }, this.props.t('ship_to')), (0,preact_module.h)("div", {
1151
+ class: "d-flex"
1152
+ }, (0,preact_module.h)("div", {
1153
+ class: shopcls + ' mr-3',
1154
+ onClick: e => this.onChangeShipping('shop')
1155
+ }, (0,preact_module.h)(Icon, {
1156
+ name: "shop",
1157
+ active: shop_icon_active
1158
+ }), " ", (0,preact_module.h)("b", {
1159
+ class: "ml-2"
1160
+ }, "Nh\u1EADn h\xE0ng t\u1EA1i shop")), (0,preact_module.h)("div", {
1161
+ class: cls,
1162
+ onClick: e => this.onChangeShipping('ship')
1163
+ }, (0,preact_module.h)(Icon, {
1164
+ name: "package",
1165
+ active: ship_icon_active
1166
+ }), " ", (0,preact_module.h)("b", {
1167
+ class: "ml-2"
1168
+ }, "Giao h\xE0ng cho t\xF4i"))), $body));
1169
+ }
1170
+ let addr = util/* default */.A.get(order, 'shipping.address') || {};
1171
+ let fulladdr = [addr.address, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
1172
+ let $phone = null;
1173
+ if (addr.phone) $phone = (0,preact_module.h)("div", {
1174
+ class: "mt-1 muted"
1175
+ }, this.props.t('phn'), ":\xA0", addr.phone);
1176
+ if (util/* default */.A.get(order, 'shipping.pickup_at_shop')) {
1177
+ fulladdr = 'Nhận hàng tại cửa hàng';
1178
+ }
1179
+ let $addr = fulladdr ? (0,preact_module.h)("div", null, fulladdr) : (0,preact_module.h)("i", {
1180
+ class: "i muted"
1181
+ }, "Ch\u01B0a c\xF3 \u0111\u1ECBa ch\u1EC9 giao h\xE0ng");
1182
+ let seccls = 'card_section';
1183
+ if (this.isMobile()) seccls = 'order_section';
1184
+ return (0,preact_module.h)("div", {
1185
+ class: seccls
1186
+ }, (0,preact_module.h)("div", {
1187
+ class: "order_label "
1188
+ }, this.props.t('ship_to')), $addr, $phone);
1189
+ }
1190
+ renderDesktopSummary(order) {
1191
+ let $deposit = null;
1192
+ if (order.deposit > 0) {
1193
+ $deposit = (0,preact_module.h)("span", {
1194
+ class: "muted"
1195
+ }, "(c\u1ECDc ", util/* default */.A.formatCurrency(order.deposit), ")");
1196
+ }
1197
+ let $discount = null;
1198
+ if (order.total_discount > 0) {
1199
+ $discount = (0,preact_module.h)("div", {
1200
+ class: "order_summary_line"
1201
+ }, (0,preact_module.h)("div", null, "Gi\u1EA3m gi\xE1"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency(order.total_discount)));
1202
+ }
1203
+ let $pay = null;
1204
+ if ($deposit || order.payment_made) {
1205
+ $pay = (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
1206
+ class: "order_summary_line"
1207
+ }, (0,preact_module.h)("div", null, "B\u1EA1n \u0111\xE3 tr\u1EA3"), (0,preact_module.h)("div", null, $deposit, " ", util/* default */.A.formatCurrency(order.payment_made))), (0,preact_module.h)("div", {
1208
+ class: "order_summary_line"
1209
+ }, (0,preact_module.h)("div", null, "B\u1EA1n ch\u01B0a tr\u1EA3"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency((order.total || 0) - (order.payment_made || 0)))));
1210
+ }
1211
+ let $tax = (0,preact_module.h)("div", {
1212
+ class: "order_summary_line"
1213
+ }, (0,preact_module.h)("div", null, "Ti\u1EC1n thu\u1EBF"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency(order.total_tax)));
1214
+ let $ship = (0,preact_module.h)("div", {
1215
+ class: "order_summary_line"
1216
+ }, (0,preact_module.h)("div", null, "Ph\xED v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", null, util/* default */.A.get(order, 'shipping.fee', 0), " d"));
1217
+ let editmode = false;
1218
+ if (!order.status || order.status == 'open') {
1219
+ editmode = !order.user_confirmation;
1220
+ }
1221
+ let $note = null;
1222
+ if (editmode) {
1223
+ $ship = null;
1224
+ $tax = null;
1225
+ $note = (0,preact_module.h)("div", {
1226
+ class: "muted"
1227
+ }, (0,preact_module.h)("img", {
1228
+ class: "order_ship_icon",
1229
+ src: __webpack_require__(7324)
1230
+ }), "\xA0 Ch\u01B0a bao g\u1ED3m thu\u1EBF v\xE0 ph\xED v\u1EADn chuy\u1EC3n");
1231
+ }
1232
+ let seccls = '';
1233
+ if (this.isMobile()) seccls = 'order_section';
1234
+ return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
1235
+ class: "order_section__line"
1236
+ }), (0,preact_module.h)("div", {
1237
+ class: seccls
1238
+ }, (0,preact_module.h)("div", {
1239
+ class: "order_label"
1240
+ }, "T\xF3m t\u1EAFt"), (0,preact_module.h)("div", {
1241
+ class: "order_summary_line"
1242
+ }, (0,preact_module.h)("div", null, "T\u1ED5ng ti\u1EC1n h\xE0ng"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency(order.subtotal))), $tax, $discount, $ship, $note, (0,preact_module.h)("div", {
1243
+ class: "order_summary_line",
1244
+ style: "margin-top: 10px !important; padding-top: 15px !important; border-top: 1px solid #eee !important"
1245
+ }, (0,preact_module.h)("div", null, "B\u1EA1n ph\u1EA3i tr\u1EA3"), (0,preact_module.h)("div", {
1246
+ class: "order__total"
1247
+ }, util/* default */.A.formatCurrency(order.total))), $pay));
1248
+ }
1249
+ renderStatusBadge(order) {
1250
+ let status = order.status || 'open';
1251
+ return (0,preact_module.h)("div", {
1252
+ style: "float: right !important;",
1253
+ class: 'order_status order_status__' + status
1254
+ }, status);
1255
+ }
1256
+ renderShippingInfo(order) {
1257
+ if (order.status != 'open' || order.user_confirmation) {}
1258
+ let shipping_provider = util/* default */.A.get(order, 'shipping.shipping_provider');
1259
+ if (!shipping_provider) return null;
1260
+ let shipping_code = util/* default */.A.get(order, 'shipping.shipping_code');
1261
+ let $tracking_code = null;
1262
+ if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
1263
+ class: "muted",
1264
+ style: "margin-top: 3px !important"
1265
+ }, "V\u1EADn \u0111\u01A1n\xA0", (0,preact_module.h)("a", {
1266
+ class: "order_tracking_link",
1267
+ target: "_blank",
1268
+ href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
1269
+ }, shipping_code, "\xA0", (0,preact_module.h)("img", {
1270
+ class: "order_tracking_link_icon",
1271
+ src: __webpack_require__(3266)
1272
+ })));
1273
+ if (shipping_provider == 'ghtk') {
1274
+ return (0,preact_module.h)("div", {
1275
+ class: "order_section"
1276
+ }, (0,preact_module.h)("div", {
1277
+ class: "order_section_label"
1278
+ }, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", {
1279
+ class: "d-flex align-items-center"
1280
+ }, (0,preact_module.h)("img", {
1281
+ class: "order_shipping_provider_logo",
1282
+ src: ShippingProvider.ghtk.logo
1283
+ }), (0,preact_module.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
1284
+ }
1285
+ return null;
1286
+ }
1287
+ renderDesktopShippingInfo(order) {
1288
+ let shipping_provider = util/* default */.A.get(order, 'shipping.shipping_provider');
1289
+ if (!shipping_provider) return null;
1290
+ let shipping_code = util/* default */.A.get(order, 'shipping.shipping_code');
1291
+ let $tracking_code = null;
1292
+ if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
1293
+ class: "muted",
1294
+ style: "margin-top: 3px !important"
1295
+ }, "V\u1EADn \u0111\u01A1n\xA0", (0,preact_module.h)("a", {
1296
+ class: "order_tracking_link",
1297
+ target: "_blank",
1298
+ href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
1299
+ }, shipping_code, "\xA0", (0,preact_module.h)("img", {
1300
+ class: "order_tracking_link_icon",
1301
+ src: __webpack_require__(3266)
1302
+ })));
1303
+ if (shipping_provider == 'ghtk') {
1304
+ return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
1305
+ class: "order_label"
1306
+ }, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", {
1307
+ class: "d-flex align-items-center"
1308
+ }, (0,preact_module.h)("img", {
1309
+ class: "order_shipping_provider_logo",
1310
+ src: ShippingProvider.ghtk.logo
1311
+ }), (0,preact_module.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
1312
+ }
1313
+ return null;
1314
+ }
1315
+ renderProducts(order) {
1316
+ let $products = null;
1317
+ $products = util/* default */.A.map(order.items, item => {
1318
+ if (!item || !item.product) return null;
1319
+ let product = item.product;
1320
+ return (0,preact_module.h)("div", {
1321
+ class: "order_attachment__product"
1322
+ }, (0,preact_module.h)("img", {
1323
+ class: "order_attachment__product_img",
1324
+ alt: '' + product.id,
1325
+ src: util/* default */.A.get(product, 'images.0') || __webpack_require__(2876)
1326
+ }), (0,preact_module.h)("div", {
1327
+ style: "overflow: hidden !important;"
1328
+ }, (0,preact_module.h)("div", {
1329
+ class: "order_attachment__product_name"
1330
+ }, product.name), (0,preact_module.h)("div", {
1331
+ class: "order_attachment__product_desc"
1332
+ }, product.description || product.long_description), (0,preact_module.h)("div", {
1333
+ class: "order_attachment__product_desc"
1334
+ }, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default */.A.formatCurrency(product.price))));
1335
+ });
1336
+ if (!this.isMobile()) return (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
1337
+ class: "order_label"
1338
+ }, this.props.t('product')), $products);
1339
+ return (0,preact_module.h)("div", {
1340
+ class: "order_section"
1341
+ }, (0,preact_module.h)("div", {
1342
+ class: "order_section_label"
1343
+ }, this.props.t('product')), $products);
1344
+ }
1345
+ renderDesktopProducts(order) {
1346
+ let $products = null;
1347
+ let editmode = false;
1348
+ if (!order.status || order.status == 'open') {
1349
+ editmode = !order.user_confirmation;
1350
+ }
1351
+ if (editmode) {
1352
+ $products = util/* default */.A.map(order.items, item => {
1353
+ if (!item || !item.product) return null;
1354
+ let product = item.product;
1355
+ return (0,preact_module.h)("div", {
1356
+ class: "order_attachment__product"
1357
+ }, (0,preact_module.h)("img", {
1358
+ class: "order_attachment__product_img",
1359
+ alt: '' + product.id,
1360
+ src: util/* default */.A.get(product, 'images.0') || __webpack_require__(2876)
1361
+ }), (0,preact_module.h)("div", {
1362
+ style: "overflow: hidden !important; flex: 1 !important"
1363
+ }, (0,preact_module.h)("div", {
1364
+ class: "order_attachment__product_name"
1365
+ }, product.name), (0,preact_module.h)("div", {
1366
+ class: "order_attachment__product_desc"
1367
+ }, product.description || product.long_description), (0,preact_module.h)("div", {
1368
+ class: "order_attachment__product_desc"
1369
+ }, util/* default */.A.formatCurrency(product.price))), (0,preact_module.h)("input", {
1370
+ class: "form-control",
1371
+ style: "text-align: center !important; font-weight: 400 !important; width: 50px !important",
1372
+ value: item.quantity,
1373
+ onInput: e => this.onChangeQuantity(item, e.target.value),
1374
+ type: "text"
1375
+ }), (0,preact_module.h)("div", {
1376
+ style: "width: 80px !important; text-align: right !important; "
1377
+ }, (0,preact_module.h)("b", null, util/* default */.A.formatCurrency(item.quantity * product.price))));
1378
+ });
1379
+ } else {
1380
+ $products = util/* default */.A.map(order.items, item => {
1381
+ if (!item || !item.product) return null;
1382
+ let product = item.product;
1383
+ return (0,preact_module.h)("div", {
1384
+ class: "order_attachment__product"
1385
+ }, (0,preact_module.h)("img", {
1386
+ class: "order_attachment__product_img",
1387
+ alt: '' + product.id,
1388
+ src: util/* default */.A.get(product, 'images.0') || __webpack_require__(2876)
1389
+ }), (0,preact_module.h)("div", {
1390
+ style: "overflow: hidden !important; flex: 1 !important"
1391
+ }, (0,preact_module.h)("div", {
1392
+ class: "order_attachment__product_name"
1393
+ }, product.name), (0,preact_module.h)("div", {
1394
+ class: "order_attachment__product_desc"
1395
+ }, product.description || product.long_description), (0,preact_module.h)("div", {
1396
+ class: "order_attachment__product_desc"
1397
+ }, util/* default */.A.formatCurrency(product.price))), (0,preact_module.h)("div", {
1398
+ style: "text-align: center !important; font-weight: 400 !important; width: 50px !important"
1399
+ }, item.quantity), (0,preact_module.h)("div", {
1400
+ style: "width: 80px !important; text-align: right !important; "
1401
+ }, (0,preact_module.h)("b", null, util/* default */.A.formatCurrency(item.total))));
1402
+ });
1403
+ }
1404
+ return (0,preact_module.h)("div", {
1405
+ class: "card_section"
1406
+ }, (0,preact_module.h)("div", {
1407
+ class: "desktop_order__heading"
1408
+ }, this.renderStatusBadge(order), (0,preact_module.h)("b", {
1409
+ style: "font-size: 18px !important;"
1410
+ }, this.props.t('order'), " #", order.order_number || order.id), (0,preact_module.h)("div", {
1411
+ class: "muted"
1412
+ }, (0,preact_module.h)(time/* default */.A, {
1413
+ style: "font-size: 13px !important;",
1414
+ time: order.issue_date || order.created
1415
+ }))), (0,preact_module.h)("div", {
1416
+ class: "order_label d-flex",
1417
+ style: "margin-top: 20px !important;justify-content: space-between !important; align-items: flex-end !important;"
1418
+ }, (0,preact_module.h)("div", {
1419
+ style: "flex: 1 !important;"
1420
+ }, this.props.t('product')), (0,preact_module.h)("div", {
1421
+ style: "font-weight: 400 !important; text-align:center !important; width: 50px !important"
1422
+ }, this.props.t('qty')), (0,preact_module.h)("div", {
1423
+ style: "font-weight: 400 !important; text-align: right !important; width: 80px !important;"
1424
+ }, this.props.t('total'))), $products);
1425
+ }
1426
+ renderMobile(order) {
1427
+ if (this.state.step === 'success') return this.renderMobileSuccess(order);
1428
+ let $error = null;
1429
+ if (this.state.g_err) {
1430
+ $error = (0,preact_module.h)("div", {
1431
+ class: "mb-2 text__danger"
1432
+ }, (0,preact_module.h)("img", {
1433
+ style: "margin-top: -4px !important; height: 15px !important;",
1434
+ src: ximg
1435
+ }), "\xA0", (0,preact_module.h)("b", null, this.state.g_err));
1436
+ }
1437
+ let $status = (0,preact_module.h)("div", null, $error, (0,preact_module.h)("div", {
1438
+ class: "btn-confirm-order",
1439
+ style: "margin-top: 0 !important;",
1440
+ onClick: this.confirm
1441
+ }, this.props.t('confirm_order')));
1442
+ let $close = (0,preact_module.h)("div", {
1443
+ class: "order_btn order__btn__light mt-3",
1444
+ onClick: this.onCancel
1445
+ }, this.props.t('cancel_order'));
1446
+ if (order.user_confirmation || order.status != 'open') {
1447
+ $status = null;
1448
+ if (this.props.cid) $close = (0,preact_module.h)("div", {
1449
+ class: "order_btn order__btn__light mt-3",
1450
+ onClick: this.close
1451
+ }, this.props.t('close'));
1452
+ }
1453
+ return (0,preact_module.h)("div", {
1454
+ class: "order",
1455
+ style: "height: 100% !important"
1456
+ }, (0,preact_module.h)("div", {
1457
+ class: "order--content"
1458
+ }, (0,preact_module.h)("div", {
1459
+ class: "order--heading"
1460
+ }, this.renderStatusBadge(order), (0,preact_module.h)("b", {
1461
+ style: "font-size: 16px !important;"
1462
+ }, this.props.t('order'), " #", order.order_number || order.id), (0,preact_module.h)("div", {
1463
+ class: "muted"
1464
+ }, (0,preact_module.h)(time/* default */.A, {
1465
+ style: "font-size: 13px !important;",
1466
+ time: order.issue_date || order.created
1467
+ }))), this.renderProducts(order), this.renderDesktopShipping(order), this.renderShippingInfo(order), this.renderDesktopPaymentMethod(order), this.renderDesktopSummary(order), (0,preact_module.h)("div", {
1468
+ class: "order_section pb-3",
1469
+ style: "padding-top: 0 !important;"
1470
+ }, $status, $close)));
1471
+ }
1472
+ renderActions(order) {
1473
+ let $actions = null;
1474
+ let editmode = false;
1475
+ if (!order.status || order.status == 'open') {
1476
+ editmode = !order.user_confirmation;
1477
+ }
1478
+ if (this.state.step === 'success') return (0,preact_module.h)("div", {
1479
+ class: "d-flex",
1480
+ style: "align-items: center !important; justify-content: flex-end !important"
1481
+ }, (0,preact_module.h)("div", null, "Ghi nh\u1EADn th\xE0nh c\xF4ng"), "\xA0", (0,preact_module.h)("img", {
1482
+ style: "width: 16px !important; height: 16px !important;",
1483
+ width: "16",
1484
+ height: "16",
1485
+ src: checkedimg
1486
+ }));
1487
+ if (editmode) {
1488
+ let $error = null;
1489
+ if (this.state.g_err) {
1490
+ $error = (0,preact_module.h)("div", {
1491
+ class: "mb-2 text__danger"
1492
+ }, (0,preact_module.h)("img", {
1493
+ style: "margin-top: -4px !important; height: 15px !important;",
1494
+ src: ximg
1495
+ }), "\xA0", (0,preact_module.h)("b", null, this.state.g_err));
1496
+ }
1497
+ $actions = (0,preact_module.h)("div", null, $error, (0,preact_module.h)("div", {
1498
+ class: "btn-confirm-order",
1499
+ onClick: this.confirm
1500
+ }, this.props.t('confirm_order')), (0,preact_module.h)("div", {
1501
+ class: "btn-cancel-order",
1502
+ onClick: this.onCancel
1503
+ }, this.props.t('cancel_order')));
1504
+ }
1505
+ return $actions;
1506
+ }
1507
+ renderDesktop(order) {
1508
+ let acc = this.props.store.matchAccount();
1509
+ var uri = acc.logo_url || __webpack_require__(3582);
1510
+ return (0,preact_module.h)("div", {
1511
+ class: "desktop order"
1512
+ }, (0,preact_module.h)("div", {
1513
+ class: "order_acc_header"
1514
+ }, (0,preact_module.h)("img", {
1515
+ class: "order_acc_logo",
1516
+ src: uri
1517
+ }), (0,preact_module.h)("div", {
1518
+ class: "order_acc_name"
1519
+ }, acc.name)), (0,preact_module.h)("div", {
1520
+ class: "desktop_order__content"
1521
+ }, (0,preact_module.h)("div", {
1522
+ style: "flex: 1 !important; padding-right: 20px !important;"
1523
+ }, this.renderDesktopProducts(order), this.renderDesktopShipping(order), this.renderDesktopShippingInfo(order), this.renderDesktopPaymentMethod(order), (0,preact_module.h)("div", {
1524
+ class: "order__footer"
1525
+ }, (0,preact_module.h)("a", {
1526
+ target: "_blank",
1527
+ href: "https://subiz.com.vn",
1528
+ class: "order__footer_link"
1529
+ }, "Cung c\u1EA5p b\u1EDFi ", (0,preact_module.h)("b", null, "Subiz")), (0,preact_module.h)("div", {
1530
+ class: "order__footer_delimiter"
1531
+ }), (0,preact_module.h)("a", {
1532
+ target: "_blank",
1533
+ href: "https://subiz.com.vn/vi/terms-of-service.html",
1534
+ class: "order__footer_link"
1535
+ }, "\u0110i\u1EC1u kho\u1EA3n"), (0,preact_module.h)("a", {
1536
+ target: "_blank",
1537
+ href: "https://subiz.com.vn/vi/privacy-policy.html",
1538
+ class: "order__footer_link"
1539
+ }, "Quy\u1EC1n ri\xEAng t\u01B0"))), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
1540
+ class: "order_recap"
1541
+ }, this.renderDesktopSummary(order), this.renderActions(order)))));
1542
+ }
1543
+ render() {
1544
+ if (this.state.loading) return (0,preact_module.h)("div", {
1545
+ class: "order_error"
1546
+ }, (0,preact_module.h)(spinner/* default */.A, {
1547
+ class: "mt-4",
1548
+ size: "60",
1549
+ static: true
1550
+ }));
1551
+ if (this.state.error) return (0,preact_module.h)("div", {
1552
+ class: "order_error"
1553
+ }, (0,preact_module.h)("img", {
1554
+ class: "mt-3",
1555
+ src: __webpack_require__(6907)
1556
+ }), (0,preact_module.h)("div", {
1557
+ class: "mt-3"
1558
+ }, this.props.t('order_load_error')));
1559
+ let order = this.state.order;
1560
+ if (this.isMobile()) return this.renderMobile(order);
1561
+ return this.renderDesktop(order);
1562
+ }
1563
+ }
1564
+ let ShippingProvider = {
1565
+ ghtk: {
1566
+ name: 'Giao hàng tiết kiệm',
1567
+ logo: __webpack_require__(7362)
1568
+ },
1569
+ ghn: {
1570
+ name: 'Giao hàng nhanh',
1571
+ logo: __webpack_require__(1113)
1572
+ }
1573
+ };
1574
+ ;// ./src/chatbox/Order.js
1575
+ function Order_defineProperty(e, r, t) { return (r = Order_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
1576
+ function Order_toPropertyKey(t) { var i = Order_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
1577
+ function Order_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1578
+
1579
+
1580
+
1581
+ const POPUP_MAX_HEIGHT = 400;
1582
+ const POPUP_HARD_MAX_HEIGHT = 500;
1583
+ const POPUP_MIN_HEIGHT = 0;
1584
+ let Order_defaultAvatar = __webpack_require__(2538);
1585
+
1586
+
1587
+
1588
+ class Order extends common/* Com */.Mw {
1589
+ constructor(props) {
1590
+ super(props);
1591
+ Order_defineProperty(this, "state", {
1592
+ hide: true,
1593
+ ratingHeight: 0,
1594
+ overlayOpacity: 0.3
1595
+ });
1596
+ Order_defineProperty(this, "onResponse", response => {
1597
+ this.setState({
1598
+ response
1599
+ });
1600
+ });
1601
+ Order_defineProperty(this, "confirm", () => {
1602
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
1603
+ message: {
1604
+ format: 'plaintext',
1605
+ text: 'confirm',
1606
+ attachments: [{
1607
+ type: 'postback',
1608
+ postback: {
1609
+ payload: JSON.stringify({
1610
+ type: 'order_confirmation',
1611
+ status: 'confirmed'
1612
+ })
1613
+ }
1614
+ }]
1615
+ }
1616
+ });
1617
+ });
1618
+ Order_defineProperty(this, "close", async () => {
1619
+ await util/* default */.A.sleep(100);
1620
+ if (this.state.response === 'confirmed') {
1621
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
1622
+ message: {
1623
+ format: 'plaintext',
1624
+ text: this.props.t('confirm_order'),
1625
+ attachments: [{
1626
+ type: 'postback',
1627
+ postback: {
1628
+ payload: JSON.stringify({
1629
+ type: 'order_confirmation',
1630
+ status: 'confirmed'
1631
+ })
1632
+ }
1633
+ }]
1634
+ }
1635
+ });
1636
+ } else if (this.state.response === 'rejected') {
1637
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
1638
+ message: {
1639
+ format: 'plaintext',
1640
+ text: this.props.t('cancel_order'),
1641
+ attachments: [{
1642
+ type: 'postback',
1643
+ postback: {
1644
+ payload: JSON.stringify({
1645
+ type: 'order_confirmation',
1646
+ status: 'cancelled'
1647
+ })
1648
+ }
1649
+ }]
1650
+ }
1651
+ });
1652
+ } else {}
1653
+ this.setState({
1654
+ response: ''
1655
+ });
1656
+ if (this.state.hide) return;
1657
+ if (!this.refRating.current) return;
1658
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
1659
+ var h0 = parseFloat(popupStyle.height);
1660
+ this.animation.play(20, h0, h => {
1661
+ this.setState({
1662
+ ratingHeight: h,
1663
+ overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
1664
+ });
1665
+ if (h < POPUP_MIN_HEIGHT + 10) {
1666
+ if (!this.state.hide) {
1667
+ this.setState({
1668
+ hide: true
1669
+ });
1670
+ }
1671
+ }
1672
+ });
1673
+ this.props.onClose();
1674
+ });
1675
+ this.refRating = (0,preact_module/* createRef */._3)();
1676
+ this.refHandle = (0,preact_module/* createRef */._3)();
1677
+ }
1678
+ componentDidMount() {
1679
+ this.mouseUp = e => this.onMouseUp(e);
1680
+ this.mouseMove = e => this.onMouseMove(e);
1681
+ this.mouseDown = e => this.onMouseDown(e);
1682
+ var $ratingHandle = this.refHandle.current;
1683
+ $ratingHandle.addEventListener('mousedown', this.mouseDown, {
1684
+ passive: true
1685
+ });
1686
+ $ratingHandle.addEventListener('touchstart', this.mouseDown, {
1687
+ passive: true
1688
+ });
1689
+ window.addEventListener('mouseup', this.mouseUp, {
1690
+ passive: true
1691
+ });
1692
+ window.addEventListener('touchend', this.mouseUp, {
1693
+ passive: true
1694
+ });
1695
+ window.addEventListener('mousemove', this.mouseMove, {
1696
+ passive: true
1697
+ });
1698
+ window.addEventListener('touchmove', this.mouseMove, {
1699
+ passive: true
1700
+ });
1701
+ this.animation = new releaseAnimation/* default */.A({
1702
+ maxY: POPUP_MAX_HEIGHT,
1703
+ minY: POPUP_MIN_HEIGHT,
1704
+ duration: 150
1705
+ });
1706
+ this.close();
1707
+ }
1708
+ componentWillUnmount() {
1709
+ var $ratingHandle = this.refHandle.current;
1710
+ $ratingHandle.removeEventListener('mousedown', this.mouseDown, 0);
1711
+ $ratingHandle.removeEventListener('touchstart', this.mouseDown, 0);
1712
+ window.removeEventListener('mouseup', this.mouseUp, 0);
1713
+ window.removeEventListener('touchend', this.mouseUp, 0);
1714
+ window.removeEventListener('mousemove', this.mouseMove, 0);
1715
+ window.removeEventListener('touchmove', this.mouseMove, 0);
1716
+ }
1717
+ render() {
1718
+ if (this._show != this.props.show) {
1719
+ this._show = this.props.show;
1720
+ util/* default */.A.setTimeout(() => {
1721
+ if (!this._show) this.close();else this.open();
1722
+ });
1723
+ }
1724
+ let cls = this.state.hide ? 'd-none' : '';
1725
+ return (0,preact_module.h)("div", {
1726
+ class: cls
1727
+ }, (0,preact_module.h)("div", {
1728
+ class: "extension--overlay",
1729
+ style: `opacity: ${this.state.overlayOpacity * 0.5} !important;`
1730
+ }), (0,preact_module.h)("div", {
1731
+ class: "extension",
1732
+ ref: this.refRating,
1733
+ style: `height: ${this.state.ratingHeight}px !important;`
1734
+ }, (0,preact_module.h)("div", {
1735
+ class: "extension--close-btn",
1736
+ onClick: this.close
1737
+ }, this.props.t('close')), (0,preact_module.h)("div", {
1738
+ class: "extension--handle",
1739
+ ref: this.refHandle
1740
+ }, (0,preact_module.h)("div", {
1741
+ class: "extension--thumb"
1742
+ })), (0,preact_module.h)("div", {
1743
+ style: "overflow-x: hidden !important; overflow-y: scroll !important; height: 100% !important;"
1744
+ }, (0,preact_module.h)(order_Order, {
1745
+ key: this.props.order_id,
1746
+ store: this.props.store,
1747
+ onResponse: this.onResponse,
1748
+ onClose: this.close,
1749
+ t: this.props.t,
1750
+ order_id: this.props.order_id,
1751
+ cid: this.props.cid
1752
+ }))));
1753
+ }
1754
+ open() {
1755
+ if (!this.state.hide) return;
1756
+ if (!this.props.order_id) return;
1757
+ this.setState({
1758
+ hide: false
1759
+ });
1760
+ if (!this.refRating.current) return;
1761
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
1762
+ var h0 = parseFloat(popupStyle.height);
1763
+ this.animation.play(-20, h0, h => {
1764
+ this.setState({
1765
+ ratingHeight: h,
1766
+ overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
1767
+ });
1768
+ });
1769
+ }
1770
+ onMouseDown(e) {
1771
+ this.mousePushed = true;
1772
+ this.animation.stop();
1773
+ e.preventDefault();
1774
+ if (e.touches && e.touches[0]) e = e.touches[0];
1775
+ this.mousePushedDy = e.pageY - window.pageYOffset - this.refRating.current.getBoundingClientRect().y;
1776
+ }
1777
+ onMouseUp(e) {
1778
+ if (!this.mousePushed) return;
1779
+ if (e.touches && e.touches[0]) e = e.touches[0];
1780
+ this.mousePushed = false;
1781
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
1782
+ var h0 = parseFloat(popupStyle.height);
1783
+ this.animation.play(this.mouseVelocity, h0, h => {
1784
+ this.setState({
1785
+ ratingHeight: h,
1786
+ overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
1787
+ });
1788
+ if (h < POPUP_MIN_HEIGHT + 10) {
1789
+ if (!this.state.hide) {
1790
+ this.setState({
1791
+ hide: true
1792
+ });
1793
+ this.props.onRate && this.props.onRate({
1794
+ no_rating: true
1795
+ });
1796
+ }
1797
+ }
1798
+ });
1799
+ }
1800
+ onMouseMove(e) {
1801
+ if (!this.mousePushed) return;
1802
+ if (e.touches && e.touches[0]) e = e.touches[0];
1803
+ var my = e.pageY;
1804
+ this.mouseVelocity = my - this.lastMouseY;
1805
+ this.lastMouseY = my;
1806
+ my = my - this.mousePushedDy;
1807
+ var K = 10000;
1808
+ var height = this.refRating.current.getBoundingClientRect().bottom - my;
1809
+ if (height > POPUP_MAX_HEIGHT) {
1810
+ var beta = K / (POPUP_HARD_MAX_HEIGHT - POPUP_MAX_HEIGHT) - POPUP_MAX_HEIGHT;
1811
+ height = POPUP_HARD_MAX_HEIGHT - K / (height + beta);
1812
+ }
1813
+ this.setState({
1814
+ ratingHeight: height,
1815
+ overlayOpacity: Math.min(1, (height - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
1816
+ });
1817
+ }
1818
+ }
1819
+
1820
+ /***/ }),
1821
+
1822
+ /***/ 5244:
1823
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1824
+
1825
+ module.exports = __webpack_require__.p + "assets/img/shop.f7dc7d8.svg";
1826
+
1827
+ /***/ }),
1828
+
1829
+ /***/ 5452:
1830
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1831
+
1832
+ module.exports = __webpack_require__.p + "assets/img/search.f9705ff.svg";
1833
+
1834
+ /***/ }),
1835
+
1836
+ /***/ 5860:
1837
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1838
+
1839
+ module.exports = __webpack_require__.p + "assets/img/done_green.b817fd4.svg";
1840
+
1841
+ /***/ }),
1842
+
1843
+ /***/ 6857:
1844
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1845
+
1846
+ module.exports = __webpack_require__.p + "assets/img/package_fade.763c001.svg";
1847
+
1848
+ /***/ }),
1849
+
1850
+ /***/ 6907:
1851
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1852
+
1853
+ module.exports = __webpack_require__.p + "assets/img/empty_1.0b98af0.svg";
1854
+
1855
+ /***/ }),
1856
+
1857
+ /***/ 7324:
1858
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1859
+
1860
+ module.exports = __webpack_require__.p + "assets/img/info.ebce7ea.svg";
1861
+
1862
+ /***/ }),
1863
+
1864
+ /***/ 7362:
1865
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1866
+
1867
+ module.exports = __webpack_require__.p + "assets/img/ghtk.326eac1.svg";
1868
+
1869
+ /***/ }),
1870
+
1871
+ /***/ 7741:
1872
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1873
+
1874
+ module.exports = __webpack_require__.p + "assets/img/caret.998eb8f.svg";
1875
+
1876
+ /***/ }),
1877
+
1878
+ /***/ 8512:
1879
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1880
+
1881
+ module.exports = __webpack_require__.p + "assets/img/package.8d37d0f.svg";
1882
+
1883
+ /***/ })
1884
+
1885
+ }]);