@subiz/widget-v4 4.1.191 → 4.1.195

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 (120) hide show
  1. package/assets/less/chatbox.less +0 -1
  2. package/assets/less/message.less +71 -4
  3. package/compiled_src/chatbox/Event.js +37 -6
  4. package/compiled_src/chatbox/Events.js +20 -0
  5. package/compiled_src/chatbox/FileAttachments.js +36 -4
  6. package/compiled_src/chatbox/ImageAttachments.js +31 -4
  7. package/compiled_src/chatbox/QuoteMessage.js +99 -0
  8. package/compiled_src/chatbox/Rating.js +4 -0
  9. package/compiled_src/chatbox/TextMessage.js +49 -4
  10. package/compiled_src/chatbox/Widget.js +43 -1
  11. package/compiled_src/store/api.js +2 -0
  12. package/compiled_src/store/store.js +44 -2
  13. package/compiled_src/util/common.js +13 -1
  14. package/dist/127.js +273 -0
  15. package/dist/132.js +2802 -0
  16. package/dist/185.js +1827 -0
  17. package/dist/19b74edd3c9.127.js +1 -0
  18. package/dist/19b74edd3c9.132.js +1 -0
  19. package/dist/19b74edd3c9.185.js +1 -0
  20. package/dist/19b74edd3c9.27.js +1 -0
  21. package/dist/19b74edd3c9.278.js +1 -0
  22. package/dist/19b74edd3c9.339.js +1 -0
  23. package/dist/19b74edd3c9.459.js +1 -0
  24. package/dist/19b74edd3c9.490.js +1 -0
  25. package/dist/19b74edd3c9.74.js +1 -0
  26. package/dist/19b74edd3c9.997.js +1 -0
  27. package/dist/19b74edd3c9.app.js +1 -0
  28. package/dist/19b74edd3c9.chat.html +1 -0
  29. package/dist/19b74edd3c9.chat.js +1 -0
  30. package/dist/19b74edd3c9.form.html +1 -0
  31. package/dist/19b74edd3c9.form.js +1 -0
  32. package/dist/19b74edd3c9.index.html +72 -0
  33. package/dist/19b74edd3c9.library.html +72 -0
  34. package/dist/19b74edd3c9.library.js +1 -0
  35. package/dist/19b74edd3c9.preview.html +759 -0
  36. package/dist/19b74edd3c9.preview.js +1 -0
  37. package/dist/19b74edd3c9.webview.js +1 -0
  38. package/dist/27.js +35 -0
  39. package/dist/459.js +35 -0
  40. package/dist/490.js +305 -0
  41. package/dist/74.js +372 -0
  42. package/dist/997.js +35 -0
  43. package/dist/HASH +1 -0
  44. package/dist/assets/img/Facebook.64607ec.png +0 -0
  45. package/dist/assets/img/Zalo.6845707.png +0 -0
  46. package/dist/assets/img/award1a.1a58e10.png +0 -0
  47. package/dist/assets/img/award3a.3b74423.png +0 -0
  48. package/dist/assets/img/award4a.ed6ccd4.png +0 -0
  49. package/dist/assets/img/award5.39eb7ae.png +0 -0
  50. package/dist/assets/img/bubble_default.7d5e4ab.svg +20 -0
  51. package/dist/assets/img/caret.998eb8f.svg +1 -0
  52. package/dist/assets/img/convos_empty.2353007.svg +72 -0
  53. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  54. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  55. package/dist/assets/img/done_gray.d7e8203.svg +4 -0
  56. package/dist/assets/img/done_green.b817fd4.svg +4 -0
  57. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  58. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  59. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  60. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  61. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  62. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  63. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  64. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  65. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  66. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  67. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  68. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  69. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  70. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  71. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  72. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  73. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  74. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  75. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  76. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  77. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  78. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  79. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  80. package/dist/assets/img/empty.29bed2d.svg +23 -0
  81. package/dist/assets/img/empty_1.0b98af0.svg +11 -0
  82. package/dist/assets/img/examplte_logo.f86535f.svg +1 -0
  83. package/dist/assets/img/external-link.90577cc.svg +1 -0
  84. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  85. package/dist/assets/img/ghn.070f8e3.svg +17 -0
  86. package/dist/assets/img/ghtk.326eac1.svg +18 -0
  87. package/dist/assets/img/image_default.be0698b.png +0 -0
  88. package/dist/assets/img/info.ebce7ea.svg +1 -0
  89. package/dist/assets/img/loader.37000a7.svg +1 -0
  90. package/dist/assets/img/loading_static.a27f0ac.svg +10 -0
  91. package/dist/assets/img/main-service1.d536cc2.png +0 -0
  92. package/dist/assets/img/main-service2.9b99549.png +0 -0
  93. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  94. package/dist/assets/img/package.8d37d0f.svg +5 -0
  95. package/dist/assets/img/package_fade.763c001.svg +1 -0
  96. package/dist/assets/img/rating--average.1ea492c.svg +12 -0
  97. package/dist/assets/img/rating--great.e3d712e.svg +16 -0
  98. package/dist/assets/img/rating--poor.2938a25.svg +12 -0
  99. package/dist/assets/img/search.f9705ff.svg +1 -0
  100. package/dist/assets/img/send.6db52a9.svg +3 -0
  101. package/dist/assets/img/shop.f7dc7d8.svg +1 -0
  102. package/dist/assets/img/shop_faded.df7845a.svg +1 -0
  103. package/dist/assets/img/stars_v2.79cf728.png +0 -0
  104. package/dist/assets/img/subiz-mono.8fbc067.svg +3 -0
  105. package/dist/assets/img/x.26fdfa3.svg +5 -0
  106. package/dist/malicious-app.js +17 -0
  107. package/dist/screenshoot.html +7 -0
  108. package/dist/screenshoot.js +13015 -0
  109. package/package.json +8 -8
  110. package/src/chatbox/Event.js +48 -7
  111. package/src/chatbox/Events.js +21 -1
  112. package/src/chatbox/FileAttachments.js +31 -4
  113. package/src/chatbox/ImageAttachments.js +26 -3
  114. package/src/chatbox/QuoteMessage.js +94 -0
  115. package/src/chatbox/Rating.js +5 -0
  116. package/src/chatbox/TextMessage.js +50 -2
  117. package/src/chatbox/Widget.js +52 -0
  118. package/src/store/api.js +3 -0
  119. package/src/store/store.js +50 -1
  120. package/src/util/common.js +19 -1
package/dist/185.js ADDED
@@ -0,0 +1,1827 @@
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 = (() => Promise.resolve(/* import() */).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
+ // removed by dead control flow
857
+
858
+ // removed by dead control flow
859
+
860
+ // removed by dead control flow
861
+
862
+ // removed by dead control flow
863
+
864
+ // removed by dead control flow
865
+
866
+ // removed by dead control flow
867
+
868
+ // removed by dead control flow
869
+
870
+ // removed by dead control flow
871
+
872
+ // removed by dead control flow
873
+
874
+ // removed by dead control flow
875
+
876
+ }
877
+ renderDesktopShipping(order) {
878
+ let editmode = false;
879
+ if (!order.status || order.status == 'open') {
880
+ editmode = !order.user_confirmation;
881
+ }
882
+ let user = this.props.store.matchUser();
883
+ if (editmode) {
884
+ let addresses = this.props.store.matchShippingAddresses();
885
+ let provinces = util/* default */.A.map(this.state.provinces, province => ({
886
+ id: province.id,
887
+ name: province.province
888
+ }));
889
+ let districts = util/* default */.A.map(this.state.districts, district => ({
890
+ id: district.id,
891
+ name: district.district
892
+ }));
893
+ let wards = util/* default */.A.map(this.state.wards, ward => ({
894
+ id: ward.id,
895
+ name: ward.ward
896
+ }));
897
+ let cls = 'ship_card';
898
+ let $body = null;
899
+ let ship_icon_active = false;
900
+ if (this.state.shipping === 'ship') {
901
+ ship_icon_active = true;
902
+ let $preaddrs = util/* default */.A.map(addresses, addr => {
903
+ let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
904
+ let $phone = null;
905
+ if (addr.phone) {
906
+ $phone = (0,preact_module.h)(preact_module/* Fragment */.FK, null, "\xA0\xB7\xA0", this.props.t('phn'), " ", addr.phone);
907
+ }
908
+ return (0,preact_module.h)("div", {
909
+ style: "margin-bottom: 15px !important"
910
+ }, (0,preact_module.h)("div", {
911
+ class: "radio d-flex "
912
+ }, (0,preact_module.h)("input", {
913
+ type: "radio",
914
+ id: 'shipping_addr.' + addr.id,
915
+ onInput: e => this.onChangeShippingAddress(addr.id),
916
+ name: "shipping_address",
917
+ checked: this.state.shipping_address === addr.id
918
+ }), (0,preact_module.h)("label", {
919
+ class: "radio--label",
920
+ for: 'shipping_addr.' + addr.id,
921
+ style: `font-weight: ${this.state.shipping_address === addr.id ? 500 : 400} !important`
922
+ }, addr.fullname, $phone, (0,preact_module.h)("div", {
923
+ class: "mt-1 muted"
924
+ }, "DC ", fulladdr)), (0,preact_module.h)("div", {
925
+ class: "radio--check"
926
+ }, (0,preact_module.h)("div", {
927
+ class: "inside"
928
+ }))));
929
+ });
930
+ $preaddrs.push((0,preact_module.h)("div", {
931
+ style: ""
932
+ }, (0,preact_module.h)("div", {
933
+ class: "radio d-flex "
934
+ }, (0,preact_module.h)("input", {
935
+ type: "radio",
936
+ id: 'shipping_addr.new',
937
+ onInput: e => this.onChangeShippingAddress('new'),
938
+ name: "shipping_address",
939
+ checked: this.state.shipping_address === 'new'
940
+ }), (0,preact_module.h)("label", {
941
+ class: "radio--label",
942
+ for: 'shipping_addr.new'
943
+ }, 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", {
944
+ class: "radio--check"
945
+ }, (0,preact_module.h)("div", {
946
+ class: "inside"
947
+ })))));
948
+ let $new = (0,preact_module.h)("div", {
949
+ style: "padding-left: 22px !important;"
950
+ }, (0,preact_module.h)("div", {
951
+ class: "d-flex"
952
+ }, (0,preact_module.h)("div", {
953
+ class: "mr-2",
954
+ style: "flex: 1 !important;"
955
+ }, (0,preact_module.h)("div", {
956
+ class: "order_form_label"
957
+ }, this.props.t('fullname')), (0,preact_module.h)("input", {
958
+ type: "text",
959
+ class: 'form-control ' + (this.state.err.name && 'err'),
960
+ onInput: this.onChangeFullname,
961
+ value: this.state.fullname
962
+ })), (0,preact_module.h)("div", {
963
+ class: "ml-2",
964
+ style: "flex: 1 !important;"
965
+ }, (0,preact_module.h)("div", {
966
+ class: "order_form_label"
967
+ }, this.props.t('phones')), (0,preact_module.h)("input", {
968
+ type: "text",
969
+ class: 'form-control ' + (this.state.err.phone && 'err'),
970
+ onInput: this.onChangePhone,
971
+ value: this.state.phone
972
+ }))), (0,preact_module.h)("div", {
973
+ class: "",
974
+ style: "width: 100% !important"
975
+ }, (0,preact_module.h)("div", {
976
+ class: "order_form_label"
977
+ }, this.props.t('address')), (0,preact_module.h)(AddressPicker, {
978
+ initAddress: this.state.address,
979
+ store: this.props.store,
980
+ width: "100%",
981
+ onChangeAddress: this.onChangeAddress,
982
+ full: this.isMobile(),
983
+ onSelect: this.onSelectAddress,
984
+ extra_cls: this.state.err.address && 'err'
985
+ })), (0,preact_module.h)("div", {
986
+ class: "d-flex",
987
+ style: "justify-content: space-between !important;"
988
+ }, (0,preact_module.h)("div", {
989
+ style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
990
+ }, (0,preact_module.h)("div", {
991
+ class: "order_form_label"
992
+ }, this.props.t('province')), (0,preact_module.h)(DropdownSelect, {
993
+ width: "194",
994
+ full: this.isMobile(),
995
+ has_search: true,
996
+ loading: this.state.loadProvince,
997
+ items: provinces,
998
+ selected: this.state.selectedProvince,
999
+ onSelect: this.onSelectProvince,
1000
+ extra_cls: this.state.err.province && 'err'
1001
+ })), (0,preact_module.h)("div", {
1002
+ style: "flex: 1 !important; overflow:hidden !important; margin-left: 7px !important;"
1003
+ }, (0,preact_module.h)("div", {
1004
+ class: "order_form_label"
1005
+ }, this.props.t('district')), (0,preact_module.h)(DropdownSelect, {
1006
+ width: "194",
1007
+ full: this.isMobile(),
1008
+ selected: this.state.selectedDistrict,
1009
+ has_search: true,
1010
+ onSelect: this.onSelectDistrict,
1011
+ loading: this.state.loadDistrict,
1012
+ extra_cls: this.state.err.district && 'err',
1013
+ items: districts
1014
+ }))), (0,preact_module.h)("div", {
1015
+ class: "d-flex",
1016
+ style: "justify-content: space-between !important;"
1017
+ }, (0,preact_module.h)("div", {
1018
+ style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
1019
+ }, (0,preact_module.h)("div", {
1020
+ class: "order_form_label"
1021
+ }, this.props.t('ward')), (0,preact_module.h)(DropdownSelect, {
1022
+ width: "194",
1023
+ selected: this.state.selectedWard,
1024
+ full: this.isMobile(),
1025
+ has_search: true,
1026
+ onSelect: this.onSelectWard,
1027
+ extra_cls: this.state.err.ward && 'err',
1028
+ loading: this.state.loadWard,
1029
+ items: wards
1030
+ })), (0,preact_module.h)("div", {
1031
+ style: "flex: 1 !important; margin-left: 7px !important;"
1032
+ })));
1033
+ cls += ' ship_card__active';
1034
+ if (util/* default */.A.size(addresses) == 0) {
1035
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
1036
+ class: 'mt-3 mb-2 '
1037
+ }, this.props.t('input_shipping_info')), $new);
1038
+ } else {
1039
+ if (this.state.shipping_address !== 'new') $new = null;
1040
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
1041
+ class: "mt-3 mb-2",
1042
+ style: "margin-bottom: 10px !important;"
1043
+ }, "Vui l\xF2ng ch\u1ECDn \u0111\u1ECBa ch\u1EC9 giao h\xE0ng"), (0,preact_module.h)("div", {
1044
+ class: "form"
1045
+ }, $preaddrs), $new);
1046
+ }
1047
+ }
1048
+ let shopcls = 'ship_card';
1049
+ let shop_icon_active = false;
1050
+ if (this.state.shipping === 'shop') {
1051
+ shop_icon_active = true;
1052
+ shopcls += ' ship_card__active';
1053
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
1054
+ class: "d-flex"
1055
+ }, (0,preact_module.h)("div", {
1056
+ class: "mr-2",
1057
+ style: "flex: 3 !important;"
1058
+ }, (0,preact_module.h)("div", {
1059
+ class: "order_form_label"
1060
+ }, this.props.t('fullname')), (0,preact_module.h)("input", {
1061
+ type: "text",
1062
+ class: 'form-control ' + (this.state.err.name && 'err'),
1063
+ onInput: this.onChangeFullname,
1064
+ value: this.state.fullname
1065
+ })), (0,preact_module.h)("div", {
1066
+ class: "ml-2",
1067
+ style: "flex: 2 !important;"
1068
+ }, (0,preact_module.h)("div", {
1069
+ class: "order_form_label"
1070
+ }, this.props.t('phones')), (0,preact_module.h)("input", {
1071
+ type: "text",
1072
+ class: 'form-control ' + (this.state.err.phone && 'err'),
1073
+ onInput: this.onChangePhone,
1074
+ value: this.state.phone
1075
+ }))), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
1076
+ class: "order_form_label"
1077
+ }, this.props.t('email')), (0,preact_module.h)("input", {
1078
+ type: "text",
1079
+ class: 'form-control ' + (this.state.err.email && 'err'),
1080
+ onInput: this.onChangeEmail,
1081
+ value: this.state.email
1082
+ })));
1083
+ }
1084
+ let seccls = 'card_section';
1085
+ if (this.isMobile()) seccls = 'order_section';
1086
+ return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
1087
+ class: "order_section__line"
1088
+ }), (0,preact_module.h)("div", {
1089
+ class: seccls
1090
+ }, (0,preact_module.h)("div", {
1091
+ class: "order_label"
1092
+ }, this.props.t('ship_to')), (0,preact_module.h)("div", {
1093
+ class: "d-flex"
1094
+ }, (0,preact_module.h)("div", {
1095
+ class: shopcls + ' mr-3',
1096
+ onClick: e => this.onChangeShipping('shop')
1097
+ }, (0,preact_module.h)(Icon, {
1098
+ name: "shop",
1099
+ active: shop_icon_active
1100
+ }), " ", (0,preact_module.h)("b", {
1101
+ class: "ml-2"
1102
+ }, "Nh\u1EADn h\xE0ng t\u1EA1i shop")), (0,preact_module.h)("div", {
1103
+ class: cls,
1104
+ onClick: e => this.onChangeShipping('ship')
1105
+ }, (0,preact_module.h)(Icon, {
1106
+ name: "package",
1107
+ active: ship_icon_active
1108
+ }), " ", (0,preact_module.h)("b", {
1109
+ class: "ml-2"
1110
+ }, "Giao h\xE0ng cho t\xF4i"))), $body));
1111
+ }
1112
+ let addr = util/* default */.A.get(order, 'shipping.address') || {};
1113
+ let fulladdr = [addr.address, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
1114
+ let $phone = null;
1115
+ if (addr.phone) $phone = (0,preact_module.h)("div", {
1116
+ class: "mt-1 muted"
1117
+ }, this.props.t('phn'), ":\xA0", addr.phone);
1118
+ if (util/* default */.A.get(order, 'shipping.pickup_at_shop')) {
1119
+ fulladdr = 'Nhận hàng tại cửa hàng';
1120
+ }
1121
+ let $addr = fulladdr ? (0,preact_module.h)("div", null, fulladdr) : (0,preact_module.h)("i", {
1122
+ class: "i muted"
1123
+ }, "Ch\u01B0a c\xF3 \u0111\u1ECBa ch\u1EC9 giao h\xE0ng");
1124
+ let seccls = 'card_section';
1125
+ if (this.isMobile()) seccls = 'order_section';
1126
+ return (0,preact_module.h)("div", {
1127
+ class: seccls
1128
+ }, (0,preact_module.h)("div", {
1129
+ class: "order_label "
1130
+ }, this.props.t('ship_to')), $addr, $phone);
1131
+ }
1132
+ renderDesktopSummary(order) {
1133
+ let $deposit = null;
1134
+ if (order.deposit > 0) {
1135
+ $deposit = (0,preact_module.h)("span", {
1136
+ class: "muted"
1137
+ }, "(c\u1ECDc ", util/* default */.A.formatCurrency(order.deposit), ")");
1138
+ }
1139
+ let $discount = null;
1140
+ if (order.total_discount > 0) {
1141
+ $discount = (0,preact_module.h)("div", {
1142
+ class: "order_summary_line"
1143
+ }, (0,preact_module.h)("div", null, "Gi\u1EA3m gi\xE1"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency(order.total_discount)));
1144
+ }
1145
+ let $pay = null;
1146
+ if ($deposit || order.payment_made) {
1147
+ $pay = (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
1148
+ class: "order_summary_line"
1149
+ }, (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", {
1150
+ class: "order_summary_line"
1151
+ }, (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)))));
1152
+ }
1153
+ let $tax = (0,preact_module.h)("div", {
1154
+ class: "order_summary_line"
1155
+ }, (0,preact_module.h)("div", null, "Ti\u1EC1n thu\u1EBF"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency(order.total_tax)));
1156
+ let $ship = (0,preact_module.h)("div", {
1157
+ class: "order_summary_line"
1158
+ }, (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"));
1159
+ let editmode = false;
1160
+ if (!order.status || order.status == 'open') {
1161
+ editmode = !order.user_confirmation;
1162
+ }
1163
+ let $note = null;
1164
+ if (editmode) {
1165
+ $ship = null;
1166
+ $tax = null;
1167
+ $note = (0,preact_module.h)("div", {
1168
+ class: "muted"
1169
+ }, (0,preact_module.h)("img", {
1170
+ class: "order_ship_icon",
1171
+ src: __webpack_require__(7324)
1172
+ }), "\xA0 Ch\u01B0a bao g\u1ED3m thu\u1EBF v\xE0 ph\xED v\u1EADn chuy\u1EC3n");
1173
+ }
1174
+ let seccls = '';
1175
+ if (this.isMobile()) seccls = 'order_section';
1176
+ return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
1177
+ class: "order_section__line"
1178
+ }), (0,preact_module.h)("div", {
1179
+ class: seccls
1180
+ }, (0,preact_module.h)("div", {
1181
+ class: "order_label"
1182
+ }, "T\xF3m t\u1EAFt"), (0,preact_module.h)("div", {
1183
+ class: "order_summary_line"
1184
+ }, (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", {
1185
+ class: "order_summary_line",
1186
+ style: "margin-top: 10px !important; padding-top: 15px !important; border-top: 1px solid #eee !important"
1187
+ }, (0,preact_module.h)("div", null, "B\u1EA1n ph\u1EA3i tr\u1EA3"), (0,preact_module.h)("div", {
1188
+ class: "order__total"
1189
+ }, util/* default */.A.formatCurrency(order.total))), $pay));
1190
+ }
1191
+ renderStatusBadge(order) {
1192
+ let status = order.status || 'open';
1193
+ return (0,preact_module.h)("div", {
1194
+ style: "float: right !important;",
1195
+ class: 'order_status order_status__' + status
1196
+ }, status);
1197
+ }
1198
+ renderShippingInfo(order) {
1199
+ if (order.status != 'open' || order.user_confirmation) {}
1200
+ let shipping_provider = util/* default */.A.get(order, 'shipping.shipping_provider');
1201
+ if (!shipping_provider) return null;
1202
+ let shipping_code = util/* default */.A.get(order, 'shipping.shipping_code');
1203
+ let $tracking_code = null;
1204
+ if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
1205
+ class: "muted",
1206
+ style: "margin-top: 3px !important"
1207
+ }, "V\u1EADn \u0111\u01A1n\xA0", (0,preact_module.h)("a", {
1208
+ class: "order_tracking_link",
1209
+ target: "_blank",
1210
+ href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
1211
+ }, shipping_code, "\xA0", (0,preact_module.h)("img", {
1212
+ class: "order_tracking_link_icon",
1213
+ src: __webpack_require__(3266)
1214
+ })));
1215
+ if (shipping_provider == 'ghtk') {
1216
+ return (0,preact_module.h)("div", {
1217
+ class: "order_section"
1218
+ }, (0,preact_module.h)("div", {
1219
+ class: "order_section_label"
1220
+ }, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", {
1221
+ class: "d-flex align-items-center"
1222
+ }, (0,preact_module.h)("img", {
1223
+ class: "order_shipping_provider_logo",
1224
+ src: ShippingProvider.ghtk.logo
1225
+ }), (0,preact_module.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
1226
+ }
1227
+ return null;
1228
+ }
1229
+ renderDesktopShippingInfo(order) {
1230
+ let shipping_provider = util/* default */.A.get(order, 'shipping.shipping_provider');
1231
+ if (!shipping_provider) return null;
1232
+ let shipping_code = util/* default */.A.get(order, 'shipping.shipping_code');
1233
+ let $tracking_code = null;
1234
+ if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
1235
+ class: "muted",
1236
+ style: "margin-top: 3px !important"
1237
+ }, "V\u1EADn \u0111\u01A1n\xA0", (0,preact_module.h)("a", {
1238
+ class: "order_tracking_link",
1239
+ target: "_blank",
1240
+ href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
1241
+ }, shipping_code, "\xA0", (0,preact_module.h)("img", {
1242
+ class: "order_tracking_link_icon",
1243
+ src: __webpack_require__(3266)
1244
+ })));
1245
+ if (shipping_provider == 'ghtk') {
1246
+ return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
1247
+ class: "order_label"
1248
+ }, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", {
1249
+ class: "d-flex align-items-center"
1250
+ }, (0,preact_module.h)("img", {
1251
+ class: "order_shipping_provider_logo",
1252
+ src: ShippingProvider.ghtk.logo
1253
+ }), (0,preact_module.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
1254
+ }
1255
+ return null;
1256
+ }
1257
+ renderProducts(order) {
1258
+ let $products = null;
1259
+ $products = util/* default */.A.map(order.items, item => {
1260
+ if (!item || !item.product) return null;
1261
+ let product = item.product;
1262
+ return (0,preact_module.h)("div", {
1263
+ class: "order_attachment__product"
1264
+ }, (0,preact_module.h)("img", {
1265
+ class: "order_attachment__product_img",
1266
+ alt: '' + product.id,
1267
+ src: util/* default */.A.get(product, 'images.0') || __webpack_require__(2876)
1268
+ }), (0,preact_module.h)("div", {
1269
+ style: "overflow: hidden !important;"
1270
+ }, (0,preact_module.h)("div", {
1271
+ class: "order_attachment__product_name"
1272
+ }, product.name), (0,preact_module.h)("div", {
1273
+ class: "order_attachment__product_desc"
1274
+ }, product.description || product.long_description), (0,preact_module.h)("div", {
1275
+ class: "order_attachment__product_desc"
1276
+ }, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default */.A.formatCurrency(product.price))));
1277
+ });
1278
+ if (!this.isMobile()) return (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
1279
+ class: "order_label"
1280
+ }, this.props.t('product')), $products);
1281
+ return (0,preact_module.h)("div", {
1282
+ class: "order_section"
1283
+ }, (0,preact_module.h)("div", {
1284
+ class: "order_section_label"
1285
+ }, this.props.t('product')), $products);
1286
+ }
1287
+ renderDesktopProducts(order) {
1288
+ let $products = null;
1289
+ let editmode = false;
1290
+ if (!order.status || order.status == 'open') {
1291
+ editmode = !order.user_confirmation;
1292
+ }
1293
+ if (editmode) {
1294
+ $products = util/* default */.A.map(order.items, item => {
1295
+ if (!item || !item.product) return null;
1296
+ let product = item.product;
1297
+ return (0,preact_module.h)("div", {
1298
+ class: "order_attachment__product"
1299
+ }, (0,preact_module.h)("img", {
1300
+ class: "order_attachment__product_img",
1301
+ alt: '' + product.id,
1302
+ src: util/* default */.A.get(product, 'images.0') || __webpack_require__(2876)
1303
+ }), (0,preact_module.h)("div", {
1304
+ style: "overflow: hidden !important; flex: 1 !important"
1305
+ }, (0,preact_module.h)("div", {
1306
+ class: "order_attachment__product_name"
1307
+ }, product.name), (0,preact_module.h)("div", {
1308
+ class: "order_attachment__product_desc"
1309
+ }, product.description || product.long_description), (0,preact_module.h)("div", {
1310
+ class: "order_attachment__product_desc"
1311
+ }, util/* default */.A.formatCurrency(product.price))), (0,preact_module.h)("input", {
1312
+ class: "form-control",
1313
+ style: "text-align: center !important; font-weight: 400 !important; width: 50px !important",
1314
+ value: item.quantity,
1315
+ onInput: e => this.onChangeQuantity(item, e.target.value),
1316
+ type: "text"
1317
+ }), (0,preact_module.h)("div", {
1318
+ style: "width: 80px !important; text-align: right !important; "
1319
+ }, (0,preact_module.h)("b", null, util/* default */.A.formatCurrency(item.quantity * product.price))));
1320
+ });
1321
+ } else {
1322
+ $products = util/* default */.A.map(order.items, item => {
1323
+ if (!item || !item.product) return null;
1324
+ let product = item.product;
1325
+ return (0,preact_module.h)("div", {
1326
+ class: "order_attachment__product"
1327
+ }, (0,preact_module.h)("img", {
1328
+ class: "order_attachment__product_img",
1329
+ alt: '' + product.id,
1330
+ src: util/* default */.A.get(product, 'images.0') || __webpack_require__(2876)
1331
+ }), (0,preact_module.h)("div", {
1332
+ style: "overflow: hidden !important; flex: 1 !important"
1333
+ }, (0,preact_module.h)("div", {
1334
+ class: "order_attachment__product_name"
1335
+ }, product.name), (0,preact_module.h)("div", {
1336
+ class: "order_attachment__product_desc"
1337
+ }, product.description || product.long_description), (0,preact_module.h)("div", {
1338
+ class: "order_attachment__product_desc"
1339
+ }, util/* default */.A.formatCurrency(product.price))), (0,preact_module.h)("div", {
1340
+ style: "text-align: center !important; font-weight: 400 !important; width: 50px !important"
1341
+ }, item.quantity), (0,preact_module.h)("div", {
1342
+ style: "width: 80px !important; text-align: right !important; "
1343
+ }, (0,preact_module.h)("b", null, util/* default */.A.formatCurrency(item.total))));
1344
+ });
1345
+ }
1346
+ return (0,preact_module.h)("div", {
1347
+ class: "card_section"
1348
+ }, (0,preact_module.h)("div", {
1349
+ class: "desktop_order__heading"
1350
+ }, this.renderStatusBadge(order), (0,preact_module.h)("b", {
1351
+ style: "font-size: 18px !important;"
1352
+ }, this.props.t('order'), " #", order.order_number || order.id), (0,preact_module.h)("div", {
1353
+ class: "muted"
1354
+ }, (0,preact_module.h)(time/* default */.A, {
1355
+ style: "font-size: 13px !important;",
1356
+ time: order.issue_date || order.created
1357
+ }))), (0,preact_module.h)("div", {
1358
+ class: "order_label d-flex",
1359
+ style: "margin-top: 20px !important;justify-content: space-between !important; align-items: flex-end !important;"
1360
+ }, (0,preact_module.h)("div", {
1361
+ style: "flex: 1 !important;"
1362
+ }, this.props.t('product')), (0,preact_module.h)("div", {
1363
+ style: "font-weight: 400 !important; text-align:center !important; width: 50px !important"
1364
+ }, this.props.t('qty')), (0,preact_module.h)("div", {
1365
+ style: "font-weight: 400 !important; text-align: right !important; width: 80px !important;"
1366
+ }, this.props.t('total'))), $products);
1367
+ }
1368
+ renderMobile(order) {
1369
+ if (this.state.step === 'success') return this.renderMobileSuccess(order);
1370
+ let $error = null;
1371
+ if (this.state.g_err) {
1372
+ $error = (0,preact_module.h)("div", {
1373
+ class: "mb-2 text__danger"
1374
+ }, (0,preact_module.h)("img", {
1375
+ style: "margin-top: -4px !important; height: 15px !important;",
1376
+ src: ximg
1377
+ }), "\xA0", (0,preact_module.h)("b", null, this.state.g_err));
1378
+ }
1379
+ let $status = (0,preact_module.h)("div", null, $error, (0,preact_module.h)("div", {
1380
+ class: "btn-confirm-order",
1381
+ style: "margin-top: 0 !important;",
1382
+ onClick: this.confirm
1383
+ }, this.props.t('confirm_order')));
1384
+ let $close = (0,preact_module.h)("div", {
1385
+ class: "order_btn order__btn__light mt-3",
1386
+ onClick: this.onCancel
1387
+ }, this.props.t('cancel_order'));
1388
+ if (order.user_confirmation || order.status != 'open') {
1389
+ $status = null;
1390
+ if (this.props.cid) $close = (0,preact_module.h)("div", {
1391
+ class: "order_btn order__btn__light mt-3",
1392
+ onClick: this.close
1393
+ }, this.props.t('close'));
1394
+ }
1395
+ return (0,preact_module.h)("div", {
1396
+ class: "order",
1397
+ style: "height: 100% !important"
1398
+ }, (0,preact_module.h)("div", {
1399
+ class: "order--content"
1400
+ }, (0,preact_module.h)("div", {
1401
+ class: "order--heading"
1402
+ }, this.renderStatusBadge(order), (0,preact_module.h)("b", {
1403
+ style: "font-size: 16px !important;"
1404
+ }, this.props.t('order'), " #", order.order_number || order.id), (0,preact_module.h)("div", {
1405
+ class: "muted"
1406
+ }, (0,preact_module.h)(time/* default */.A, {
1407
+ style: "font-size: 13px !important;",
1408
+ time: order.issue_date || order.created
1409
+ }))), this.renderProducts(order), this.renderDesktopShipping(order), this.renderShippingInfo(order), this.renderDesktopPaymentMethod(order), this.renderDesktopSummary(order), (0,preact_module.h)("div", {
1410
+ class: "order_section pb-3",
1411
+ style: "padding-top: 0 !important;"
1412
+ }, $status, $close)));
1413
+ }
1414
+ renderActions(order) {
1415
+ let $actions = null;
1416
+ let editmode = false;
1417
+ if (!order.status || order.status == 'open') {
1418
+ editmode = !order.user_confirmation;
1419
+ }
1420
+ if (this.state.step === 'success') return (0,preact_module.h)("div", {
1421
+ class: "d-flex",
1422
+ style: "align-items: center !important; justify-content: flex-end !important"
1423
+ }, (0,preact_module.h)("div", null, "Ghi nh\u1EADn th\xE0nh c\xF4ng"), "\xA0", (0,preact_module.h)("img", {
1424
+ style: "width: 16px !important; height: 16px !important;",
1425
+ width: "16",
1426
+ height: "16",
1427
+ src: checkedimg
1428
+ }));
1429
+ if (editmode) {
1430
+ let $error = null;
1431
+ if (this.state.g_err) {
1432
+ $error = (0,preact_module.h)("div", {
1433
+ class: "mb-2 text__danger"
1434
+ }, (0,preact_module.h)("img", {
1435
+ style: "margin-top: -4px !important; height: 15px !important;",
1436
+ src: ximg
1437
+ }), "\xA0", (0,preact_module.h)("b", null, this.state.g_err));
1438
+ }
1439
+ $actions = (0,preact_module.h)("div", null, $error, (0,preact_module.h)("div", {
1440
+ class: "btn-confirm-order",
1441
+ onClick: this.confirm
1442
+ }, this.props.t('confirm_order')), (0,preact_module.h)("div", {
1443
+ class: "btn-cancel-order",
1444
+ onClick: this.onCancel
1445
+ }, this.props.t('cancel_order')));
1446
+ }
1447
+ return $actions;
1448
+ }
1449
+ renderDesktop(order) {
1450
+ let acc = this.props.store.matchAccount();
1451
+ var uri = acc.logo_url || __webpack_require__(3582);
1452
+ return (0,preact_module.h)("div", {
1453
+ class: "desktop order"
1454
+ }, (0,preact_module.h)("div", {
1455
+ class: "order_acc_header"
1456
+ }, (0,preact_module.h)("img", {
1457
+ class: "order_acc_logo",
1458
+ src: uri
1459
+ }), (0,preact_module.h)("div", {
1460
+ class: "order_acc_name"
1461
+ }, acc.name)), (0,preact_module.h)("div", {
1462
+ class: "desktop_order__content"
1463
+ }, (0,preact_module.h)("div", {
1464
+ style: "flex: 1 !important; padding-right: 20px !important;"
1465
+ }, this.renderDesktopProducts(order), this.renderDesktopShipping(order), this.renderDesktopShippingInfo(order), this.renderDesktopPaymentMethod(order), (0,preact_module.h)("div", {
1466
+ class: "order__footer"
1467
+ }, (0,preact_module.h)("a", {
1468
+ target: "_blank",
1469
+ href: "https://subiz.com.vn",
1470
+ class: "order__footer_link"
1471
+ }, "Cung c\u1EA5p b\u1EDFi ", (0,preact_module.h)("b", null, "Subiz")), (0,preact_module.h)("div", {
1472
+ class: "order__footer_delimiter"
1473
+ }), (0,preact_module.h)("a", {
1474
+ target: "_blank",
1475
+ href: "https://subiz.com.vn/vi/terms-of-service.html",
1476
+ class: "order__footer_link"
1477
+ }, "\u0110i\u1EC1u kho\u1EA3n"), (0,preact_module.h)("a", {
1478
+ target: "_blank",
1479
+ href: "https://subiz.com.vn/vi/privacy-policy.html",
1480
+ class: "order__footer_link"
1481
+ }, "Quy\u1EC1n ri\xEAng t\u01B0"))), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
1482
+ class: "order_recap"
1483
+ }, this.renderDesktopSummary(order), this.renderActions(order)))));
1484
+ }
1485
+ render() {
1486
+ if (this.state.loading) return (0,preact_module.h)("div", {
1487
+ class: "order_error"
1488
+ }, (0,preact_module.h)(spinner/* default */.A, {
1489
+ class: "mt-4",
1490
+ size: "60",
1491
+ static: true
1492
+ }));
1493
+ if (this.state.error) return (0,preact_module.h)("div", {
1494
+ class: "order_error"
1495
+ }, (0,preact_module.h)("img", {
1496
+ class: "mt-3",
1497
+ src: __webpack_require__(6907)
1498
+ }), (0,preact_module.h)("div", {
1499
+ class: "mt-3"
1500
+ }, this.props.t('order_load_error')));
1501
+ let order = this.state.order;
1502
+ if (this.isMobile()) return this.renderMobile(order);
1503
+ return this.renderDesktop(order);
1504
+ }
1505
+ }
1506
+ let ShippingProvider = {
1507
+ ghtk: {
1508
+ name: 'Giao hàng tiết kiệm',
1509
+ logo: __webpack_require__(7362)
1510
+ },
1511
+ ghn: {
1512
+ name: 'Giao hàng nhanh',
1513
+ logo: __webpack_require__(1113)
1514
+ }
1515
+ };
1516
+ ;// ./src/chatbox/Order.js
1517
+ 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; }
1518
+ function Order_toPropertyKey(t) { var i = Order_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
1519
+ 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); }
1520
+
1521
+
1522
+
1523
+ const POPUP_MAX_HEIGHT = 400;
1524
+ const POPUP_HARD_MAX_HEIGHT = 500;
1525
+ const POPUP_MIN_HEIGHT = 0;
1526
+ let Order_defaultAvatar = __webpack_require__(2538);
1527
+
1528
+
1529
+
1530
+ class Order extends common/* Com */.Mw {
1531
+ constructor(props) {
1532
+ super(props);
1533
+ Order_defineProperty(this, "state", {
1534
+ hide: true,
1535
+ ratingHeight: 0,
1536
+ overlayOpacity: 0.3
1537
+ });
1538
+ Order_defineProperty(this, "onResponse", response => {
1539
+ this.setState({
1540
+ response
1541
+ });
1542
+ });
1543
+ Order_defineProperty(this, "confirm", () => {
1544
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
1545
+ message: {
1546
+ format: 'plaintext',
1547
+ text: 'confirm',
1548
+ attachments: [{
1549
+ type: 'postback',
1550
+ postback: {
1551
+ payload: JSON.stringify({
1552
+ type: 'order_confirmation',
1553
+ status: 'confirmed'
1554
+ })
1555
+ }
1556
+ }]
1557
+ }
1558
+ });
1559
+ });
1560
+ Order_defineProperty(this, "close", async () => {
1561
+ await util/* default */.A.sleep(100);
1562
+ if (this.state.response === 'confirmed') {
1563
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
1564
+ message: {
1565
+ format: 'plaintext',
1566
+ text: this.props.t('confirm_order'),
1567
+ attachments: [{
1568
+ type: 'postback',
1569
+ postback: {
1570
+ payload: JSON.stringify({
1571
+ type: 'order_confirmation',
1572
+ status: 'confirmed'
1573
+ })
1574
+ }
1575
+ }]
1576
+ }
1577
+ });
1578
+ } else if (this.state.response === 'rejected') {
1579
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
1580
+ message: {
1581
+ format: 'plaintext',
1582
+ text: this.props.t('cancel_order'),
1583
+ attachments: [{
1584
+ type: 'postback',
1585
+ postback: {
1586
+ payload: JSON.stringify({
1587
+ type: 'order_confirmation',
1588
+ status: 'cancelled'
1589
+ })
1590
+ }
1591
+ }]
1592
+ }
1593
+ });
1594
+ } else {}
1595
+ this.setState({
1596
+ response: ''
1597
+ });
1598
+ if (this.state.hide) return;
1599
+ if (!this.refRating.current) return;
1600
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
1601
+ var h0 = parseFloat(popupStyle.height);
1602
+ this.animation.play(20, h0, h => {
1603
+ this.setState({
1604
+ ratingHeight: h,
1605
+ overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
1606
+ });
1607
+ if (h < POPUP_MIN_HEIGHT + 10) {
1608
+ if (!this.state.hide) {
1609
+ this.setState({
1610
+ hide: true
1611
+ });
1612
+ }
1613
+ }
1614
+ });
1615
+ this.props.onClose();
1616
+ });
1617
+ this.refRating = (0,preact_module/* createRef */._3)();
1618
+ this.refHandle = (0,preact_module/* createRef */._3)();
1619
+ }
1620
+ componentDidMount() {
1621
+ this.mouseUp = e => this.onMouseUp(e);
1622
+ this.mouseMove = e => this.onMouseMove(e);
1623
+ this.mouseDown = e => this.onMouseDown(e);
1624
+ var $ratingHandle = this.refHandle.current;
1625
+ $ratingHandle.addEventListener('mousedown', this.mouseDown, {
1626
+ passive: true
1627
+ });
1628
+ $ratingHandle.addEventListener('touchstart', this.mouseDown, {
1629
+ passive: true
1630
+ });
1631
+ window.addEventListener('mouseup', this.mouseUp, {
1632
+ passive: true
1633
+ });
1634
+ window.addEventListener('touchend', this.mouseUp, {
1635
+ passive: true
1636
+ });
1637
+ window.addEventListener('mousemove', this.mouseMove, {
1638
+ passive: true
1639
+ });
1640
+ window.addEventListener('touchmove', this.mouseMove, {
1641
+ passive: true
1642
+ });
1643
+ this.animation = new releaseAnimation/* default */.A({
1644
+ maxY: POPUP_MAX_HEIGHT,
1645
+ minY: POPUP_MIN_HEIGHT,
1646
+ duration: 150
1647
+ });
1648
+ this.close();
1649
+ }
1650
+ componentWillUnmount() {
1651
+ var $ratingHandle = this.refHandle.current;
1652
+ $ratingHandle.removeEventListener('mousedown', this.mouseDown, 0);
1653
+ $ratingHandle.removeEventListener('touchstart', this.mouseDown, 0);
1654
+ window.removeEventListener('mouseup', this.mouseUp, 0);
1655
+ window.removeEventListener('touchend', this.mouseUp, 0);
1656
+ window.removeEventListener('mousemove', this.mouseMove, 0);
1657
+ window.removeEventListener('touchmove', this.mouseMove, 0);
1658
+ }
1659
+ render() {
1660
+ if (this._show != this.props.show) {
1661
+ this._show = this.props.show;
1662
+ util/* default */.A.setTimeout(() => {
1663
+ if (!this._show) this.close();else this.open();
1664
+ });
1665
+ }
1666
+ let cls = this.state.hide ? 'd-none' : '';
1667
+ return (0,preact_module.h)("div", {
1668
+ class: cls
1669
+ }, (0,preact_module.h)("div", {
1670
+ class: "extension--overlay",
1671
+ style: `opacity: ${this.state.overlayOpacity * 0.5} !important;`
1672
+ }), (0,preact_module.h)("div", {
1673
+ class: "extension",
1674
+ ref: this.refRating,
1675
+ style: `height: ${this.state.ratingHeight}px !important;`
1676
+ }, (0,preact_module.h)("div", {
1677
+ class: "extension--close-btn",
1678
+ onClick: this.close
1679
+ }, this.props.t('close')), (0,preact_module.h)("div", {
1680
+ class: "extension--handle",
1681
+ ref: this.refHandle
1682
+ }, (0,preact_module.h)("div", {
1683
+ class: "extension--thumb"
1684
+ })), (0,preact_module.h)("div", {
1685
+ style: "overflow-x: hidden !important; overflow-y: scroll !important; height: 100% !important;"
1686
+ }, (0,preact_module.h)(order_Order, {
1687
+ key: this.props.order_id,
1688
+ store: this.props.store,
1689
+ onResponse: this.onResponse,
1690
+ onClose: this.close,
1691
+ t: this.props.t,
1692
+ order_id: this.props.order_id,
1693
+ cid: this.props.cid
1694
+ }))));
1695
+ }
1696
+ open() {
1697
+ if (!this.state.hide) return;
1698
+ if (!this.props.order_id) return;
1699
+ this.setState({
1700
+ hide: false
1701
+ });
1702
+ if (!this.refRating.current) return;
1703
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
1704
+ var h0 = parseFloat(popupStyle.height);
1705
+ this.animation.play(-20, h0, h => {
1706
+ this.setState({
1707
+ ratingHeight: h,
1708
+ overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
1709
+ });
1710
+ });
1711
+ }
1712
+ onMouseDown(e) {
1713
+ this.mousePushed = true;
1714
+ this.animation.stop();
1715
+ e.preventDefault();
1716
+ if (e.touches && e.touches[0]) e = e.touches[0];
1717
+ this.mousePushedDy = e.pageY - window.pageYOffset - this.refRating.current.getBoundingClientRect().y;
1718
+ }
1719
+ onMouseUp(e) {
1720
+ if (!this.mousePushed) return;
1721
+ if (e.touches && e.touches[0]) e = e.touches[0];
1722
+ this.mousePushed = false;
1723
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
1724
+ var h0 = parseFloat(popupStyle.height);
1725
+ this.animation.play(this.mouseVelocity, h0, h => {
1726
+ this.setState({
1727
+ ratingHeight: h,
1728
+ overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
1729
+ });
1730
+ if (h < POPUP_MIN_HEIGHT + 10) {
1731
+ if (!this.state.hide) {
1732
+ this.setState({
1733
+ hide: true
1734
+ });
1735
+ this.props.onRate && this.props.onRate({
1736
+ no_rating: true
1737
+ });
1738
+ }
1739
+ }
1740
+ });
1741
+ }
1742
+ onMouseMove(e) {
1743
+ if (!this.mousePushed) return;
1744
+ if (e.touches && e.touches[0]) e = e.touches[0];
1745
+ var my = e.pageY;
1746
+ this.mouseVelocity = my - this.lastMouseY;
1747
+ this.lastMouseY = my;
1748
+ my = my - this.mousePushedDy;
1749
+ var K = 10000;
1750
+ var height = this.refRating.current.getBoundingClientRect().bottom - my;
1751
+ if (height > POPUP_MAX_HEIGHT) {
1752
+ var beta = K / (POPUP_HARD_MAX_HEIGHT - POPUP_MAX_HEIGHT) - POPUP_MAX_HEIGHT;
1753
+ height = POPUP_HARD_MAX_HEIGHT - K / (height + beta);
1754
+ }
1755
+ this.setState({
1756
+ ratingHeight: height,
1757
+ overlayOpacity: Math.min(1, (height - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
1758
+ });
1759
+ }
1760
+ }
1761
+
1762
+ /***/ },
1763
+
1764
+ /***/ 5244
1765
+ (module, __unused_webpack_exports, __webpack_require__) {
1766
+
1767
+ module.exports = __webpack_require__.p + "assets/img/shop.f7dc7d8.svg";
1768
+
1769
+ /***/ },
1770
+
1771
+ /***/ 5452
1772
+ (module, __unused_webpack_exports, __webpack_require__) {
1773
+
1774
+ module.exports = __webpack_require__.p + "assets/img/search.f9705ff.svg";
1775
+
1776
+ /***/ },
1777
+
1778
+ /***/ 5860
1779
+ (module, __unused_webpack_exports, __webpack_require__) {
1780
+
1781
+ module.exports = __webpack_require__.p + "assets/img/done_green.b817fd4.svg";
1782
+
1783
+ /***/ },
1784
+
1785
+ /***/ 6857
1786
+ (module, __unused_webpack_exports, __webpack_require__) {
1787
+
1788
+ module.exports = __webpack_require__.p + "assets/img/package_fade.763c001.svg";
1789
+
1790
+ /***/ },
1791
+
1792
+ /***/ 6907
1793
+ (module, __unused_webpack_exports, __webpack_require__) {
1794
+
1795
+ module.exports = __webpack_require__.p + "assets/img/empty_1.0b98af0.svg";
1796
+
1797
+ /***/ },
1798
+
1799
+ /***/ 7324
1800
+ (module, __unused_webpack_exports, __webpack_require__) {
1801
+
1802
+ module.exports = __webpack_require__.p + "assets/img/info.ebce7ea.svg";
1803
+
1804
+ /***/ },
1805
+
1806
+ /***/ 7362
1807
+ (module, __unused_webpack_exports, __webpack_require__) {
1808
+
1809
+ module.exports = __webpack_require__.p + "assets/img/ghtk.326eac1.svg";
1810
+
1811
+ /***/ },
1812
+
1813
+ /***/ 7741
1814
+ (module, __unused_webpack_exports, __webpack_require__) {
1815
+
1816
+ module.exports = __webpack_require__.p + "assets/img/caret.998eb8f.svg";
1817
+
1818
+ /***/ },
1819
+
1820
+ /***/ 8512
1821
+ (module, __unused_webpack_exports, __webpack_require__) {
1822
+
1823
+ module.exports = __webpack_require__.p + "assets/img/package.8d37d0f.svg";
1824
+
1825
+ /***/ }
1826
+
1827
+ }]);