@subiz/widget-v4 4.0.58 → 4.0.63

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 (156) 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 +35 -0
  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/compiled_src/call/call.js +12 -15
  25. package/compiled_src/chatbox/DropdownSelect.js +239 -0
  26. package/compiled_src/chatbox/Event.js +4 -2
  27. package/compiled_src/chatbox/Events.js +1 -0
  28. package/compiled_src/chatbox/MessageInput.js +4 -7
  29. package/compiled_src/chatbox/Order.js +281 -0
  30. package/compiled_src/chatbox/OrderAttachments.js +2 -1
  31. package/compiled_src/chatbox/Rating.js +7 -10
  32. package/compiled_src/chatbox/TextMessage.js +9 -2
  33. package/compiled_src/chatbox/Widget.js +40 -3
  34. package/compiled_src/chatbox/main.js +2 -1
  35. package/compiled_src/chatbox/spinner.js +1 -1
  36. package/compiled_src/chatbox/time.js +3 -1
  37. package/compiled_src/common.js +40 -1
  38. package/compiled_src/contact/contact.js +7 -12
  39. package/compiled_src/lib.js +9 -14
  40. package/compiled_src/notif/notif.js +12 -15
  41. package/compiled_src/order/address_picker.js +241 -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 +1220 -0
  45. package/compiled_src/plugin.js +9 -42
  46. package/compiled_src/popup/countdown.js +4 -7
  47. package/compiled_src/popup/popup.js +40 -13
  48. package/compiled_src/store/api.js +80 -90
  49. package/compiled_src/store/api_fake.js +55 -82
  50. package/compiled_src/store/store.js +163 -158
  51. package/compiled_src/util/common.js +40 -4
  52. package/dist/0b82fa7e5c3b07b40a44.png +1 -0
  53. package/dist/0f4af006e38ee8b93633.png +1 -0
  54. package/dist/{74.js → 132.js} +2234 -236
  55. package/dist/178.js +341 -174
  56. package/dist/17e757ccadd.132.js +1 -0
  57. package/dist/17e757ccadd.178.js +1 -0
  58. package/dist/17e757ccadd.213.js +1 -0
  59. package/dist/17e757ccadd.335.js +1 -0
  60. package/dist/17e757ccadd.362.js +1 -0
  61. package/dist/17e757ccadd.441.js +1 -0
  62. package/dist/17e757ccadd.605.js +1 -0
  63. package/dist/17e757ccadd.678.js +1 -0
  64. package/dist/17e757ccadd.782.js +1 -0
  65. package/dist/17e757ccadd.app.js +1 -0
  66. package/dist/{17d938a5acb.index.html → 17e757ccadd.index.html} +3 -18
  67. package/dist/{17d938a5acb.library.html → 17e757ccadd.library.html} +3 -18
  68. package/dist/17e757ccadd.library.js +1 -0
  69. package/dist/{17d938a5acb.preview.html → 17e757ccadd.preview.html} +1 -1
  70. package/dist/17e757ccadd.preview.js +1 -0
  71. package/dist/17e757ccadd.screenshoot.js +1 -0
  72. package/dist/1ea1c6cd21d25176810c.png +1 -0
  73. package/dist/213.js +46 -87
  74. package/dist/292d42404e1b03398f61.png +1 -0
  75. package/dist/312d376370831b7bea83.png +1 -0
  76. package/dist/313d1bfc1cf776d1aefe.png +1 -0
  77. package/dist/335.js +408 -0
  78. package/dist/362.js +71 -21
  79. package/dist/441.js +69 -43
  80. package/dist/4aa58bb7a66bb44975aa.png +1 -0
  81. package/dist/56ce063bc6c81adb7322.png +1 -0
  82. package/dist/605.js +13 -79
  83. package/dist/678.js +70 -20
  84. package/dist/6a411166ef5cc79e0714.png +1 -0
  85. package/dist/6faf403782fefacc1649.png +1 -0
  86. package/dist/782.js +118 -21
  87. package/dist/79dca33c68fab79c067f.png +1 -0
  88. package/dist/82da1578fa84f9debaeb.png +1 -0
  89. package/dist/8b8e0f0824743974b282.png +1 -0
  90. package/dist/8d551390d81e39130a3c.png +1 -0
  91. package/dist/9fc61b9479877ebdb6c7.png +1 -0
  92. package/dist/HASH +1 -1
  93. package/dist/a165d31dcb3dc90f1057.png +1 -0
  94. package/dist/a98d4a5698812c4426b3.png +1 -0
  95. package/dist/assets/img/caret.998eb8f.svg +1 -0
  96. package/dist/assets/img/done_green.b817fd4.svg +4 -0
  97. package/dist/assets/img/empty_1.0b98af0.svg +11 -0
  98. package/dist/assets/img/ghn.070f8e3.svg +17 -0
  99. package/dist/assets/img/ghtk.326eac1.svg +18 -0
  100. package/dist/assets/img/info.ebce7ea.svg +1 -0
  101. package/dist/assets/img/loader.37000a7.svg +1 -0
  102. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  103. package/dist/assets/img/package.8d37d0f.svg +5 -0
  104. package/dist/assets/img/package_fade.763c001.svg +1 -0
  105. package/dist/assets/img/search.f9705ff.svg +1 -0
  106. package/dist/assets/img/shop.f7dc7d8.svg +1 -0
  107. package/dist/assets/img/shop_faded.df7845a.svg +1 -0
  108. package/dist/assets/img/x.26fdfa3.svg +5 -0
  109. package/dist/c41606bf9d1b604e46d5.png +1 -0
  110. package/dist/ce1f7450ce6c1aacd330.png +1 -0
  111. package/dist/cf8c01e88f4770a6e3e5.png +1 -0
  112. package/dist/dfbcfeab1d5622a737e2.png +1 -0
  113. package/dist/e4893ed8c2f7b8329919.png +1 -0
  114. package/dist/ec2ab4eb4ef73d186186.png +1 -0
  115. package/dist/screenshoot.html +1 -1
  116. package/dist/screenshoot.js +452 -389
  117. package/index.html +3 -18
  118. package/order.html +32 -0
  119. package/package.json +13 -14
  120. package/src/chatbox/DropdownSelect.js +229 -0
  121. package/src/chatbox/Event.js +2 -2
  122. package/src/chatbox/Events.js +43 -42
  123. package/src/chatbox/Order.js +232 -0
  124. package/src/chatbox/OrderAttachments.js +2 -1
  125. package/src/chatbox/TextMessage.js +21 -12
  126. package/src/chatbox/Widget.js +34 -4
  127. package/src/chatbox/main.js +2 -2
  128. package/src/chatbox/spinner.js +1 -1
  129. package/src/chatbox/time.js +1 -1
  130. package/src/common.js +52 -8
  131. package/src/contact/contact.js +1 -1
  132. package/src/order/address_picker.js +235 -0
  133. package/src/order/icon.js +32 -0
  134. package/src/order/index.js +86 -0
  135. package/src/order/order.js +1157 -0
  136. package/src/order/scratch +211 -0
  137. package/src/plugin.js +7 -52
  138. package/src/popup/popup.js +27 -2
  139. package/src/store/api.js +26 -1
  140. package/src/store/store.js +46 -9
  141. package/src/util/common.js +52 -4
  142. package/webpack.dev.js +2 -0
  143. package/dist/17d938a5acb.178.js +0 -1
  144. package/dist/17d938a5acb.213.js +0 -1
  145. package/dist/17d938a5acb.362.js +0 -1
  146. package/dist/17d938a5acb.441.js +0 -1
  147. package/dist/17d938a5acb.605.js +0 -1
  148. package/dist/17d938a5acb.619.js +0 -1
  149. package/dist/17d938a5acb.678.js +0 -1
  150. package/dist/17d938a5acb.74.js +0 -1
  151. package/dist/17d938a5acb.782.js +0 -1
  152. package/dist/17d938a5acb.app.js +0 -1
  153. package/dist/17d938a5acb.library.js +0 -1
  154. package/dist/17d938a5acb.preview.js +0 -1
  155. package/dist/17d938a5acb.screenshoot.js +0 -1
  156. package/dist/619.js +0 -777
@@ -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({
@@ -424,7 +424,7 @@ var logo = __webpack_require__(8430);
424
424
 
425
425
 
426
426
 
427
- class PoweredBy extends common/* Com */.M {
427
+ class PoweredBy extends common/* Com */.up {
428
428
  constructor(props) {
429
429
  super(props);
430
430
  }
@@ -454,7 +454,7 @@ class PoweredBy extends common/* Com */.M {
454
454
 
455
455
 
456
456
 
457
- class AgentsAvatar extends common/* Com */.M {
457
+ class AgentsAvatar extends common/* Com */.up {
458
458
  constructor(props) {
459
459
  super(props);
460
460
  }
@@ -587,7 +587,7 @@ class AgentsAvatar extends common/* Com */.M {
587
587
 
588
588
 
589
589
 
590
- class Header extends common/* Com */.M {
590
+ class Header extends common/* Com */.up {
591
591
  constructor(props) {
592
592
  super(props);
593
593
  }
@@ -805,20 +805,13 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
805
805
 
806
806
  let getJoinedNameMember = agents => util/* default.map */.Z.map(agents, agent => agent.name).join(', ');
807
807
  ;// CONCATENATED MODULE: ./src/chatbox/MessageInput.js
808
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
809
808
 
810
809
 
811
810
 
812
811
 
813
-
814
- class MessageInput extends common/* Com */.M {
812
+ class MessageInput extends common/* Com */.up {
815
813
  constructor(props) {
816
814
  super(props);
817
-
818
- _defineProperty(this, "onEnter", util/* default.throttle */.Z.throttle(function () {
819
- this.submitMessage();
820
- }, 50));
821
-
822
815
  this.refFileInput = (0,preact_module/* createRef */.Vf)();
823
816
  this.refMessageInput = (0,preact_module/* createRef */.Vf)();
824
817
  this.props.store.onUpdate(this, _ => this.forceUpdate());
@@ -1056,6 +1049,10 @@ class MessageInput extends common/* Com */.M {
1056
1049
  input.focus();
1057
1050
  }
1058
1051
 
1052
+ onEnter = util/* default.throttle */.Z.throttle(function () {
1053
+ this.submitMessage();
1054
+ }, 50);
1055
+
1059
1056
  onKeydown(e) {
1060
1057
  if (e.keyCode === 13 && e.shiftKey === false) {
1061
1058
  this.onEnter();
@@ -1157,7 +1154,7 @@ function isSummited(form) {
1157
1154
 
1158
1155
 
1159
1156
 
1160
- class ImageAttachment extends common/* Com */.M {
1157
+ class ImageAttachment extends common/* Com */.up {
1161
1158
  constructor(props) {
1162
1159
  super(props);
1163
1160
  }
@@ -1207,7 +1204,7 @@ class ImageAttachment extends common/* Com */.M {
1207
1204
 
1208
1205
 
1209
1206
 
1210
- class AudioAttachments extends common/* Com */.M {
1207
+ class AudioAttachments extends common/* Com */.up {
1211
1208
  constructor(props) {
1212
1209
  super(props);
1213
1210
  }
@@ -1243,7 +1240,7 @@ class AudioAttachments extends common/* Com */.M {
1243
1240
 
1244
1241
 
1245
1242
 
1246
- class FileAttachments extends common/* Com */.M {
1243
+ class FileAttachments extends common/* Com */.up {
1247
1244
  render() {
1248
1245
  var byType = util/* default.get */.Z.get(this.props.ev, 'by.type', 'agent');
1249
1246
  var attachments = util/* default.get */.Z.get(this.props.ev, 'data.message.attachments', []);
@@ -1281,7 +1278,7 @@ class FileAttachments extends common/* Com */.M {
1281
1278
 
1282
1279
 
1283
1280
 
1284
- class Buttons extends common/* Com */.M {
1281
+ class Buttons extends common/* Com */.up {
1285
1282
  constructor(props) {
1286
1283
  super(props);
1287
1284
  }
@@ -1331,7 +1328,7 @@ class Buttons extends common/* Com */.M {
1331
1328
 
1332
1329
 
1333
1330
 
1334
- class ButtonAttachments extends common/* Com */.M {
1331
+ class ButtonAttachments extends common/* Com */.up {
1335
1332
  constructor(props) {
1336
1333
  super(props);
1337
1334
  }
@@ -1356,7 +1353,7 @@ class ButtonAttachments extends common/* Com */.M {
1356
1353
 
1357
1354
 
1358
1355
 
1359
- class QuickReplies extends common/* Com */.M {
1356
+ class QuickReplies extends common/* Com */.up {
1360
1357
  constructor(props) {
1361
1358
  super(props);
1362
1359
  }
@@ -1405,7 +1402,7 @@ class QuickReplies extends common/* Com */.M {
1405
1402
 
1406
1403
 
1407
1404
 
1408
- class ListField extends common/* Com */.M {
1405
+ class ListField extends common/* Com */.up {
1409
1406
  constructor(props) {
1410
1407
  super(props);
1411
1408
  this.setState({
@@ -1461,7 +1458,7 @@ class ListField extends common/* Com */.M {
1461
1458
 
1462
1459
  return (0,preact_module.h)("div", {
1463
1460
  class: "form-control custom-select"
1464
- }, (0,preact_module.h)(common/* Clickaway */.u, {
1461
+ }, (0,preact_module.h)(common/* Clickaway */.u$, {
1465
1462
  onClickaway: e => this.clickaway()
1466
1463
  }, (0,preact_module.h)("div", {
1467
1464
  class: "custom-select--wrap-selected",
@@ -1508,7 +1505,7 @@ class ListField extends common/* Com */.M {
1508
1505
 
1509
1506
 
1510
1507
 
1511
- class FormAttachment extends common/* Com */.M {
1508
+ class FormAttachment extends common/* Com */.up {
1512
1509
  constructor(props) {
1513
1510
  super(props);
1514
1511
  this.props.store.onUpdate(this, _ => this.forceUpdate());
@@ -1821,7 +1818,7 @@ function encode(key) {
1821
1818
 
1822
1819
 
1823
1820
 
1824
- class FormAttachments extends common/* Com */.M {
1821
+ class FormAttachments extends common/* Com */.up {
1825
1822
  constructor(props) {
1826
1823
  super(props);
1827
1824
  }
@@ -1866,7 +1863,7 @@ class FormAttachments extends common/* Com */.M {
1866
1863
 
1867
1864
 
1868
1865
 
1869
- class FormSubmitAttachments extends common/* Com */.M {
1866
+ class FormSubmitAttachments extends common/* Com */.up {
1870
1867
  constructor(props) {
1871
1868
  super(props);
1872
1869
  }
@@ -1939,7 +1936,7 @@ function getFirstTouch(ev) {
1939
1936
 
1940
1937
 
1941
1938
 
1942
- class GenericTemplateAttachments extends common/* Com */.M {
1939
+ class GenericTemplateAttachments extends common/* Com */.up {
1943
1940
  constructor(props) {
1944
1941
  super(props);
1945
1942
  this.state = {
@@ -2020,7 +2017,7 @@ class GenericTemplateAttachments extends common/* Com */.M {
2020
2017
 
2021
2018
 
2022
2019
 
2023
- class ProductAttachments extends common/* Com */.M {
2020
+ class ProductAttachments extends common/* Com */.up {
2024
2021
  render() {
2025
2022
  let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
2026
2023
  if (byType === 'user') return null;
@@ -2080,7 +2077,7 @@ class ProductAttachments extends common/* Com */.M {
2080
2077
 
2081
2078
 
2082
2079
 
2083
- class OrderAttachments_ProductAttachments extends common/* Com */.M {
2080
+ class OrderAttachments_ProductAttachments extends common/* Com */.up {
2084
2081
  render() {
2085
2082
  let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
2086
2083
  if (byType === 'user') return null;
@@ -2110,7 +2107,8 @@ class OrderAttachments_ProductAttachments extends common/* Com */.M {
2110
2107
  class: "order_attachment__product"
2111
2108
  }, (0,preact_module.h)("img", {
2112
2109
  class: "order_attachment__product_img",
2113
- src: (util/* default.get */.Z.get(product, 'images.0'), __webpack_require__(9270))
2110
+ alt: '' + util/* default.get */.Z.get(product, 'id'),
2111
+ src: util/* default.get */.Z.get(product, 'images.0', __webpack_require__(9270))
2114
2112
  }), (0,preact_module.h)("div", {
2115
2113
  style: "overflow: hidden !important;"
2116
2114
  }, (0,preact_module.h)("div", {
@@ -2166,7 +2164,7 @@ class OrderAttachments_ProductAttachments extends common/* Com */.M {
2166
2164
 
2167
2165
 
2168
2166
 
2169
- class VideoAttachments extends common/* Com */.M {
2167
+ class VideoAttachments extends common/* Com */.up {
2170
2168
  constructor(props) {
2171
2169
  super(props);
2172
2170
  }
@@ -2203,7 +2201,7 @@ class VideoAttachments extends common/* Com */.M {
2203
2201
  ;// CONCATENATED MODULE: ./src/chatbox/ShadowDomRoot.js
2204
2202
 
2205
2203
 
2206
- class ShadowDomRoot extends common/* Com */.M {
2204
+ class ShadowDomRoot extends common/* Com */.up {
2207
2205
  constructor(props) {
2208
2206
  super(props);
2209
2207
  this.ref = (0,preact_module/* createRef */.Vf)();
@@ -2266,7 +2264,7 @@ const loadMarked = () => __webpack_require__.e(/* import() */ 441).then(__webpac
2266
2264
 
2267
2265
 
2268
2266
 
2269
- class TextMessage extends common/* Com */.M {
2267
+ class TextMessage extends common/* Com */.up {
2270
2268
  render() {
2271
2269
  var format = util/* default.get */.Z.get(this.props.ev, 'data.message.format', 'plaintext');
2272
2270
  if (format === 'markdown') return this.renderMarkdown();
@@ -2281,9 +2279,16 @@ class TextMessage extends common/* Com */.M {
2281
2279
  });
2282
2280
 
2283
2281
  if (tag.type === 'link') {
2282
+ let url = tag.text || '';
2283
+
2284
+ if (!url.startsWith('//') && !url.startsWith('https://') && !url.startsWith('http://') && !url.startsWith('data:')) {
2285
+ url = '//' + url;
2286
+ }
2287
+
2284
2288
  return (0,preact_module.h)("a", {
2285
- href: tag.text,
2286
- target: "_blank"
2289
+ href: url,
2290
+ target: "_blank",
2291
+ onClick: e => this.props.onLink(e, url)
2287
2292
  }, tag.text);
2288
2293
  }
2289
2294
 
@@ -2339,7 +2344,7 @@ var g_pub = new util/* default.Pubsub */.Z.Pubsub();
2339
2344
  setInterval(() => g_pub.publish('time'), 20 * 1000);
2340
2345
 
2341
2346
 
2342
- class Time extends common/* Com */.M {
2347
+ class Time extends common/* Com */.up {
2343
2348
  constructor(props) {
2344
2349
  super(props);
2345
2350
  this.setState({
@@ -2381,7 +2386,9 @@ class Time extends common/* Com */.M {
2381
2386
  }
2382
2387
 
2383
2388
  render() {
2384
- return (0,preact_module.h)("span", null, this.state.t);
2389
+ return (0,preact_module.h)("span", {
2390
+ style: this.props.style
2391
+ }, this.state.t);
2385
2392
  }
2386
2393
 
2387
2394
  }
@@ -2475,7 +2482,7 @@ function getRateLang(rating) {
2475
2482
 
2476
2483
 
2477
2484
 
2478
- class InfoMessage extends common/* Com */.M {
2485
+ class InfoMessage extends common/* Com */.up {
2479
2486
  render() {
2480
2487
  let ev = this.props.ev.ev;
2481
2488
  var $time = null;
@@ -2531,7 +2538,7 @@ class InfoMessage extends common/* Com */.M {
2531
2538
 
2532
2539
 
2533
2540
 
2534
- class Event extends common/* Com */.M {
2541
+ class Event extends common/* Com */.up {
2535
2542
  constructor(props) {
2536
2543
  super(props);
2537
2544
  this.refForm = (0,preact_module/* createRef */.Vf)();
@@ -2653,7 +2660,8 @@ class Event extends common/* Com */.M {
2653
2660
  title: t
2654
2661
  }, $time, $sender, (0,preact_module.h)(TextMessage, {
2655
2662
  store: this.props.store,
2656
- ev: ev
2663
+ ev: ev,
2664
+ onLink: this.props.onLink
2657
2665
  }), (0,preact_module.h)(ImageAttachment, {
2658
2666
  store: this.props.store,
2659
2667
  ev: ev
@@ -2740,7 +2748,8 @@ class Event extends common/* Com */.M {
2740
2748
  }, $dot, (0,preact_module.h)(TextMessage, {
2741
2749
  store: this.props.store,
2742
2750
  ev: ev,
2743
- refresh: this.state.refresh
2751
+ refresh: this.state.refresh,
2752
+ onLink: this.props.onLink
2744
2753
  }), (0,preact_module.h)(ImageAttachment, {
2745
2754
  store: this.props.store,
2746
2755
  ev: ev
@@ -2807,7 +2816,7 @@ const loadingimg = __webpack_require__(6484);
2807
2816
 
2808
2817
 
2809
2818
 
2810
- class Spinner extends common/* Com */.M {
2819
+ class Spinner extends common/* Com */.up {
2811
2820
  render() {
2812
2821
  let mode = (this.props.mode + '').toLowerCase();
2813
2822
  let mainColor = mode === 'dark' ? '#000000dd' : mode === 'blue' ? 'rgba(52, 152, 220, .8)' : '#ffffffdd';
@@ -2819,7 +2828,7 @@ class Spinner extends common/* Com */.M {
2819
2828
  border-bottom-color: ${borderColor} !important;border-right-color: ${mainColor} !important;`;
2820
2829
 
2821
2830
  if (this.props.static) {
2822
- let style = `width: ${size}px;height: ${size}px;`;
2831
+ let style = `width: ${size}px !important;height: ${size}px !important;`;
2823
2832
  if (size < 40) return (0,preact_module.h)(LoaderIcon, {
2824
2833
  size: size + '',
2825
2834
  style: `stroke:${mainColor}`
@@ -2859,7 +2868,7 @@ const convoemptyimg = __webpack_require__(6188);
2859
2868
 
2860
2869
 
2861
2870
 
2862
- class Events extends common/* Com */.M {
2871
+ class Events extends common/* Com */.up {
2863
2872
  constructor(props) {
2864
2873
  super(props);
2865
2874
  this.props.store.onUpdate(this, _ => this.forceUpdate());
@@ -2904,6 +2913,7 @@ class Events extends common/* Com */.M {
2904
2913
  }));
2905
2914
  processEvents(convo, events);
2906
2915
  let $events = util/* default.map */.Z.map(events, ev => (0,preact_module.h)(Event, {
2916
+ onLink: this.props.onLink,
2907
2917
  store: this.props.store,
2908
2918
  onFormSubmit: this.props.onFormSubmit,
2909
2919
  onSend: this.props.onSend,
@@ -3110,7 +3120,7 @@ function Events_isSummited(form) {
3110
3120
 
3111
3121
 
3112
3122
 
3113
- class Typing extends common/* Com */.M {
3123
+ class Typing extends common/* Com */.up {
3114
3124
  constructor(props) {
3115
3125
  super(props);
3116
3126
  }
@@ -3226,8 +3236,6 @@ function eqFloat(a, b) {
3226
3236
  return Math.abs(a - b) <= 0.001;
3227
3237
  }
3228
3238
  ;// CONCATENATED MODULE: ./src/chatbox/Rating.js
3229
- function Rating_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; }
3230
-
3231
3239
 
3232
3240
 
3233
3241
  const POPUP_MAX_HEIGHT = 400;
@@ -3235,22 +3243,21 @@ const POPUP_HARD_MAX_HEIGHT = 500;
3235
3243
  const POPUP_MIN_HEIGHT = 0;
3236
3244
 
3237
3245
 
3238
- class Rating extends common/* Com */.M {
3246
+ class Rating extends common/* Com */.up {
3239
3247
  constructor(props) {
3240
3248
  super(props);
3241
-
3242
- Rating_defineProperty(this, "state", {
3243
- hide: true,
3244
- ratingHeight: 0,
3245
- overlayOpacity: 0.3,
3246
- comment: ''
3247
- });
3248
-
3249
3249
  this.refComment = (0,preact_module/* createRef */.Vf)();
3250
3250
  this.refRating = (0,preact_module/* createRef */.Vf)();
3251
3251
  this.refHandle = (0,preact_module/* createRef */.Vf)();
3252
3252
  }
3253
3253
 
3254
+ state = {
3255
+ hide: true,
3256
+ ratingHeight: 0,
3257
+ overlayOpacity: 0.3,
3258
+ comment: ''
3259
+ };
3260
+
3254
3261
  componentDidMount() {
3255
3262
  this.props.store.onUpdate(this, () => {
3256
3263
  if (this.shoudDisplay()) this.open();
@@ -3514,162 +3521,2085 @@ class Rating extends common/* Com */.M {
3514
3521
  }
3515
3522
 
3516
3523
  }
3517
- ;// CONCATENATED MODULE: ./src/chatbox/Widget.js
3524
+ ;// CONCATENATED MODULE: ./src/chatbox/DropdownSelect.js
3518
3525
 
3519
3526
 
3520
3527
 
3521
3528
 
3529
+ class DropdownSelect extends common/* Com */.up {
3530
+ state = {
3531
+ show: false,
3532
+ searchValue: ''
3533
+ };
3534
+ filterRef = (0,preact_module/* createRef */.Vf)();
3535
+ overlayRef = (0,preact_module/* createRef */.Vf)();
3522
3536
 
3537
+ constructor(props) {
3538
+ super(props);
3539
+ document.addEventListener('touchmove', function (e) {});
3540
+ }
3523
3541
 
3524
- var send = __webpack_require__(9737);
3542
+ onTouchMove = e => {
3543
+ if (e.target === this.overlayRef.current) {
3544
+ e.preventDefault();
3545
+ e.stopPropagation();
3546
+ }
3547
+ };
3548
+ hideDropdown = () => {
3549
+ this.setState({
3550
+ show: false,
3551
+ searchValue: ''
3552
+ });
3553
+ };
3554
+ onKeydown = e => {
3555
+ if (e.key === 'Escape') {
3556
+ if (!this.state.show) return;
3557
+ if (this.state.searchValue) this.setState({
3558
+ searchValue: ''
3559
+ });else this.hideDropdown();
3560
+ e.preventDefault();
3561
+ e.stopPropagation();
3562
+ }
3563
+ };
3564
+ hasSearch = () => {
3565
+ if (this.props.has_search) return true;
3566
+ return util/* default.size */.Z.size(this.props.items) >= 10;
3567
+ };
3568
+ getFilteredOptions = () => {
3569
+ let items = this.props.items;
3570
+
3571
+ if (this.state.searchValue && this.hasSearch()) {
3572
+ items = util/* default.filter */.Z.filter(items, item => {
3573
+ let optionName = util/* default.unicodeToAscii */.Z.unicodeToAscii(item.name).toLowerCase().replace(/ /g, '');
3574
+ let optionDesc = util/* default.unicodeToAscii */.Z.unicodeToAscii(item.desc).toLowerCase().replace(/ /g, '');
3575
+ let searchValue = util/* default.unicodeToAscii */.Z.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g, '');
3576
+ return optionName.indexOf(searchValue) != -1 || optionDesc.indexOf(searchValue) != -1;
3577
+ });
3578
+ }
3525
3579
 
3526
- var checkedimg = __webpack_require__(8909);
3580
+ return items;
3581
+ };
3527
3582
 
3528
- var empty = __webpack_require__(29);
3583
+ componentDidMount() {
3584
+ window.addEventListener('keydown', this.onKeydown);
3585
+ }
3529
3586
 
3587
+ componentWillUnmount() {
3588
+ window.removeEventListener('keydown', this.onKeydown);
3589
+ }
3590
+
3591
+ onChangeSearchValue = e => {
3592
+ this.setState({
3593
+ searchValue: e.target.value
3594
+ });
3595
+ };
3596
+
3597
+ renderEmpty() {
3598
+ return (0,preact_module.h)("div", {
3599
+ class: "dropdown_select_filter__empty"
3600
+ }, (0,preact_module.h)("img", {
3601
+ class: "dropdown_select_filter__empty_img",
3602
+ src: __webpack_require__(6071)
3603
+ }), (0,preact_module.h)("div", {
3604
+ class: "muted",
3605
+ style: "text-align: center !important;"
3606
+ }, "Kh\xF4ng c\xF3 k\u1EBFt qu\u1EA3"));
3607
+ }
3530
3608
 
3609
+ renderLoading() {
3610
+ return (0,preact_module.h)("div", {
3611
+ class: "dropdown_select_filter__empty pt-3"
3612
+ }, (0,preact_module.h)(Spinner, {
3613
+ size: "40",
3614
+ static: true
3615
+ }), (0,preact_module.h)("div", {
3616
+ class: "muted mt-2",
3617
+ style: "text-align: center !important;"
3618
+ }, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
3619
+ }
3531
3620
 
3621
+ toogleDropdown = async () => {
3622
+ await this.setState({
3623
+ show: true,
3624
+ searchValue: ''
3625
+ });
3626
+ this.focusFilter();
3627
+ };
3532
3628
 
3629
+ focusFilter() {
3630
+ if (!this.filterRef.current) return;
3631
+ this.filterRef.current.focus();
3632
+ setTimeout(() => {
3633
+ if (!this.filterRef.current) return;
3634
+ this.filterRef.current.focus();
3635
+ }, 100);
3636
+ }
3533
3637
 
3638
+ onSelect = item => {
3639
+ this.props.onSelect(item);
3640
+ this.hideDropdown();
3641
+ };
3534
3642
 
3535
- const Widget_defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png';
3643
+ renderDropdown() {
3644
+ if (!this.state.show) return null;
3645
+ let items = this.getFilteredOptions();
3646
+ let $items = util/* default.map */.Z.map(items, item => {
3647
+ return (0,preact_module.h)("div", {
3648
+ class: "dropdown_select__item",
3649
+ onClick: _ => this.onSelect(item)
3650
+ }, item.name);
3651
+ });
3652
+ let $filter = null;
3653
+
3654
+ if (this.hasSearch()) {
3655
+ let $img = (0,preact_module.h)("img", {
3656
+ class: "dropdown_select_filter__icon",
3657
+ src: __webpack_require__(636)
3658
+ });
3659
+
3660
+ if (this.props.loading) {
3661
+ $img = (0,preact_module.h)("img", {
3662
+ class: "dropdown_select_filter__icon",
3663
+ src: __webpack_require__(5770)
3664
+ });
3665
+ }
3666
+
3667
+ $filter = (0,preact_module.h)("div", {
3668
+ class: "dropdown_select_filter"
3669
+ }, $img, (0,preact_module.h)("input", {
3670
+ ref: this.filterRef,
3671
+ value: this.state.searchValue,
3672
+ onInput: this.onChangeSearchValue,
3673
+ type: "text",
3674
+ class: "dropdown_select_filter_input "
3675
+ }));
3676
+ }
3677
+
3678
+ if ($items.length == 0) $items = this.renderEmpty();
3679
+ if (this.props.loading) $items = this.renderLoading();
3680
+ let style = `width: ${this.props.width || '150px'} !important;`;
3681
+
3682
+ if (this.props.full) {
3683
+ style = ` top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; `;
3684
+ return (0,preact_module.h)("div", {
3685
+ class: "dropdown_select__overlay",
3686
+ ref: this.overlayRef,
3687
+ onClick: this.hideDropdown,
3688
+ onTouchMove: this.onTouchMove
3689
+ }, (0,preact_module.h)("div", {
3690
+ class: "dropdown_select",
3691
+ style: style,
3692
+ onClick: e => {
3693
+ e.preventDefault();
3694
+ e.stopPropagation();
3695
+ }
3696
+ }, $filter, (0,preact_module.h)("div", {
3697
+ class: "dropdown_select__items"
3698
+ }, $items)));
3699
+ }
3700
+
3701
+ return (0,preact_module.h)("div", {
3702
+ class: "dropdown_select",
3703
+ style: style
3704
+ }, $filter, (0,preact_module.h)("div", {
3705
+ class: "dropdown_select__items"
3706
+ }, $items));
3707
+ }
3708
+
3709
+ onBackgroundScroll = e => {
3710
+ console.log('EEEEEEE', e);
3711
+ alert('y');
3712
+ };
3713
+
3714
+ render() {
3715
+ let $name = (0,preact_module.h)("div", {
3716
+ class: "muted text-truncate",
3717
+ style: "flex: 1 !important;"
3718
+ }, "Ch\u1ECDn m\u1ED9t ph\u1EA7n t\u1EED");
3719
+ if (util/* default.get */.Z.get(this.props, 'selected.name')) $name = (0,preact_module.h)("div", {
3720
+ class: "text-truncate",
3721
+ style: "flex: 1 !important;"
3722
+ }, util/* default.get */.Z.get(this.props, 'selected.name'));
3723
+ let style = 'position: relative !important;';
3724
+
3725
+ if (this.props.full) {
3726
+ style = '';
3727
+ }
3728
+
3729
+ return (0,preact_module.h)("div", {
3730
+ style: style
3731
+ }, (0,preact_module.h)(common/* Clickaway */.u$, {
3732
+ onClickaway: this.hideDropdown
3733
+ }, (0,preact_module.h)("div", {
3734
+ type: "text",
3735
+ class: 'dropdown_select_input ' + this.props.extra_cls,
3736
+ onClick: this.toogleDropdown
3737
+ }, $name, "\xA0", (0,preact_module.h)("img", {
3738
+ class: "dropdown_select__caret",
3739
+ src: __webpack_require__(8712)
3740
+ })), this.renderDropdown()));
3741
+ }
3742
+
3743
+ }
3744
+ ;// CONCATENATED MODULE: ./src/order/address_picker.js
3536
3745
 
3537
3746
 
3538
3747
 
3539
3748
 
3540
- class Widget extends common/* Com */.M {
3749
+ class AddressPicker extends common/* Com */.up {
3750
+ state = {
3751
+ show: false,
3752
+ searchValue: '',
3753
+ addresses: []
3754
+ };
3755
+ filterRef = (0,preact_module/* createRef */.Vf)();
3756
+ overlayRef = (0,preact_module/* createRef */.Vf)();
3757
+
3541
3758
  constructor(props) {
3542
3759
  super(props);
3543
- this.userSent = {};
3760
+ document.addEventListener('touchmove', function (e) {});
3761
+ }
3762
+
3763
+ onTouchMove = e => {
3764
+ if (e.target === this.overlayRef.current) {
3765
+ e.preventDefault();
3766
+ e.stopPropagation();
3767
+ }
3768
+ };
3769
+ hideDropdown = () => {
3544
3770
  this.setState({
3545
- creating: false,
3546
- clickedJoin: false,
3547
- formData: {}
3771
+ show: false,
3772
+ searchValue: ''
3548
3773
  });
3549
- this.props.store.onUpdate(this, _ => this.forceUpdate());
3550
- }
3774
+ };
3775
+ onKeydown = e => {
3776
+ if (e.key === 'Escape') {
3777
+ if (!this.state.show) return;
3778
+ if (this.state.searchValue) this.setState({
3779
+ searchValue: ''
3780
+ });else this.hideDropdown();
3781
+ e.preventDefault();
3782
+ e.stopPropagation();
3783
+ }
3784
+
3785
+ if (e.key == 'Enter') {}
3786
+ };
3787
+ doSearch = util/* default.throttle */.Z.throttle(async () => {
3788
+ let requestId = Date.now();
3789
+ this.requestId = requestId;
3790
+ let res = await this.props.store.suggest_addresses(this.state.searchValue);
3791
+ if (this.requestId !== requestId) return;
3792
+ this.setState({
3793
+ addresses: util/* default.get */.Z.get(res, 'body.addresses', [])
3794
+ });
3795
+ }, 100);
3551
3796
 
3552
3797
  componentDidMount() {
3553
- if (!this.props.store.isMobile()) this.focusInput();
3798
+ window.addEventListener('keydown', this.onKeydown);
3554
3799
  }
3555
3800
 
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
- }
3801
+ componentWillUnmount() {
3802
+ window.removeEventListener('keydown', this.onKeydown);
3803
+ }
3561
3804
 
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
- }
3805
+ onChangeSearchValue = e => {
3806
+ this.setState({
3807
+ searchValue: e.target.value
3808
+ });
3809
+ this.props.onChangeAddress(e.target.value);
3810
+ this.doSearch();
3811
+ };
3571
3812
 
3572
- this.updateFormDataFields();
3813
+ renderEmpty() {
3814
+ return (0,preact_module.h)("div", {
3815
+ class: "dropdown_select_filter__empty"
3816
+ }, (0,preact_module.h)("img", {
3817
+ class: "dropdown_select_filter__empty_img",
3818
+ src: __webpack_require__(6071)
3819
+ }), (0,preact_module.h)("div", {
3820
+ class: "muted",
3821
+ style: "text-align: center !important;"
3822
+ }, "Kh\xF4ng c\xF3 k\u1EBFt qu\u1EA3"));
3573
3823
  }
3574
3824
 
3575
- shouldShowForm() {
3576
- let formRequired = this.isFormRequired();
3577
- return formRequired && !this.props.cid || formRequired && this.props.cid && this.state.clickedJoin;
3825
+ renderLoading() {
3826
+ return (0,preact_module.h)("div", {
3827
+ class: "dropdown_select_filter__empty pt-3"
3828
+ }, (0,preact_module.h)(Spinner, {
3829
+ size: "40",
3830
+ static: true
3831
+ }), (0,preact_module.h)("div", {
3832
+ class: "muted mt-2",
3833
+ style: "text-align: center !important;"
3834
+ }, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
3578
3835
  }
3579
3836
 
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');
3837
+ toogleDropdown = async () => {
3838
+ await this.setState({
3839
+ show: true,
3840
+ searchValue: this.props.initAddress || ''
3841
+ });
3842
+ this.focusFilter();
3843
+ };
3589
3844
 
3590
- if (this.isOffline(acc, accountSetting) && offlineEnabled) {
3591
- form = accountSetting.offline_form;
3592
- submitLabel = this.props.t('offline_form_btn');
3845
+ focusFilter() {
3846
+ if (!this.filterRef.current) return;
3847
+ this.filterRef.current.focus();
3848
+ setTimeout(() => {
3849
+ if (!this.filterRef.current) return;
3850
+ this.filterRef.current.focus();
3851
+ }, 100);
3852
+ }
3853
+
3854
+ onSelect = item => {
3855
+ this.props.onSelect(item);
3856
+ this.hideDropdown();
3857
+ };
3858
+
3859
+ renderDropdown() {
3860
+ if (!this.state.show) return null;
3861
+ let $items = util/* default.map */.Z.map(this.state.addresses, (addr, i) => {
3862
+ let label = [((addr.address || '') + ' ' + normalize(addr.street)).trim()].join(', ');
3863
+ let desc = [normalize(addr.ward), normalize(addr.district), normalize(addr.province)].join(', ');
3864
+ return (0,preact_module.h)("div", {
3865
+ class: "dropdown_select__item",
3866
+ onClick: _ => this.onSelect(addr),
3867
+ key: i
3868
+ }, (0,preact_module.h)("div", null, (0,preact_module.h)("b", null, label)), (0,preact_module.h)("div", {
3869
+ style: "opacity: 0.7 !important;"
3870
+ }, desc));
3871
+ });
3872
+ let $filter = null;
3873
+ let $img = (0,preact_module.h)("img", {
3874
+ class: "dropdown_select_filter__icon",
3875
+ src: __webpack_require__(636)
3876
+ });
3877
+
3878
+ if (this.props.loading) {
3879
+ $img = (0,preact_module.h)("img", {
3880
+ class: "dropdown_select_filter__icon",
3881
+ src: __webpack_require__(5770)
3882
+ });
3593
3883
  }
3594
3884
 
3595
- if (this.props.view === 'offline_form') {
3596
- showform = true;
3597
- form = accountSetting.offline_form;
3598
- submitLabel = this.props.t('offline_form_btn');
3885
+ $filter = (0,preact_module.h)("div", {
3886
+ class: "dropdown_select_filter"
3887
+ }, $img, (0,preact_module.h)("input", {
3888
+ ref: this.filterRef,
3889
+ value: this.state.searchValue,
3890
+ onInput: this.onChangeSearchValue,
3891
+ type: "text",
3892
+ class: "dropdown_select_filter_input "
3893
+ }));
3894
+ if ($items.length == 0) $items = this.renderEmpty();
3895
+ if (this.props.loading) $items = this.renderLoading();
3896
+ let style = `width: ${this.props.width || '150px'} !important;`;
3897
+
3898
+ if (this.props.full) {
3899
+ style = ` top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; `;
3900
+ return (0,preact_module.h)("div", {
3901
+ class: "dropdown_select__overlay",
3902
+ ref: this.overlayRef,
3903
+ onClick: this.hideDropdown,
3904
+ onTouchMove: this.onTouchMove
3905
+ }, (0,preact_module.h)("div", {
3906
+ class: "dropdown_select",
3907
+ style: style,
3908
+ onClick: e => {
3909
+ e.preventDefault();
3910
+ e.stopPropagation();
3911
+ }
3912
+ }, $filter, (0,preact_module.h)("div", {
3913
+ class: "dropdown_select__items"
3914
+ }, $items)));
3599
3915
  }
3600
3916
 
3601
- if (this.props.view === 'prechat_form') {
3602
- showform = true;
3603
- form = accountSetting.prechat_form;
3604
- submitLabel = this.props.t('prechat_form_btn');
3917
+ return (0,preact_module.h)("div", {
3918
+ class: "dropdown_select",
3919
+ style: style
3920
+ }, $filter, (0,preact_module.h)("div", {
3921
+ class: "dropdown_select__items"
3922
+ }, $items));
3923
+ }
3924
+
3925
+ onBackgroundScroll = e => {
3926
+ console.log('EEEEEEE', e);
3927
+ };
3928
+
3929
+ render() {
3930
+ let $name = (0,preact_module.h)("div", {
3931
+ class: "text-truncate",
3932
+ style: "flex: 1 !important;"
3933
+ }, this.props.initAddress);
3934
+ let style = 'position: relative !important;';
3935
+
3936
+ if (this.props.full) {
3937
+ style = '';
3605
3938
  }
3606
3939
 
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
3940
  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);
3941
+ style: style
3942
+ }, (0,preact_module.h)(common/* Clickaway */.u$, {
3943
+ onClickaway: this.hideDropdown
3944
+ }, (0,preact_module.h)("div", {
3945
+ type: "text",
3946
+ class: 'dropdown_select_input ' + this.props.extra_cls,
3947
+ onClick: this.toogleDropdown
3948
+ }, $name), this.renderDropdown()));
3626
3949
  }
3627
3950
 
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 = '';
3951
+ }
3635
3952
 
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
- }
3953
+ function normalize(s) {
3954
+ let ls = (s + '').toLowerCase();
3955
+ if (ls.startsWith('tp ')) return s.substr(3);
3956
+ if (ls.startsWith('thanh pho ')) return s.substr('thanh pho '.length);
3957
+ if (ls.startsWith('thành phố ')) return s.substr('thành phố '.length);
3958
+ if (ls.startsWith('tỉnh ')) return s.substr('tỉnh '.length);
3959
+ if (ls.startsWith('huyện ')) return s.substr('huyện '.length);
3960
+ if (ls.startsWith('tỉnh ')) return s.substr('tỉnh '.length);
3961
+ if (ls.startsWith('xã ')) return s.substr('xã '.length);
3962
+ if (ls.startsWith('thị trấn ')) return s.substr('thị trấn '.length);
3963
+ if (ls.startsWith('thị xã ')) return s.substr('thị xã '.length);
3964
+ if (ls.startsWith('đường ') && (s[7] < '0' || s[7] > '9')) return s.substr('đường '.length);
3965
+ if (ls.startsWith('phường ') && (s[7] < '0' || s[7] > '9')) return s.substr('phường '.length);
3966
+ if (ls.startsWith('quận ') && (s[7] < '0' || s[7] > '9')) return s.substr('quận '.length);
3967
+ return s;
3968
+ }
3969
+ ;// CONCATENATED MODULE: ./src/order/icon.js
3640
3970
 
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
- }
3645
- });
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);
3659
- });
3660
- let firstmsg = util/* default.get */.Z.get(data, 'question.value');
3661
- let groupid = util/* default.get */.Z.get(data, 'group.value', '');
3662
3971
 
3663
- if (this.props.cid) {
3664
- this.props.store.setUser(user);
3665
- 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: [{
3972
+ let promiseMainCSS = (() => __webpack_require__.e(/* import() */ 178).then(__webpack_require__.bind(__webpack_require__, 178)))();
3973
+
3974
+ var $link = document.createElement('link');
3975
+ $link.href = 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap';
3976
+ $link.rel = 'stylesheet';
3977
+ document.head.append($link);
3978
+ util/* default.preloadWebfonts */.Z.preloadWebfonts(['Roboto'], [400, 500]);
3979
+
3980
+
3981
+ let icon_defaultAvatar = __webpack_require__(4761);
3982
+
3983
+
3984
+
3985
+
3986
+ class Icon extends common/* Com */.up {
3987
+ render() {
3988
+ if (this.props.name == 'package') {
3989
+ if (this.props.active) return (0,preact_module.h)("img", {
3990
+ style: "width: 18px !important;",
3991
+ src: __webpack_require__(25)
3992
+ });
3993
+ return (0,preact_module.h)("img", {
3994
+ style: "width: 18px !important;",
3995
+ src: __webpack_require__(1216)
3996
+ });
3997
+ }
3998
+
3999
+ if (this.props.name === 'shop') {
4000
+ if (this.props.active) return (0,preact_module.h)("img", {
4001
+ style: "width: 18px !important;",
4002
+ src: __webpack_require__(6180)
4003
+ });
4004
+ return (0,preact_module.h)("img", {
4005
+ style: "width: 18px !important;",
4006
+ src: __webpack_require__(750)
4007
+ });
4008
+ }
4009
+ }
4010
+
4011
+ }
4012
+ ;// CONCATENATED MODULE: ./src/order/order.js
4013
+
4014
+
4015
+
4016
+
4017
+
4018
+
4019
+
4020
+
4021
+
4022
+ var checkedimg = __webpack_require__(763);
4023
+
4024
+ var ximg = __webpack_require__(2514);
4025
+
4026
+ class order_Order extends common/* Com */.up {
4027
+ state = {
4028
+ loadProvince: true,
4029
+ g_err: '',
4030
+ fullname: '',
4031
+ email: '',
4032
+ phone: '',
4033
+ loading: true,
4034
+ order: {},
4035
+ err: {},
4036
+ selectedProvince: null,
4037
+ selectedDistrict: null,
4038
+ selectedWard: null,
4039
+ street: '',
4040
+ address: '',
4041
+ sending: false,
4042
+ step: ''
4043
+ };
4044
+
4045
+ constructor(props) {
4046
+ super(props);
4047
+ this.load();
4048
+ }
4049
+
4050
+ async load() {
4051
+ if (!this.props.order_id) return;
4052
+ let orderout = await this.props.store.fetchOrder(this.props.order_id);
4053
+ this.setState({
4054
+ loading: false
4055
+ });
4056
+
4057
+ if (!orderout.error) {
4058
+ this.setState({
4059
+ order: orderout.body
4060
+ });
4061
+ } else {
4062
+ this.setState({
4063
+ error: orderout.error
4064
+ });
4065
+ }
4066
+
4067
+ let user = this.props.store.matchUser();
4068
+ let attributes = util/* default.get */.Z.get(this.props.store.matchUser(), 'attributes', []);
4069
+ let fullname = util/* default.get */.Z.get(util/* default.find */.Z.find(attributes, att => att.key === 'fullname'), 'text');
4070
+ let email = util/* default.get */.Z.get(util/* default.find */.Z.find(attributes, att => att.key === 'emails'), 'text');
4071
+ let phone = util/* default.get */.Z.get(util/* default.find */.Z.find(attributes, att => att.key === 'phones'), 'text');
4072
+ this.setState({
4073
+ fullname,
4074
+ email,
4075
+ phone
4076
+ });
4077
+ await this.props.store.fetchShippingAddresses();
4078
+ let out = await this.props.store.list_provinces();
4079
+ this.setState({
4080
+ loadProvince: false
4081
+ });
4082
+ if (!out.error) this.setState({
4083
+ provinces: util/* default.get */.Z.get(out, 'body.addresses')
4084
+ });
4085
+ }
4086
+
4087
+ isMobile() {
4088
+ if (this.props.cid) return true;
4089
+ if (this.props.isMobile) return true;
4090
+ return this.props.store.isMobile();
4091
+ }
4092
+
4093
+ onChangeShippingAddress(id) {
4094
+ this.setState({
4095
+ shipping_address: id,
4096
+ err: {},
4097
+ g_err: ''
4098
+ });
4099
+ }
4100
+
4101
+ renderMobileSuccess = order => {
4102
+ return (0,preact_module.h)("div", {
4103
+ class: "order",
4104
+ style: "height: 100% !important"
4105
+ }, (0,preact_module.h)("div", {
4106
+ style: "display: flex !important; align-items: center !important; padding-top: 40px !important; padding-bottom: 20px !important; flex-direction: column !important; height: 100% !important"
4107
+ }, (0,preact_module.h)("img", {
4108
+ style: "width: 60px !important; height: 60px !important;",
4109
+ width: "60",
4110
+ height: "60",
4111
+ src: checkedimg
4112
+ }), (0,preact_module.h)("div", {
4113
+ style: "margin-top: 20px !important; margin-bottom: 10px !important"
4114
+ }, (0,preact_module.h)("b", {
4115
+ style: "font-size: 18px !important;"
4116
+ }, "\u0110\u01A1n h\xE0ng c\u1EE7a b\u1EA1n \u0111\xE3 \u0111\u01B0\u1EE3c ghi nh\u1EADn")), (0,preact_module.h)("div", {
4117
+ class: "muted"
4118
+ }, "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", {
4119
+ style: "flex:1 !important"
4120
+ }), (0,preact_module.h)("div", {
4121
+ style: "margin-top: 20px !important; padding: 0px 20px 0 20px !important; width: 100% !important"
4122
+ }, (0,preact_module.h)("div", {
4123
+ class: "order_btn order__btn__light",
4124
+ onClick: this.close
4125
+ }, this.props.t('close')))));
4126
+ };
4127
+
4128
+ onChangeShipping(id) {
4129
+ this.setState({
4130
+ shipping: id,
4131
+ err: {},
4132
+ g_err: ''
4133
+ });
4134
+ }
4135
+
4136
+ onSelectProvince = async item => {
4137
+ this.setState({
4138
+ selectedProvince: item,
4139
+ err: {},
4140
+ g_err: ''
4141
+ });
4142
+ this.setState({
4143
+ loadDistrict: true
4144
+ });
4145
+ let out = await this.props.store.list_districts({
4146
+ id: item.id
4147
+ });
4148
+ this.setState({
4149
+ loadDistrict: false
4150
+ });
4151
+ if (!out.error) this.setState({
4152
+ districts: util/* default.get */.Z.get(out, 'body.addresses')
4153
+ });
4154
+ };
4155
+ onSelectDistrict = async item => {
4156
+ this.setState({
4157
+ selectedDistrict: item,
4158
+ err: {},
4159
+ g_err: ''
4160
+ });
4161
+ this.setState({
4162
+ loadWard: true
4163
+ });
4164
+ let out = await this.props.store.list_wards({
4165
+ id: item.id
4166
+ });
4167
+ this.setState({
4168
+ loadWard: false
4169
+ });
4170
+ if (!out.error) this.setState({
4171
+ wards: util/* default.get */.Z.get(out, 'body.addresses')
4172
+ });
4173
+ };
4174
+ onSelectWard = item => this.setState({
4175
+ selectedWard: item,
4176
+ err: {},
4177
+ g_err: ''
4178
+ });
4179
+ onChangeFullname = e => this.setState({
4180
+ fullname: e.target.value,
4181
+ err: {},
4182
+ g_err: ''
4183
+ });
4184
+ onChangeAddress = e => this.setState({
4185
+ address: e,
4186
+ err: {},
4187
+ g_err: ''
4188
+ });
4189
+ onSelectAddress = addr => {
4190
+ if (!addr) return;
4191
+ this.setState({
4192
+ address: [util/* default.trim */.Z.trim(addr.address), util/* default.trim */.Z.trim(addr.street)].join(' ').trim(),
4193
+ street: addr.street,
4194
+ err: {},
4195
+ g_err: ''
4196
+ });
4197
+ this.onSelectWard({
4198
+ id: addr.ward_id,
4199
+ name: addr.ward
4200
+ });
4201
+ this.onSelectDistrict({
4202
+ id: addr.district_id,
4203
+ name: addr.district
4204
+ });
4205
+ this.onSelectProvince({
4206
+ id: addr.province_id,
4207
+ name: addr.province
4208
+ });
4209
+ };
4210
+ onChangeEmail = e => this.setState({
4211
+ email: e.target.value,
4212
+ err: {},
4213
+ g_err: ''
4214
+ });
4215
+ onChangePhone = e => this.setState({
4216
+ phone: e.target.value,
4217
+ err: {},
4218
+ g_err: ''
4219
+ });
4220
+ onChangePaymentMethod = id => this.setState({
4221
+ pm: id
4222
+ });
4223
+
4224
+ renderDesktopPaymentMethod(order) {
4225
+ return null;
4226
+ let editmode = false;
4227
+
4228
+ if (!order.status || order.status == 'new') {
4229
+ editmode = !order.user_confirmation;
4230
+ }
4231
+
4232
+ if (editmode) {
4233
+ let pms = this.props.store.matchPaymentMethods();
4234
+ let $pms = util/* default.map */.Z.map(pms, pm => {
4235
+ let $name = pm.description;
4236
+
4237
+ if (pm.method == 'bank_transfer') {
4238
+ $name = pm.description + ' ' + pm.bank_name + ' ' + pm.bank_branch;
4239
+ }
4240
+
4241
+ let cls = 'order__card';
4242
+ let $desc = null;
4243
+
4244
+ if (this.state.pm === pm.id) {
4245
+ cls += ' order__card__active';
4246
+ $desc = (0,preact_module.h)("div", {
4247
+ class: "muted mt-1",
4248
+ style: "margin-left: 26px !important;"
4249
+ }, "Tr\u1EA3 ti\u1EC1n m\u1EB7t khi b\u1EA1n nh\u1EADn h\xE0ng");
4250
+
4251
+ if (pm.method == 'bank_transfer') {
4252
+ $desc = (0,preact_module.h)("div", {
4253
+ class: "muted mt-1",
4254
+ style: "margin-left: 26px !important;"
4255
+ }, (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));
4256
+ }
4257
+ }
4258
+
4259
+ return (0,preact_module.h)("div", {
4260
+ style: "width: 100% !important; margin-top: 10px !important;"
4261
+ }, (0,preact_module.h)("div", {
4262
+ class: "radio"
4263
+ }, (0,preact_module.h)("input", {
4264
+ type: "radio",
4265
+ id: 'pm.' + pm.id,
4266
+ onInput: e => this.onChangePaymentMethod(pm.id),
4267
+ name: "pm",
4268
+ checked: this.state.pm === pm.id
4269
+ }), (0,preact_module.h)("label", {
4270
+ class: "radio--label",
4271
+ style: `margin-left: 4px !important; font-weight: ${this.state.pm === pm.id ? 500 : 400} !important;`,
4272
+ for: 'pm.' + pm.id
4273
+ }, $name), (0,preact_module.h)("div", {
4274
+ class: "radio--check"
4275
+ }, (0,preact_module.h)("div", {
4276
+ class: "inside"
4277
+ })), $desc));
4278
+ });
4279
+ let seccls = 'card_section';
4280
+ if (this.isMobile()) seccls = 'order_section';
4281
+ return (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
4282
+ class: "order_section__line"
4283
+ }), (0,preact_module.h)("div", {
4284
+ class: seccls
4285
+ }, (0,preact_module.h)("div", {
4286
+ class: "order_label"
4287
+ }, this.props.t('payment')), (0,preact_module.h)("div", {
4288
+ class: "form",
4289
+ style: "justify-content: space-between !important;"
4290
+ }, $pms)));
4291
+ }
4292
+
4293
+ let pm = order.payment_method || {
4294
+ method: 'cod'
4295
+ };
4296
+ let $body = null;
4297
+ if (pm.method === 'cash') $body = (0,preact_module.h)("div", null, this.props.t('pm_cash'));
4298
+ if (pm.method === 'cod') $body = (0,preact_module.h)("div", null, this.props.t('pm_cod'));
4299
+
4300
+ if (pm.method === 'bank_transfer') {
4301
+ let name = pm.bank_name;
4302
+ if (pm.bank_branch) name += ' - ' + pm.bank_branch;
4303
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", null, "Ng\xE2n h\xE0ng: ", name), (0,preact_module.h)("div", {
4304
+ class: "mt-1"
4305
+ }, "Ch\u1EE7 t\xE0i kho\u1EA3n: ", pm.bank_owner), (0,preact_module.h)("div", {
4306
+ class: "mt-1"
4307
+ }, "S\u1ED1 t\xE0i kho\u1EA3n: ", pm.bank_number));
4308
+ }
4309
+
4310
+ if (!$body) return null;
4311
+ return (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
4312
+ class: "order_label"
4313
+ }, this.props.t('payment')), $body);
4314
+ }
4315
+
4316
+ renderDesktopShipping(order) {
4317
+ let editmode = false;
4318
+
4319
+ if (!order.status || order.status == 'new') {
4320
+ editmode = !order.user_confirmation;
4321
+ }
4322
+
4323
+ let user = this.props.store.matchUser();
4324
+
4325
+ if (editmode) {
4326
+ let addresses = this.props.store.matchShippingAddresses();
4327
+ let provinces = util/* default.map */.Z.map(this.state.provinces, province => ({
4328
+ id: province.id,
4329
+ name: province.province
4330
+ }));
4331
+ let districts = util/* default.map */.Z.map(this.state.districts, district => ({
4332
+ id: district.id,
4333
+ name: district.district
4334
+ }));
4335
+ let wards = util/* default.map */.Z.map(this.state.wards, ward => ({
4336
+ id: ward.id,
4337
+ name: ward.ward
4338
+ }));
4339
+ let cls = 'ship_card';
4340
+ let $body = null;
4341
+ let ship_icon_active = false;
4342
+
4343
+ if (this.state.shipping === 'ship') {
4344
+ ship_icon_active = true;
4345
+ let $preaddrs = util/* default.map */.Z.map(addresses, addr => {
4346
+ let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
4347
+ let $phone = null;
4348
+
4349
+ if (addr.phone) {
4350
+ $phone = (0,preact_module.h)(preact_module/* Fragment */.HY, null, "\xA0\xB7\xA0", this.props.t('phn'), " ", addr.phone);
4351
+ }
4352
+
4353
+ return (0,preact_module.h)("div", {
4354
+ style: "margin-bottom: 15px !important"
4355
+ }, (0,preact_module.h)("div", {
4356
+ class: "radio d-flex "
4357
+ }, (0,preact_module.h)("input", {
4358
+ type: "radio",
4359
+ id: 'shipping_addr.' + addr.id,
4360
+ onInput: e => this.onChangeShippingAddress(addr.id),
4361
+ name: "shipping_address",
4362
+ checked: this.state.shipping_address === addr.id
4363
+ }), (0,preact_module.h)("label", {
4364
+ class: "radio--label",
4365
+ for: 'shipping_addr.' + addr.id,
4366
+ style: `font-weight: ${this.state.shipping_address === addr.id ? 500 : 400} !important`
4367
+ }, addr.fullname, $phone, (0,preact_module.h)("div", {
4368
+ class: "mt-1 muted"
4369
+ }, "DC ", fulladdr)), (0,preact_module.h)("div", {
4370
+ class: "radio--check"
4371
+ }, (0,preact_module.h)("div", {
4372
+ class: "inside"
4373
+ }))));
4374
+ });
4375
+ $preaddrs.push((0,preact_module.h)("div", {
4376
+ style: ""
4377
+ }, (0,preact_module.h)("div", {
4378
+ class: "radio d-flex "
4379
+ }, (0,preact_module.h)("input", {
4380
+ type: "radio",
4381
+ id: 'shipping_addr.new',
4382
+ onInput: e => this.onChangeShippingAddress('new'),
4383
+ name: "shipping_address",
4384
+ checked: this.state.shipping_address === 'new'
4385
+ }), (0,preact_module.h)("label", {
4386
+ class: "radio--label",
4387
+ for: 'shipping_addr.new'
4388
+ }, 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", {
4389
+ class: "radio--check"
4390
+ }, (0,preact_module.h)("div", {
4391
+ class: "inside"
4392
+ })))));
4393
+ let $new = (0,preact_module.h)("div", {
4394
+ style: "padding-left: 22px !important;"
4395
+ }, (0,preact_module.h)("div", {
4396
+ class: "d-flex"
4397
+ }, (0,preact_module.h)("div", {
4398
+ class: "mr-2",
4399
+ style: "flex: 1 !important;"
4400
+ }, (0,preact_module.h)("div", {
4401
+ class: "order_form_label"
4402
+ }, this.props.t('fullname')), (0,preact_module.h)("input", {
4403
+ type: "text",
4404
+ class: 'form-control ' + (this.state.err.name && 'err'),
4405
+ onInput: this.onChangeFullname,
4406
+ value: this.state.fullname
4407
+ })), (0,preact_module.h)("div", {
4408
+ class: "ml-2",
4409
+ style: "flex: 1 !important;"
4410
+ }, (0,preact_module.h)("div", {
4411
+ class: "order_form_label"
4412
+ }, this.props.t('phones')), (0,preact_module.h)("input", {
4413
+ type: "text",
4414
+ class: 'form-control ' + (this.state.err.phone && 'err'),
4415
+ onInput: this.onChangePhone,
4416
+ value: this.state.phone
4417
+ }))), (0,preact_module.h)("div", {
4418
+ class: "",
4419
+ style: "width: 100% !important"
4420
+ }, (0,preact_module.h)("div", {
4421
+ class: "order_form_label"
4422
+ }, this.props.t('address')), (0,preact_module.h)(AddressPicker, {
4423
+ initAddress: this.state.address,
4424
+ store: this.props.store,
4425
+ width: "100%",
4426
+ onChangeAddress: this.onChangeAddress,
4427
+ full: this.isMobile(),
4428
+ onSelect: this.onSelectAddress,
4429
+ extra_cls: this.state.err.address && 'err'
4430
+ })), (0,preact_module.h)("div", {
4431
+ class: "d-flex",
4432
+ style: "justify-content: space-between !important;"
4433
+ }, (0,preact_module.h)("div", {
4434
+ style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
4435
+ }, (0,preact_module.h)("div", {
4436
+ class: "order_form_label"
4437
+ }, this.props.t('province')), (0,preact_module.h)(DropdownSelect, {
4438
+ width: "194",
4439
+ full: this.isMobile(),
4440
+ has_search: true,
4441
+ loading: this.state.loadProvince,
4442
+ items: provinces,
4443
+ selected: this.state.selectedProvince,
4444
+ onSelect: this.onSelectProvince,
4445
+ extra_cls: this.state.err.province && 'err'
4446
+ })), (0,preact_module.h)("div", {
4447
+ style: "flex: 1 !important; overflow:hidden !important; margin-left: 7px !important;"
4448
+ }, (0,preact_module.h)("div", {
4449
+ class: "order_form_label"
4450
+ }, this.props.t('district')), (0,preact_module.h)(DropdownSelect, {
4451
+ width: "194",
4452
+ full: this.isMobile(),
4453
+ selected: this.state.selectedDistrict,
4454
+ has_search: true,
4455
+ onSelect: this.onSelectDistrict,
4456
+ loading: this.state.loadDistrict,
4457
+ extra_cls: this.state.err.district && 'err',
4458
+ items: districts
4459
+ }))), (0,preact_module.h)("div", {
4460
+ class: "d-flex",
4461
+ style: "justify-content: space-between !important;"
4462
+ }, (0,preact_module.h)("div", {
4463
+ style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
4464
+ }, (0,preact_module.h)("div", {
4465
+ class: "order_form_label"
4466
+ }, this.props.t('ward')), (0,preact_module.h)(DropdownSelect, {
4467
+ width: "194",
4468
+ selected: this.state.selectedWard,
4469
+ full: this.isMobile(),
4470
+ has_search: true,
4471
+ onSelect: this.onSelectWard,
4472
+ extra_cls: this.state.err.ward && 'err',
4473
+ loading: this.state.loadWard,
4474
+ items: wards
4475
+ })), (0,preact_module.h)("div", {
4476
+ style: "flex: 1 !important; margin-left: 7px !important;"
4477
+ })));
4478
+ cls += ' ship_card__active';
4479
+
4480
+ if (util/* default.size */.Z.size(addresses) == 0) {
4481
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
4482
+ class: 'mt-3 mb-2 '
4483
+ }, this.props.t('input_shipping_info')), $new);
4484
+ } else {
4485
+ if (this.state.shipping_address !== 'new') $new = null;
4486
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
4487
+ class: "mt-3 mb-2",
4488
+ style: "margin-bottom: 10px !important;"
4489
+ }, "Vui l\xF2ng ch\u1ECDn \u0111\u1ECBa ch\u1EC9 giao h\xE0ng"), (0,preact_module.h)("div", {
4490
+ class: "form"
4491
+ }, $preaddrs), $new);
4492
+ }
4493
+ }
4494
+
4495
+ let shopcls = 'ship_card';
4496
+ let shop_icon_active = false;
4497
+
4498
+ if (this.state.shipping === 'shop') {
4499
+ shop_icon_active = true;
4500
+ shopcls += ' ship_card__active';
4501
+ $body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
4502
+ class: "d-flex"
4503
+ }, (0,preact_module.h)("div", {
4504
+ class: "mr-2",
4505
+ style: "flex: 3 !important;"
4506
+ }, (0,preact_module.h)("div", {
4507
+ class: "order_form_label"
4508
+ }, this.props.t('fullname')), (0,preact_module.h)("input", {
4509
+ type: "text",
4510
+ class: 'form-control ' + (this.state.err.name && 'err'),
4511
+ onInput: this.onChangeFullname,
4512
+ value: this.state.fullname
4513
+ })), (0,preact_module.h)("div", {
4514
+ class: "ml-2",
4515
+ style: "flex: 2 !important;"
4516
+ }, (0,preact_module.h)("div", {
4517
+ class: "order_form_label"
4518
+ }, this.props.t('phones')), (0,preact_module.h)("input", {
4519
+ type: "text",
4520
+ class: 'form-control ' + (this.state.err.phone && 'err'),
4521
+ onInput: this.onChangePhone,
4522
+ value: this.state.phone
4523
+ }))), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
4524
+ class: "order_form_label"
4525
+ }, this.props.t('email')), (0,preact_module.h)("input", {
4526
+ type: "text",
4527
+ class: 'form-control ' + (this.state.err.email && 'err'),
4528
+ onInput: this.onChangeEmail,
4529
+ value: this.state.email
4530
+ })));
4531
+ }
4532
+
4533
+ let seccls = 'card_section';
4534
+ if (this.isMobile()) seccls = 'order_section';
4535
+ return (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
4536
+ class: "order_section__line"
4537
+ }), (0,preact_module.h)("div", {
4538
+ class: seccls
4539
+ }, (0,preact_module.h)("div", {
4540
+ class: "order_label"
4541
+ }, this.props.t('ship_to')), (0,preact_module.h)("div", {
4542
+ class: "d-flex"
4543
+ }, (0,preact_module.h)("div", {
4544
+ class: shopcls + ' mr-3',
4545
+ onClick: e => this.onChangeShipping('shop')
4546
+ }, (0,preact_module.h)(Icon, {
4547
+ name: "shop",
4548
+ active: shop_icon_active
4549
+ }), " ", (0,preact_module.h)("b", {
4550
+ class: "ml-2"
4551
+ }, "Nh\u1EADn h\xE0ng t\u1EA1i shop")), (0,preact_module.h)("div", {
4552
+ class: cls,
4553
+ onClick: e => this.onChangeShipping('ship')
4554
+ }, (0,preact_module.h)(Icon, {
4555
+ name: "package",
4556
+ active: ship_icon_active
4557
+ }), " ", (0,preact_module.h)("b", {
4558
+ class: "ml-2"
4559
+ }, "Giao h\xE0ng cho t\xF4i"))), $body));
4560
+ }
4561
+
4562
+ let addr = util/* default.get */.Z.get(order, 'shipping.address') || {};
4563
+ let fulladdr = [addr.address, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
4564
+ let $phone = null;
4565
+ if (addr.phone) $phone = (0,preact_module.h)("div", {
4566
+ class: "mt-1 muted"
4567
+ }, this.props.t('phn'), ":\xA0", addr.phone);
4568
+
4569
+ if (util/* default.get */.Z.get(order, 'shipping.pickup_at_shop')) {
4570
+ fulladdr = 'Nhận hàng tại cửa hàng';
4571
+ }
4572
+
4573
+ let $addr = fulladdr ? (0,preact_module.h)("div", null, fulladdr) : (0,preact_module.h)("i", {
4574
+ class: "i muted"
4575
+ }, "Ch\u01B0a c\xF3 \u0111\u1ECBa ch\u1EC9 giao h\xE0ng");
4576
+ let seccls = 'card_section';
4577
+ if (this.isMobile()) seccls = 'order_section';
4578
+ return (0,preact_module.h)("div", {
4579
+ class: seccls
4580
+ }, (0,preact_module.h)("div", {
4581
+ class: "order_label "
4582
+ }, this.props.t('ship_to')), $addr, $phone);
4583
+ }
4584
+
4585
+ renderDesktopSummary(order) {
4586
+ let $deposit = null;
4587
+
4588
+ if (order.deposit > 0) {
4589
+ $deposit = (0,preact_module.h)("span", {
4590
+ class: "muted"
4591
+ }, "(c\u1ECDc ", util/* default.formatCurrency */.Z.formatCurrency(order.deposit), ")");
4592
+ }
4593
+
4594
+ let $discount = null;
4595
+
4596
+ if (order.total_discount > 0) {
4597
+ $discount = (0,preact_module.h)("div", {
4598
+ class: "order_summary_line"
4599
+ }, (0,preact_module.h)("div", null, "Gi\u1EA3m gi\xE1"), (0,preact_module.h)("div", null, util/* default.formatCurrency */.Z.formatCurrency(order.total_discount)));
4600
+ }
4601
+
4602
+ let $pay = null;
4603
+
4604
+ if ($deposit || order.payment_made) {
4605
+ $pay = (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
4606
+ class: "order_summary_line"
4607
+ }, (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", {
4608
+ class: "order_summary_line"
4609
+ }, (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)))));
4610
+ }
4611
+
4612
+ let $tax = (0,preact_module.h)("div", {
4613
+ class: "order_summary_line"
4614
+ }, (0,preact_module.h)("div", null, "Ti\u1EC1n thu\u1EBF"), (0,preact_module.h)("div", null, util/* default.formatCurrency */.Z.formatCurrency(order.total_tax)));
4615
+ let $ship = (0,preact_module.h)("div", {
4616
+ class: "order_summary_line"
4617
+ }, (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"));
4618
+ let editmode = false;
4619
+
4620
+ if (!order.status || order.status == 'new') {
4621
+ editmode = !order.user_confirmation;
4622
+ }
4623
+
4624
+ let $note = null;
4625
+
4626
+ if (editmode) {
4627
+ $ship = null;
4628
+ $tax = null;
4629
+ $note = (0,preact_module.h)("div", {
4630
+ class: "muted"
4631
+ }, (0,preact_module.h)("img", {
4632
+ class: "order_ship_icon",
4633
+ src: __webpack_require__(9256)
4634
+ }), "\xA0 Ch\u01B0a bao g\u1ED3m thu\u1EBF v\xE0 ph\xED v\u1EADn chuy\u1EC3n");
4635
+ }
4636
+
4637
+ let seccls = '';
4638
+ if (this.isMobile()) seccls = 'order_section';
4639
+ return (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
4640
+ class: "order_section__line"
4641
+ }), (0,preact_module.h)("div", {
4642
+ class: seccls
4643
+ }, (0,preact_module.h)("div", {
4644
+ class: "order_label"
4645
+ }, "T\xF3m t\u1EAFt"), (0,preact_module.h)("div", {
4646
+ class: "order_summary_line"
4647
+ }, (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", {
4648
+ class: "order_summary_line",
4649
+ style: "margin-top: 10px !important; padding-top: 15px !important; border-top: 1px solid #eee !important"
4650
+ }, (0,preact_module.h)("div", null, "B\u1EA1n ph\u1EA3i tr\u1EA3"), (0,preact_module.h)("div", {
4651
+ class: "order__total"
4652
+ }, util/* default.formatCurrency */.Z.formatCurrency(order.total))), $pay));
4653
+ }
4654
+
4655
+ renderStatusBadge(order) {
4656
+ let status = order.status || 'new';
4657
+ return (0,preact_module.h)("div", {
4658
+ style: "float: right !important;",
4659
+ class: 'order_status order_status__' + status
4660
+ }, status);
4661
+ }
4662
+
4663
+ renderShippingInfo(order) {
4664
+ if (order.status != 'new' || order.user_confirmation) {}
4665
+
4666
+ let shipping_provider = util/* default.get */.Z.get(order, 'shipping.shipping_provider');
4667
+ if (!shipping_provider) return null;
4668
+ let shipping_code = util/* default.get */.Z.get(order, 'shipping.shipping_code');
4669
+ let $tracking_code = null;
4670
+ if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
4671
+ class: "muted",
4672
+ style: "margin-top: 3px !important"
4673
+ }, "V\u1EADn \u0111\u01A1n\xA0", (0,preact_module.h)("a", {
4674
+ class: "order_tracking_link",
4675
+ target: "_blank",
4676
+ href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
4677
+ }, shipping_code, "\xA0", (0,preact_module.h)("img", {
4678
+ class: "order_tracking_link_icon",
4679
+ src: __webpack_require__(8453)
4680
+ })));
4681
+
4682
+ if (shipping_provider == 'ghtk') {
4683
+ return (0,preact_module.h)("div", {
4684
+ class: "order_section"
4685
+ }, (0,preact_module.h)("div", {
4686
+ class: "order_section_label"
4687
+ }, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", {
4688
+ class: "d-flex align-items-center"
4689
+ }, (0,preact_module.h)("img", {
4690
+ class: "order_shipping_provider_logo",
4691
+ src: ShippingProvider.ghtk.logo
4692
+ }), (0,preact_module.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
4693
+ }
4694
+
4695
+ return null;
4696
+ }
4697
+
4698
+ renderDesktopShippingInfo(order) {
4699
+ let shipping_provider = util/* default.get */.Z.get(order, 'shipping.shipping_provider');
4700
+ if (!shipping_provider) return null;
4701
+ let shipping_code = util/* default.get */.Z.get(order, 'shipping.shipping_code');
4702
+ let $tracking_code = null;
4703
+ if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
4704
+ class: "muted",
4705
+ style: "margin-top: 3px !important"
4706
+ }, "V\u1EADn \u0111\u01A1n\xA0", (0,preact_module.h)("a", {
4707
+ class: "order_tracking_link",
4708
+ target: "_blank",
4709
+ href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
4710
+ }, shipping_code, "\xA0", (0,preact_module.h)("img", {
4711
+ class: "order_tracking_link_icon",
4712
+ src: __webpack_require__(8453)
4713
+ })));
4714
+
4715
+ if (shipping_provider == 'ghtk') {
4716
+ return (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
4717
+ class: "order_label"
4718
+ }, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", {
4719
+ class: "d-flex align-items-center"
4720
+ }, (0,preact_module.h)("img", {
4721
+ class: "order_shipping_provider_logo",
4722
+ src: ShippingProvider.ghtk.logo
4723
+ }), (0,preact_module.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
4724
+ }
4725
+
4726
+ return null;
4727
+ }
4728
+
4729
+ renderProducts(order) {
4730
+ let $products = null;
4731
+ $products = util/* default.map */.Z.map(order.items, item => {
4732
+ if (!item || !item.product) return null;
4733
+ let product = item.product;
4734
+ return (0,preact_module.h)("div", {
4735
+ class: "order_attachment__product"
4736
+ }, (0,preact_module.h)("img", {
4737
+ class: "order_attachment__product_img",
4738
+ alt: '' + product.id,
4739
+ src: util/* default.get */.Z.get(product, 'images.0') || __webpack_require__(9270)
4740
+ }), (0,preact_module.h)("div", {
4741
+ style: "overflow: hidden !important;"
4742
+ }, (0,preact_module.h)("div", {
4743
+ class: "order_attachment__product_name"
4744
+ }, product.name), (0,preact_module.h)("div", {
4745
+ class: "order_attachment__product_desc"
4746
+ }, product.description || product.long_description), (0,preact_module.h)("div", {
4747
+ class: "order_attachment__product_desc"
4748
+ }, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default.formatCurrency */.Z.formatCurrency(product.price))));
4749
+ });
4750
+ if (!this.isMobile()) return (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
4751
+ class: "order_label"
4752
+ }, this.props.t('product')), $products);
4753
+ return (0,preact_module.h)("div", {
4754
+ class: "order_section"
4755
+ }, (0,preact_module.h)("div", {
4756
+ class: "order_section_label"
4757
+ }, this.props.t('product')), $products);
4758
+ }
4759
+
4760
+ onChangeQuantity = (item, text) => {
4761
+ let qty = parseInt(text) || 1;
4762
+ item.quantity = qty;
4763
+ this.forceUpdate();
4764
+ };
4765
+
4766
+ renderDesktopProducts(order) {
4767
+ let $products = null;
4768
+ let editmode = false;
4769
+
4770
+ if (!order.status || order.status == 'new') {
4771
+ editmode = !order.user_confirmation;
4772
+ }
4773
+
4774
+ if (editmode) {
4775
+ $products = util/* default.map */.Z.map(order.items, item => {
4776
+ if (!item || !item.product) return null;
4777
+ let product = item.product;
4778
+ return (0,preact_module.h)("div", {
4779
+ class: "order_attachment__product"
4780
+ }, (0,preact_module.h)("img", {
4781
+ class: "order_attachment__product_img",
4782
+ alt: '' + product.id,
4783
+ src: util/* default.get */.Z.get(product, 'images.0') || __webpack_require__(9270)
4784
+ }), (0,preact_module.h)("div", {
4785
+ style: "overflow: hidden !important; flex: 1 !important"
4786
+ }, (0,preact_module.h)("div", {
4787
+ class: "order_attachment__product_name"
4788
+ }, product.name), (0,preact_module.h)("div", {
4789
+ class: "order_attachment__product_desc"
4790
+ }, product.description || product.long_description), (0,preact_module.h)("div", {
4791
+ class: "order_attachment__product_desc"
4792
+ }, util/* default.formatCurrency */.Z.formatCurrency(product.price))), (0,preact_module.h)("input", {
4793
+ class: "form-control",
4794
+ style: "text-align: center !important; font-weight: 400 !important; width: 50px !important",
4795
+ value: item.quantity,
4796
+ onInput: e => this.onChangeQuantity(item, e.target.value),
4797
+ type: "text"
4798
+ }), (0,preact_module.h)("div", {
4799
+ style: "width: 80px !important; text-align: right !important; "
4800
+ }, (0,preact_module.h)("b", null, util/* default.formatCurrency */.Z.formatCurrency(item.quantity * product.price))));
4801
+ });
4802
+ } else {
4803
+ $products = util/* default.map */.Z.map(order.items, item => {
4804
+ if (!item || !item.product) return null;
4805
+ let product = item.product;
4806
+ return (0,preact_module.h)("div", {
4807
+ class: "order_attachment__product"
4808
+ }, (0,preact_module.h)("img", {
4809
+ class: "order_attachment__product_img",
4810
+ alt: '' + product.id,
4811
+ src: util/* default.get */.Z.get(product, 'images.0') || __webpack_require__(9270)
4812
+ }), (0,preact_module.h)("div", {
4813
+ style: "overflow: hidden !important; flex: 1 !important"
4814
+ }, (0,preact_module.h)("div", {
4815
+ class: "order_attachment__product_name"
4816
+ }, product.name), (0,preact_module.h)("div", {
4817
+ class: "order_attachment__product_desc"
4818
+ }, product.description || product.long_description), (0,preact_module.h)("div", {
4819
+ class: "order_attachment__product_desc"
4820
+ }, util/* default.formatCurrency */.Z.formatCurrency(product.price))), (0,preact_module.h)("div", {
4821
+ style: "text-align: center !important; font-weight: 400 !important; width: 50px !important"
4822
+ }, item.quantity), (0,preact_module.h)("div", {
4823
+ style: "width: 80px !important; text-align: right !important; "
4824
+ }, (0,preact_module.h)("b", null, util/* default.formatCurrency */.Z.formatCurrency(item.total))));
4825
+ });
4826
+ }
4827
+
4828
+ return (0,preact_module.h)("div", {
4829
+ class: "card_section"
4830
+ }, (0,preact_module.h)("div", {
4831
+ class: "desktop_order__heading"
4832
+ }, this.renderStatusBadge(order), (0,preact_module.h)("b", {
4833
+ style: "font-size: 18px !important;"
4834
+ }, this.props.t('order'), " #", order.order_number || order.id), (0,preact_module.h)("div", {
4835
+ class: "muted"
4836
+ }, (0,preact_module.h)(Time, {
4837
+ style: "font-size: 13px !important;",
4838
+ time: order.issue_date || order.created
4839
+ }))), (0,preact_module.h)("div", {
4840
+ class: "order_label d-flex",
4841
+ style: "margin-top: 20px !important;justify-content: space-between !important; align-items: flex-end !important;"
4842
+ }, (0,preact_module.h)("div", {
4843
+ style: "flex: 1 !important;"
4844
+ }, this.props.t('product')), (0,preact_module.h)("div", {
4845
+ style: "font-weight: 400 !important; text-align:center !important; width: 50px !important"
4846
+ }, this.props.t('qty')), (0,preact_module.h)("div", {
4847
+ style: "font-weight: 400 !important; text-align: right !important; width: 80px !important;"
4848
+ }, this.props.t('total'))), $products);
4849
+ }
4850
+
4851
+ renderMobile(order) {
4852
+ if (this.state.step === 'success') return this.renderMobileSuccess(order);
4853
+ let $error = null;
4854
+
4855
+ if (this.state.g_err) {
4856
+ $error = (0,preact_module.h)("div", {
4857
+ class: "mb-2 text__danger"
4858
+ }, (0,preact_module.h)("img", {
4859
+ style: "margin-top: -4px !important; height: 15px !important;",
4860
+ src: ximg
4861
+ }), "\xA0", (0,preact_module.h)("b", null, this.state.g_err));
4862
+ }
4863
+
4864
+ let $status = (0,preact_module.h)("div", null, $error, (0,preact_module.h)("div", {
4865
+ class: "btn-confirm-order",
4866
+ style: "margin-top: 0 !important;",
4867
+ onClick: this.confirm
4868
+ }, this.props.t('confirm_order')));
4869
+ let $close = (0,preact_module.h)("div", {
4870
+ class: "order_btn order__btn__light mt-3",
4871
+ onClick: this.onCancel
4872
+ }, this.props.t('cancel_order'));
4873
+
4874
+ if (order.user_confirmation || order.status != 'new') {
4875
+ $status = null;
4876
+ if (this.props.cid) $close = (0,preact_module.h)("div", {
4877
+ class: "order_btn order__btn__light mt-3",
4878
+ onClick: this.close
4879
+ }, this.props.t('close'));
4880
+ }
4881
+
4882
+ return (0,preact_module.h)("div", {
4883
+ class: "order",
4884
+ style: "height: 100% !important"
4885
+ }, (0,preact_module.h)("div", {
4886
+ class: "order--content"
4887
+ }, (0,preact_module.h)("div", {
4888
+ class: "order--heading"
4889
+ }, this.renderStatusBadge(order), (0,preact_module.h)("b", {
4890
+ style: "font-size: 16px !important;"
4891
+ }, this.props.t('order'), " #", order.order_number || order.id), (0,preact_module.h)("div", {
4892
+ class: "muted"
4893
+ }, (0,preact_module.h)(Time, {
4894
+ style: "font-size: 13px !important;",
4895
+ time: order.issue_date || order.created
4896
+ }))), this.renderProducts(order), this.renderDesktopShipping(order), this.renderShippingInfo(order), this.renderDesktopPaymentMethod(order), this.renderDesktopSummary(order), (0,preact_module.h)("div", {
4897
+ class: "order_section pb-3",
4898
+ style: "padding-top: 0 !important;"
4899
+ }, $status, $close)));
4900
+ }
4901
+
4902
+ renderActions(order) {
4903
+ let $actions = null;
4904
+ let editmode = false;
4905
+
4906
+ if (!order.status || order.status == 'new') {
4907
+ editmode = !order.user_confirmation;
4908
+ }
4909
+
4910
+ if (this.state.step === 'success') return (0,preact_module.h)("div", {
4911
+ class: "d-flex",
4912
+ style: "align-items: center !important; justify-content: flex-end !important"
4913
+ }, (0,preact_module.h)("div", null, "Ghi nh\u1EADn th\xE0nh c\xF4ng"), "\xA0", (0,preact_module.h)("img", {
4914
+ style: "width: 16px !important; height: 16px !important;",
4915
+ width: "16",
4916
+ height: "16",
4917
+ src: checkedimg
4918
+ }));
4919
+
4920
+ if (editmode) {
4921
+ let $error = null;
4922
+
4923
+ if (this.state.g_err) {
4924
+ $error = (0,preact_module.h)("div", {
4925
+ class: "mb-2 text__danger"
4926
+ }, (0,preact_module.h)("img", {
4927
+ style: "margin-top: -4px !important; height: 15px !important;",
4928
+ src: ximg
4929
+ }), "\xA0", (0,preact_module.h)("b", null, this.state.g_err));
4930
+ }
4931
+
4932
+ $actions = (0,preact_module.h)("div", null, $error, (0,preact_module.h)("div", {
4933
+ class: "btn-confirm-order",
4934
+ onClick: this.confirm
4935
+ }, this.props.t('confirm_order')), (0,preact_module.h)("div", {
4936
+ class: "btn-cancel-order",
4937
+ onClick: this.onCancel
4938
+ }, this.props.t('cancel_order')));
4939
+ }
4940
+
4941
+ return $actions;
4942
+ }
4943
+
4944
+ renderDesktop(order) {
4945
+ let acc = this.props.store.matchAccount();
4946
+
4947
+ var uri = acc.logo_url || __webpack_require__(9895);
4948
+
4949
+ return (0,preact_module.h)("div", {
4950
+ class: "desktop order"
4951
+ }, (0,preact_module.h)("div", {
4952
+ class: "order_acc_header"
4953
+ }, (0,preact_module.h)("img", {
4954
+ class: "order_acc_logo",
4955
+ src: uri
4956
+ }), (0,preact_module.h)("div", {
4957
+ class: "order_acc_name"
4958
+ }, acc.name)), (0,preact_module.h)("div", {
4959
+ class: "desktop_order__content"
4960
+ }, (0,preact_module.h)("div", {
4961
+ style: "flex: 1 !important; padding-right: 20px !important;"
4962
+ }, this.renderDesktopProducts(order), this.renderDesktopShipping(order), this.renderDesktopShippingInfo(order), this.renderDesktopPaymentMethod(order), (0,preact_module.h)("div", {
4963
+ class: "order__footer"
4964
+ }, (0,preact_module.h)("a", {
4965
+ target: "_blank",
4966
+ href: "https://subiz.com.vn",
4967
+ class: "order__footer_link"
4968
+ }, "Cung c\u1EA5p b\u1EDFi ", (0,preact_module.h)("b", null, "Subiz")), (0,preact_module.h)("div", {
4969
+ class: "order__footer_delimiter"
4970
+ }), (0,preact_module.h)("a", {
4971
+ target: "_blank",
4972
+ href: "https://subiz.com.vn/vi/terms-of-service.html",
4973
+ class: "order__footer_link"
4974
+ }, "\u0110i\u1EC1u kho\u1EA3n"), (0,preact_module.h)("a", {
4975
+ target: "_blank",
4976
+ href: "https://subiz.com.vn/vi/privacy-policy.html",
4977
+ class: "order__footer_link"
4978
+ }, "Quy\u1EC1n ri\xEAng t\u01B0"))), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
4979
+ class: "order_recap"
4980
+ }, this.renderDesktopSummary(order), this.renderActions(order)))));
4981
+ }
4982
+
4983
+ render() {
4984
+ if (this.state.loading) return (0,preact_module.h)("div", {
4985
+ class: "order_error"
4986
+ }, (0,preact_module.h)(Spinner, {
4987
+ class: "mt-4",
4988
+ size: "60",
4989
+ static: true
4990
+ }));
4991
+ if (this.state.error) return (0,preact_module.h)("div", {
4992
+ class: "order_error"
4993
+ }, (0,preact_module.h)("img", {
4994
+ class: "mt-3",
4995
+ src: __webpack_require__(6825)
4996
+ }), (0,preact_module.h)("div", {
4997
+ class: "mt-3"
4998
+ }, this.props.t('order_load_error')));
4999
+ let order = this.state.order;
5000
+ if (this.isMobile()) return this.renderMobile(order);
5001
+ return this.renderDesktop(order);
5002
+ }
5003
+
5004
+ confirm = async () => {
5005
+ this.setState({
5006
+ g_err: ''
5007
+ });
5008
+ let err = {};
5009
+
5010
+ if (!this.state.shipping) {
5011
+ this.setState({
5012
+ g_err: 'Mời bạn chọn địa chỉ giao hàng trước khi xác nhận'
5013
+ });
5014
+ }
5015
+
5016
+ if (this.state.shipping === 'shop') {
5017
+ if (!util/* default.isPhone */.Z.isPhone(this.state.phone)) {
5018
+ err.phone = true;
5019
+ }
5020
+
5021
+ if (!util/* default.trim */.Z.trim(this.state.fullname)) {
5022
+ err.name = true;
5023
+ }
5024
+
5025
+ if (!util/* default.trim */.Z.trim(this.state.email)) {
5026
+ err.email = true;
5027
+ }
5028
+ } else if (this.state.shipping_address == 'new') {
5029
+ if (!util/* default.isPhone */.Z.isPhone(this.state.phone)) {
5030
+ err.phone = true;
5031
+ }
5032
+
5033
+ if (!util/* default.trim */.Z.trim(this.state.fullname)) {
5034
+ err.name = true;
5035
+ }
5036
+
5037
+ if (!util/* default.trim */.Z.trim(this.state.address)) {
5038
+ err.address = true;
5039
+ }
5040
+
5041
+ if (util/* default.size */.Z.size(this.state.selectedWard) == 0) {
5042
+ err.ward = true;
5043
+ }
5044
+
5045
+ if (util/* default.size */.Z.size(this.state.selectedDistrict) == 0) {
5046
+ err.district = true;
5047
+ }
5048
+
5049
+ if (util/* default.size */.Z.size(this.state.selectedProvince) == 0) {
5050
+ err.province = true;
5051
+ }
5052
+ }
5053
+
5054
+ if (util/* default.size */.Z.size(err) > 0) {
5055
+ this.setState({
5056
+ err,
5057
+ g_err: this.props.t('input_shipping_info_err')
5058
+ });
5059
+ return;
5060
+ }
5061
+
5062
+ let user = this.props.store.matchUser();
5063
+ let ufullname = util/* default.getUserAttr */.Z.getUserAttr(user, 'fullname', 'text');
5064
+ let uemail = util/* default.getUserAttr */.Z.getUserAttr(user, 'emails', 'text');
5065
+ let uphone = util/* default.getUserAttr */.Z.getUserAttr(user, 'phones', 'text');
5066
+ let order = util/* default.cloneDeep */.Z.cloneDeep(this.state.order);
5067
+
5068
+ if (this.state.shipping === 'shop') {
5069
+ util/* default.set */.Z.set(order, 'shipping.pickup_at_shop', true);
5070
+ util/* default.set */.Z.set(order, 'shipping.address.phone', this.state.phone);
5071
+ util/* default.set */.Z.set(order, 'shipping.address.fullname', this.state.fullname);
5072
+ util/* default.set */.Z.set(order, 'shipping.address.email', this.state.email);
5073
+ } else {
5074
+ if (this.state.shipping_address == 'new') {
5075
+ let out = await this.props.store.createShippingAddress({
5076
+ address: this.state.address,
5077
+ country: 'Việt Nam',
5078
+ fullname: this.state.fullname,
5079
+ email: this.state.email,
5080
+ phone: this.state.phone,
5081
+ district: this.state.selectedDistrict.name,
5082
+ district_id: this.state.selectedDistrict.id,
5083
+ province: this.state.selectedProvince.name,
5084
+ province_id: this.state.selectedProvince.id,
5085
+ ward: this.state.selectedWard.name,
5086
+ street: this.state.street,
5087
+ ward_id: this.state.selectedWard.id
5088
+ });
5089
+ if (out.error) return this.setState({
5090
+ g_err: this.props.t('update_failed')
5091
+ });
5092
+ util/* default.set */.Z.set(order, 'shipping.address', out.body);
5093
+ } else {
5094
+ let addresses = this.props.store.matchShippingAddresses();
5095
+ let sa = util/* default.find */.Z.find(addresses, addr => addr.id === this.state.shipping_address);
5096
+
5097
+ if (!sa) {
5098
+ return this.setState({
5099
+ err,
5100
+ g_err: this.props.t('input_shipping_info_err')
5101
+ });
5102
+ }
5103
+
5104
+ util/* default.set */.Z.set(order, 'shipping.address', sa);
5105
+ }
5106
+ }
5107
+
5108
+ let changeduser = false;
5109
+
5110
+ if (!ufullname && this.state.fullname) {
5111
+ changeduser = true;
5112
+ util/* default.setUserAttr */.Z.setUserAttr(user, {
5113
+ key: 'fullname',
5114
+ text: this.state.fullname
5115
+ });
5116
+ }
5117
+
5118
+ if (!uemail && this.state.email) {
5119
+ changeduser = true;
5120
+ util/* default.setUserAttr */.Z.setUserAttr(user, {
5121
+ key: 'emails',
5122
+ text: this.state.email
5123
+ });
5124
+ }
5125
+
5126
+ if (!uphone && this.state.phone) {
5127
+ changeduser = true;
5128
+ util/* default.setUserAttr */.Z.setUserAttr(user, {
5129
+ key: 'phones',
5130
+ text: this.state.phone
5131
+ });
5132
+ }
5133
+
5134
+ if (changeduser) this.props.store.setUser(user);
5135
+ this.setState({
5136
+ sending: true
5137
+ });
5138
+ order.user_confirmation = 'confirmed';
5139
+ let out = await this.props.store.updateOrder(order);
5140
+ this.setState({
5141
+ sending: false
5142
+ });
5143
+
5144
+ if (out.error) {
5145
+ return this.setState({
5146
+ g_err: this.props.t('update_failed')
5147
+ });
5148
+ }
5149
+
5150
+ this.setState({
5151
+ step: 'success'
5152
+ });
5153
+ if (this.props.onResponse) this.props.onResponse('confirmed');
5154
+ };
5155
+ onCancel = () => {
5156
+ if (this.props.onResponse) this.props.onResponse('rejected');
5157
+ this.close();
5158
+ };
5159
+ close = () => {
5160
+ if (this.props.cid && !this.state.order.user_confirmation) {
5161
+ let order = util/* default.cloneDeep */.Z.cloneDeep(this.state.order);
5162
+ order.user_confirmation = 'rejected';
5163
+ this.props.store.updateOrder(order);
5164
+ }
5165
+
5166
+ if (this.props.onClose) this.props.onClose();
5167
+ };
5168
+ }
5169
+ let ShippingProvider = {
5170
+ ghtk: {
5171
+ name: 'Giao hàng tiết kiệm',
5172
+ logo: __webpack_require__(6890)
5173
+ },
5174
+ ghn: {
5175
+ name: 'Giao hàng nhanh',
5176
+ logo: __webpack_require__(1473)
5177
+ }
5178
+ };
5179
+ ;// CONCATENATED MODULE: ./src/chatbox/Order.js
5180
+
5181
+
5182
+
5183
+ const Order_POPUP_MAX_HEIGHT = 400;
5184
+ const Order_POPUP_HARD_MAX_HEIGHT = 500;
5185
+ const Order_POPUP_MIN_HEIGHT = 0;
5186
+
5187
+ let Order_defaultAvatar = __webpack_require__(4761);
5188
+
5189
+
5190
+
5191
+
5192
+ class Order extends common/* Com */.up {
5193
+ constructor(props) {
5194
+ super(props);
5195
+ this.refRating = (0,preact_module/* createRef */.Vf)();
5196
+ this.refHandle = (0,preact_module/* createRef */.Vf)();
5197
+ }
5198
+
5199
+ state = {
5200
+ hide: true,
5201
+ ratingHeight: 0,
5202
+ overlayOpacity: 0.3
5203
+ };
5204
+
5205
+ componentDidMount() {
5206
+ this.mouseUp = e => this.onMouseUp(e);
5207
+
5208
+ this.mouseMove = e => this.onMouseMove(e);
5209
+
5210
+ this.mouseDown = e => this.onMouseDown(e);
5211
+
5212
+ var $ratingHandle = this.refHandle.current;
5213
+ $ratingHandle.addEventListener('mousedown', this.mouseDown, {
5214
+ passive: true
5215
+ });
5216
+ $ratingHandle.addEventListener('touchstart', this.mouseDown, {
5217
+ passive: true
5218
+ });
5219
+ window.addEventListener('mouseup', this.mouseUp, {
5220
+ passive: true
5221
+ });
5222
+ window.addEventListener('touchend', this.mouseUp, {
5223
+ passive: true
5224
+ });
5225
+ window.addEventListener('mousemove', this.mouseMove, {
5226
+ passive: true
5227
+ });
5228
+ window.addEventListener('touchmove', this.mouseMove, {
5229
+ passive: true
5230
+ });
5231
+ this.animation = new releaseAnimation({
5232
+ maxY: Order_POPUP_MAX_HEIGHT,
5233
+ minY: Order_POPUP_MIN_HEIGHT,
5234
+ duration: 150
5235
+ });
5236
+ this.close();
5237
+ }
5238
+
5239
+ componentWillUnmount() {
5240
+ var $ratingHandle = this.refHandle.current;
5241
+ $ratingHandle.removeEventListener('mousedown', this.mouseDown, 0);
5242
+ $ratingHandle.removeEventListener('touchstart', this.mouseDown, 0);
5243
+ window.removeEventListener('mouseup', this.mouseUp, 0);
5244
+ window.removeEventListener('touchend', this.mouseUp, 0);
5245
+ window.removeEventListener('mousemove', this.mouseMove, 0);
5246
+ window.removeEventListener('touchmove', this.mouseMove, 0);
5247
+ }
5248
+
5249
+ render() {
5250
+ if (this._show != this.props.show) {
5251
+ this._show = this.props.show;
5252
+ setTimeout(() => {
5253
+ if (!this._show) this.close();else this.open();
5254
+ });
5255
+ }
5256
+
5257
+ let cls = this.state.hide ? 'd-none' : '';
5258
+ return (0,preact_module.h)("div", {
5259
+ class: cls
5260
+ }, (0,preact_module.h)("div", {
5261
+ class: "extension--overlay",
5262
+ style: `opacity: ${this.state.overlayOpacity * 0.5} !important;`
5263
+ }), (0,preact_module.h)("div", {
5264
+ class: "extension",
5265
+ ref: this.refRating,
5266
+ style: `height: ${this.state.ratingHeight}px !important;`
5267
+ }, (0,preact_module.h)("div", {
5268
+ class: "extension--close-btn",
5269
+ onClick: this.close
5270
+ }, this.props.t('close')), (0,preact_module.h)("div", {
5271
+ class: "extension--handle",
5272
+ ref: this.refHandle
5273
+ }, (0,preact_module.h)("div", {
5274
+ class: "extension--thumb"
5275
+ })), (0,preact_module.h)("div", {
5276
+ style: "overflow-x: hidden !important; overflow-y: scroll !important; height: 100% !important;"
5277
+ }, (0,preact_module.h)(order_Order, {
5278
+ key: this.props.order_id,
5279
+ store: this.props.store,
5280
+ onResponse: this.onResponse,
5281
+ onClose: this.close,
5282
+ t: this.props.t,
5283
+ order_id: this.props.order_id,
5284
+ cid: this.props.cid
5285
+ }))));
5286
+ }
5287
+
5288
+ onResponse = response => {
5289
+ this.setState({
5290
+ response
5291
+ });
5292
+ };
5293
+
5294
+ open() {
5295
+ if (!this.state.hide) return;
5296
+ if (!this.props.order_id) return;
5297
+ this.setState({
5298
+ hide: false
5299
+ });
5300
+ if (!this.refRating.current) return;
5301
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
5302
+ var h0 = parseFloat(popupStyle.height);
5303
+ this.animation.play(-20, h0, h => {
5304
+ this.setState({
5305
+ ratingHeight: h,
5306
+ overlayOpacity: Math.min(1, (h - Order_POPUP_MIN_HEIGHT) / (Order_POPUP_HARD_MAX_HEIGHT - Order_POPUP_MIN_HEIGHT))
5307
+ });
5308
+ });
5309
+ }
5310
+
5311
+ confirm = () => {
5312
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5313
+ message: {
5314
+ format: 'plaintext',
5315
+ text: 'confirm',
5316
+ attachments: [{
5317
+ type: 'postback',
5318
+ postback: {
5319
+ payload: JSON.stringify({
5320
+ type: 'order_confirmation',
5321
+ status: 'confirmed'
5322
+ })
5323
+ }
5324
+ }]
5325
+ }
5326
+ });
5327
+ };
5328
+ close = async () => {
5329
+ await util/* default.sleep */.Z.sleep(100);
5330
+
5331
+ if (this.state.response === 'confirmed') {
5332
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5333
+ message: {
5334
+ format: 'plaintext',
5335
+ text: this.props.t('confirm_order'),
5336
+ attachments: [{
5337
+ type: 'postback',
5338
+ postback: {
5339
+ payload: JSON.stringify({
5340
+ type: 'order_confirmation',
5341
+ status: 'confirmed'
5342
+ })
5343
+ }
5344
+ }]
5345
+ }
5346
+ });
5347
+ } else if (this.state.response === 'rejected') {
5348
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5349
+ message: {
5350
+ format: 'plaintext',
5351
+ text: this.props.t('cancel_order'),
5352
+ attachments: [{
5353
+ type: 'postback',
5354
+ postback: {
5355
+ payload: JSON.stringify({
5356
+ type: 'order_confirmation',
5357
+ status: 'cancelled'
5358
+ })
5359
+ }
5360
+ }]
5361
+ }
5362
+ });
5363
+ } else {}
5364
+
5365
+ this.setState({
5366
+ response: ''
5367
+ });
5368
+ if (this.state.hide) return;
5369
+ if (!this.refRating.current) return;
5370
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
5371
+ var h0 = parseFloat(popupStyle.height);
5372
+ this.animation.play(20, h0, h => {
5373
+ this.setState({
5374
+ ratingHeight: h,
5375
+ overlayOpacity: Math.min(1, (h - Order_POPUP_MIN_HEIGHT) / (Order_POPUP_HARD_MAX_HEIGHT - Order_POPUP_MIN_HEIGHT))
5376
+ });
5377
+
5378
+ if (h < Order_POPUP_MIN_HEIGHT + 10) {
5379
+ if (!this.state.hide) {
5380
+ this.setState({
5381
+ hide: true
5382
+ });
5383
+ }
5384
+ }
5385
+ });
5386
+ this.props.onClose();
5387
+ };
5388
+
5389
+ onMouseDown(e) {
5390
+ this.mousePushed = true;
5391
+ this.animation.stop();
5392
+ e.preventDefault();
5393
+ if (e.touches && e.touches[0]) e = e.touches[0];
5394
+ this.mousePushedDy = e.pageY - window.pageYOffset - this.refRating.current.getBoundingClientRect().y;
5395
+ }
5396
+
5397
+ onMouseUp(e) {
5398
+ if (!this.mousePushed) return;
5399
+ if (e.touches && e.touches[0]) e = e.touches[0];
5400
+ this.mousePushed = false;
5401
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
5402
+ var h0 = parseFloat(popupStyle.height);
5403
+ this.animation.play(this.mouseVelocity, h0, h => {
5404
+ this.setState({
5405
+ ratingHeight: h,
5406
+ overlayOpacity: Math.min(1, (h - Order_POPUP_MIN_HEIGHT) / (Order_POPUP_HARD_MAX_HEIGHT - Order_POPUP_MIN_HEIGHT))
5407
+ });
5408
+
5409
+ if (h < Order_POPUP_MIN_HEIGHT + 10) {
5410
+ if (!this.state.hide) {
5411
+ this.setState({
5412
+ hide: true
5413
+ });
5414
+ this.props.onRate && this.props.onRate({
5415
+ no_rating: true
5416
+ });
5417
+ }
5418
+ }
5419
+ });
5420
+ }
5421
+
5422
+ onMouseMove(e) {
5423
+ if (!this.mousePushed) return;
5424
+ if (e.touches && e.touches[0]) e = e.touches[0];
5425
+ var my = e.pageY;
5426
+ this.mouseVelocity = my - this.lastMouseY;
5427
+ this.lastMouseY = my;
5428
+ my = my - this.mousePushedDy;
5429
+ var K = 10000;
5430
+ var height = this.refRating.current.getBoundingClientRect().bottom - my;
5431
+
5432
+ if (height > Order_POPUP_MAX_HEIGHT) {
5433
+ var beta = K / (Order_POPUP_HARD_MAX_HEIGHT - Order_POPUP_MAX_HEIGHT) - Order_POPUP_MAX_HEIGHT;
5434
+ height = Order_POPUP_HARD_MAX_HEIGHT - K / (height + beta);
5435
+ }
5436
+
5437
+ this.setState({
5438
+ ratingHeight: height,
5439
+ overlayOpacity: Math.min(1, (height - Order_POPUP_MIN_HEIGHT) / (Order_POPUP_HARD_MAX_HEIGHT - Order_POPUP_MIN_HEIGHT))
5440
+ });
5441
+ }
5442
+
5443
+ }
5444
+ ;// CONCATENATED MODULE: ./src/chatbox/Widget.js
5445
+
5446
+
5447
+
5448
+
5449
+
5450
+
5451
+ var send = __webpack_require__(9737);
5452
+
5453
+ var Widget_checkedimg = __webpack_require__(8909);
5454
+
5455
+ var empty = __webpack_require__(29);
5456
+
5457
+
5458
+
5459
+
5460
+
5461
+
5462
+
5463
+ const Widget_defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png';
5464
+
5465
+
5466
+
5467
+
5468
+ class Widget extends common/* Com */.up {
5469
+ constructor(props) {
5470
+ super(props);
5471
+ this.userSent = {};
5472
+ this.setState({
5473
+ creating: false,
5474
+ clickedJoin: false,
5475
+ formData: {},
5476
+ showOrder: false,
5477
+ order_id: ''
5478
+ });
5479
+ this.props.store.onUpdate(this, _ => this.forceUpdate());
5480
+ }
5481
+
5482
+ componentDidMount() {
5483
+ if (!this.props.store.isMobile()) this.focusInput();
5484
+ }
5485
+
5486
+ componentDidUpdate(prevProp) {
5487
+ if (prevProp.isShow !== this.props.isShow) {
5488
+ if (this.props.isShow && !this.props.store.isMobile()) this.focusInput();
5489
+ if (this.props.isShow && this.props.store.isMobile()) this.blur();
5490
+ }
5491
+
5492
+ if (prevProp.cid !== this.props.cid) {
5493
+ this.closeOrder();
5494
+ this.setState({
5495
+ clickedJoin: false
5496
+ });
5497
+ setTimeout(() => {
5498
+ this.events && this.events.focus();
5499
+ if (!this.props.store.isMobile()) this.focusInput();
5500
+ }, 100);
5501
+ }
5502
+
5503
+ this.updateFormDataFields();
5504
+ }
5505
+
5506
+ shouldShowForm() {
5507
+ let formRequired = this.isFormRequired();
5508
+ return formRequired && !this.props.cid || formRequired && this.props.cid && this.state.clickedJoin;
5509
+ }
5510
+
5511
+ render() {
5512
+ let showform = this.shouldShowForm();
5513
+ let form;
5514
+ let accountSetting = this.props.plugin.chatbox || {};
5515
+ let acc = this.props.store.matchAccount() || {};
5516
+ let submitLabel = this.props.t('prechat_form_btn');
5517
+ if (util/* default.get */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
5518
+ let offlineEnabled = util/* default.get */.Z.get(accountSetting, 'offline_form.enabled');
5519
+
5520
+ if (this.isOffline(acc, accountSetting) && offlineEnabled) {
5521
+ form = accountSetting.offline_form;
5522
+ submitLabel = this.props.t('offline_form_btn');
5523
+ }
5524
+
5525
+ if (this.props.view === 'offline_form') {
5526
+ showform = true;
5527
+ form = accountSetting.offline_form;
5528
+ submitLabel = this.props.t('offline_form_btn');
5529
+ }
5530
+
5531
+ if (this.props.view === 'prechat_form') {
5532
+ showform = true;
5533
+ form = accountSetting.prechat_form;
5534
+ submitLabel = this.props.t('prechat_form_btn');
5535
+ }
5536
+
5537
+ let $body = null;
5538
+ if (this.props.view === 'list') $body = this.renderConvoList();else if (showform) $body = this.renderForm(form, submitLabel);else $body = this.renderChat();
5539
+ let position = util/* default.get */.Z.get(accountSetting, 'desktop_button.position') || 'right';
5540
+ if (this.props.store.isMobile()) position = util/* default.get */.Z.get(accountSetting, 'mobile_button.position', position);
5541
+ let cls = 'widget-container widget-container--' + position;
5542
+ if (!this.props.isShow) cls += ' widget-container--hide';
5543
+ return (0,preact_module.h)("div", {
5544
+ class: cls
5545
+ }, (0,preact_module.h)(Header, {
5546
+ t: this.props.t,
5547
+ plugin: this.props.plugin,
5548
+ store: this.props.store,
5549
+ cid: this.props.cid,
5550
+ view: this.props.view,
5551
+ onClose: this.props.onClose,
5552
+ onGotoList: () => this.props.onGo({
5553
+ view: 'list'
5554
+ })
5555
+ }), $body);
5556
+ }
5557
+
5558
+ async submitPrechatForm(form) {
5559
+ var hasError = false;
5560
+ util/* default.map */.Z.map(this.state.formData, (field, key) => {
5561
+ if (field.is_required && (field.value === undefined || field.value === '' || util/* default.size */.Z.size(field.value) === 0 && Array.isArray(field.value))) {
5562
+ field.error = this.props.t('error_empty');
5563
+ hasError = true;
5564
+ } else field.error = '';
5565
+
5566
+ if (key.substr(5) === 'emails' && !util/* default.isEmail */.Z.isEmail(field.value) && field.is_required) {
5567
+ field.error = this.props.t('error_email_invalid');
5568
+ hasError = true;
5569
+ }
5570
+
5571
+ if (key.substr(5) === 'phones' && !util/* default.isPhone */.Z.isPhone(field.value) && field.is_required) {
5572
+ field.error = this.props.t('error_phone_invalid');
5573
+ hasError = true;
5574
+ }
5575
+ });
5576
+ if (hasError) return this.forceUpdate();
5577
+ let data = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
5578
+ let user = util/* default.cloneDeep */.Z.cloneDeep(this.props.store.matchUser());
5579
+ util/* default.map */.Z.map(data, (field, key) => {
5580
+ if (!key.startsWith('attr:')) return;
5581
+ var attr = {
5582
+ key: key.substr(5)
5583
+ };
5584
+ if (field.type === 'number') attr.number = parseInt(field.value);
5585
+ if (field.type === 'datetime') attr.datetime = new util/* default.Date */.Z.Date(field.value).toISOString();
5586
+ if (field.type === 'list') attr.list = field.value;
5587
+ if (field.type === 'text' || field.type === 'boolean') attr[field.type] = field.value;
5588
+ util/* default.setUserAttr */.Z.setUserAttr(user, attr);
5589
+ });
5590
+ let firstmsg = util/* default.get */.Z.get(data, 'question.value');
5591
+ let groupid = util/* default.get */.Z.get(data, 'group.value', '');
5592
+
5593
+ if (this.props.cid) {
5594
+ this.props.store.setUser(user);
5595
+ this.setState({
5596
+ clickedJoin: false
5597
+ });
5598
+ await this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5599
+ message: {
5600
+ text: firstmsg,
5601
+ format: 'plaintext',
5602
+ fields: [{
3673
5603
  key: 'to_agent_group',
3674
5604
  value: util/* default.stringify */.Z.stringify(groupid)
3675
5605
  }]
@@ -4102,6 +6032,7 @@ class Widget extends common/* Com */.M {
4102
6032
  onClick: e => this.onContainerClick(e)
4103
6033
  }, (0,preact_module.h)(Events, {
4104
6034
  isShow: this.props.isShow,
6035
+ onLink: this.onLink,
4105
6036
  store: this.props.store,
4106
6037
  onFormSubmit: e => this.onEventFormSubmit(e),
4107
6038
  ref: ref => this.events = ref,
@@ -4121,9 +6052,41 @@ class Widget extends common/* Com */.M {
4121
6052
  onRate: e => this.onRate(e),
4122
6053
  cid: this.props.cid,
4123
6054
  t: this.props.t
6055
+ }), (0,preact_module.h)(Order, {
6056
+ forceView: this.props.view,
6057
+ plugin: this.props.plugin,
6058
+ show: this.state.showOrder,
6059
+ order_id: this.state.order_id,
6060
+ store: this.props.store,
6061
+ onClose: this.closeOrder,
6062
+ cid: this.props.cid,
6063
+ t: this.props.t
4124
6064
  }), $input);
4125
6065
  }
4126
6066
 
6067
+ onLink = (e, url) => {
6068
+ if (!url) return e.preventDefault();
6069
+ let noschemeurl = url.replace(/(^\w+:|^)\/\//, '');
6070
+
6071
+ if (noschemeurl.startsWith('widget.subiz.com.vn/orders/')) {
6072
+ let orderid = noschemeurl.substr('widget.subiz.com.vn/orders/'.length);
6073
+ orderid = orderid.split('/')[0];
6074
+ this.setState({
6075
+ showOrder: true,
6076
+ order_id: orderid
6077
+ });
6078
+ e.preventDefault();
6079
+ return;
6080
+ }
6081
+ };
6082
+ closeOrder = e => {
6083
+ this.setState({
6084
+ showOrder: false,
6085
+ order_id: ''
6086
+ });
6087
+ this.focusInput();
6088
+ };
6089
+
4127
6090
  async onStartConvoClick() {
4128
6091
  var convo = this.props.store.matchConvo(this.props.cid) || {};
4129
6092
  if (convo.state === 'ended') return this.props.onGo({
@@ -4204,7 +6167,7 @@ class Widget extends common/* Com */.M {
4204
6167
  $unread = (0,preact_module.h)("img", {
4205
6168
  alt: "conversation ended",
4206
6169
  class: "convo-list--convo-completed",
4207
- src: checkedimg,
6170
+ src: Widget_checkedimg,
4208
6171
  title: this.props.t('conversation_ended')
4209
6172
  });
4210
6173
  }
@@ -4383,7 +6346,7 @@ class Widget extends common/* Com */.M {
4383
6346
 
4384
6347
  }
4385
6348
 
4386
- class FormMounter extends common/* Com */.M {
6349
+ class FormMounter extends common/* Com */.up {
4387
6350
  componentDidMount() {
4388
6351
  this.props.onMount(this.props.form);
4389
6352
  }
@@ -4391,7 +6354,7 @@ class FormMounter extends common/* Com */.M {
4391
6354
  }
4392
6355
 
4393
6356
  function Widget_encode(key) {
4394
- return btoa(key).split('=').join('');
6357
+ return encodeURIComponent(key);
4395
6358
  }
4396
6359
  ;// CONCATENATED MODULE: ./src/chatbox/main.js
4397
6360
 
@@ -4400,9 +6363,9 @@ function Widget_encode(key) {
4400
6363
 
4401
6364
 
4402
6365
 
4403
- let promiseMainCSS = (() => __webpack_require__.e(/* import() */ 178).then(__webpack_require__.bind(__webpack_require__, 178)))();
6366
+ let main_promiseMainCSS = (() => __webpack_require__.e(/* import() */ 178).then(__webpack_require__.bind(__webpack_require__, 178)))();
4404
6367
 
4405
- class Main extends common/* Com */.M {
6368
+ class Main extends common/* Com */.up {
4406
6369
  constructor(props) {
4407
6370
  super(props);
4408
6371
  this.refButton = (0,preact_module/* createRef */.Vf)();
@@ -4412,7 +6375,7 @@ class Main extends common/* Com */.M {
4412
6375
  let plugins = this.props.store.matchPlugin();
4413
6376
  let found = util/* default.find */.Z.find(plugins, plugin => plugin.id === this.props.plugin.id);
4414
6377
  if (!found) return;
4415
- let css = (await promiseMainCSS).default.default.toString();
6378
+ let css = (await main_promiseMainCSS).default.default.toString();
4416
6379
  var outcss = util/* default.replaceCssVariable */.Z.replaceCssVariable(css, this.props.plugin.chatbox);
4417
6380
  util/* default.setCss */.Z.setCss(this.props.plugin.id, this.$cssStyleDiv, outcss);
4418
6381
  }
@@ -4452,7 +6415,8 @@ class Main extends common/* Com */.M {
4452
6415
  view: this.props.store.matchLastview().view
4453
6416
  }));
4454
6417
  } else {
4455
- this.hideWidget();
6418
+ restoreViewport();
6419
+ if (!this.state.isShowWidget) this.hideWidget();
4456
6420
  }
4457
6421
  }
4458
6422
 
@@ -4569,74 +6533,17 @@ function modifyViewport() {
4569
6533
 
4570
6534
  /***/ }),
4571
6535
 
4572
- /***/ 2493:
4573
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4574
-
4575
- "use strict";
4576
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4577
- /* harmony export */ "M": () => (/* binding */ Com),
4578
- /* harmony export */ "u": () => (/* binding */ Clickaway)
4579
- /* harmony export */ });
4580
- /* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6400);
4581
- /* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(819);
4582
-
4583
-
4584
- class Com extends preact__WEBPACK_IMPORTED_MODULE_0__/* .Component */ .wA {
4585
- constructor(props) {
4586
- super(props);
4587
- this._isMounted = true;
4588
- setTimeout(() => {
4589
- if (this.componentWillUnmount) {
4590
- let old = this.componentWillUnmount.bind(this);
4591
-
4592
- this.componentWillUnmount = () => {
4593
- old();
4594
- this._isMounted = false;
4595
- };
4596
- }
4597
- }, 10);
4598
- }
4599
-
4600
- }
4601
- class Clickaway extends Com {
4602
- constructor(props) {
4603
- super(props);
4604
- this.setWrapperRef = this.setWrapperRef.bind(this);
4605
- this.onClick = this.onClick.bind(this);
4606
- }
4607
-
4608
- componentDidMount() {
4609
- document.addEventListener('mousedown', this.onClick);
4610
- }
4611
-
4612
- componentWillUnmount() {
4613
- document.removeEventListener('mousedown', this.onClick);
4614
- }
4615
-
4616
- setWrapperRef(node) {
4617
- this.wrapperRef = node;
4618
- }
4619
-
4620
- onClick(event) {
4621
- if (this.wrapperRef && !this.wrapperRef.contains(event.target)) {
4622
- this.props.onClickaway && this.props.onClickaway();
4623
- }
4624
- }
4625
-
4626
- render() {
4627
- return (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", {
4628
- ref: this.setWrapperRef
4629
- }, this.props.children);
4630
- }
6536
+ /***/ 6755:
6537
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4631
6538
 
4632
- }
6539
+ module.exports = __webpack_require__.p + "assets/img/bubble_default.7d5e4ab.svg";
4633
6540
 
4634
6541
  /***/ }),
4635
6542
 
4636
- /***/ 6755:
6543
+ /***/ 8712:
4637
6544
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4638
6545
 
4639
- module.exports = __webpack_require__.p + "assets/img/bubble_default.7d5e4ab.svg";
6546
+ module.exports = __webpack_require__.p + "assets/img/caret.998eb8f.svg";
4640
6547
 
4641
6548
  /***/ }),
4642
6549
 
@@ -4668,6 +6575,13 @@ module.exports = __webpack_require__.p + "assets/img/done_gray.d7e8203.svg";
4668
6575
 
4669
6576
  /***/ }),
4670
6577
 
6578
+ /***/ 763:
6579
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6580
+
6581
+ module.exports = __webpack_require__.p + "assets/img/done_green.b817fd4.svg";
6582
+
6583
+ /***/ }),
6584
+
4671
6585
  /***/ 29:
4672
6586
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4673
6587
 
@@ -4675,6 +6589,13 @@ module.exports = __webpack_require__.p + "assets/img/empty.29bed2d.svg";
4675
6589
 
4676
6590
  /***/ }),
4677
6591
 
6592
+ /***/ 6825:
6593
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6594
+
6595
+ module.exports = __webpack_require__.p + "assets/img/empty_1.0b98af0.svg";
6596
+
6597
+ /***/ }),
6598
+
4678
6599
  /***/ 8453:
4679
6600
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4680
6601
 
@@ -4682,6 +6603,20 @@ module.exports = __webpack_require__.p + "assets/img/external-link.90577cc.svg";
4682
6603
 
4683
6604
  /***/ }),
4684
6605
 
6606
+ /***/ 1473:
6607
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6608
+
6609
+ module.exports = __webpack_require__.p + "assets/img/ghn.070f8e3.svg";
6610
+
6611
+ /***/ }),
6612
+
6613
+ /***/ 6890:
6614
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6615
+
6616
+ module.exports = __webpack_require__.p + "assets/img/ghtk.326eac1.svg";
6617
+
6618
+ /***/ }),
6619
+
4685
6620
  /***/ 9895:
4686
6621
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4687
6622
 
@@ -4689,6 +6624,20 @@ module.exports = __webpack_require__.p + "assets/img/image_default.be0698b.png";
4689
6624
 
4690
6625
  /***/ }),
4691
6626
 
6627
+ /***/ 9256:
6628
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6629
+
6630
+ module.exports = __webpack_require__.p + "assets/img/info.ebce7ea.svg";
6631
+
6632
+ /***/ }),
6633
+
6634
+ /***/ 5770:
6635
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6636
+
6637
+ module.exports = __webpack_require__.p + "assets/img/loader.37000a7.svg";
6638
+
6639
+ /***/ }),
6640
+
4692
6641
  /***/ 6484:
4693
6642
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4694
6643
 
@@ -4696,6 +6645,27 @@ module.exports = __webpack_require__.p + "assets/img/loading_static.8f403ae.svg"
4696
6645
 
4697
6646
  /***/ }),
4698
6647
 
6648
+ /***/ 6071:
6649
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6650
+
6651
+ module.exports = __webpack_require__.p + "assets/img/not_found_search.2ddb8d1.png";
6652
+
6653
+ /***/ }),
6654
+
6655
+ /***/ 25:
6656
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6657
+
6658
+ module.exports = __webpack_require__.p + "assets/img/package.8d37d0f.svg";
6659
+
6660
+ /***/ }),
6661
+
6662
+ /***/ 1216:
6663
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6664
+
6665
+ module.exports = __webpack_require__.p + "assets/img/package_fade.763c001.svg";
6666
+
6667
+ /***/ }),
6668
+
4699
6669
  /***/ 6535:
4700
6670
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4701
6671
 
@@ -4717,6 +6687,13 @@ module.exports = __webpack_require__.p + "assets/img/rating--poor.2938a25.svg";
4717
6687
 
4718
6688
  /***/ }),
4719
6689
 
6690
+ /***/ 636:
6691
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6692
+
6693
+ module.exports = __webpack_require__.p + "assets/img/search.f9705ff.svg";
6694
+
6695
+ /***/ }),
6696
+
4720
6697
  /***/ 9737:
4721
6698
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4722
6699
 
@@ -4724,11 +6701,32 @@ module.exports = __webpack_require__.p + "assets/img/send.6db52a9.svg";
4724
6701
 
4725
6702
  /***/ }),
4726
6703
 
6704
+ /***/ 6180:
6705
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6706
+
6707
+ module.exports = __webpack_require__.p + "assets/img/shop.f7dc7d8.svg";
6708
+
6709
+ /***/ }),
6710
+
6711
+ /***/ 750:
6712
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6713
+
6714
+ module.exports = __webpack_require__.p + "assets/img/shop_faded.df7845a.svg";
6715
+
6716
+ /***/ }),
6717
+
4727
6718
  /***/ 8430:
4728
6719
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4729
6720
 
4730
6721
  module.exports = __webpack_require__.p + "assets/img/subiz-mono.877e9f5.svg";
4731
6722
 
6723
+ /***/ }),
6724
+
6725
+ /***/ 2514:
6726
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6727
+
6728
+ module.exports = __webpack_require__.p + "assets/img/x.26fdfa3.svg";
6729
+
4732
6730
  /***/ })
4733
6731
 
4734
6732
  }]);