@subiz/widget-v4 4.0.61 → 4.0.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/assets/img/caret.svg +1 -0
  2. package/assets/img/done_green.svg +4 -0
  3. package/assets/img/empty_1.svg +11 -0
  4. package/assets/img/ghn.svg +17 -0
  5. package/assets/img/ghtk.svg +18 -0
  6. package/assets/img/home.svg +1 -0
  7. package/assets/img/info.svg +1 -0
  8. package/assets/img/loader.svg +1 -0
  9. package/assets/img/map-pin.svg +1 -0
  10. package/assets/img/not_found_search.png +0 -0
  11. package/assets/img/package.svg +5 -0
  12. package/assets/img/package_fade.svg +1 -0
  13. package/assets/img/phone.svg +1 -0
  14. package/assets/img/search.svg +1 -0
  15. package/assets/img/shop.svg +1 -0
  16. package/assets/img/shop_faded.svg +1 -0
  17. package/assets/img/user.svg +1 -0
  18. package/assets/img/x.svg +5 -0
  19. package/assets/less/chatbox.less +39 -1
  20. package/assets/less/dropdown_select.less +130 -0
  21. package/assets/less/form.less +7 -20
  22. package/assets/less/order.less +489 -0
  23. package/assets/less/rating.less +3 -8
  24. package/babel.config.js +2 -4
  25. package/compiled_src/bot.js +7 -1
  26. package/compiled_src/chatbox/ChatButton.js +3 -1
  27. package/compiled_src/chatbox/DropdownSelect.js +248 -0
  28. package/compiled_src/chatbox/Event.js +5 -2
  29. package/compiled_src/chatbox/Events.js +1 -0
  30. package/compiled_src/chatbox/Order.js +285 -0
  31. package/compiled_src/chatbox/OrderAttachments.js +2 -1
  32. package/compiled_src/chatbox/ProductAttachments.js +40 -4
  33. package/compiled_src/chatbox/TextMessage.js +9 -2
  34. package/compiled_src/chatbox/Typing.js +3 -1
  35. package/compiled_src/chatbox/Widget.js +44 -3
  36. package/compiled_src/chatbox/main.js +2 -0
  37. package/compiled_src/chatbox/spinner.js +1 -1
  38. package/compiled_src/chatbox/time.js +3 -1
  39. package/compiled_src/common.js +40 -1
  40. package/compiled_src/contact/contact.js +1 -3
  41. package/compiled_src/order/address_picker.js +249 -0
  42. package/compiled_src/order/icon.js +62 -0
  43. package/compiled_src/order/index.js +113 -0
  44. package/compiled_src/order/order.js +1234 -0
  45. package/compiled_src/plugin.js +9 -42
  46. package/compiled_src/store/api.js +20 -0
  47. package/compiled_src/store/store.js +67 -3
  48. package/compiled_src/util/common.js +36 -2
  49. package/dist/{74.js → 132.js} +2355 -271
  50. package/dist/178.js +1 -1
  51. package/dist/17fdfed03d1.132.js +1 -0
  52. package/dist/17fdfed03d1.178.js +1 -0
  53. package/dist/17fdfed03d1.213.js +1 -0
  54. package/dist/17fdfed03d1.335.js +1 -0
  55. package/dist/17fdfed03d1.362.js +1 -0
  56. package/dist/17fdfed03d1.441.js +1 -0
  57. package/dist/17fdfed03d1.605.js +1 -0
  58. package/dist/{17db8166252.678.js → 17fdfed03d1.678.js} +0 -0
  59. package/dist/17fdfed03d1.782.js +1 -0
  60. package/dist/17fdfed03d1.app.js +1 -0
  61. package/dist/{17db8166252.index.html → 17fdfed03d1.index.html} +1 -1
  62. package/dist/{17db8166252.library.html → 17fdfed03d1.library.html} +1 -1
  63. package/dist/17fdfed03d1.library.js +1 -0
  64. package/dist/{17db8166252.preview.html → 17fdfed03d1.preview.html} +1 -1
  65. package/dist/17fdfed03d1.preview.js +1 -0
  66. package/dist/17fdfed03d1.screenshoot.js +1 -0
  67. package/dist/213.js +5 -69
  68. package/dist/335.js +411 -0
  69. package/dist/362.js +1 -1
  70. package/dist/441.js +70 -44
  71. package/dist/605.js +1 -64
  72. package/dist/782.js +1 -1
  73. package/dist/HASH +1 -1
  74. package/dist/assets/img/caret.998eb8f.svg +1 -0
  75. package/dist/assets/img/done_green.b817fd4.svg +4 -0
  76. package/dist/assets/img/empty_1.0b98af0.svg +11 -0
  77. package/dist/assets/img/ghn.070f8e3.svg +17 -0
  78. package/dist/assets/img/ghtk.326eac1.svg +18 -0
  79. package/dist/assets/img/info.ebce7ea.svg +1 -0
  80. package/dist/assets/img/loader.37000a7.svg +1 -0
  81. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  82. package/dist/assets/img/package.8d37d0f.svg +5 -0
  83. package/dist/assets/img/package_fade.763c001.svg +1 -0
  84. package/dist/assets/img/search.f9705ff.svg +1 -0
  85. package/dist/assets/img/shop.f7dc7d8.svg +1 -0
  86. package/dist/assets/img/shop_faded.df7845a.svg +1 -0
  87. package/dist/assets/img/x.26fdfa3.svg +5 -0
  88. package/dist/screenshoot.html +1 -1
  89. package/dist/screenshoot.js +281 -98
  90. package/order.html +19 -771
  91. package/package.json +15 -16
  92. package/src/bot.js +2 -1
  93. package/src/chatbox/Buttons.js +8 -8
  94. package/src/chatbox/ChatButton.js +2 -2
  95. package/src/chatbox/DropdownSelect.js +229 -0
  96. package/src/chatbox/Event.js +3 -3
  97. package/src/chatbox/Events.js +43 -42
  98. package/src/chatbox/Order.js +232 -0
  99. package/src/chatbox/OrderAttachments.js +2 -1
  100. package/src/chatbox/ProductAttachments.js +41 -5
  101. package/src/chatbox/TextMessage.js +21 -12
  102. package/src/chatbox/Typing.js +5 -1
  103. package/src/chatbox/Widget.js +34 -4
  104. package/src/chatbox/main.js +4 -1
  105. package/src/chatbox/spinner.js +1 -1
  106. package/src/chatbox/time.js +1 -1
  107. package/src/common.js +52 -8
  108. package/src/contact/contact.js +1 -1
  109. package/src/order/address_picker.js +235 -0
  110. package/src/order/icon.js +32 -0
  111. package/src/order/index.js +86 -0
  112. package/src/order/order.js +1157 -0
  113. package/src/order/scratch +211 -0
  114. package/src/plugin.js +7 -52
  115. package/src/store/api.js +26 -1
  116. package/src/store/store.js +53 -3
  117. package/src/util/common.js +48 -2
  118. package/up +1 -1
  119. package/webpack.dev.js +2 -0
  120. package/dist/17db8166252.178.js +0 -1
  121. package/dist/17db8166252.213.js +0 -1
  122. package/dist/17db8166252.362.js +0 -1
  123. package/dist/17db8166252.441.js +0 -1
  124. package/dist/17db8166252.605.js +0 -1
  125. package/dist/17db8166252.619.js +0 -1
  126. package/dist/17db8166252.74.js +0 -1
  127. package/dist/17db8166252.782.js +0 -1
  128. package/dist/17db8166252.app.js +0 -1
  129. package/dist/17db8166252.library.js +0 -1
  130. package/dist/17db8166252.preview.js +0 -1
  131. package/dist/17db8166252.screenshoot.js +0 -1
  132. package/dist/619.js +0 -777
  133. package/order.js +0 -0
  134. package/test.js +0 -1
@@ -1,6 +1,6 @@
1
- (self["webpackChunk_subiz_widget_v4"] = self["webpackChunk_subiz_widget_v4"] || []).push([[74],{
1
+ (self["webpackChunk_subiz_widget_v4"] = self["webpackChunk_subiz_widget_v4"] || []).push([[132],{
2
2
 
3
- /***/ 1074:
3
+ /***/ 8132:
4
4
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5
5
 
6
6
  "use strict";
@@ -22,7 +22,7 @@ var preact_module = __webpack_require__(6400);
22
22
 
23
23
 
24
24
 
25
- class Emoji extends common/* Com */.M {
25
+ class Emoji extends common/* Com */.up {
26
26
  render() {
27
27
  var emojiCode = this.props.emojiCode;
28
28
  if (util/* default.size */.Z.size(emojiCode) < 3) return null;
@@ -44,7 +44,7 @@ let defaultAvatar = __webpack_require__(4761);
44
44
 
45
45
 
46
46
 
47
- class ChatButton extends common/* Com */.M {
47
+ class ChatButton extends common/* Com */.up {
48
48
  constructor(props) {
49
49
  super(props);
50
50
  this.setState({
@@ -161,8 +161,9 @@ class ChatButton extends common/* Com */.M {
161
161
  let accountSetting = this.props.plugin.chatbox;
162
162
  if (new util/* default.Date */.Z.Date().getTime() - this.props.store.matchClosePreviewAt() < Ms30Mins) return;
163
163
  let greeting = util/* default.get */.Z.get(accountSetting, 'greeting', {});
164
+ let text = this.props.t.i18n(util/* default.get */.Z.get(greeting, 'greeting', {})) || greeting.message;
164
165
 
165
- if (!greeting.message || !greeting.enabled) {
166
+ if (!text || !greeting.enabled) {
166
167
  this.setState({
167
168
  previewEvent: {}
168
169
  });
@@ -424,7 +425,7 @@ var logo = __webpack_require__(8430);
424
425
 
425
426
 
426
427
 
427
- class PoweredBy extends common/* Com */.M {
428
+ class PoweredBy extends common/* Com */.up {
428
429
  constructor(props) {
429
430
  super(props);
430
431
  }
@@ -454,7 +455,7 @@ class PoweredBy extends common/* Com */.M {
454
455
 
455
456
 
456
457
 
457
- class AgentsAvatar extends common/* Com */.M {
458
+ class AgentsAvatar extends common/* Com */.up {
458
459
  constructor(props) {
459
460
  super(props);
460
461
  }
@@ -587,7 +588,7 @@ class AgentsAvatar extends common/* Com */.M {
587
588
 
588
589
 
589
590
 
590
- class Header extends common/* Com */.M {
591
+ class Header extends common/* Com */.up {
591
592
  constructor(props) {
592
593
  super(props);
593
594
  }
@@ -811,7 +812,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
811
812
 
812
813
 
813
814
 
814
- class MessageInput extends common/* Com */.M {
815
+ class MessageInput extends common/* Com */.up {
815
816
  constructor(props) {
816
817
  super(props);
817
818
 
@@ -1157,7 +1158,7 @@ function isSummited(form) {
1157
1158
 
1158
1159
 
1159
1160
 
1160
- class ImageAttachment extends common/* Com */.M {
1161
+ class ImageAttachment extends common/* Com */.up {
1161
1162
  constructor(props) {
1162
1163
  super(props);
1163
1164
  }
@@ -1207,7 +1208,7 @@ class ImageAttachment extends common/* Com */.M {
1207
1208
 
1208
1209
 
1209
1210
 
1210
- class AudioAttachments extends common/* Com */.M {
1211
+ class AudioAttachments extends common/* Com */.up {
1211
1212
  constructor(props) {
1212
1213
  super(props);
1213
1214
  }
@@ -1243,7 +1244,7 @@ class AudioAttachments extends common/* Com */.M {
1243
1244
 
1244
1245
 
1245
1246
 
1246
- class FileAttachments extends common/* Com */.M {
1247
+ class FileAttachments extends common/* Com */.up {
1247
1248
  render() {
1248
1249
  var byType = util/* default.get */.Z.get(this.props.ev, 'by.type', 'agent');
1249
1250
  var attachments = util/* default.get */.Z.get(this.props.ev, 'data.message.attachments', []);
@@ -1281,7 +1282,7 @@ class FileAttachments extends common/* Com */.M {
1281
1282
 
1282
1283
 
1283
1284
 
1284
- class Buttons extends common/* Com */.M {
1285
+ class Buttons extends common/* Com */.up {
1285
1286
  constructor(props) {
1286
1287
  super(props);
1287
1288
  }
@@ -1331,7 +1332,7 @@ class Buttons extends common/* Com */.M {
1331
1332
 
1332
1333
 
1333
1334
 
1334
- class ButtonAttachments extends common/* Com */.M {
1335
+ class ButtonAttachments extends common/* Com */.up {
1335
1336
  constructor(props) {
1336
1337
  super(props);
1337
1338
  }
@@ -1356,7 +1357,7 @@ class ButtonAttachments extends common/* Com */.M {
1356
1357
 
1357
1358
 
1358
1359
 
1359
- class QuickReplies extends common/* Com */.M {
1360
+ class QuickReplies extends common/* Com */.up {
1360
1361
  constructor(props) {
1361
1362
  super(props);
1362
1363
  }
@@ -1405,7 +1406,7 @@ class QuickReplies extends common/* Com */.M {
1405
1406
 
1406
1407
 
1407
1408
 
1408
- class ListField extends common/* Com */.M {
1409
+ class ListField extends common/* Com */.up {
1409
1410
  constructor(props) {
1410
1411
  super(props);
1411
1412
  this.setState({
@@ -1461,7 +1462,7 @@ class ListField extends common/* Com */.M {
1461
1462
 
1462
1463
  return (0,preact_module.h)("div", {
1463
1464
  class: "form-control custom-select"
1464
- }, (0,preact_module.h)(common/* Clickaway */.u, {
1465
+ }, (0,preact_module.h)(common/* Clickaway */.u$, {
1465
1466
  onClickaway: e => this.clickaway()
1466
1467
  }, (0,preact_module.h)("div", {
1467
1468
  class: "custom-select--wrap-selected",
@@ -1508,7 +1509,7 @@ class ListField extends common/* Com */.M {
1508
1509
 
1509
1510
 
1510
1511
 
1511
- class FormAttachment extends common/* Com */.M {
1512
+ class FormAttachment extends common/* Com */.up {
1512
1513
  constructor(props) {
1513
1514
  super(props);
1514
1515
  this.props.store.onUpdate(this, _ => this.forceUpdate());
@@ -1821,7 +1822,7 @@ function encode(key) {
1821
1822
 
1822
1823
 
1823
1824
 
1824
- class FormAttachments extends common/* Com */.M {
1825
+ class FormAttachments extends common/* Com */.up {
1825
1826
  constructor(props) {
1826
1827
  super(props);
1827
1828
  }
@@ -1866,7 +1867,7 @@ class FormAttachments extends common/* Com */.M {
1866
1867
 
1867
1868
 
1868
1869
 
1869
- class FormSubmitAttachments extends common/* Com */.M {
1870
+ class FormSubmitAttachments extends common/* Com */.up {
1870
1871
  constructor(props) {
1871
1872
  super(props);
1872
1873
  }
@@ -1939,7 +1940,7 @@ function getFirstTouch(ev) {
1939
1940
 
1940
1941
 
1941
1942
 
1942
- class GenericTemplateAttachments extends common/* Com */.M {
1943
+ class GenericTemplateAttachments extends common/* Com */.up {
1943
1944
  constructor(props) {
1944
1945
  super(props);
1945
1946
  this.state = {
@@ -2020,7 +2021,7 @@ class GenericTemplateAttachments extends common/* Com */.M {
2020
2021
 
2021
2022
 
2022
2023
 
2023
- class ProductAttachments extends common/* Com */.M {
2024
+ class ProductAttachments extends common/* Com */.up {
2024
2025
  render() {
2025
2026
  let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
2026
2027
  if (byType === 'user') return null;
@@ -2031,17 +2032,53 @@ class ProductAttachments extends common/* Com */.M {
2031
2032
  let acc = this.props.store.matchAccount();
2032
2033
  let $products = util/* default.map */.Z.map(products, (att, index) => {
2033
2034
  let product = att.product;
2034
- let $detailbtn = null;
2035
+ let $detailbtns = [];
2035
2036
  let url = product.url || product.mobile_url;
2036
2037
  if (this.props.store.isMobile()) url = product.mobile_url || product.url;
2037
- if (url) $detailbtn = (0,preact_module.h)("a", {
2038
+ if (url && util/* default.size */.Z.size(product.buttons) == 0) $detailbtns.push((0,preact_module.h)("a", {
2038
2039
  class: "product_attachment__btn",
2039
2040
  href: url,
2040
2041
  target: "_blank"
2041
2042
  }, this.props.t('detail'), (0,preact_module.h)("img", {
2042
2043
  src: __webpack_require__(8453),
2043
2044
  class: "product_attachment__btn_external_link"
2044
- }));
2045
+ })));
2046
+ console.log("P", product);
2047
+
2048
+ if (util/* default.size */.Z.size(product.buttons) > 0) {
2049
+ $detailbtns = $detailbtns.concat(util/* default.map */.Z.map(product.buttons, (button, index) => {
2050
+ if (button.type === 'call_button') {
2051
+ return (0,preact_module.h)("a", {
2052
+ class: "product_attachment__btn",
2053
+ href: 'tel:' + button.phone_number,
2054
+ key: index,
2055
+ title: button.title
2056
+ }, button.title);
2057
+ }
2058
+
2059
+ if (button.type === 'url_button') {
2060
+ return (0,preact_module.h)("a", {
2061
+ class: "product_attachment__btn",
2062
+ href: button.url,
2063
+ target: "_blank",
2064
+ key: index,
2065
+ title: button.title
2066
+ }, button.title || this.props.t('detail'), ' ', (0,preact_module.h)("img", {
2067
+ src: __webpack_require__(8453),
2068
+ class: "product_attachment__btn_external_link"
2069
+ }));
2070
+ }
2071
+
2072
+ if (button.type === 'postback_button') {
2073
+ return (0,preact_module.h)("a", {
2074
+ class: "product_attachment__btn",
2075
+ href: "javascript:;",
2076
+ onClick: _ => this.props.onPostback(button)
2077
+ }, button.title);
2078
+ }
2079
+ }));
2080
+ }
2081
+
2045
2082
  let $title = (0,preact_module.h)("a", {
2046
2083
  href: url,
2047
2084
  class: "product_attachment__title",
@@ -2070,7 +2107,7 @@ class ProductAttachments extends common/* Com */.M {
2070
2107
  src: this.props.store.replaceFileUrl(product.image)
2071
2108
  }))), $title, $subtitle, $price, (0,preact_module.h)("div", {
2072
2109
  class: "product_attachment__btns"
2073
- }, $detailbtn));
2110
+ }, $detailbtns));
2074
2111
  });
2075
2112
  return $products;
2076
2113
  }
@@ -2080,7 +2117,7 @@ class ProductAttachments extends common/* Com */.M {
2080
2117
 
2081
2118
 
2082
2119
 
2083
- class OrderAttachments_ProductAttachments extends common/* Com */.M {
2120
+ class OrderAttachments_ProductAttachments extends common/* Com */.up {
2084
2121
  render() {
2085
2122
  let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
2086
2123
  if (byType === 'user') return null;
@@ -2110,7 +2147,8 @@ class OrderAttachments_ProductAttachments extends common/* Com */.M {
2110
2147
  class: "order_attachment__product"
2111
2148
  }, (0,preact_module.h)("img", {
2112
2149
  class: "order_attachment__product_img",
2113
- src: (util/* default.get */.Z.get(product, 'images.0'), __webpack_require__(9270))
2150
+ alt: '' + util/* default.get */.Z.get(product, 'id'),
2151
+ src: util/* default.get */.Z.get(product, 'images.0', __webpack_require__(9270))
2114
2152
  }), (0,preact_module.h)("div", {
2115
2153
  style: "overflow: hidden !important;"
2116
2154
  }, (0,preact_module.h)("div", {
@@ -2166,7 +2204,7 @@ class OrderAttachments_ProductAttachments extends common/* Com */.M {
2166
2204
 
2167
2205
 
2168
2206
 
2169
- class VideoAttachments extends common/* Com */.M {
2207
+ class VideoAttachments extends common/* Com */.up {
2170
2208
  constructor(props) {
2171
2209
  super(props);
2172
2210
  }
@@ -2203,7 +2241,7 @@ class VideoAttachments extends common/* Com */.M {
2203
2241
  ;// CONCATENATED MODULE: ./src/chatbox/ShadowDomRoot.js
2204
2242
 
2205
2243
 
2206
- class ShadowDomRoot extends common/* Com */.M {
2244
+ class ShadowDomRoot extends common/* Com */.up {
2207
2245
  constructor(props) {
2208
2246
  super(props);
2209
2247
  this.ref = (0,preact_module/* createRef */.Vf)();
@@ -2266,7 +2304,7 @@ const loadMarked = () => __webpack_require__.e(/* import() */ 441).then(__webpac
2266
2304
 
2267
2305
 
2268
2306
 
2269
- class TextMessage extends common/* Com */.M {
2307
+ class TextMessage extends common/* Com */.up {
2270
2308
  render() {
2271
2309
  var format = util/* default.get */.Z.get(this.props.ev, 'data.message.format', 'plaintext');
2272
2310
  if (format === 'markdown') return this.renderMarkdown();
@@ -2281,9 +2319,16 @@ class TextMessage extends common/* Com */.M {
2281
2319
  });
2282
2320
 
2283
2321
  if (tag.type === 'link') {
2322
+ let url = tag.text || '';
2323
+
2324
+ if (!url.startsWith('//') && !url.startsWith('https://') && !url.startsWith('http://') && !url.startsWith('data:')) {
2325
+ url = '//' + url;
2326
+ }
2327
+
2284
2328
  return (0,preact_module.h)("a", {
2285
- href: tag.text,
2286
- target: "_blank"
2329
+ href: url,
2330
+ target: "_blank",
2331
+ onClick: e => this.props.onLink(e, url)
2287
2332
  }, tag.text);
2288
2333
  }
2289
2334
 
@@ -2339,7 +2384,7 @@ var g_pub = new util/* default.Pubsub */.Z.Pubsub();
2339
2384
  setInterval(() => g_pub.publish('time'), 20 * 1000);
2340
2385
 
2341
2386
 
2342
- class Time extends common/* Com */.M {
2387
+ class Time extends common/* Com */.up {
2343
2388
  constructor(props) {
2344
2389
  super(props);
2345
2390
  this.setState({
@@ -2381,7 +2426,9 @@ class Time extends common/* Com */.M {
2381
2426
  }
2382
2427
 
2383
2428
  render() {
2384
- return (0,preact_module.h)("span", null, this.state.t);
2429
+ return (0,preact_module.h)("span", {
2430
+ style: this.props.style
2431
+ }, this.state.t);
2385
2432
  }
2386
2433
 
2387
2434
  }
@@ -2475,7 +2522,7 @@ function getRateLang(rating) {
2475
2522
 
2476
2523
 
2477
2524
 
2478
- class InfoMessage extends common/* Com */.M {
2525
+ class InfoMessage extends common/* Com */.up {
2479
2526
  render() {
2480
2527
  let ev = this.props.ev.ev;
2481
2528
  var $time = null;
@@ -2531,7 +2578,7 @@ class InfoMessage extends common/* Com */.M {
2531
2578
 
2532
2579
 
2533
2580
 
2534
- class Event extends common/* Com */.M {
2581
+ class Event extends common/* Com */.up {
2535
2582
  constructor(props) {
2536
2583
  super(props);
2537
2584
  this.refForm = (0,preact_module/* createRef */.Vf)();
@@ -2653,7 +2700,8 @@ class Event extends common/* Com */.M {
2653
2700
  title: t
2654
2701
  }, $time, $sender, (0,preact_module.h)(TextMessage, {
2655
2702
  store: this.props.store,
2656
- ev: ev
2703
+ ev: ev,
2704
+ onLink: this.props.onLink
2657
2705
  }), (0,preact_module.h)(ImageAttachment, {
2658
2706
  store: this.props.store,
2659
2707
  ev: ev
@@ -2685,6 +2733,7 @@ class Event extends common/* Com */.M {
2685
2733
  onSelect: e => this.choosePostbackBtn(e)
2686
2734
  }), (0,preact_module.h)(ProductAttachments, {
2687
2735
  t: this.props.t,
2736
+ onPostback: e => this.choosePostbackBtn(e),
2688
2737
  store: this.props.store,
2689
2738
  ev: ev
2690
2739
  }), (0,preact_module.h)(OrderAttachments_ProductAttachments, {
@@ -2740,7 +2789,8 @@ class Event extends common/* Com */.M {
2740
2789
  }, $dot, (0,preact_module.h)(TextMessage, {
2741
2790
  store: this.props.store,
2742
2791
  ev: ev,
2743
- refresh: this.state.refresh
2792
+ refresh: this.state.refresh,
2793
+ onLink: this.props.onLink
2744
2794
  }), (0,preact_module.h)(ImageAttachment, {
2745
2795
  store: this.props.store,
2746
2796
  ev: ev
@@ -2807,7 +2857,7 @@ const loadingimg = __webpack_require__(6484);
2807
2857
 
2808
2858
 
2809
2859
 
2810
- class Spinner extends common/* Com */.M {
2860
+ class Spinner extends common/* Com */.up {
2811
2861
  render() {
2812
2862
  let mode = (this.props.mode + '').toLowerCase();
2813
2863
  let mainColor = mode === 'dark' ? '#000000dd' : mode === 'blue' ? 'rgba(52, 152, 220, .8)' : '#ffffffdd';
@@ -2819,7 +2869,7 @@ class Spinner extends common/* Com */.M {
2819
2869
  border-bottom-color: ${borderColor} !important;border-right-color: ${mainColor} !important;`;
2820
2870
 
2821
2871
  if (this.props.static) {
2822
- let style = `width: ${size}px;height: ${size}px;`;
2872
+ let style = `width: ${size}px !important;height: ${size}px !important;`;
2823
2873
  if (size < 40) return (0,preact_module.h)(LoaderIcon, {
2824
2874
  size: size + '',
2825
2875
  style: `stroke:${mainColor}`
@@ -2859,7 +2909,7 @@ const convoemptyimg = __webpack_require__(6188);
2859
2909
 
2860
2910
 
2861
2911
 
2862
- class Events extends common/* Com */.M {
2912
+ class Events extends common/* Com */.up {
2863
2913
  constructor(props) {
2864
2914
  super(props);
2865
2915
  this.props.store.onUpdate(this, _ => this.forceUpdate());
@@ -2904,6 +2954,7 @@ class Events extends common/* Com */.M {
2904
2954
  }));
2905
2955
  processEvents(convo, events);
2906
2956
  let $events = util/* default.map */.Z.map(events, ev => (0,preact_module.h)(Event, {
2957
+ onLink: this.props.onLink,
2907
2958
  store: this.props.store,
2908
2959
  onFormSubmit: this.props.onFormSubmit,
2909
2960
  onSend: this.props.onSend,
@@ -3110,7 +3161,7 @@ function Events_isSummited(form) {
3110
3161
 
3111
3162
 
3112
3163
 
3113
- class Typing extends common/* Com */.M {
3164
+ class Typing extends common/* Com */.up {
3114
3165
  constructor(props) {
3115
3166
  super(props);
3116
3167
  }
@@ -3136,6 +3187,8 @@ class Typing extends common/* Com */.M {
3136
3187
  return;
3137
3188
  }
3138
3189
 
3190
+ let ag = this.props.store.matchAgent(ev.by.id);
3191
+ if (ag.type == 'agent') return;
3139
3192
  if (util/* default.get */.Z.get(ev, 'type') !== 'conversation_typing') return;
3140
3193
  this.setState({
3141
3194
  ev: ev,
@@ -3148,7 +3201,7 @@ class Typing extends common/* Com */.M {
3148
3201
  this.setState({
3149
3202
  isShow: false
3150
3203
  });
3151
- }, 10000);
3204
+ }, 5000);
3152
3205
  });
3153
3206
  }
3154
3207
 
@@ -3235,7 +3288,7 @@ const POPUP_HARD_MAX_HEIGHT = 500;
3235
3288
  const POPUP_MIN_HEIGHT = 0;
3236
3289
 
3237
3290
 
3238
- class Rating extends common/* Com */.M {
3291
+ class Rating extends common/* Com */.up {
3239
3292
  constructor(props) {
3240
3293
  super(props);
3241
3294
 
@@ -3514,222 +3567,2207 @@ class Rating extends common/* Com */.M {
3514
3567
  }
3515
3568
 
3516
3569
  }
3517
- ;// CONCATENATED MODULE: ./src/chatbox/Widget.js
3570
+ ;// CONCATENATED MODULE: ./src/chatbox/DropdownSelect.js
3571
+ function DropdownSelect_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3518
3572
 
3519
3573
 
3520
3574
 
3521
3575
 
3522
3576
 
3577
+ class DropdownSelect extends common/* Com */.up {
3578
+ constructor(props) {
3579
+ super(props);
3580
+
3581
+ DropdownSelect_defineProperty(this, "state", {
3582
+ show: false,
3583
+ searchValue: ''
3584
+ });
3523
3585
 
3524
- var send = __webpack_require__(9737);
3586
+ DropdownSelect_defineProperty(this, "filterRef", (0,preact_module/* createRef */.Vf)());
3525
3587
 
3526
- var checkedimg = __webpack_require__(8909);
3588
+ DropdownSelect_defineProperty(this, "overlayRef", (0,preact_module/* createRef */.Vf)());
3527
3589
 
3528
- var empty = __webpack_require__(29);
3590
+ DropdownSelect_defineProperty(this, "onTouchMove", e => {
3591
+ if (e.target === this.overlayRef.current) {
3592
+ e.preventDefault();
3593
+ e.stopPropagation();
3594
+ }
3595
+ });
3529
3596
 
3597
+ DropdownSelect_defineProperty(this, "hideDropdown", () => {
3598
+ this.setState({
3599
+ show: false,
3600
+ searchValue: ''
3601
+ });
3602
+ });
3530
3603
 
3604
+ DropdownSelect_defineProperty(this, "onKeydown", e => {
3605
+ if (e.key === 'Escape') {
3606
+ if (!this.state.show) return;
3607
+ if (this.state.searchValue) this.setState({
3608
+ searchValue: ''
3609
+ });else this.hideDropdown();
3610
+ e.preventDefault();
3611
+ e.stopPropagation();
3612
+ }
3613
+ });
3531
3614
 
3615
+ DropdownSelect_defineProperty(this, "hasSearch", () => {
3616
+ if (this.props.has_search) return true;
3617
+ return util/* default.size */.Z.size(this.props.items) >= 10;
3618
+ });
3532
3619
 
3620
+ DropdownSelect_defineProperty(this, "getFilteredOptions", () => {
3621
+ let items = this.props.items;
3533
3622
 
3623
+ if (this.state.searchValue && this.hasSearch()) {
3624
+ items = util/* default.filter */.Z.filter(items, item => {
3625
+ let optionName = util/* default.unicodeToAscii */.Z.unicodeToAscii(item.name).toLowerCase().replace(/ /g, '');
3626
+ let optionDesc = util/* default.unicodeToAscii */.Z.unicodeToAscii(item.desc).toLowerCase().replace(/ /g, '');
3627
+ let searchValue = util/* default.unicodeToAscii */.Z.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g, '');
3628
+ return optionName.indexOf(searchValue) != -1 || optionDesc.indexOf(searchValue) != -1;
3629
+ });
3630
+ }
3534
3631
 
3535
- const Widget_defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png';
3632
+ return items;
3633
+ });
3536
3634
 
3635
+ DropdownSelect_defineProperty(this, "onChangeSearchValue", e => {
3636
+ this.setState({
3637
+ searchValue: e.target.value
3638
+ });
3639
+ });
3537
3640
 
3641
+ DropdownSelect_defineProperty(this, "toogleDropdown", async () => {
3642
+ await this.setState({
3643
+ show: true,
3644
+ searchValue: ''
3645
+ });
3646
+ this.focusFilter();
3647
+ });
3538
3648
 
3649
+ DropdownSelect_defineProperty(this, "onSelect", item => {
3650
+ this.props.onSelect(item);
3651
+ this.hideDropdown();
3652
+ });
3539
3653
 
3540
- class Widget extends common/* Com */.M {
3541
- constructor(props) {
3542
- super(props);
3543
- this.userSent = {};
3544
- this.setState({
3545
- creating: false,
3546
- clickedJoin: false,
3547
- formData: {}
3654
+ DropdownSelect_defineProperty(this, "onBackgroundScroll", e => {
3655
+ console.log('EEEEEEE', e);
3656
+ alert('y');
3548
3657
  });
3549
- this.props.store.onUpdate(this, _ => this.forceUpdate());
3658
+
3659
+ document.addEventListener('touchmove', function (e) {});
3550
3660
  }
3551
3661
 
3552
3662
  componentDidMount() {
3553
- if (!this.props.store.isMobile()) this.focusInput();
3663
+ window.addEventListener('keydown', this.onKeydown);
3554
3664
  }
3555
3665
 
3556
- componentDidUpdate(prevProp) {
3557
- if (prevProp.isShow !== this.props.isShow) {
3558
- if (this.props.isShow && !this.props.store.isMobile()) this.focusInput();
3559
- if (this.props.isShow && this.props.store.isMobile()) this.blur();
3560
- }
3666
+ componentWillUnmount() {
3667
+ window.removeEventListener('keydown', this.onKeydown);
3668
+ }
3561
3669
 
3562
- if (prevProp.cid !== this.props.cid) {
3563
- this.setState({
3564
- clickedJoin: false
3565
- });
3566
- setTimeout(() => {
3567
- this.events && this.events.focus();
3568
- if (!this.props.store.isMobile()) this.focusInput();
3569
- }, 100);
3570
- }
3670
+ renderEmpty() {
3671
+ return (0,preact_module.h)("div", {
3672
+ class: "dropdown_select_filter__empty"
3673
+ }, (0,preact_module.h)("img", {
3674
+ class: "dropdown_select_filter__empty_img",
3675
+ src: __webpack_require__(6071)
3676
+ }), (0,preact_module.h)("div", {
3677
+ class: "muted",
3678
+ style: "text-align: center !important;"
3679
+ }, "Kh\xF4ng c\xF3 k\u1EBFt qu\u1EA3"));
3680
+ }
3571
3681
 
3572
- this.updateFormDataFields();
3682
+ renderLoading() {
3683
+ return (0,preact_module.h)("div", {
3684
+ class: "dropdown_select_filter__empty pt-3"
3685
+ }, (0,preact_module.h)(Spinner, {
3686
+ size: "40",
3687
+ static: true
3688
+ }), (0,preact_module.h)("div", {
3689
+ class: "muted mt-2",
3690
+ style: "text-align: center !important;"
3691
+ }, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
3573
3692
  }
3574
3693
 
3575
- shouldShowForm() {
3576
- let formRequired = this.isFormRequired();
3577
- return formRequired && !this.props.cid || formRequired && this.props.cid && this.state.clickedJoin;
3694
+ focusFilter() {
3695
+ if (!this.filterRef.current) return;
3696
+ this.filterRef.current.focus();
3697
+ setTimeout(() => {
3698
+ if (!this.filterRef.current) return;
3699
+ this.filterRef.current.focus();
3700
+ }, 100);
3578
3701
  }
3579
3702
 
3580
- render() {
3581
- let formRequired = this.isFormRequired();
3582
- let showform = this.shouldShowForm();
3583
- let form;
3584
- let accountSetting = this.props.plugin.chatbox || {};
3585
- let acc = this.props.store.matchAccount() || {};
3586
- let submitLabel = this.props.t('prechat_form_btn');
3587
- if (util/* default.get */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
3588
- let offlineEnabled = util/* default.get */.Z.get(accountSetting, 'offline_form.enabled');
3703
+ renderDropdown() {
3704
+ if (!this.state.show) return null;
3705
+ let items = this.getFilteredOptions();
3706
+ let $items = util/* default.map */.Z.map(items, item => {
3707
+ return (0,preact_module.h)("div", {
3708
+ class: "dropdown_select__item",
3709
+ onClick: _ => this.onSelect(item)
3710
+ }, item.name);
3711
+ });
3712
+ let $filter = null;
3589
3713
 
3590
- if (this.isOffline(acc, accountSetting) && offlineEnabled) {
3591
- form = accountSetting.offline_form;
3592
- submitLabel = this.props.t('offline_form_btn');
3714
+ if (this.hasSearch()) {
3715
+ let $img = (0,preact_module.h)("img", {
3716
+ class: "dropdown_select_filter__icon",
3717
+ src: __webpack_require__(636)
3718
+ });
3719
+
3720
+ if (this.props.loading) {
3721
+ $img = (0,preact_module.h)("img", {
3722
+ class: "dropdown_select_filter__icon",
3723
+ src: __webpack_require__(5770)
3724
+ });
3725
+ }
3726
+
3727
+ $filter = (0,preact_module.h)("div", {
3728
+ class: "dropdown_select_filter"
3729
+ }, $img, (0,preact_module.h)("input", {
3730
+ ref: this.filterRef,
3731
+ value: this.state.searchValue,
3732
+ onInput: this.onChangeSearchValue,
3733
+ type: "text",
3734
+ class: "dropdown_select_filter_input "
3735
+ }));
3593
3736
  }
3594
3737
 
3595
- if (this.props.view === 'offline_form') {
3596
- showform = true;
3597
- form = accountSetting.offline_form;
3598
- submitLabel = this.props.t('offline_form_btn');
3738
+ if ($items.length == 0) $items = this.renderEmpty();
3739
+ if (this.props.loading) $items = this.renderLoading();
3740
+ let style = `width: ${this.props.width || '150px'} !important;`;
3741
+
3742
+ if (this.props.full) {
3743
+ style = ` top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; `;
3744
+ return (0,preact_module.h)("div", {
3745
+ class: "dropdown_select__overlay",
3746
+ ref: this.overlayRef,
3747
+ onClick: this.hideDropdown,
3748
+ onTouchMove: this.onTouchMove
3749
+ }, (0,preact_module.h)("div", {
3750
+ class: "dropdown_select",
3751
+ style: style,
3752
+ onClick: e => {
3753
+ e.preventDefault();
3754
+ e.stopPropagation();
3755
+ }
3756
+ }, $filter, (0,preact_module.h)("div", {
3757
+ class: "dropdown_select__items"
3758
+ }, $items)));
3599
3759
  }
3600
3760
 
3601
- if (this.props.view === 'prechat_form') {
3602
- showform = true;
3603
- form = accountSetting.prechat_form;
3604
- submitLabel = this.props.t('prechat_form_btn');
3761
+ return (0,preact_module.h)("div", {
3762
+ class: "dropdown_select",
3763
+ style: style
3764
+ }, $filter, (0,preact_module.h)("div", {
3765
+ class: "dropdown_select__items"
3766
+ }, $items));
3767
+ }
3768
+
3769
+ render() {
3770
+ let $name = (0,preact_module.h)("div", {
3771
+ class: "muted text-truncate",
3772
+ style: "flex: 1 !important;"
3773
+ }, "Ch\u1ECDn m\u1ED9t ph\u1EA7n t\u1EED");
3774
+ if (util/* default.get */.Z.get(this.props, 'selected.name')) $name = (0,preact_module.h)("div", {
3775
+ class: "text-truncate",
3776
+ style: "flex: 1 !important;"
3777
+ }, util/* default.get */.Z.get(this.props, 'selected.name'));
3778
+ let style = 'position: relative !important;';
3779
+
3780
+ if (this.props.full) {
3781
+ style = '';
3605
3782
  }
3606
3783
 
3607
- let $body = null;
3608
- if (this.props.view === 'list') $body = this.renderConvoList();else if (showform) $body = this.renderForm(form, submitLabel);else $body = this.renderChat();
3609
- let position = util/* default.get */.Z.get(accountSetting, 'desktop_button.position') || 'right';
3610
- if (this.props.store.isMobile()) position = util/* default.get */.Z.get(accountSetting, 'mobile_button.position', position);
3611
- let cls = 'widget-container widget-container--' + position;
3612
- if (!this.props.isShow) cls += ' widget-container--hide';
3613
3784
  return (0,preact_module.h)("div", {
3614
- class: cls
3615
- }, (0,preact_module.h)(Header, {
3616
- t: this.props.t,
3617
- plugin: this.props.plugin,
3618
- store: this.props.store,
3619
- cid: this.props.cid,
3620
- view: this.props.view,
3621
- onClose: this.props.onClose,
3622
- onGotoList: () => this.props.onGo({
3623
- view: 'list'
3624
- })
3625
- }), $body);
3785
+ style: style
3786
+ }, (0,preact_module.h)(common/* Clickaway */.u$, {
3787
+ onClickaway: this.hideDropdown
3788
+ }, (0,preact_module.h)("div", {
3789
+ type: "text",
3790
+ class: 'dropdown_select_input ' + this.props.extra_cls,
3791
+ onClick: this.toogleDropdown
3792
+ }, $name, "\xA0", (0,preact_module.h)("img", {
3793
+ class: "dropdown_select__caret",
3794
+ src: __webpack_require__(8712)
3795
+ })), this.renderDropdown()));
3626
3796
  }
3627
3797
 
3628
- async submitPrechatForm(form) {
3629
- var hasError = false;
3630
- util/* default.map */.Z.map(this.state.formData, (field, key) => {
3631
- if (field.is_required && (field.value === undefined || field.value === '' || util/* default.size */.Z.size(field.value) === 0 && Array.isArray(field.value))) {
3632
- field.error = this.props.t('error_empty');
3633
- hasError = true;
3634
- } else field.error = '';
3798
+ }
3799
+ ;// CONCATENATED MODULE: ./src/order/address_picker.js
3800
+ function address_picker_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3635
3801
 
3636
- if (key.substr(5) === 'emails' && !util/* default.isEmail */.Z.isEmail(field.value) && field.is_required) {
3637
- field.error = this.props.t('error_email_invalid');
3638
- hasError = true;
3639
- }
3640
3802
 
3641
- if (key.substr(5) === 'phones' && !util/* default.isPhone */.Z.isPhone(field.value) && field.is_required) {
3642
- field.error = this.props.t('error_phone_invalid');
3643
- hasError = true;
3644
- }
3803
+
3804
+
3805
+
3806
+ class AddressPicker extends common/* Com */.up {
3807
+ constructor(props) {
3808
+ super(props);
3809
+
3810
+ address_picker_defineProperty(this, "state", {
3811
+ show: false,
3812
+ searchValue: '',
3813
+ addresses: []
3645
3814
  });
3646
- if (hasError) return this.forceUpdate();
3647
- let data = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
3648
- let user = util/* default.cloneDeep */.Z.cloneDeep(this.props.store.matchUser());
3649
- util/* default.map */.Z.map(data, (field, key) => {
3650
- if (!key.startsWith('attr:')) return;
3651
- var attr = {
3652
- key: key.substr(5)
3653
- };
3654
- if (field.type === 'number') attr.number = parseInt(field.value);
3655
- if (field.type === 'datetime') attr.datetime = new util/* default.Date */.Z.Date(field.value).toISOString();
3656
- if (field.type === 'list') attr.list = field.value;
3657
- if (field.type === 'text' || field.type === 'boolean') attr[field.type] = field.value;
3658
- util/* default.setUserAttr */.Z.setUserAttr(user, attr);
3815
+
3816
+ address_picker_defineProperty(this, "filterRef", (0,preact_module/* createRef */.Vf)());
3817
+
3818
+ address_picker_defineProperty(this, "overlayRef", (0,preact_module/* createRef */.Vf)());
3819
+
3820
+ address_picker_defineProperty(this, "onTouchMove", e => {
3821
+ if (e.target === this.overlayRef.current) {
3822
+ e.preventDefault();
3823
+ e.stopPropagation();
3824
+ }
3659
3825
  });
3660
- let firstmsg = util/* default.get */.Z.get(data, 'question.value');
3661
- let groupid = util/* default.get */.Z.get(data, 'group.value', '');
3662
3826
 
3663
- if (this.props.cid) {
3664
- this.props.store.setUser(user);
3827
+ address_picker_defineProperty(this, "hideDropdown", () => {
3665
3828
  this.setState({
3666
- clickedJoin: false
3667
- });
3668
- await this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
3669
- message: {
3670
- text: firstmsg,
3671
- format: 'plaintext',
3672
- fields: [{
3673
- key: 'to_agent_group',
3674
- value: util/* default.stringify */.Z.stringify(groupid)
3675
- }]
3676
- }
3829
+ show: false,
3830
+ searchValue: ''
3677
3831
  });
3678
- if (form.end_conversation_after_submit) await this.props.store.endConvo(this.props.cid);
3679
- return;
3680
- }
3681
-
3682
- this.setState({
3683
- creating: true
3684
3832
  });
3685
- let message = {
3686
- text: firstmsg,
3687
- format: 'plaintext'
3688
- };
3689
- let req = {
3690
- group_id: groupid,
3691
- message: firstmsg,
3692
- locale: this.props.t.locale(),
3693
- initial_by: user.id
3694
- };
3695
- this.setState({
3696
- creatingError: null
3833
+
3834
+ address_picker_defineProperty(this, "onKeydown", e => {
3835
+ if (e.key === 'Escape') {
3836
+ if (!this.state.show) return;
3837
+ if (this.state.searchValue) this.setState({
3838
+ searchValue: ''
3839
+ });else this.hideDropdown();
3840
+ e.preventDefault();
3841
+ e.stopPropagation();
3842
+ }
3843
+
3844
+ if (e.key == 'Enter') {}
3697
3845
  });
3698
- const {
3699
- error,
3700
- convo
3701
- } = await this.props.store.startConvo(req);
3702
- this.props.store.setUser(user);
3703
3846
 
3704
- if (error) {
3847
+ address_picker_defineProperty(this, "doSearch", util/* default.throttle */.Z.throttle(async () => {
3848
+ let requestId = Date.now();
3849
+ this.requestId = requestId;
3850
+ let res = await this.props.store.suggest_addresses(this.state.searchValue);
3851
+ if (this.requestId !== requestId) return;
3705
3852
  this.setState({
3706
- creating: false,
3707
- creatingError: error
3853
+ addresses: util/* default.get */.Z.get(res, 'body.addresses', [])
3708
3854
  });
3709
- return;
3710
- }
3855
+ }, 100));
3711
3856
 
3712
- let newconvoid = convo.id;
3713
- this.userSent[newconvoid] = true;
3714
- this.props.onGo({
3715
- view: 'chat',
3716
- cid: newconvoid
3857
+ address_picker_defineProperty(this, "onChangeSearchValue", e => {
3858
+ this.setState({
3859
+ searchValue: e.target.value
3860
+ });
3861
+ this.props.onChangeAddress(e.target.value);
3862
+ this.doSearch();
3717
3863
  });
3718
- this.props.store.sendConvoEvent(newconvoid, 'message_sent', {
3719
- message
3864
+
3865
+ address_picker_defineProperty(this, "toogleDropdown", async () => {
3866
+ await this.setState({
3867
+ show: true,
3868
+ searchValue: this.props.initAddress || ''
3869
+ });
3870
+ this.focusFilter();
3720
3871
  });
3721
- this.setState({
3722
- creating: false,
3723
- clickedJoin: false
3872
+
3873
+ address_picker_defineProperty(this, "onSelect", item => {
3874
+ this.props.onSelect(item);
3875
+ this.hideDropdown();
3724
3876
  });
3725
- if (!this.props.store.isMobile()) this.focusInput();
3877
+
3878
+ address_picker_defineProperty(this, "onBackgroundScroll", e => {
3879
+ console.log('EEEEEEE', e);
3880
+ });
3881
+
3882
+ document.addEventListener('touchmove', function (e) {});
3726
3883
  }
3727
3884
 
3728
- formMounted(form) {
3729
- let formData = this.fillForm(form);
3730
- formData['question'] = {
3731
- key: 'question',
3732
- is_required: true,
3885
+ componentDidMount() {
3886
+ window.addEventListener('keydown', this.onKeydown);
3887
+ }
3888
+
3889
+ componentWillUnmount() {
3890
+ window.removeEventListener('keydown', this.onKeydown);
3891
+ }
3892
+
3893
+ renderEmpty() {
3894
+ return (0,preact_module.h)("div", {
3895
+ class: "dropdown_select_filter__empty"
3896
+ }, (0,preact_module.h)("img", {
3897
+ class: "dropdown_select_filter__empty_img",
3898
+ src: __webpack_require__(6071)
3899
+ }), (0,preact_module.h)("div", {
3900
+ class: "muted",
3901
+ style: "text-align: center !important;"
3902
+ }, "Kh\xF4ng c\xF3 k\u1EBFt qu\u1EA3"));
3903
+ }
3904
+
3905
+ renderLoading() {
3906
+ return (0,preact_module.h)("div", {
3907
+ class: "dropdown_select_filter__empty pt-3"
3908
+ }, (0,preact_module.h)(Spinner, {
3909
+ size: "40",
3910
+ static: true
3911
+ }), (0,preact_module.h)("div", {
3912
+ class: "muted mt-2",
3913
+ style: "text-align: center !important;"
3914
+ }, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
3915
+ }
3916
+
3917
+ focusFilter() {
3918
+ if (!this.filterRef.current) return;
3919
+ this.filterRef.current.focus();
3920
+ setTimeout(() => {
3921
+ if (!this.filterRef.current) return;
3922
+ this.filterRef.current.focus();
3923
+ }, 100);
3924
+ }
3925
+
3926
+ renderDropdown() {
3927
+ if (!this.state.show) return null;
3928
+ let $items = util/* default.map */.Z.map(this.state.addresses, (addr, i) => {
3929
+ let label = [((addr.address || '') + ' ' + normalize(addr.street)).trim()].join(', ');
3930
+ let desc = [normalize(addr.ward), normalize(addr.district), normalize(addr.province)].join(', ');
3931
+ return (0,preact_module.h)("div", {
3932
+ class: "dropdown_select__item",
3933
+ onClick: _ => this.onSelect(addr),
3934
+ key: i
3935
+ }, (0,preact_module.h)("div", null, (0,preact_module.h)("b", null, label)), (0,preact_module.h)("div", {
3936
+ style: "opacity: 0.7 !important;"
3937
+ }, desc));
3938
+ });
3939
+ let $filter = null;
3940
+ let $img = (0,preact_module.h)("img", {
3941
+ class: "dropdown_select_filter__icon",
3942
+ src: __webpack_require__(636)
3943
+ });
3944
+
3945
+ if (this.props.loading) {
3946
+ $img = (0,preact_module.h)("img", {
3947
+ class: "dropdown_select_filter__icon",
3948
+ src: __webpack_require__(5770)
3949
+ });
3950
+ }
3951
+
3952
+ $filter = (0,preact_module.h)("div", {
3953
+ class: "dropdown_select_filter"
3954
+ }, $img, (0,preact_module.h)("input", {
3955
+ ref: this.filterRef,
3956
+ value: this.state.searchValue,
3957
+ onInput: this.onChangeSearchValue,
3958
+ type: "text",
3959
+ class: "dropdown_select_filter_input "
3960
+ }));
3961
+ if ($items.length == 0) $items = this.renderEmpty();
3962
+ if (this.props.loading) $items = this.renderLoading();
3963
+ let style = `width: ${this.props.width || '150px'} !important;`;
3964
+
3965
+ if (this.props.full) {
3966
+ style = ` top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; `;
3967
+ return (0,preact_module.h)("div", {
3968
+ class: "dropdown_select__overlay",
3969
+ ref: this.overlayRef,
3970
+ onClick: this.hideDropdown,
3971
+ onTouchMove: this.onTouchMove
3972
+ }, (0,preact_module.h)("div", {
3973
+ class: "dropdown_select",
3974
+ style: style,
3975
+ onClick: e => {
3976
+ e.preventDefault();
3977
+ e.stopPropagation();
3978
+ }
3979
+ }, $filter, (0,preact_module.h)("div", {
3980
+ class: "dropdown_select__items"
3981
+ }, $items)));
3982
+ }
3983
+
3984
+ return (0,preact_module.h)("div", {
3985
+ class: "dropdown_select",
3986
+ style: style
3987
+ }, $filter, (0,preact_module.h)("div", {
3988
+ class: "dropdown_select__items"
3989
+ }, $items));
3990
+ }
3991
+
3992
+ render() {
3993
+ let $name = (0,preact_module.h)("div", {
3994
+ class: "text-truncate",
3995
+ style: "flex: 1 !important;"
3996
+ }, this.props.initAddress);
3997
+ let style = 'position: relative !important;';
3998
+
3999
+ if (this.props.full) {
4000
+ style = '';
4001
+ }
4002
+
4003
+ return (0,preact_module.h)("div", {
4004
+ style: style
4005
+ }, (0,preact_module.h)(common/* Clickaway */.u$, {
4006
+ onClickaway: this.hideDropdown
4007
+ }, (0,preact_module.h)("div", {
4008
+ type: "text",
4009
+ class: 'dropdown_select_input ' + this.props.extra_cls,
4010
+ onClick: this.toogleDropdown
4011
+ }, $name), this.renderDropdown()));
4012
+ }
4013
+
4014
+ }
4015
+
4016
+ function normalize(s) {
4017
+ let ls = (s + '').toLowerCase();
4018
+ if (ls.startsWith('tp ')) return s.substr(3);
4019
+ if (ls.startsWith('thanh pho ')) return s.substr('thanh pho '.length);
4020
+ if (ls.startsWith('thành phố ')) return s.substr('thành phố '.length);
4021
+ if (ls.startsWith('tỉnh ')) return s.substr('tỉnh '.length);
4022
+ if (ls.startsWith('huyện ')) return s.substr('huyện '.length);
4023
+ if (ls.startsWith('tỉnh ')) return s.substr('tỉnh '.length);
4024
+ if (ls.startsWith('xã ')) return s.substr('xã '.length);
4025
+ if (ls.startsWith('thị trấn ')) return s.substr('thị trấn '.length);
4026
+ if (ls.startsWith('thị xã ')) return s.substr('thị xã '.length);
4027
+ if (ls.startsWith('đường ') && (s[7] < '0' || s[7] > '9')) return s.substr('đường '.length);
4028
+ if (ls.startsWith('phường ') && (s[7] < '0' || s[7] > '9')) return s.substr('phường '.length);
4029
+ if (ls.startsWith('quận ') && (s[7] < '0' || s[7] > '9')) return s.substr('quận '.length);
4030
+ return s;
4031
+ }
4032
+ ;// CONCATENATED MODULE: ./src/order/icon.js
4033
+
4034
+
4035
+ let promiseMainCSS = (() => __webpack_require__.e(/* import() */ 178).then(__webpack_require__.bind(__webpack_require__, 178)))();
4036
+
4037
+ var $link = document.createElement('link');
4038
+ $link.href = 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap';
4039
+ $link.rel = 'stylesheet';
4040
+ document.head.append($link);
4041
+ util/* default.preloadWebfonts */.Z.preloadWebfonts(['Roboto'], [400, 500]);
4042
+
4043
+
4044
+ let icon_defaultAvatar = __webpack_require__(4761);
4045
+
4046
+
4047
+
4048
+
4049
+ class Icon extends common/* Com */.up {
4050
+ render() {
4051
+ if (this.props.name == 'package') {
4052
+ if (this.props.active) return (0,preact_module.h)("img", {
4053
+ style: "width: 18px !important;",
4054
+ src: __webpack_require__(25)
4055
+ });
4056
+ return (0,preact_module.h)("img", {
4057
+ style: "width: 18px !important;",
4058
+ src: __webpack_require__(1216)
4059
+ });
4060
+ }
4061
+
4062
+ if (this.props.name === 'shop') {
4063
+ if (this.props.active) return (0,preact_module.h)("img", {
4064
+ style: "width: 18px !important;",
4065
+ src: __webpack_require__(6180)
4066
+ });
4067
+ return (0,preact_module.h)("img", {
4068
+ style: "width: 18px !important;",
4069
+ src: __webpack_require__(750)
4070
+ });
4071
+ }
4072
+ }
4073
+
4074
+ }
4075
+ ;// CONCATENATED MODULE: ./src/order/order.js
4076
+ function order_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4077
+
4078
+
4079
+
4080
+
4081
+
4082
+
4083
+
4084
+
4085
+
4086
+
4087
+ var checkedimg = __webpack_require__(763);
4088
+
4089
+ var ximg = __webpack_require__(2514);
4090
+
4091
+ class order_Order extends common/* Com */.up {
4092
+ constructor(props) {
4093
+ super(props);
4094
+
4095
+ order_defineProperty(this, "state", {
4096
+ loadProvince: true,
4097
+ g_err: '',
4098
+ fullname: '',
4099
+ email: '',
4100
+ phone: '',
4101
+ loading: true,
4102
+ order: {},
4103
+ err: {},
4104
+ selectedProvince: null,
4105
+ selectedDistrict: null,
4106
+ selectedWard: null,
4107
+ street: '',
4108
+ address: '',
4109
+ sending: false,
4110
+ step: ''
4111
+ });
4112
+
4113
+ order_defineProperty(this, "renderMobileSuccess", order => {
4114
+ return (0,preact_module.h)("div", {
4115
+ class: "order",
4116
+ style: "height: 100% !important"
4117
+ }, (0,preact_module.h)("div", {
4118
+ style: "display: flex !important; align-items: center !important; padding-top: 40px !important; padding-bottom: 20px !important; flex-direction: column !important; height: 100% !important"
4119
+ }, (0,preact_module.h)("img", {
4120
+ style: "width: 60px !important; height: 60px !important;",
4121
+ width: "60",
4122
+ height: "60",
4123
+ src: checkedimg
4124
+ }), (0,preact_module.h)("div", {
4125
+ style: "margin-top: 20px !important; margin-bottom: 10px !important"
4126
+ }, (0,preact_module.h)("b", {
4127
+ style: "font-size: 18px !important;"
4128
+ }, "\u0110\u01A1n h\xE0ng c\u1EE7a b\u1EA1n \u0111\xE3 \u0111\u01B0\u1EE3c ghi nh\u1EADn")), (0,preact_module.h)("div", {
4129
+ class: "muted"
4130
+ }, "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", {
4131
+ style: "flex:1 !important"
4132
+ }), (0,preact_module.h)("div", {
4133
+ style: "margin-top: 20px !important; padding: 0px 20px 0 20px !important; width: 100% !important"
4134
+ }, (0,preact_module.h)("div", {
4135
+ class: "order_btn order__btn__light",
4136
+ onClick: this.close
4137
+ }, this.props.t('close')))));
4138
+ });
4139
+
4140
+ order_defineProperty(this, "onSelectProvince", async item => {
4141
+ this.setState({
4142
+ selectedProvince: item,
4143
+ err: {},
4144
+ g_err: ''
4145
+ });
4146
+ this.setState({
4147
+ loadDistrict: true
4148
+ });
4149
+ let out = await this.props.store.list_districts({
4150
+ id: item.id
4151
+ });
4152
+ this.setState({
4153
+ loadDistrict: false
4154
+ });
4155
+ if (!out.error) this.setState({
4156
+ districts: util/* default.get */.Z.get(out, 'body.addresses')
4157
+ });
4158
+ });
4159
+
4160
+ order_defineProperty(this, "onSelectDistrict", async item => {
4161
+ this.setState({
4162
+ selectedDistrict: item,
4163
+ err: {},
4164
+ g_err: ''
4165
+ });
4166
+ this.setState({
4167
+ loadWard: true
4168
+ });
4169
+ let out = await this.props.store.list_wards({
4170
+ id: item.id
4171
+ });
4172
+ this.setState({
4173
+ loadWard: false
4174
+ });
4175
+ if (!out.error) this.setState({
4176
+ wards: util/* default.get */.Z.get(out, 'body.addresses')
4177
+ });
4178
+ });
4179
+
4180
+ order_defineProperty(this, "onSelectWard", item => this.setState({
4181
+ selectedWard: item,
4182
+ err: {},
4183
+ g_err: ''
4184
+ }));
4185
+
4186
+ order_defineProperty(this, "onChangeFullname", e => this.setState({
4187
+ fullname: e.target.value,
4188
+ err: {},
4189
+ g_err: ''
4190
+ }));
4191
+
4192
+ order_defineProperty(this, "onChangeAddress", e => this.setState({
4193
+ address: e,
4194
+ err: {},
4195
+ g_err: ''
4196
+ }));
4197
+
4198
+ order_defineProperty(this, "onSelectAddress", addr => {
4199
+ if (!addr) return;
4200
+ this.setState({
4201
+ address: [util/* default.trim */.Z.trim(addr.address), util/* default.trim */.Z.trim(addr.street)].join(' ').trim(),
4202
+ street: addr.street,
4203
+ err: {},
4204
+ g_err: ''
4205
+ });
4206
+ this.onSelectWard({
4207
+ id: addr.ward_id,
4208
+ name: addr.ward
4209
+ });
4210
+ this.onSelectDistrict({
4211
+ id: addr.district_id,
4212
+ name: addr.district
4213
+ });
4214
+ this.onSelectProvince({
4215
+ id: addr.province_id,
4216
+ name: addr.province
4217
+ });
4218
+ });
4219
+
4220
+ order_defineProperty(this, "onChangeEmail", e => this.setState({
4221
+ email: e.target.value,
4222
+ err: {},
4223
+ g_err: ''
4224
+ }));
4225
+
4226
+ order_defineProperty(this, "onChangePhone", e => this.setState({
4227
+ phone: e.target.value,
4228
+ err: {},
4229
+ g_err: ''
4230
+ }));
4231
+
4232
+ order_defineProperty(this, "onChangePaymentMethod", id => this.setState({
4233
+ pm: id
4234
+ }));
4235
+
4236
+ order_defineProperty(this, "onChangeQuantity", (item, text) => {
4237
+ let qty = parseInt(text) || 1;
4238
+ item.quantity = qty;
4239
+ this.forceUpdate();
4240
+ });
4241
+
4242
+ order_defineProperty(this, "confirm", async () => {
4243
+ this.setState({
4244
+ g_err: ''
4245
+ });
4246
+ let err = {};
4247
+
4248
+ if (!this.state.shipping) {
4249
+ this.setState({
4250
+ g_err: 'Mời bạn chọn địa chỉ giao hàng trước khi xác nhận'
4251
+ });
4252
+ }
4253
+
4254
+ if (this.state.shipping === 'shop') {
4255
+ if (!util/* default.isPhone */.Z.isPhone(this.state.phone)) {
4256
+ err.phone = true;
4257
+ }
4258
+
4259
+ if (!util/* default.trim */.Z.trim(this.state.fullname)) {
4260
+ err.name = true;
4261
+ }
4262
+
4263
+ if (!util/* default.trim */.Z.trim(this.state.email)) {
4264
+ err.email = true;
4265
+ }
4266
+ } else if (this.state.shipping_address == 'new') {
4267
+ if (!util/* default.isPhone */.Z.isPhone(this.state.phone)) {
4268
+ err.phone = true;
4269
+ }
4270
+
4271
+ if (!util/* default.trim */.Z.trim(this.state.fullname)) {
4272
+ err.name = true;
4273
+ }
4274
+
4275
+ if (!util/* default.trim */.Z.trim(this.state.address)) {
4276
+ err.address = true;
4277
+ }
4278
+
4279
+ if (util/* default.size */.Z.size(this.state.selectedWard) == 0) {
4280
+ err.ward = true;
4281
+ }
4282
+
4283
+ if (util/* default.size */.Z.size(this.state.selectedDistrict) == 0) {
4284
+ err.district = true;
4285
+ }
4286
+
4287
+ if (util/* default.size */.Z.size(this.state.selectedProvince) == 0) {
4288
+ err.province = true;
4289
+ }
4290
+ }
4291
+
4292
+ if (util/* default.size */.Z.size(err) > 0) {
4293
+ this.setState({
4294
+ err,
4295
+ g_err: this.props.t('input_shipping_info_err')
4296
+ });
4297
+ return;
4298
+ }
4299
+
4300
+ let user = this.props.store.matchUser();
4301
+ let ufullname = util/* default.getUserAttr */.Z.getUserAttr(user, 'fullname', 'text');
4302
+ let uemail = util/* default.getUserAttr */.Z.getUserAttr(user, 'emails', 'text');
4303
+ let uphone = util/* default.getUserAttr */.Z.getUserAttr(user, 'phones', 'text');
4304
+ let order = util/* default.cloneDeep */.Z.cloneDeep(this.state.order);
4305
+
4306
+ if (this.state.shipping === 'shop') {
4307
+ util/* default.set */.Z.set(order, 'shipping.pickup_at_shop', true);
4308
+ util/* default.set */.Z.set(order, 'shipping.address.phone', this.state.phone);
4309
+ util/* default.set */.Z.set(order, 'shipping.address.fullname', this.state.fullname);
4310
+ util/* default.set */.Z.set(order, 'shipping.address.email', this.state.email);
4311
+ } else {
4312
+ if (this.state.shipping_address == 'new') {
4313
+ let out = await this.props.store.createShippingAddress({
4314
+ address: this.state.address,
4315
+ country: 'Việt Nam',
4316
+ fullname: this.state.fullname,
4317
+ email: this.state.email,
4318
+ phone: this.state.phone,
4319
+ district: this.state.selectedDistrict.name,
4320
+ district_id: this.state.selectedDistrict.id,
4321
+ province: this.state.selectedProvince.name,
4322
+ province_id: this.state.selectedProvince.id,
4323
+ ward: this.state.selectedWard.name,
4324
+ street: this.state.street,
4325
+ ward_id: this.state.selectedWard.id
4326
+ });
4327
+ if (out.error) return this.setState({
4328
+ g_err: this.props.t('update_failed')
4329
+ });
4330
+ util/* default.set */.Z.set(order, 'shipping.address', out.body);
4331
+ } else {
4332
+ let addresses = this.props.store.matchShippingAddresses();
4333
+ let sa = util/* default.find */.Z.find(addresses, addr => addr.id === this.state.shipping_address);
4334
+
4335
+ if (!sa) {
4336
+ return this.setState({
4337
+ err,
4338
+ g_err: this.props.t('input_shipping_info_err')
4339
+ });
4340
+ }
4341
+
4342
+ util/* default.set */.Z.set(order, 'shipping.address', sa);
4343
+ }
4344
+ }
4345
+
4346
+ let changeduser = false;
4347
+
4348
+ if (!ufullname && this.state.fullname) {
4349
+ changeduser = true;
4350
+ util/* default.setUserAttr */.Z.setUserAttr(user, {
4351
+ key: 'fullname',
4352
+ text: this.state.fullname
4353
+ });
4354
+ }
4355
+
4356
+ if (!uemail && this.state.email) {
4357
+ changeduser = true;
4358
+ util/* default.setUserAttr */.Z.setUserAttr(user, {
4359
+ key: 'emails',
4360
+ text: this.state.email
4361
+ });
4362
+ }
4363
+
4364
+ if (!uphone && this.state.phone) {
4365
+ changeduser = true;
4366
+ util/* default.setUserAttr */.Z.setUserAttr(user, {
4367
+ key: 'phones',
4368
+ text: this.state.phone
4369
+ });
4370
+ }
4371
+
4372
+ if (changeduser) this.props.store.setUser(user);
4373
+ this.setState({
4374
+ sending: true
4375
+ });
4376
+ order.user_confirmation = 'confirmed';
4377
+ let out = await this.props.store.updateOrder(order);
4378
+ this.setState({
4379
+ sending: false
4380
+ });
4381
+
4382
+ if (out.error) {
4383
+ return this.setState({
4384
+ g_err: this.props.t('update_failed')
4385
+ });
4386
+ }
4387
+
4388
+ this.setState({
4389
+ step: 'success'
4390
+ });
4391
+ if (this.props.onResponse) this.props.onResponse('confirmed');
4392
+ });
4393
+
4394
+ order_defineProperty(this, "onCancel", () => {
4395
+ if (this.props.onResponse) this.props.onResponse('rejected');
4396
+ this.close();
4397
+ });
4398
+
4399
+ order_defineProperty(this, "close", () => {
4400
+ if (this.props.cid && !this.state.order.user_confirmation) {
4401
+ let order = util/* default.cloneDeep */.Z.cloneDeep(this.state.order);
4402
+ order.user_confirmation = 'rejected';
4403
+ this.props.store.updateOrder(order);
4404
+ }
4405
+
4406
+ if (this.props.onClose) this.props.onClose();
4407
+ });
4408
+
4409
+ this.load();
4410
+ }
4411
+
4412
+ async load() {
4413
+ if (!this.props.order_id) return;
4414
+ let orderout = await this.props.store.fetchOrder(this.props.order_id);
4415
+ this.setState({
4416
+ loading: false
4417
+ });
4418
+
4419
+ if (!orderout.error) {
4420
+ this.setState({
4421
+ order: orderout.body
4422
+ });
4423
+ } else {
4424
+ this.setState({
4425
+ error: orderout.error
4426
+ });
4427
+ }
4428
+
4429
+ let user = this.props.store.matchUser();
4430
+ let attributes = util/* default.get */.Z.get(this.props.store.matchUser(), 'attributes', []);
4431
+ let fullname = util/* default.get */.Z.get(util/* default.find */.Z.find(attributes, att => att.key === 'fullname'), 'text');
4432
+ let email = util/* default.get */.Z.get(util/* default.find */.Z.find(attributes, att => att.key === 'emails'), 'text');
4433
+ let phone = util/* default.get */.Z.get(util/* default.find */.Z.find(attributes, att => att.key === 'phones'), 'text');
4434
+ this.setState({
4435
+ fullname,
4436
+ email,
4437
+ phone
4438
+ });
4439
+ await this.props.store.fetchShippingAddresses();
4440
+ let out = await this.props.store.list_provinces();
4441
+ this.setState({
4442
+ loadProvince: false
4443
+ });
4444
+ if (!out.error) this.setState({
4445
+ provinces: util/* default.get */.Z.get(out, 'body.addresses')
4446
+ });
4447
+ }
4448
+
4449
+ isMobile() {
4450
+ if (this.props.cid) return true;
4451
+ if (this.props.isMobile) return true;
4452
+ return this.props.store.isMobile();
4453
+ }
4454
+
4455
+ onChangeShippingAddress(id) {
4456
+ this.setState({
4457
+ shipping_address: id,
4458
+ err: {},
4459
+ g_err: ''
4460
+ });
4461
+ }
4462
+
4463
+ onChangeShipping(id) {
4464
+ this.setState({
4465
+ shipping: id,
4466
+ err: {},
4467
+ g_err: ''
4468
+ });
4469
+ }
4470
+
4471
+ renderDesktopPaymentMethod(order) {
4472
+ return null;
4473
+ let editmode = false;
4474
+
4475
+ if (!order.status || order.status == 'new') {
4476
+ editmode = !order.user_confirmation;
4477
+ }
4478
+
4479
+ if (editmode) {
4480
+ let pms = this.props.store.matchPaymentMethods();
4481
+ let $pms = util/* default.map */.Z.map(pms, pm => {
4482
+ let $name = pm.description;
4483
+
4484
+ if (pm.method == 'bank_transfer') {
4485
+ $name = pm.description + ' ' + pm.bank_name + ' ' + pm.bank_branch;
4486
+ }
4487
+
4488
+ let cls = 'order__card';
4489
+ let $desc = null;
4490
+
4491
+ if (this.state.pm === pm.id) {
4492
+ cls += ' order__card__active';
4493
+ $desc = (0,preact_module.h)("div", {
4494
+ class: "muted mt-1",
4495
+ style: "margin-left: 26px !important;"
4496
+ }, "Tr\u1EA3 ti\u1EC1n m\u1EB7t khi b\u1EA1n nh\u1EADn h\xE0ng");
4497
+
4498
+ if (pm.method == 'bank_transfer') {
4499
+ $desc = (0,preact_module.h)("div", {
4500
+ class: "muted mt-1",
4501
+ style: "margin-left: 26px !important;"
4502
+ }, (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));
4503
+ }
4504
+ }
4505
+
4506
+ return (0,preact_module.h)("div", {
4507
+ style: "width: 100% !important; margin-top: 10px !important;"
4508
+ }, (0,preact_module.h)("div", {
4509
+ class: "radio"
4510
+ }, (0,preact_module.h)("input", {
4511
+ type: "radio",
4512
+ id: 'pm.' + pm.id,
4513
+ onInput: e => this.onChangePaymentMethod(pm.id),
4514
+ name: "pm",
4515
+ checked: this.state.pm === pm.id
4516
+ }), (0,preact_module.h)("label", {
4517
+ class: "radio--label",
4518
+ style: `margin-left: 4px !important; font-weight: ${this.state.pm === pm.id ? 500 : 400} !important;`,
4519
+ for: 'pm.' + pm.id
4520
+ }, $name), (0,preact_module.h)("div", {
4521
+ class: "radio--check"
4522
+ }, (0,preact_module.h)("div", {
4523
+ class: "inside"
4524
+ })), $desc));
4525
+ });
4526
+ let seccls = 'card_section';
4527
+ if (this.isMobile()) seccls = 'order_section';
4528
+ return (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
4529
+ class: "order_section__line"
4530
+ }), (0,preact_module.h)("div", {
4531
+ class: seccls
4532
+ }, (0,preact_module.h)("div", {
4533
+ class: "order_label"
4534
+ }, this.props.t('payment')), (0,preact_module.h)("div", {
4535
+ class: "form",
4536
+ style: "justify-content: space-between !important;"
4537
+ }, $pms)));
4538
+ }
4539
+
4540
+ let pm = order.payment_method || {
4541
+ method: 'cod'
4542
+ };
4543
+ let $body = null;
4544
+ if (pm.method === 'cash') $body = (0,preact_module.h)("div", null, this.props.t('pm_cash'));
4545
+ if (pm.method === 'cod') $body = (0,preact_module.h)("div", null, this.props.t('pm_cod'));
4546
+
4547
+ if (pm.method === 'bank_transfer') {
4548
+ let name = pm.bank_name;
4549
+ if (pm.bank_branch) name += ' - ' + pm.bank_branch;
4550
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", null, "Ng\xE2n h\xE0ng: ", name), (0,preact_module.h)("div", {
4551
+ class: "mt-1"
4552
+ }, "Ch\u1EE7 t\xE0i kho\u1EA3n: ", pm.bank_owner), (0,preact_module.h)("div", {
4553
+ class: "mt-1"
4554
+ }, "S\u1ED1 t\xE0i kho\u1EA3n: ", pm.bank_number));
4555
+ }
4556
+
4557
+ if (!$body) return null;
4558
+ return (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
4559
+ class: "order_label"
4560
+ }, this.props.t('payment')), $body);
4561
+ }
4562
+
4563
+ renderDesktopShipping(order) {
4564
+ let editmode = false;
4565
+
4566
+ if (!order.status || order.status == 'new') {
4567
+ editmode = !order.user_confirmation;
4568
+ }
4569
+
4570
+ let user = this.props.store.matchUser();
4571
+
4572
+ if (editmode) {
4573
+ let addresses = this.props.store.matchShippingAddresses();
4574
+ let provinces = util/* default.map */.Z.map(this.state.provinces, province => ({
4575
+ id: province.id,
4576
+ name: province.province
4577
+ }));
4578
+ let districts = util/* default.map */.Z.map(this.state.districts, district => ({
4579
+ id: district.id,
4580
+ name: district.district
4581
+ }));
4582
+ let wards = util/* default.map */.Z.map(this.state.wards, ward => ({
4583
+ id: ward.id,
4584
+ name: ward.ward
4585
+ }));
4586
+ let cls = 'ship_card';
4587
+ let $body = null;
4588
+ let ship_icon_active = false;
4589
+
4590
+ if (this.state.shipping === 'ship') {
4591
+ ship_icon_active = true;
4592
+ let $preaddrs = util/* default.map */.Z.map(addresses, addr => {
4593
+ let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
4594
+ let $phone = null;
4595
+
4596
+ if (addr.phone) {
4597
+ $phone = (0,preact_module.h)(preact_module/* Fragment */.HY, null, "\xA0\xB7\xA0", this.props.t('phn'), " ", addr.phone);
4598
+ }
4599
+
4600
+ return (0,preact_module.h)("div", {
4601
+ style: "margin-bottom: 15px !important"
4602
+ }, (0,preact_module.h)("div", {
4603
+ class: "radio d-flex "
4604
+ }, (0,preact_module.h)("input", {
4605
+ type: "radio",
4606
+ id: 'shipping_addr.' + addr.id,
4607
+ onInput: e => this.onChangeShippingAddress(addr.id),
4608
+ name: "shipping_address",
4609
+ checked: this.state.shipping_address === addr.id
4610
+ }), (0,preact_module.h)("label", {
4611
+ class: "radio--label",
4612
+ for: 'shipping_addr.' + addr.id,
4613
+ style: `font-weight: ${this.state.shipping_address === addr.id ? 500 : 400} !important`
4614
+ }, addr.fullname, $phone, (0,preact_module.h)("div", {
4615
+ class: "mt-1 muted"
4616
+ }, "DC ", fulladdr)), (0,preact_module.h)("div", {
4617
+ class: "radio--check"
4618
+ }, (0,preact_module.h)("div", {
4619
+ class: "inside"
4620
+ }))));
4621
+ });
4622
+ $preaddrs.push((0,preact_module.h)("div", {
4623
+ style: ""
4624
+ }, (0,preact_module.h)("div", {
4625
+ class: "radio d-flex "
4626
+ }, (0,preact_module.h)("input", {
4627
+ type: "radio",
4628
+ id: 'shipping_addr.new',
4629
+ onInput: e => this.onChangeShippingAddress('new'),
4630
+ name: "shipping_address",
4631
+ checked: this.state.shipping_address === 'new'
4632
+ }), (0,preact_module.h)("label", {
4633
+ class: "radio--label",
4634
+ for: 'shipping_addr.new'
4635
+ }, 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", {
4636
+ class: "radio--check"
4637
+ }, (0,preact_module.h)("div", {
4638
+ class: "inside"
4639
+ })))));
4640
+ let $new = (0,preact_module.h)("div", {
4641
+ style: "padding-left: 22px !important;"
4642
+ }, (0,preact_module.h)("div", {
4643
+ class: "d-flex"
4644
+ }, (0,preact_module.h)("div", {
4645
+ class: "mr-2",
4646
+ style: "flex: 1 !important;"
4647
+ }, (0,preact_module.h)("div", {
4648
+ class: "order_form_label"
4649
+ }, this.props.t('fullname')), (0,preact_module.h)("input", {
4650
+ type: "text",
4651
+ class: 'form-control ' + (this.state.err.name && 'err'),
4652
+ onInput: this.onChangeFullname,
4653
+ value: this.state.fullname
4654
+ })), (0,preact_module.h)("div", {
4655
+ class: "ml-2",
4656
+ style: "flex: 1 !important;"
4657
+ }, (0,preact_module.h)("div", {
4658
+ class: "order_form_label"
4659
+ }, this.props.t('phones')), (0,preact_module.h)("input", {
4660
+ type: "text",
4661
+ class: 'form-control ' + (this.state.err.phone && 'err'),
4662
+ onInput: this.onChangePhone,
4663
+ value: this.state.phone
4664
+ }))), (0,preact_module.h)("div", {
4665
+ class: "",
4666
+ style: "width: 100% !important"
4667
+ }, (0,preact_module.h)("div", {
4668
+ class: "order_form_label"
4669
+ }, this.props.t('address')), (0,preact_module.h)(AddressPicker, {
4670
+ initAddress: this.state.address,
4671
+ store: this.props.store,
4672
+ width: "100%",
4673
+ onChangeAddress: this.onChangeAddress,
4674
+ full: this.isMobile(),
4675
+ onSelect: this.onSelectAddress,
4676
+ extra_cls: this.state.err.address && 'err'
4677
+ })), (0,preact_module.h)("div", {
4678
+ class: "d-flex",
4679
+ style: "justify-content: space-between !important;"
4680
+ }, (0,preact_module.h)("div", {
4681
+ style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
4682
+ }, (0,preact_module.h)("div", {
4683
+ class: "order_form_label"
4684
+ }, this.props.t('province')), (0,preact_module.h)(DropdownSelect, {
4685
+ width: "194",
4686
+ full: this.isMobile(),
4687
+ has_search: true,
4688
+ loading: this.state.loadProvince,
4689
+ items: provinces,
4690
+ selected: this.state.selectedProvince,
4691
+ onSelect: this.onSelectProvince,
4692
+ extra_cls: this.state.err.province && 'err'
4693
+ })), (0,preact_module.h)("div", {
4694
+ style: "flex: 1 !important; overflow:hidden !important; margin-left: 7px !important;"
4695
+ }, (0,preact_module.h)("div", {
4696
+ class: "order_form_label"
4697
+ }, this.props.t('district')), (0,preact_module.h)(DropdownSelect, {
4698
+ width: "194",
4699
+ full: this.isMobile(),
4700
+ selected: this.state.selectedDistrict,
4701
+ has_search: true,
4702
+ onSelect: this.onSelectDistrict,
4703
+ loading: this.state.loadDistrict,
4704
+ extra_cls: this.state.err.district && 'err',
4705
+ items: districts
4706
+ }))), (0,preact_module.h)("div", {
4707
+ class: "d-flex",
4708
+ style: "justify-content: space-between !important;"
4709
+ }, (0,preact_module.h)("div", {
4710
+ style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
4711
+ }, (0,preact_module.h)("div", {
4712
+ class: "order_form_label"
4713
+ }, this.props.t('ward')), (0,preact_module.h)(DropdownSelect, {
4714
+ width: "194",
4715
+ selected: this.state.selectedWard,
4716
+ full: this.isMobile(),
4717
+ has_search: true,
4718
+ onSelect: this.onSelectWard,
4719
+ extra_cls: this.state.err.ward && 'err',
4720
+ loading: this.state.loadWard,
4721
+ items: wards
4722
+ })), (0,preact_module.h)("div", {
4723
+ style: "flex: 1 !important; margin-left: 7px !important;"
4724
+ })));
4725
+ cls += ' ship_card__active';
4726
+
4727
+ if (util/* default.size */.Z.size(addresses) == 0) {
4728
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
4729
+ class: 'mt-3 mb-2 '
4730
+ }, this.props.t('input_shipping_info')), $new);
4731
+ } else {
4732
+ if (this.state.shipping_address !== 'new') $new = null;
4733
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
4734
+ class: "mt-3 mb-2",
4735
+ style: "margin-bottom: 10px !important;"
4736
+ }, "Vui l\xF2ng ch\u1ECDn \u0111\u1ECBa ch\u1EC9 giao h\xE0ng"), (0,preact_module.h)("div", {
4737
+ class: "form"
4738
+ }, $preaddrs), $new);
4739
+ }
4740
+ }
4741
+
4742
+ let shopcls = 'ship_card';
4743
+ let shop_icon_active = false;
4744
+
4745
+ if (this.state.shipping === 'shop') {
4746
+ shop_icon_active = true;
4747
+ shopcls += ' ship_card__active';
4748
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
4749
+ class: "d-flex"
4750
+ }, (0,preact_module.h)("div", {
4751
+ class: "mr-2",
4752
+ style: "flex: 3 !important;"
4753
+ }, (0,preact_module.h)("div", {
4754
+ class: "order_form_label"
4755
+ }, this.props.t('fullname')), (0,preact_module.h)("input", {
4756
+ type: "text",
4757
+ class: 'form-control ' + (this.state.err.name && 'err'),
4758
+ onInput: this.onChangeFullname,
4759
+ value: this.state.fullname
4760
+ })), (0,preact_module.h)("div", {
4761
+ class: "ml-2",
4762
+ style: "flex: 2 !important;"
4763
+ }, (0,preact_module.h)("div", {
4764
+ class: "order_form_label"
4765
+ }, this.props.t('phones')), (0,preact_module.h)("input", {
4766
+ type: "text",
4767
+ class: 'form-control ' + (this.state.err.phone && 'err'),
4768
+ onInput: this.onChangePhone,
4769
+ value: this.state.phone
4770
+ }))), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
4771
+ class: "order_form_label"
4772
+ }, this.props.t('email')), (0,preact_module.h)("input", {
4773
+ type: "text",
4774
+ class: 'form-control ' + (this.state.err.email && 'err'),
4775
+ onInput: this.onChangeEmail,
4776
+ value: this.state.email
4777
+ })));
4778
+ }
4779
+
4780
+ let seccls = 'card_section';
4781
+ if (this.isMobile()) seccls = 'order_section';
4782
+ return (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
4783
+ class: "order_section__line"
4784
+ }), (0,preact_module.h)("div", {
4785
+ class: seccls
4786
+ }, (0,preact_module.h)("div", {
4787
+ class: "order_label"
4788
+ }, this.props.t('ship_to')), (0,preact_module.h)("div", {
4789
+ class: "d-flex"
4790
+ }, (0,preact_module.h)("div", {
4791
+ class: shopcls + ' mr-3',
4792
+ onClick: e => this.onChangeShipping('shop')
4793
+ }, (0,preact_module.h)(Icon, {
4794
+ name: "shop",
4795
+ active: shop_icon_active
4796
+ }), " ", (0,preact_module.h)("b", {
4797
+ class: "ml-2"
4798
+ }, "Nh\u1EADn h\xE0ng t\u1EA1i shop")), (0,preact_module.h)("div", {
4799
+ class: cls,
4800
+ onClick: e => this.onChangeShipping('ship')
4801
+ }, (0,preact_module.h)(Icon, {
4802
+ name: "package",
4803
+ active: ship_icon_active
4804
+ }), " ", (0,preact_module.h)("b", {
4805
+ class: "ml-2"
4806
+ }, "Giao h\xE0ng cho t\xF4i"))), $body));
4807
+ }
4808
+
4809
+ let addr = util/* default.get */.Z.get(order, 'shipping.address') || {};
4810
+ let fulladdr = [addr.address, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
4811
+ let $phone = null;
4812
+ if (addr.phone) $phone = (0,preact_module.h)("div", {
4813
+ class: "mt-1 muted"
4814
+ }, this.props.t('phn'), ":\xA0", addr.phone);
4815
+
4816
+ if (util/* default.get */.Z.get(order, 'shipping.pickup_at_shop')) {
4817
+ fulladdr = 'Nhận hàng tại cửa hàng';
4818
+ }
4819
+
4820
+ let $addr = fulladdr ? (0,preact_module.h)("div", null, fulladdr) : (0,preact_module.h)("i", {
4821
+ class: "i muted"
4822
+ }, "Ch\u01B0a c\xF3 \u0111\u1ECBa ch\u1EC9 giao h\xE0ng");
4823
+ let seccls = 'card_section';
4824
+ if (this.isMobile()) seccls = 'order_section';
4825
+ return (0,preact_module.h)("div", {
4826
+ class: seccls
4827
+ }, (0,preact_module.h)("div", {
4828
+ class: "order_label "
4829
+ }, this.props.t('ship_to')), $addr, $phone);
4830
+ }
4831
+
4832
+ renderDesktopSummary(order) {
4833
+ let $deposit = null;
4834
+
4835
+ if (order.deposit > 0) {
4836
+ $deposit = (0,preact_module.h)("span", {
4837
+ class: "muted"
4838
+ }, "(c\u1ECDc ", util/* default.formatCurrency */.Z.formatCurrency(order.deposit), ")");
4839
+ }
4840
+
4841
+ let $discount = null;
4842
+
4843
+ if (order.total_discount > 0) {
4844
+ $discount = (0,preact_module.h)("div", {
4845
+ class: "order_summary_line"
4846
+ }, (0,preact_module.h)("div", null, "Gi\u1EA3m gi\xE1"), (0,preact_module.h)("div", null, util/* default.formatCurrency */.Z.formatCurrency(order.total_discount)));
4847
+ }
4848
+
4849
+ let $pay = null;
4850
+
4851
+ if ($deposit || order.payment_made) {
4852
+ $pay = (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
4853
+ class: "order_summary_line"
4854
+ }, (0,preact_module.h)("div", null, "B\u1EA1n \u0111\xE3 tr\u1EA3"), (0,preact_module.h)("div", null, $deposit, " ", util/* default.formatCurrency */.Z.formatCurrency(order.payment_made))), (0,preact_module.h)("div", {
4855
+ class: "order_summary_line"
4856
+ }, (0,preact_module.h)("div", null, "B\u1EA1n ch\u01B0a tr\u1EA3"), (0,preact_module.h)("div", null, util/* default.formatCurrency */.Z.formatCurrency((order.total || 0) - (order.payment_made || 0)))));
4857
+ }
4858
+
4859
+ let $tax = (0,preact_module.h)("div", {
4860
+ class: "order_summary_line"
4861
+ }, (0,preact_module.h)("div", null, "Ti\u1EC1n thu\u1EBF"), (0,preact_module.h)("div", null, util/* default.formatCurrency */.Z.formatCurrency(order.total_tax)));
4862
+ let $ship = (0,preact_module.h)("div", {
4863
+ class: "order_summary_line"
4864
+ }, (0,preact_module.h)("div", null, "Ph\xED v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", null, util/* default.get */.Z.get(order, 'shipping.fee', 0), " d"));
4865
+ let editmode = false;
4866
+
4867
+ if (!order.status || order.status == 'new') {
4868
+ editmode = !order.user_confirmation;
4869
+ }
4870
+
4871
+ let $note = null;
4872
+
4873
+ if (editmode) {
4874
+ $ship = null;
4875
+ $tax = null;
4876
+ $note = (0,preact_module.h)("div", {
4877
+ class: "muted"
4878
+ }, (0,preact_module.h)("img", {
4879
+ class: "order_ship_icon",
4880
+ src: __webpack_require__(9256)
4881
+ }), "\xA0 Ch\u01B0a bao g\u1ED3m thu\u1EBF v\xE0 ph\xED v\u1EADn chuy\u1EC3n");
4882
+ }
4883
+
4884
+ let seccls = '';
4885
+ if (this.isMobile()) seccls = 'order_section';
4886
+ return (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
4887
+ class: "order_section__line"
4888
+ }), (0,preact_module.h)("div", {
4889
+ class: seccls
4890
+ }, (0,preact_module.h)("div", {
4891
+ class: "order_label"
4892
+ }, "T\xF3m t\u1EAFt"), (0,preact_module.h)("div", {
4893
+ class: "order_summary_line"
4894
+ }, (0,preact_module.h)("div", null, "T\u1ED5ng ti\u1EC1n h\xE0ng"), (0,preact_module.h)("div", null, util/* default.formatCurrency */.Z.formatCurrency(order.subtotal))), $tax, $discount, $ship, $note, (0,preact_module.h)("div", {
4895
+ class: "order_summary_line",
4896
+ style: "margin-top: 10px !important; padding-top: 15px !important; border-top: 1px solid #eee !important"
4897
+ }, (0,preact_module.h)("div", null, "B\u1EA1n ph\u1EA3i tr\u1EA3"), (0,preact_module.h)("div", {
4898
+ class: "order__total"
4899
+ }, util/* default.formatCurrency */.Z.formatCurrency(order.total))), $pay));
4900
+ }
4901
+
4902
+ renderStatusBadge(order) {
4903
+ let status = order.status || 'new';
4904
+ return (0,preact_module.h)("div", {
4905
+ style: "float: right !important;",
4906
+ class: 'order_status order_status__' + status
4907
+ }, status);
4908
+ }
4909
+
4910
+ renderShippingInfo(order) {
4911
+ if (order.status != 'new' || order.user_confirmation) {}
4912
+
4913
+ let shipping_provider = util/* default.get */.Z.get(order, 'shipping.shipping_provider');
4914
+ if (!shipping_provider) return null;
4915
+ let shipping_code = util/* default.get */.Z.get(order, 'shipping.shipping_code');
4916
+ let $tracking_code = null;
4917
+ if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
4918
+ class: "muted",
4919
+ style: "margin-top: 3px !important"
4920
+ }, "V\u1EADn \u0111\u01A1n\xA0", (0,preact_module.h)("a", {
4921
+ class: "order_tracking_link",
4922
+ target: "_blank",
4923
+ href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
4924
+ }, shipping_code, "\xA0", (0,preact_module.h)("img", {
4925
+ class: "order_tracking_link_icon",
4926
+ src: __webpack_require__(8453)
4927
+ })));
4928
+
4929
+ if (shipping_provider == 'ghtk') {
4930
+ return (0,preact_module.h)("div", {
4931
+ class: "order_section"
4932
+ }, (0,preact_module.h)("div", {
4933
+ class: "order_section_label"
4934
+ }, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", {
4935
+ class: "d-flex align-items-center"
4936
+ }, (0,preact_module.h)("img", {
4937
+ class: "order_shipping_provider_logo",
4938
+ src: ShippingProvider.ghtk.logo
4939
+ }), (0,preact_module.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
4940
+ }
4941
+
4942
+ return null;
4943
+ }
4944
+
4945
+ renderDesktopShippingInfo(order) {
4946
+ let shipping_provider = util/* default.get */.Z.get(order, 'shipping.shipping_provider');
4947
+ if (!shipping_provider) return null;
4948
+ let shipping_code = util/* default.get */.Z.get(order, 'shipping.shipping_code');
4949
+ let $tracking_code = null;
4950
+ if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
4951
+ class: "muted",
4952
+ style: "margin-top: 3px !important"
4953
+ }, "V\u1EADn \u0111\u01A1n\xA0", (0,preact_module.h)("a", {
4954
+ class: "order_tracking_link",
4955
+ target: "_blank",
4956
+ href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
4957
+ }, shipping_code, "\xA0", (0,preact_module.h)("img", {
4958
+ class: "order_tracking_link_icon",
4959
+ src: __webpack_require__(8453)
4960
+ })));
4961
+
4962
+ if (shipping_provider == 'ghtk') {
4963
+ return (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
4964
+ class: "order_label"
4965
+ }, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", {
4966
+ class: "d-flex align-items-center"
4967
+ }, (0,preact_module.h)("img", {
4968
+ class: "order_shipping_provider_logo",
4969
+ src: ShippingProvider.ghtk.logo
4970
+ }), (0,preact_module.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
4971
+ }
4972
+
4973
+ return null;
4974
+ }
4975
+
4976
+ renderProducts(order) {
4977
+ let $products = null;
4978
+ $products = util/* default.map */.Z.map(order.items, item => {
4979
+ if (!item || !item.product) return null;
4980
+ let product = item.product;
4981
+ return (0,preact_module.h)("div", {
4982
+ class: "order_attachment__product"
4983
+ }, (0,preact_module.h)("img", {
4984
+ class: "order_attachment__product_img",
4985
+ alt: '' + product.id,
4986
+ src: util/* default.get */.Z.get(product, 'images.0') || __webpack_require__(9270)
4987
+ }), (0,preact_module.h)("div", {
4988
+ style: "overflow: hidden !important;"
4989
+ }, (0,preact_module.h)("div", {
4990
+ class: "order_attachment__product_name"
4991
+ }, product.name), (0,preact_module.h)("div", {
4992
+ class: "order_attachment__product_desc"
4993
+ }, product.description || product.long_description), (0,preact_module.h)("div", {
4994
+ class: "order_attachment__product_desc"
4995
+ }, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default.formatCurrency */.Z.formatCurrency(product.price))));
4996
+ });
4997
+ if (!this.isMobile()) return (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
4998
+ class: "order_label"
4999
+ }, this.props.t('product')), $products);
5000
+ return (0,preact_module.h)("div", {
5001
+ class: "order_section"
5002
+ }, (0,preact_module.h)("div", {
5003
+ class: "order_section_label"
5004
+ }, this.props.t('product')), $products);
5005
+ }
5006
+
5007
+ renderDesktopProducts(order) {
5008
+ let $products = null;
5009
+ let editmode = false;
5010
+
5011
+ if (!order.status || order.status == 'new') {
5012
+ editmode = !order.user_confirmation;
5013
+ }
5014
+
5015
+ if (editmode) {
5016
+ $products = util/* default.map */.Z.map(order.items, item => {
5017
+ if (!item || !item.product) return null;
5018
+ let product = item.product;
5019
+ return (0,preact_module.h)("div", {
5020
+ class: "order_attachment__product"
5021
+ }, (0,preact_module.h)("img", {
5022
+ class: "order_attachment__product_img",
5023
+ alt: '' + product.id,
5024
+ src: util/* default.get */.Z.get(product, 'images.0') || __webpack_require__(9270)
5025
+ }), (0,preact_module.h)("div", {
5026
+ style: "overflow: hidden !important; flex: 1 !important"
5027
+ }, (0,preact_module.h)("div", {
5028
+ class: "order_attachment__product_name"
5029
+ }, product.name), (0,preact_module.h)("div", {
5030
+ class: "order_attachment__product_desc"
5031
+ }, product.description || product.long_description), (0,preact_module.h)("div", {
5032
+ class: "order_attachment__product_desc"
5033
+ }, util/* default.formatCurrency */.Z.formatCurrency(product.price))), (0,preact_module.h)("input", {
5034
+ class: "form-control",
5035
+ style: "text-align: center !important; font-weight: 400 !important; width: 50px !important",
5036
+ value: item.quantity,
5037
+ onInput: e => this.onChangeQuantity(item, e.target.value),
5038
+ type: "text"
5039
+ }), (0,preact_module.h)("div", {
5040
+ style: "width: 80px !important; text-align: right !important; "
5041
+ }, (0,preact_module.h)("b", null, util/* default.formatCurrency */.Z.formatCurrency(item.quantity * product.price))));
5042
+ });
5043
+ } else {
5044
+ $products = util/* default.map */.Z.map(order.items, item => {
5045
+ if (!item || !item.product) return null;
5046
+ let product = item.product;
5047
+ return (0,preact_module.h)("div", {
5048
+ class: "order_attachment__product"
5049
+ }, (0,preact_module.h)("img", {
5050
+ class: "order_attachment__product_img",
5051
+ alt: '' + product.id,
5052
+ src: util/* default.get */.Z.get(product, 'images.0') || __webpack_require__(9270)
5053
+ }), (0,preact_module.h)("div", {
5054
+ style: "overflow: hidden !important; flex: 1 !important"
5055
+ }, (0,preact_module.h)("div", {
5056
+ class: "order_attachment__product_name"
5057
+ }, product.name), (0,preact_module.h)("div", {
5058
+ class: "order_attachment__product_desc"
5059
+ }, product.description || product.long_description), (0,preact_module.h)("div", {
5060
+ class: "order_attachment__product_desc"
5061
+ }, util/* default.formatCurrency */.Z.formatCurrency(product.price))), (0,preact_module.h)("div", {
5062
+ style: "text-align: center !important; font-weight: 400 !important; width: 50px !important"
5063
+ }, item.quantity), (0,preact_module.h)("div", {
5064
+ style: "width: 80px !important; text-align: right !important; "
5065
+ }, (0,preact_module.h)("b", null, util/* default.formatCurrency */.Z.formatCurrency(item.total))));
5066
+ });
5067
+ }
5068
+
5069
+ return (0,preact_module.h)("div", {
5070
+ class: "card_section"
5071
+ }, (0,preact_module.h)("div", {
5072
+ class: "desktop_order__heading"
5073
+ }, this.renderStatusBadge(order), (0,preact_module.h)("b", {
5074
+ style: "font-size: 18px !important;"
5075
+ }, this.props.t('order'), " #", order.order_number || order.id), (0,preact_module.h)("div", {
5076
+ class: "muted"
5077
+ }, (0,preact_module.h)(Time, {
5078
+ style: "font-size: 13px !important;",
5079
+ time: order.issue_date || order.created
5080
+ }))), (0,preact_module.h)("div", {
5081
+ class: "order_label d-flex",
5082
+ style: "margin-top: 20px !important;justify-content: space-between !important; align-items: flex-end !important;"
5083
+ }, (0,preact_module.h)("div", {
5084
+ style: "flex: 1 !important;"
5085
+ }, this.props.t('product')), (0,preact_module.h)("div", {
5086
+ style: "font-weight: 400 !important; text-align:center !important; width: 50px !important"
5087
+ }, this.props.t('qty')), (0,preact_module.h)("div", {
5088
+ style: "font-weight: 400 !important; text-align: right !important; width: 80px !important;"
5089
+ }, this.props.t('total'))), $products);
5090
+ }
5091
+
5092
+ renderMobile(order) {
5093
+ if (this.state.step === 'success') return this.renderMobileSuccess(order);
5094
+ let $error = null;
5095
+
5096
+ if (this.state.g_err) {
5097
+ $error = (0,preact_module.h)("div", {
5098
+ class: "mb-2 text__danger"
5099
+ }, (0,preact_module.h)("img", {
5100
+ style: "margin-top: -4px !important; height: 15px !important;",
5101
+ src: ximg
5102
+ }), "\xA0", (0,preact_module.h)("b", null, this.state.g_err));
5103
+ }
5104
+
5105
+ let $status = (0,preact_module.h)("div", null, $error, (0,preact_module.h)("div", {
5106
+ class: "btn-confirm-order",
5107
+ style: "margin-top: 0 !important;",
5108
+ onClick: this.confirm
5109
+ }, this.props.t('confirm_order')));
5110
+ let $close = (0,preact_module.h)("div", {
5111
+ class: "order_btn order__btn__light mt-3",
5112
+ onClick: this.onCancel
5113
+ }, this.props.t('cancel_order'));
5114
+
5115
+ if (order.user_confirmation || order.status != 'new') {
5116
+ $status = null;
5117
+ if (this.props.cid) $close = (0,preact_module.h)("div", {
5118
+ class: "order_btn order__btn__light mt-3",
5119
+ onClick: this.close
5120
+ }, this.props.t('close'));
5121
+ }
5122
+
5123
+ return (0,preact_module.h)("div", {
5124
+ class: "order",
5125
+ style: "height: 100% !important"
5126
+ }, (0,preact_module.h)("div", {
5127
+ class: "order--content"
5128
+ }, (0,preact_module.h)("div", {
5129
+ class: "order--heading"
5130
+ }, this.renderStatusBadge(order), (0,preact_module.h)("b", {
5131
+ style: "font-size: 16px !important;"
5132
+ }, this.props.t('order'), " #", order.order_number || order.id), (0,preact_module.h)("div", {
5133
+ class: "muted"
5134
+ }, (0,preact_module.h)(Time, {
5135
+ style: "font-size: 13px !important;",
5136
+ time: order.issue_date || order.created
5137
+ }))), this.renderProducts(order), this.renderDesktopShipping(order), this.renderShippingInfo(order), this.renderDesktopPaymentMethod(order), this.renderDesktopSummary(order), (0,preact_module.h)("div", {
5138
+ class: "order_section pb-3",
5139
+ style: "padding-top: 0 !important;"
5140
+ }, $status, $close)));
5141
+ }
5142
+
5143
+ renderActions(order) {
5144
+ let $actions = null;
5145
+ let editmode = false;
5146
+
5147
+ if (!order.status || order.status == 'new') {
5148
+ editmode = !order.user_confirmation;
5149
+ }
5150
+
5151
+ if (this.state.step === 'success') return (0,preact_module.h)("div", {
5152
+ class: "d-flex",
5153
+ style: "align-items: center !important; justify-content: flex-end !important"
5154
+ }, (0,preact_module.h)("div", null, "Ghi nh\u1EADn th\xE0nh c\xF4ng"), "\xA0", (0,preact_module.h)("img", {
5155
+ style: "width: 16px !important; height: 16px !important;",
5156
+ width: "16",
5157
+ height: "16",
5158
+ src: checkedimg
5159
+ }));
5160
+
5161
+ if (editmode) {
5162
+ let $error = null;
5163
+
5164
+ if (this.state.g_err) {
5165
+ $error = (0,preact_module.h)("div", {
5166
+ class: "mb-2 text__danger"
5167
+ }, (0,preact_module.h)("img", {
5168
+ style: "margin-top: -4px !important; height: 15px !important;",
5169
+ src: ximg
5170
+ }), "\xA0", (0,preact_module.h)("b", null, this.state.g_err));
5171
+ }
5172
+
5173
+ $actions = (0,preact_module.h)("div", null, $error, (0,preact_module.h)("div", {
5174
+ class: "btn-confirm-order",
5175
+ onClick: this.confirm
5176
+ }, this.props.t('confirm_order')), (0,preact_module.h)("div", {
5177
+ class: "btn-cancel-order",
5178
+ onClick: this.onCancel
5179
+ }, this.props.t('cancel_order')));
5180
+ }
5181
+
5182
+ return $actions;
5183
+ }
5184
+
5185
+ renderDesktop(order) {
5186
+ let acc = this.props.store.matchAccount();
5187
+
5188
+ var uri = acc.logo_url || __webpack_require__(9895);
5189
+
5190
+ return (0,preact_module.h)("div", {
5191
+ class: "desktop order"
5192
+ }, (0,preact_module.h)("div", {
5193
+ class: "order_acc_header"
5194
+ }, (0,preact_module.h)("img", {
5195
+ class: "order_acc_logo",
5196
+ src: uri
5197
+ }), (0,preact_module.h)("div", {
5198
+ class: "order_acc_name"
5199
+ }, acc.name)), (0,preact_module.h)("div", {
5200
+ class: "desktop_order__content"
5201
+ }, (0,preact_module.h)("div", {
5202
+ style: "flex: 1 !important; padding-right: 20px !important;"
5203
+ }, this.renderDesktopProducts(order), this.renderDesktopShipping(order), this.renderDesktopShippingInfo(order), this.renderDesktopPaymentMethod(order), (0,preact_module.h)("div", {
5204
+ class: "order__footer"
5205
+ }, (0,preact_module.h)("a", {
5206
+ target: "_blank",
5207
+ href: "https://subiz.com.vn",
5208
+ class: "order__footer_link"
5209
+ }, "Cung c\u1EA5p b\u1EDFi ", (0,preact_module.h)("b", null, "Subiz")), (0,preact_module.h)("div", {
5210
+ class: "order__footer_delimiter"
5211
+ }), (0,preact_module.h)("a", {
5212
+ target: "_blank",
5213
+ href: "https://subiz.com.vn/vi/terms-of-service.html",
5214
+ class: "order__footer_link"
5215
+ }, "\u0110i\u1EC1u kho\u1EA3n"), (0,preact_module.h)("a", {
5216
+ target: "_blank",
5217
+ href: "https://subiz.com.vn/vi/privacy-policy.html",
5218
+ class: "order__footer_link"
5219
+ }, "Quy\u1EC1n ri\xEAng t\u01B0"))), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
5220
+ class: "order_recap"
5221
+ }, this.renderDesktopSummary(order), this.renderActions(order)))));
5222
+ }
5223
+
5224
+ render() {
5225
+ if (this.state.loading) return (0,preact_module.h)("div", {
5226
+ class: "order_error"
5227
+ }, (0,preact_module.h)(Spinner, {
5228
+ class: "mt-4",
5229
+ size: "60",
5230
+ static: true
5231
+ }));
5232
+ if (this.state.error) return (0,preact_module.h)("div", {
5233
+ class: "order_error"
5234
+ }, (0,preact_module.h)("img", {
5235
+ class: "mt-3",
5236
+ src: __webpack_require__(6825)
5237
+ }), (0,preact_module.h)("div", {
5238
+ class: "mt-3"
5239
+ }, this.props.t('order_load_error')));
5240
+ let order = this.state.order;
5241
+ if (this.isMobile()) return this.renderMobile(order);
5242
+ return this.renderDesktop(order);
5243
+ }
5244
+
5245
+ }
5246
+ let ShippingProvider = {
5247
+ ghtk: {
5248
+ name: 'Giao hàng tiết kiệm',
5249
+ logo: __webpack_require__(6890)
5250
+ },
5251
+ ghn: {
5252
+ name: 'Giao hàng nhanh',
5253
+ logo: __webpack_require__(1473)
5254
+ }
5255
+ };
5256
+ ;// CONCATENATED MODULE: ./src/chatbox/Order.js
5257
+ function Order_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5258
+
5259
+
5260
+
5261
+
5262
+ const Order_POPUP_MAX_HEIGHT = 400;
5263
+ const Order_POPUP_HARD_MAX_HEIGHT = 500;
5264
+ const Order_POPUP_MIN_HEIGHT = 0;
5265
+
5266
+ let Order_defaultAvatar = __webpack_require__(4761);
5267
+
5268
+
5269
+
5270
+
5271
+ class Order extends common/* Com */.up {
5272
+ constructor(props) {
5273
+ super(props);
5274
+
5275
+ Order_defineProperty(this, "state", {
5276
+ hide: true,
5277
+ ratingHeight: 0,
5278
+ overlayOpacity: 0.3
5279
+ });
5280
+
5281
+ Order_defineProperty(this, "onResponse", response => {
5282
+ this.setState({
5283
+ response
5284
+ });
5285
+ });
5286
+
5287
+ Order_defineProperty(this, "confirm", () => {
5288
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5289
+ message: {
5290
+ format: 'plaintext',
5291
+ text: 'confirm',
5292
+ attachments: [{
5293
+ type: 'postback',
5294
+ postback: {
5295
+ payload: JSON.stringify({
5296
+ type: 'order_confirmation',
5297
+ status: 'confirmed'
5298
+ })
5299
+ }
5300
+ }]
5301
+ }
5302
+ });
5303
+ });
5304
+
5305
+ Order_defineProperty(this, "close", async () => {
5306
+ await util/* default.sleep */.Z.sleep(100);
5307
+
5308
+ if (this.state.response === 'confirmed') {
5309
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5310
+ message: {
5311
+ format: 'plaintext',
5312
+ text: this.props.t('confirm_order'),
5313
+ attachments: [{
5314
+ type: 'postback',
5315
+ postback: {
5316
+ payload: JSON.stringify({
5317
+ type: 'order_confirmation',
5318
+ status: 'confirmed'
5319
+ })
5320
+ }
5321
+ }]
5322
+ }
5323
+ });
5324
+ } else if (this.state.response === 'rejected') {
5325
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5326
+ message: {
5327
+ format: 'plaintext',
5328
+ text: this.props.t('cancel_order'),
5329
+ attachments: [{
5330
+ type: 'postback',
5331
+ postback: {
5332
+ payload: JSON.stringify({
5333
+ type: 'order_confirmation',
5334
+ status: 'cancelled'
5335
+ })
5336
+ }
5337
+ }]
5338
+ }
5339
+ });
5340
+ } else {}
5341
+
5342
+ this.setState({
5343
+ response: ''
5344
+ });
5345
+ if (this.state.hide) return;
5346
+ if (!this.refRating.current) return;
5347
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
5348
+ var h0 = parseFloat(popupStyle.height);
5349
+ this.animation.play(20, h0, h => {
5350
+ this.setState({
5351
+ ratingHeight: h,
5352
+ overlayOpacity: Math.min(1, (h - Order_POPUP_MIN_HEIGHT) / (Order_POPUP_HARD_MAX_HEIGHT - Order_POPUP_MIN_HEIGHT))
5353
+ });
5354
+
5355
+ if (h < Order_POPUP_MIN_HEIGHT + 10) {
5356
+ if (!this.state.hide) {
5357
+ this.setState({
5358
+ hide: true
5359
+ });
5360
+ }
5361
+ }
5362
+ });
5363
+ this.props.onClose();
5364
+ });
5365
+
5366
+ this.refRating = (0,preact_module/* createRef */.Vf)();
5367
+ this.refHandle = (0,preact_module/* createRef */.Vf)();
5368
+ }
5369
+
5370
+ componentDidMount() {
5371
+ this.mouseUp = e => this.onMouseUp(e);
5372
+
5373
+ this.mouseMove = e => this.onMouseMove(e);
5374
+
5375
+ this.mouseDown = e => this.onMouseDown(e);
5376
+
5377
+ var $ratingHandle = this.refHandle.current;
5378
+ $ratingHandle.addEventListener('mousedown', this.mouseDown, {
5379
+ passive: true
5380
+ });
5381
+ $ratingHandle.addEventListener('touchstart', this.mouseDown, {
5382
+ passive: true
5383
+ });
5384
+ window.addEventListener('mouseup', this.mouseUp, {
5385
+ passive: true
5386
+ });
5387
+ window.addEventListener('touchend', this.mouseUp, {
5388
+ passive: true
5389
+ });
5390
+ window.addEventListener('mousemove', this.mouseMove, {
5391
+ passive: true
5392
+ });
5393
+ window.addEventListener('touchmove', this.mouseMove, {
5394
+ passive: true
5395
+ });
5396
+ this.animation = new releaseAnimation({
5397
+ maxY: Order_POPUP_MAX_HEIGHT,
5398
+ minY: Order_POPUP_MIN_HEIGHT,
5399
+ duration: 150
5400
+ });
5401
+ this.close();
5402
+ }
5403
+
5404
+ componentWillUnmount() {
5405
+ var $ratingHandle = this.refHandle.current;
5406
+ $ratingHandle.removeEventListener('mousedown', this.mouseDown, 0);
5407
+ $ratingHandle.removeEventListener('touchstart', this.mouseDown, 0);
5408
+ window.removeEventListener('mouseup', this.mouseUp, 0);
5409
+ window.removeEventListener('touchend', this.mouseUp, 0);
5410
+ window.removeEventListener('mousemove', this.mouseMove, 0);
5411
+ window.removeEventListener('touchmove', this.mouseMove, 0);
5412
+ }
5413
+
5414
+ render() {
5415
+ if (this._show != this.props.show) {
5416
+ this._show = this.props.show;
5417
+ setTimeout(() => {
5418
+ if (!this._show) this.close();else this.open();
5419
+ });
5420
+ }
5421
+
5422
+ let cls = this.state.hide ? 'd-none' : '';
5423
+ return (0,preact_module.h)("div", {
5424
+ class: cls
5425
+ }, (0,preact_module.h)("div", {
5426
+ class: "extension--overlay",
5427
+ style: `opacity: ${this.state.overlayOpacity * 0.5} !important;`
5428
+ }), (0,preact_module.h)("div", {
5429
+ class: "extension",
5430
+ ref: this.refRating,
5431
+ style: `height: ${this.state.ratingHeight}px !important;`
5432
+ }, (0,preact_module.h)("div", {
5433
+ class: "extension--close-btn",
5434
+ onClick: this.close
5435
+ }, this.props.t('close')), (0,preact_module.h)("div", {
5436
+ class: "extension--handle",
5437
+ ref: this.refHandle
5438
+ }, (0,preact_module.h)("div", {
5439
+ class: "extension--thumb"
5440
+ })), (0,preact_module.h)("div", {
5441
+ style: "overflow-x: hidden !important; overflow-y: scroll !important; height: 100% !important;"
5442
+ }, (0,preact_module.h)(order_Order, {
5443
+ key: this.props.order_id,
5444
+ store: this.props.store,
5445
+ onResponse: this.onResponse,
5446
+ onClose: this.close,
5447
+ t: this.props.t,
5448
+ order_id: this.props.order_id,
5449
+ cid: this.props.cid
5450
+ }))));
5451
+ }
5452
+
5453
+ open() {
5454
+ if (!this.state.hide) return;
5455
+ if (!this.props.order_id) return;
5456
+ this.setState({
5457
+ hide: false
5458
+ });
5459
+ if (!this.refRating.current) return;
5460
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
5461
+ var h0 = parseFloat(popupStyle.height);
5462
+ this.animation.play(-20, h0, h => {
5463
+ this.setState({
5464
+ ratingHeight: h,
5465
+ overlayOpacity: Math.min(1, (h - Order_POPUP_MIN_HEIGHT) / (Order_POPUP_HARD_MAX_HEIGHT - Order_POPUP_MIN_HEIGHT))
5466
+ });
5467
+ });
5468
+ }
5469
+
5470
+ onMouseDown(e) {
5471
+ this.mousePushed = true;
5472
+ this.animation.stop();
5473
+ e.preventDefault();
5474
+ if (e.touches && e.touches[0]) e = e.touches[0];
5475
+ this.mousePushedDy = e.pageY - window.pageYOffset - this.refRating.current.getBoundingClientRect().y;
5476
+ }
5477
+
5478
+ onMouseUp(e) {
5479
+ if (!this.mousePushed) return;
5480
+ if (e.touches && e.touches[0]) e = e.touches[0];
5481
+ this.mousePushed = false;
5482
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
5483
+ var h0 = parseFloat(popupStyle.height);
5484
+ this.animation.play(this.mouseVelocity, h0, h => {
5485
+ this.setState({
5486
+ ratingHeight: h,
5487
+ overlayOpacity: Math.min(1, (h - Order_POPUP_MIN_HEIGHT) / (Order_POPUP_HARD_MAX_HEIGHT - Order_POPUP_MIN_HEIGHT))
5488
+ });
5489
+
5490
+ if (h < Order_POPUP_MIN_HEIGHT + 10) {
5491
+ if (!this.state.hide) {
5492
+ this.setState({
5493
+ hide: true
5494
+ });
5495
+ this.props.onRate && this.props.onRate({
5496
+ no_rating: true
5497
+ });
5498
+ }
5499
+ }
5500
+ });
5501
+ }
5502
+
5503
+ onMouseMove(e) {
5504
+ if (!this.mousePushed) return;
5505
+ if (e.touches && e.touches[0]) e = e.touches[0];
5506
+ var my = e.pageY;
5507
+ this.mouseVelocity = my - this.lastMouseY;
5508
+ this.lastMouseY = my;
5509
+ my = my - this.mousePushedDy;
5510
+ var K = 10000;
5511
+ var height = this.refRating.current.getBoundingClientRect().bottom - my;
5512
+
5513
+ if (height > Order_POPUP_MAX_HEIGHT) {
5514
+ var beta = K / (Order_POPUP_HARD_MAX_HEIGHT - Order_POPUP_MAX_HEIGHT) - Order_POPUP_MAX_HEIGHT;
5515
+ height = Order_POPUP_HARD_MAX_HEIGHT - K / (height + beta);
5516
+ }
5517
+
5518
+ this.setState({
5519
+ ratingHeight: height,
5520
+ overlayOpacity: Math.min(1, (height - Order_POPUP_MIN_HEIGHT) / (Order_POPUP_HARD_MAX_HEIGHT - Order_POPUP_MIN_HEIGHT))
5521
+ });
5522
+ }
5523
+
5524
+ }
5525
+ ;// CONCATENATED MODULE: ./src/chatbox/Widget.js
5526
+ function Widget_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5527
+
5528
+
5529
+
5530
+
5531
+
5532
+
5533
+
5534
+ var send = __webpack_require__(9737);
5535
+
5536
+ var Widget_checkedimg = __webpack_require__(8909);
5537
+
5538
+ var empty = __webpack_require__(29);
5539
+
5540
+
5541
+
5542
+
5543
+
5544
+
5545
+
5546
+ const Widget_defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png';
5547
+
5548
+
5549
+
5550
+
5551
+ class Widget extends common/* Com */.up {
5552
+ constructor(props) {
5553
+ super(props);
5554
+
5555
+ Widget_defineProperty(this, "onLink", (e, url) => {
5556
+ if (!url) return e.preventDefault();
5557
+ let noschemeurl = url.replace(/(^\w+:|^)\/\//, '');
5558
+
5559
+ if (noschemeurl.startsWith('widget.subiz.com.vn/orders/')) {
5560
+ let orderid = noschemeurl.substr('widget.subiz.com.vn/orders/'.length);
5561
+ orderid = orderid.split('/')[0];
5562
+ this.setState({
5563
+ showOrder: true,
5564
+ order_id: orderid
5565
+ });
5566
+ e.preventDefault();
5567
+ return;
5568
+ }
5569
+ });
5570
+
5571
+ Widget_defineProperty(this, "closeOrder", e => {
5572
+ this.setState({
5573
+ showOrder: false,
5574
+ order_id: ''
5575
+ });
5576
+ this.focusInput();
5577
+ });
5578
+
5579
+ this.userSent = {};
5580
+ this.setState({
5581
+ creating: false,
5582
+ clickedJoin: false,
5583
+ formData: {},
5584
+ showOrder: false,
5585
+ order_id: ''
5586
+ });
5587
+ this.props.store.onUpdate(this, _ => this.forceUpdate());
5588
+ }
5589
+
5590
+ componentDidMount() {
5591
+ if (!this.props.store.isMobile()) this.focusInput();
5592
+ }
5593
+
5594
+ componentDidUpdate(prevProp) {
5595
+ if (prevProp.isShow !== this.props.isShow) {
5596
+ if (this.props.isShow && !this.props.store.isMobile()) this.focusInput();
5597
+ if (this.props.isShow && this.props.store.isMobile()) this.blur();
5598
+ }
5599
+
5600
+ if (prevProp.cid !== this.props.cid) {
5601
+ this.closeOrder();
5602
+ this.setState({
5603
+ clickedJoin: false
5604
+ });
5605
+ setTimeout(() => {
5606
+ this.events && this.events.focus();
5607
+ if (!this.props.store.isMobile()) this.focusInput();
5608
+ }, 100);
5609
+ }
5610
+
5611
+ this.updateFormDataFields();
5612
+ }
5613
+
5614
+ shouldShowForm() {
5615
+ let formRequired = this.isFormRequired();
5616
+ return formRequired && !this.props.cid || formRequired && this.props.cid && this.state.clickedJoin;
5617
+ }
5618
+
5619
+ render() {
5620
+ let showform = this.shouldShowForm();
5621
+ let form;
5622
+ let accountSetting = this.props.plugin.chatbox || {};
5623
+ let acc = this.props.store.matchAccount() || {};
5624
+ let submitLabel = this.props.t('prechat_form_btn');
5625
+ if (util/* default.get */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
5626
+ let offlineEnabled = util/* default.get */.Z.get(accountSetting, 'offline_form.enabled');
5627
+
5628
+ if (this.isOffline(acc, accountSetting) && offlineEnabled) {
5629
+ form = accountSetting.offline_form;
5630
+ submitLabel = this.props.t('offline_form_btn');
5631
+ }
5632
+
5633
+ if (this.props.view === 'offline_form') {
5634
+ showform = true;
5635
+ form = accountSetting.offline_form;
5636
+ submitLabel = this.props.t('offline_form_btn');
5637
+ }
5638
+
5639
+ if (this.props.view === 'prechat_form') {
5640
+ showform = true;
5641
+ form = accountSetting.prechat_form;
5642
+ submitLabel = this.props.t('prechat_form_btn');
5643
+ }
5644
+
5645
+ let $body = null;
5646
+ if (this.props.view === 'list') $body = this.renderConvoList();else if (showform) $body = this.renderForm(form, submitLabel);else $body = this.renderChat();
5647
+ let position = util/* default.get */.Z.get(accountSetting, 'desktop_button.position') || 'right';
5648
+ if (this.props.store.isMobile()) position = util/* default.get */.Z.get(accountSetting, 'mobile_button.position', position);
5649
+ let cls = 'widget-container widget-container--' + position;
5650
+ if (!this.props.isShow) cls += ' widget-container--hide';
5651
+ return (0,preact_module.h)("div", {
5652
+ class: cls
5653
+ }, (0,preact_module.h)(Header, {
5654
+ t: this.props.t,
5655
+ plugin: this.props.plugin,
5656
+ store: this.props.store,
5657
+ cid: this.props.cid,
5658
+ view: this.props.view,
5659
+ onClose: this.props.onClose,
5660
+ onGotoList: () => this.props.onGo({
5661
+ view: 'list'
5662
+ })
5663
+ }), $body);
5664
+ }
5665
+
5666
+ async submitPrechatForm(form) {
5667
+ var hasError = false;
5668
+ util/* default.map */.Z.map(this.state.formData, (field, key) => {
5669
+ if (field.is_required && (field.value === undefined || field.value === '' || util/* default.size */.Z.size(field.value) === 0 && Array.isArray(field.value))) {
5670
+ field.error = this.props.t('error_empty');
5671
+ hasError = true;
5672
+ } else field.error = '';
5673
+
5674
+ if (key.substr(5) === 'emails' && !util/* default.isEmail */.Z.isEmail(field.value) && field.is_required) {
5675
+ field.error = this.props.t('error_email_invalid');
5676
+ hasError = true;
5677
+ }
5678
+
5679
+ if (key.substr(5) === 'phones' && !util/* default.isPhone */.Z.isPhone(field.value) && field.is_required) {
5680
+ field.error = this.props.t('error_phone_invalid');
5681
+ hasError = true;
5682
+ }
5683
+ });
5684
+ if (hasError) return this.forceUpdate();
5685
+ let data = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
5686
+ let user = util/* default.cloneDeep */.Z.cloneDeep(this.props.store.matchUser());
5687
+ util/* default.map */.Z.map(data, (field, key) => {
5688
+ if (!key.startsWith('attr:')) return;
5689
+ var attr = {
5690
+ key: key.substr(5)
5691
+ };
5692
+ if (field.type === 'number') attr.number = parseInt(field.value);
5693
+ if (field.type === 'datetime') attr.datetime = new util/* default.Date */.Z.Date(field.value).toISOString();
5694
+ if (field.type === 'list') attr.list = field.value;
5695
+ if (field.type === 'text' || field.type === 'boolean') attr[field.type] = field.value;
5696
+ util/* default.setUserAttr */.Z.setUserAttr(user, attr);
5697
+ });
5698
+ let firstmsg = util/* default.get */.Z.get(data, 'question.value');
5699
+ let groupid = util/* default.get */.Z.get(data, 'group.value', '');
5700
+
5701
+ if (this.props.cid) {
5702
+ this.props.store.setUser(user);
5703
+ this.setState({
5704
+ clickedJoin: false
5705
+ });
5706
+ await this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5707
+ message: {
5708
+ text: firstmsg,
5709
+ format: 'plaintext',
5710
+ fields: [{
5711
+ key: 'to_agent_group',
5712
+ value: util/* default.stringify */.Z.stringify(groupid)
5713
+ }]
5714
+ }
5715
+ });
5716
+ if (form.end_conversation_after_submit) await this.props.store.endConvo(this.props.cid);
5717
+ return;
5718
+ }
5719
+
5720
+ this.setState({
5721
+ creating: true
5722
+ });
5723
+ let message = {
5724
+ text: firstmsg,
5725
+ format: 'plaintext'
5726
+ };
5727
+ let req = {
5728
+ group_id: groupid,
5729
+ message: firstmsg,
5730
+ locale: this.props.t.locale(),
5731
+ initial_by: user.id
5732
+ };
5733
+ this.setState({
5734
+ creatingError: null
5735
+ });
5736
+ const {
5737
+ error,
5738
+ convo
5739
+ } = await this.props.store.startConvo(req);
5740
+ this.props.store.setUser(user);
5741
+
5742
+ if (error) {
5743
+ this.setState({
5744
+ creating: false,
5745
+ creatingError: error
5746
+ });
5747
+ return;
5748
+ }
5749
+
5750
+ let newconvoid = convo.id;
5751
+ this.userSent[newconvoid] = true;
5752
+ this.props.onGo({
5753
+ view: 'chat',
5754
+ cid: newconvoid
5755
+ });
5756
+ this.props.store.sendConvoEvent(newconvoid, 'message_sent', {
5757
+ message
5758
+ });
5759
+ this.setState({
5760
+ creating: false,
5761
+ clickedJoin: false
5762
+ });
5763
+ if (!this.props.store.isMobile()) this.focusInput();
5764
+ }
5765
+
5766
+ formMounted(form) {
5767
+ let formData = this.fillForm(form);
5768
+ formData['question'] = {
5769
+ key: 'question',
5770
+ is_required: true,
3733
5771
  label: this.props.t.i18n(util/* default.get */.Z.get(form, `i18n_question_label`, {})) || form.question_label,
3734
5772
  type: 'text'
3735
5773
  };
@@ -4102,6 +6140,7 @@ class Widget extends common/* Com */.M {
4102
6140
  onClick: e => this.onContainerClick(e)
4103
6141
  }, (0,preact_module.h)(Events, {
4104
6142
  isShow: this.props.isShow,
6143
+ onLink: this.onLink,
4105
6144
  store: this.props.store,
4106
6145
  onFormSubmit: e => this.onEventFormSubmit(e),
4107
6146
  ref: ref => this.events = ref,
@@ -4121,6 +6160,15 @@ class Widget extends common/* Com */.M {
4121
6160
  onRate: e => this.onRate(e),
4122
6161
  cid: this.props.cid,
4123
6162
  t: this.props.t
6163
+ }), (0,preact_module.h)(Order, {
6164
+ forceView: this.props.view,
6165
+ plugin: this.props.plugin,
6166
+ show: this.state.showOrder,
6167
+ order_id: this.state.order_id,
6168
+ store: this.props.store,
6169
+ onClose: this.closeOrder,
6170
+ cid: this.props.cid,
6171
+ t: this.props.t
4124
6172
  }), $input);
4125
6173
  }
4126
6174
 
@@ -4204,7 +6252,7 @@ class Widget extends common/* Com */.M {
4204
6252
  $unread = (0,preact_module.h)("img", {
4205
6253
  alt: "conversation ended",
4206
6254
  class: "convo-list--convo-completed",
4207
- src: checkedimg,
6255
+ src: Widget_checkedimg,
4208
6256
  title: this.props.t('conversation_ended')
4209
6257
  });
4210
6258
  }
@@ -4383,7 +6431,7 @@ class Widget extends common/* Com */.M {
4383
6431
 
4384
6432
  }
4385
6433
 
4386
- class FormMounter extends common/* Com */.M {
6434
+ class FormMounter extends common/* Com */.up {
4387
6435
  componentDidMount() {
4388
6436
  this.props.onMount(this.props.form);
4389
6437
  }
@@ -4391,7 +6439,7 @@ class FormMounter extends common/* Com */.M {
4391
6439
  }
4392
6440
 
4393
6441
  function Widget_encode(key) {
4394
- return btoa(key).split('=').join('');
6442
+ return encodeURIComponent(key);
4395
6443
  }
4396
6444
  ;// CONCATENATED MODULE: ./src/chatbox/main.js
4397
6445
 
@@ -4400,9 +6448,9 @@ function Widget_encode(key) {
4400
6448
 
4401
6449
 
4402
6450
 
4403
- let promiseMainCSS = (() => __webpack_require__.e(/* import() */ 178).then(__webpack_require__.bind(__webpack_require__, 178)))();
6451
+ let main_promiseMainCSS = (() => __webpack_require__.e(/* import() */ 178).then(__webpack_require__.bind(__webpack_require__, 178)))();
4404
6452
 
4405
- class Main extends common/* Com */.M {
6453
+ class Main extends common/* Com */.up {
4406
6454
  constructor(props) {
4407
6455
  super(props);
4408
6456
  this.refButton = (0,preact_module/* createRef */.Vf)();
@@ -4412,7 +6460,7 @@ class Main extends common/* Com */.M {
4412
6460
  let plugins = this.props.store.matchPlugin();
4413
6461
  let found = util/* default.find */.Z.find(plugins, plugin => plugin.id === this.props.plugin.id);
4414
6462
  if (!found) return;
4415
- let css = (await promiseMainCSS).default.default.toString();
6463
+ let css = (await main_promiseMainCSS).default.default.toString();
4416
6464
  var outcss = util/* default.replaceCssVariable */.Z.replaceCssVariable(css, this.props.plugin.chatbox);
4417
6465
  util/* default.setCss */.Z.setCss(this.props.plugin.id, this.$cssStyleDiv, outcss);
4418
6466
  }
@@ -4555,11 +6603,13 @@ class Main extends common/* Com */.M {
4555
6603
  }
4556
6604
 
4557
6605
  function restoreViewport() {
6606
+ if (document.body && document.body.classList) document.body.classList.remove('sbz_no_scroll');
4558
6607
  let metatag = document.getElementById('subiz-meta-viewport');
4559
6608
  if (metatag) metatag.remove();
4560
6609
  }
4561
6610
 
4562
6611
  function modifyViewport() {
6612
+ if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll');
4563
6613
  let metatag = document.createElement('meta');
4564
6614
  metatag.httpEquiv = 'X-UA-Compatible';
4565
6615
  metatag.name = 'viewport';
@@ -4570,74 +6620,17 @@ function modifyViewport() {
4570
6620
 
4571
6621
  /***/ }),
4572
6622
 
4573
- /***/ 2493:
4574
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4575
-
4576
- "use strict";
4577
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4578
- /* harmony export */ "M": () => (/* binding */ Com),
4579
- /* harmony export */ "u": () => (/* binding */ Clickaway)
4580
- /* harmony export */ });
4581
- /* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6400);
4582
- /* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(819);
4583
-
4584
-
4585
- class Com extends preact__WEBPACK_IMPORTED_MODULE_0__/* .Component */ .wA {
4586
- constructor(props) {
4587
- super(props);
4588
- this._isMounted = true;
4589
- setTimeout(() => {
4590
- if (this.componentWillUnmount) {
4591
- let old = this.componentWillUnmount.bind(this);
4592
-
4593
- this.componentWillUnmount = () => {
4594
- old();
4595
- this._isMounted = false;
4596
- };
4597
- }
4598
- }, 10);
4599
- }
4600
-
4601
- }
4602
- class Clickaway extends Com {
4603
- constructor(props) {
4604
- super(props);
4605
- this.setWrapperRef = this.setWrapperRef.bind(this);
4606
- this.onClick = this.onClick.bind(this);
4607
- }
4608
-
4609
- componentDidMount() {
4610
- document.addEventListener('mousedown', this.onClick);
4611
- }
4612
-
4613
- componentWillUnmount() {
4614
- document.removeEventListener('mousedown', this.onClick);
4615
- }
4616
-
4617
- setWrapperRef(node) {
4618
- this.wrapperRef = node;
4619
- }
4620
-
4621
- onClick(event) {
4622
- if (this.wrapperRef && !this.wrapperRef.contains(event.target)) {
4623
- this.props.onClickaway && this.props.onClickaway();
4624
- }
4625
- }
4626
-
4627
- render() {
4628
- return (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", {
4629
- ref: this.setWrapperRef
4630
- }, this.props.children);
4631
- }
6623
+ /***/ 6755:
6624
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4632
6625
 
4633
- }
6626
+ module.exports = __webpack_require__.p + "assets/img/bubble_default.7d5e4ab.svg";
4634
6627
 
4635
6628
  /***/ }),
4636
6629
 
4637
- /***/ 6755:
6630
+ /***/ 8712:
4638
6631
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4639
6632
 
4640
- module.exports = __webpack_require__.p + "assets/img/bubble_default.7d5e4ab.svg";
6633
+ module.exports = __webpack_require__.p + "assets/img/caret.998eb8f.svg";
4641
6634
 
4642
6635
  /***/ }),
4643
6636
 
@@ -4669,6 +6662,13 @@ module.exports = __webpack_require__.p + "assets/img/done_gray.d7e8203.svg";
4669
6662
 
4670
6663
  /***/ }),
4671
6664
 
6665
+ /***/ 763:
6666
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6667
+
6668
+ module.exports = __webpack_require__.p + "assets/img/done_green.b817fd4.svg";
6669
+
6670
+ /***/ }),
6671
+
4672
6672
  /***/ 29:
4673
6673
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4674
6674
 
@@ -4676,6 +6676,13 @@ module.exports = __webpack_require__.p + "assets/img/empty.29bed2d.svg";
4676
6676
 
4677
6677
  /***/ }),
4678
6678
 
6679
+ /***/ 6825:
6680
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6681
+
6682
+ module.exports = __webpack_require__.p + "assets/img/empty_1.0b98af0.svg";
6683
+
6684
+ /***/ }),
6685
+
4679
6686
  /***/ 8453:
4680
6687
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4681
6688
 
@@ -4683,6 +6690,20 @@ module.exports = __webpack_require__.p + "assets/img/external-link.90577cc.svg";
4683
6690
 
4684
6691
  /***/ }),
4685
6692
 
6693
+ /***/ 1473:
6694
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6695
+
6696
+ module.exports = __webpack_require__.p + "assets/img/ghn.070f8e3.svg";
6697
+
6698
+ /***/ }),
6699
+
6700
+ /***/ 6890:
6701
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6702
+
6703
+ module.exports = __webpack_require__.p + "assets/img/ghtk.326eac1.svg";
6704
+
6705
+ /***/ }),
6706
+
4686
6707
  /***/ 9895:
4687
6708
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4688
6709
 
@@ -4690,6 +6711,20 @@ module.exports = __webpack_require__.p + "assets/img/image_default.be0698b.png";
4690
6711
 
4691
6712
  /***/ }),
4692
6713
 
6714
+ /***/ 9256:
6715
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6716
+
6717
+ module.exports = __webpack_require__.p + "assets/img/info.ebce7ea.svg";
6718
+
6719
+ /***/ }),
6720
+
6721
+ /***/ 5770:
6722
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6723
+
6724
+ module.exports = __webpack_require__.p + "assets/img/loader.37000a7.svg";
6725
+
6726
+ /***/ }),
6727
+
4693
6728
  /***/ 6484:
4694
6729
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4695
6730
 
@@ -4697,6 +6732,27 @@ module.exports = __webpack_require__.p + "assets/img/loading_static.8f403ae.svg"
4697
6732
 
4698
6733
  /***/ }),
4699
6734
 
6735
+ /***/ 6071:
6736
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6737
+
6738
+ module.exports = __webpack_require__.p + "assets/img/not_found_search.2ddb8d1.png";
6739
+
6740
+ /***/ }),
6741
+
6742
+ /***/ 25:
6743
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6744
+
6745
+ module.exports = __webpack_require__.p + "assets/img/package.8d37d0f.svg";
6746
+
6747
+ /***/ }),
6748
+
6749
+ /***/ 1216:
6750
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6751
+
6752
+ module.exports = __webpack_require__.p + "assets/img/package_fade.763c001.svg";
6753
+
6754
+ /***/ }),
6755
+
4700
6756
  /***/ 6535:
4701
6757
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4702
6758
 
@@ -4718,6 +6774,13 @@ module.exports = __webpack_require__.p + "assets/img/rating--poor.2938a25.svg";
4718
6774
 
4719
6775
  /***/ }),
4720
6776
 
6777
+ /***/ 636:
6778
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6779
+
6780
+ module.exports = __webpack_require__.p + "assets/img/search.f9705ff.svg";
6781
+
6782
+ /***/ }),
6783
+
4721
6784
  /***/ 9737:
4722
6785
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4723
6786
 
@@ -4725,11 +6788,32 @@ module.exports = __webpack_require__.p + "assets/img/send.6db52a9.svg";
4725
6788
 
4726
6789
  /***/ }),
4727
6790
 
6791
+ /***/ 6180:
6792
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6793
+
6794
+ module.exports = __webpack_require__.p + "assets/img/shop.f7dc7d8.svg";
6795
+
6796
+ /***/ }),
6797
+
6798
+ /***/ 750:
6799
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6800
+
6801
+ module.exports = __webpack_require__.p + "assets/img/shop_faded.df7845a.svg";
6802
+
6803
+ /***/ }),
6804
+
4728
6805
  /***/ 8430:
4729
6806
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4730
6807
 
4731
6808
  module.exports = __webpack_require__.p + "assets/img/subiz-mono.877e9f5.svg";
4732
6809
 
6810
+ /***/ }),
6811
+
6812
+ /***/ 2514:
6813
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6814
+
6815
+ module.exports = __webpack_require__.p + "assets/img/x.26fdfa3.svg";
6816
+
4733
6817
  /***/ })
4734
6818
 
4735
6819
  }]);