@subiz/widget-v4 4.0.59 → 4.0.64

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