@subiz/widget-v4 4.0.63 → 4.0.67

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 (100) hide show
  1. package/assets/less/chatbox.less +6 -1
  2. package/babel.config.js +2 -4
  3. package/compiled_src/bot.js +7 -1
  4. package/compiled_src/call/call.js +15 -12
  5. package/compiled_src/chatbox/ChatButton.js +3 -1
  6. package/compiled_src/chatbox/DropdownSelect.js +75 -66
  7. package/compiled_src/chatbox/Event.js +1 -0
  8. package/compiled_src/chatbox/MessageInput.js +7 -4
  9. package/compiled_src/chatbox/Order.js +94 -90
  10. package/compiled_src/chatbox/ProductAttachments.js +40 -4
  11. package/compiled_src/chatbox/Rating.js +10 -7
  12. package/compiled_src/chatbox/Typing.js +3 -1
  13. package/compiled_src/chatbox/Widget.js +27 -23
  14. package/compiled_src/chatbox/main.js +2 -0
  15. package/compiled_src/contact/contact.js +9 -6
  16. package/compiled_src/lib.js +14 -9
  17. package/compiled_src/notif/notif.js +15 -12
  18. package/compiled_src/order/address_picker.js +71 -63
  19. package/compiled_src/order/order.js +330 -316
  20. package/compiled_src/popup/countdown.js +7 -4
  21. package/compiled_src/popup/popup.js +12 -9
  22. package/compiled_src/store/api.js +110 -80
  23. package/compiled_src/store/api_fake.js +82 -55
  24. package/compiled_src/store/store.js +194 -135
  25. package/compiled_src/util/common.js +1 -1
  26. package/dist/132.js +678 -591
  27. package/dist/178.js +174 -341
  28. package/dist/17ff367201e.132.js +1 -0
  29. package/dist/17ff367201e.178.js +1 -0
  30. package/dist/17ff367201e.213.js +1 -0
  31. package/dist/17ff367201e.335.js +1 -0
  32. package/dist/17ff367201e.362.js +1 -0
  33. package/dist/17ff367201e.441.js +1 -0
  34. package/dist/17ff367201e.605.js +1 -0
  35. package/dist/17ff367201e.678.js +1 -0
  36. package/dist/17ff367201e.782.js +1 -0
  37. package/dist/17ff367201e.app.js +1 -0
  38. package/dist/{17e757ccadd.index.html → 17ff367201e.index.html} +1 -1
  39. package/dist/{17e757ccadd.library.html → 17ff367201e.library.html} +1 -1
  40. package/dist/17ff367201e.library.js +1 -0
  41. package/dist/{17e757ccadd.preview.html → 17ff367201e.preview.html} +1 -1
  42. package/dist/17ff367201e.preview.js +1 -0
  43. package/dist/17ff367201e.screenshoot.js +1 -0
  44. package/dist/213.js +19 -13
  45. package/dist/335.js +11 -8
  46. package/dist/362.js +21 -71
  47. package/dist/441.js +2 -2
  48. package/dist/605.js +15 -12
  49. package/dist/678.js +20 -70
  50. package/dist/782.js +21 -118
  51. package/dist/HASH +1 -1
  52. package/dist/screenshoot.html +1 -1
  53. package/dist/screenshoot.js +453 -332
  54. package/package.json +14 -14
  55. package/src/bot.js +2 -1
  56. package/src/chatbox/Buttons.js +8 -8
  57. package/src/chatbox/ChatButton.js +2 -2
  58. package/src/chatbox/Event.js +1 -1
  59. package/src/chatbox/ProductAttachments.js +41 -5
  60. package/src/chatbox/Typing.js +5 -1
  61. package/src/chatbox/main.js +4 -1
  62. package/src/store/store.js +24 -11
  63. package/src/util/common.js +1 -1
  64. package/up +1 -1
  65. package/dist/0b82fa7e5c3b07b40a44.png +0 -1
  66. package/dist/0f4af006e38ee8b93633.png +0 -1
  67. package/dist/17e757ccadd.132.js +0 -1
  68. package/dist/17e757ccadd.178.js +0 -1
  69. package/dist/17e757ccadd.213.js +0 -1
  70. package/dist/17e757ccadd.335.js +0 -1
  71. package/dist/17e757ccadd.362.js +0 -1
  72. package/dist/17e757ccadd.441.js +0 -1
  73. package/dist/17e757ccadd.605.js +0 -1
  74. package/dist/17e757ccadd.678.js +0 -1
  75. package/dist/17e757ccadd.782.js +0 -1
  76. package/dist/17e757ccadd.app.js +0 -1
  77. package/dist/17e757ccadd.library.js +0 -1
  78. package/dist/17e757ccadd.preview.js +0 -1
  79. package/dist/17e757ccadd.screenshoot.js +0 -1
  80. package/dist/1ea1c6cd21d25176810c.png +0 -1
  81. package/dist/292d42404e1b03398f61.png +0 -1
  82. package/dist/312d376370831b7bea83.png +0 -1
  83. package/dist/313d1bfc1cf776d1aefe.png +0 -1
  84. package/dist/4aa58bb7a66bb44975aa.png +0 -1
  85. package/dist/56ce063bc6c81adb7322.png +0 -1
  86. package/dist/6a411166ef5cc79e0714.png +0 -1
  87. package/dist/6faf403782fefacc1649.png +0 -1
  88. package/dist/79dca33c68fab79c067f.png +0 -1
  89. package/dist/82da1578fa84f9debaeb.png +0 -1
  90. package/dist/8b8e0f0824743974b282.png +0 -1
  91. package/dist/8d551390d81e39130a3c.png +0 -1
  92. package/dist/9fc61b9479877ebdb6c7.png +0 -1
  93. package/dist/a165d31dcb3dc90f1057.png +0 -1
  94. package/dist/a98d4a5698812c4426b3.png +0 -1
  95. package/dist/c41606bf9d1b604e46d5.png +0 -1
  96. package/dist/ce1f7450ce6c1aacd330.png +0 -1
  97. package/dist/cf8c01e88f4770a6e3e5.png +0 -1
  98. package/dist/dfbcfeab1d5622a737e2.png +0 -1
  99. package/dist/e4893ed8c2f7b8329919.png +0 -1
  100. package/dist/ec2ab4eb4ef73d186186.png +0 -1
package/dist/132.js CHANGED
@@ -161,8 +161,9 @@ class ChatButton extends common/* Com */.up {
161
161
  let accountSetting = this.props.plugin.chatbox;
162
162
  if (new util/* default.Date */.Z.Date().getTime() - this.props.store.matchClosePreviewAt() < Ms30Mins) return;
163
163
  let greeting = util/* default.get */.Z.get(accountSetting, 'greeting', {});
164
+ let text = this.props.t.i18n(util/* default.get */.Z.get(greeting, 'greeting', {})) || greeting.message;
164
165
 
165
- if (!greeting.message || !greeting.enabled) {
166
+ if (!text || !greeting.enabled) {
166
167
  this.setState({
167
168
  previewEvent: {}
168
169
  });
@@ -805,6 +806,8 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
805
806
 
806
807
  let getJoinedNameMember = agents => util/* default.map */.Z.map(agents, agent => agent.name).join(', ');
807
808
  ;// CONCATENATED MODULE: ./src/chatbox/MessageInput.js
809
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
810
+
808
811
 
809
812
 
810
813
 
@@ -812,6 +815,11 @@ let getJoinedNameMember = agents => util/* default.map */.Z.map(agents, agent =>
812
815
  class MessageInput extends common/* Com */.up {
813
816
  constructor(props) {
814
817
  super(props);
818
+
819
+ _defineProperty(this, "onEnter", util/* default.throttle */.Z.throttle(function () {
820
+ this.submitMessage();
821
+ }, 50));
822
+
815
823
  this.refFileInput = (0,preact_module/* createRef */.Vf)();
816
824
  this.refMessageInput = (0,preact_module/* createRef */.Vf)();
817
825
  this.props.store.onUpdate(this, _ => this.forceUpdate());
@@ -1049,10 +1057,6 @@ class MessageInput extends common/* Com */.up {
1049
1057
  input.focus();
1050
1058
  }
1051
1059
 
1052
- onEnter = util/* default.throttle */.Z.throttle(function () {
1053
- this.submitMessage();
1054
- }, 50);
1055
-
1056
1060
  onKeydown(e) {
1057
1061
  if (e.keyCode === 13 && e.shiftKey === false) {
1058
1062
  this.onEnter();
@@ -2028,17 +2032,53 @@ class ProductAttachments extends common/* Com */.up {
2028
2032
  let acc = this.props.store.matchAccount();
2029
2033
  let $products = util/* default.map */.Z.map(products, (att, index) => {
2030
2034
  let product = att.product;
2031
- let $detailbtn = null;
2035
+ let $detailbtns = [];
2032
2036
  let url = product.url || product.mobile_url;
2033
2037
  if (this.props.store.isMobile()) url = product.mobile_url || product.url;
2034
- if (url) $detailbtn = (0,preact_module.h)("a", {
2038
+ if (url && util/* default.size */.Z.size(product.buttons) == 0) $detailbtns.push((0,preact_module.h)("a", {
2035
2039
  class: "product_attachment__btn",
2036
2040
  href: url,
2037
2041
  target: "_blank"
2038
2042
  }, this.props.t('detail'), (0,preact_module.h)("img", {
2039
2043
  src: __webpack_require__(8453),
2040
2044
  class: "product_attachment__btn_external_link"
2041
- }));
2045
+ })));
2046
+ console.log("P", product);
2047
+
2048
+ if (util/* default.size */.Z.size(product.buttons) > 0) {
2049
+ $detailbtns = $detailbtns.concat(util/* default.map */.Z.map(product.buttons, (button, index) => {
2050
+ if (button.type === 'call_button') {
2051
+ return (0,preact_module.h)("a", {
2052
+ class: "product_attachment__btn",
2053
+ href: 'tel:' + button.phone_number,
2054
+ key: index,
2055
+ title: button.title
2056
+ }, button.title);
2057
+ }
2058
+
2059
+ if (button.type === 'url_button') {
2060
+ return (0,preact_module.h)("a", {
2061
+ class: "product_attachment__btn",
2062
+ href: button.url,
2063
+ target: "_blank",
2064
+ key: index,
2065
+ title: button.title
2066
+ }, button.title || this.props.t('detail'), ' ', (0,preact_module.h)("img", {
2067
+ src: __webpack_require__(8453),
2068
+ class: "product_attachment__btn_external_link"
2069
+ }));
2070
+ }
2071
+
2072
+ if (button.type === 'postback_button') {
2073
+ return (0,preact_module.h)("a", {
2074
+ class: "product_attachment__btn",
2075
+ href: "javascript:;",
2076
+ onClick: _ => this.props.onPostback(button)
2077
+ }, button.title);
2078
+ }
2079
+ }));
2080
+ }
2081
+
2042
2082
  let $title = (0,preact_module.h)("a", {
2043
2083
  href: url,
2044
2084
  class: "product_attachment__title",
@@ -2067,7 +2107,7 @@ class ProductAttachments extends common/* Com */.up {
2067
2107
  src: this.props.store.replaceFileUrl(product.image)
2068
2108
  }))), $title, $subtitle, $price, (0,preact_module.h)("div", {
2069
2109
  class: "product_attachment__btns"
2070
- }, $detailbtn));
2110
+ }, $detailbtns));
2071
2111
  });
2072
2112
  return $products;
2073
2113
  }
@@ -2693,6 +2733,7 @@ class Event extends common/* Com */.up {
2693
2733
  onSelect: e => this.choosePostbackBtn(e)
2694
2734
  }), (0,preact_module.h)(ProductAttachments, {
2695
2735
  t: this.props.t,
2736
+ onPostback: e => this.choosePostbackBtn(e),
2696
2737
  store: this.props.store,
2697
2738
  ev: ev
2698
2739
  }), (0,preact_module.h)(OrderAttachments_ProductAttachments, {
@@ -3146,6 +3187,8 @@ class Typing extends common/* Com */.up {
3146
3187
  return;
3147
3188
  }
3148
3189
 
3190
+ let ag = this.props.store.matchAgent(ev.by.id);
3191
+ if (ag.type == 'agent') return;
3149
3192
  if (util/* default.get */.Z.get(ev, 'type') !== 'conversation_typing') return;
3150
3193
  this.setState({
3151
3194
  ev: ev,
@@ -3158,7 +3201,7 @@ class Typing extends common/* Com */.up {
3158
3201
  this.setState({
3159
3202
  isShow: false
3160
3203
  });
3161
- }, 10000);
3204
+ }, 5000);
3162
3205
  });
3163
3206
  }
3164
3207
 
@@ -3236,6 +3279,8 @@ function eqFloat(a, b) {
3236
3279
  return Math.abs(a - b) <= 0.001;
3237
3280
  }
3238
3281
  ;// CONCATENATED MODULE: ./src/chatbox/Rating.js
3282
+ function Rating_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3283
+
3239
3284
 
3240
3285
 
3241
3286
  const POPUP_MAX_HEIGHT = 400;
@@ -3246,18 +3291,19 @@ const POPUP_MIN_HEIGHT = 0;
3246
3291
  class Rating extends common/* Com */.up {
3247
3292
  constructor(props) {
3248
3293
  super(props);
3294
+
3295
+ Rating_defineProperty(this, "state", {
3296
+ hide: true,
3297
+ ratingHeight: 0,
3298
+ overlayOpacity: 0.3,
3299
+ comment: ''
3300
+ });
3301
+
3249
3302
  this.refComment = (0,preact_module/* createRef */.Vf)();
3250
3303
  this.refRating = (0,preact_module/* createRef */.Vf)();
3251
3304
  this.refHandle = (0,preact_module/* createRef */.Vf)();
3252
3305
  }
3253
3306
 
3254
- state = {
3255
- hide: true,
3256
- ratingHeight: 0,
3257
- overlayOpacity: 0.3,
3258
- comment: ''
3259
- };
3260
-
3261
3307
  componentDidMount() {
3262
3308
  this.props.store.onUpdate(this, () => {
3263
3309
  if (this.shoudDisplay()) this.open();
@@ -3522,63 +3568,96 @@ class Rating extends common/* Com */.up {
3522
3568
 
3523
3569
  }
3524
3570
  ;// CONCATENATED MODULE: ./src/chatbox/DropdownSelect.js
3571
+ function DropdownSelect_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3525
3572
 
3526
3573
 
3527
3574
 
3528
3575
 
3529
- class DropdownSelect extends common/* Com */.up {
3530
- state = {
3531
- show: false,
3532
- searchValue: ''
3533
- };
3534
- filterRef = (0,preact_module/* createRef */.Vf)();
3535
- overlayRef = (0,preact_module/* createRef */.Vf)();
3536
3576
 
3577
+ class DropdownSelect extends common/* Com */.up {
3537
3578
  constructor(props) {
3538
3579
  super(props);
3539
- document.addEventListener('touchmove', function (e) {});
3540
- }
3541
3580
 
3542
- onTouchMove = e => {
3543
- if (e.target === this.overlayRef.current) {
3544
- e.preventDefault();
3545
- e.stopPropagation();
3546
- }
3547
- };
3548
- hideDropdown = () => {
3549
- this.setState({
3581
+ DropdownSelect_defineProperty(this, "state", {
3550
3582
  show: false,
3551
3583
  searchValue: ''
3552
3584
  });
3553
- };
3554
- onKeydown = e => {
3555
- if (e.key === 'Escape') {
3556
- if (!this.state.show) return;
3557
- if (this.state.searchValue) this.setState({
3585
+
3586
+ DropdownSelect_defineProperty(this, "filterRef", (0,preact_module/* createRef */.Vf)());
3587
+
3588
+ DropdownSelect_defineProperty(this, "overlayRef", (0,preact_module/* createRef */.Vf)());
3589
+
3590
+ DropdownSelect_defineProperty(this, "onTouchMove", e => {
3591
+ if (e.target === this.overlayRef.current) {
3592
+ e.preventDefault();
3593
+ e.stopPropagation();
3594
+ }
3595
+ });
3596
+
3597
+ DropdownSelect_defineProperty(this, "hideDropdown", () => {
3598
+ this.setState({
3599
+ show: false,
3558
3600
  searchValue: ''
3559
- });else this.hideDropdown();
3560
- e.preventDefault();
3561
- e.stopPropagation();
3562
- }
3563
- };
3564
- hasSearch = () => {
3565
- if (this.props.has_search) return true;
3566
- return util/* default.size */.Z.size(this.props.items) >= 10;
3567
- };
3568
- getFilteredOptions = () => {
3569
- let items = this.props.items;
3570
-
3571
- if (this.state.searchValue && this.hasSearch()) {
3572
- items = util/* default.filter */.Z.filter(items, item => {
3573
- let optionName = util/* default.unicodeToAscii */.Z.unicodeToAscii(item.name).toLowerCase().replace(/ /g, '');
3574
- let optionDesc = util/* default.unicodeToAscii */.Z.unicodeToAscii(item.desc).toLowerCase().replace(/ /g, '');
3575
- let searchValue = util/* default.unicodeToAscii */.Z.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g, '');
3576
- return optionName.indexOf(searchValue) != -1 || optionDesc.indexOf(searchValue) != -1;
3577
3601
  });
3578
- }
3602
+ });
3579
3603
 
3580
- return items;
3581
- };
3604
+ DropdownSelect_defineProperty(this, "onKeydown", e => {
3605
+ if (e.key === 'Escape') {
3606
+ if (!this.state.show) return;
3607
+ if (this.state.searchValue) this.setState({
3608
+ searchValue: ''
3609
+ });else this.hideDropdown();
3610
+ e.preventDefault();
3611
+ e.stopPropagation();
3612
+ }
3613
+ });
3614
+
3615
+ DropdownSelect_defineProperty(this, "hasSearch", () => {
3616
+ if (this.props.has_search) return true;
3617
+ return util/* default.size */.Z.size(this.props.items) >= 10;
3618
+ });
3619
+
3620
+ DropdownSelect_defineProperty(this, "getFilteredOptions", () => {
3621
+ let items = this.props.items;
3622
+
3623
+ if (this.state.searchValue && this.hasSearch()) {
3624
+ items = util/* default.filter */.Z.filter(items, item => {
3625
+ let optionName = util/* default.unicodeToAscii */.Z.unicodeToAscii(item.name).toLowerCase().replace(/ /g, '');
3626
+ let optionDesc = util/* default.unicodeToAscii */.Z.unicodeToAscii(item.desc).toLowerCase().replace(/ /g, '');
3627
+ let searchValue = util/* default.unicodeToAscii */.Z.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g, '');
3628
+ return optionName.indexOf(searchValue) != -1 || optionDesc.indexOf(searchValue) != -1;
3629
+ });
3630
+ }
3631
+
3632
+ return items;
3633
+ });
3634
+
3635
+ DropdownSelect_defineProperty(this, "onChangeSearchValue", e => {
3636
+ this.setState({
3637
+ searchValue: e.target.value
3638
+ });
3639
+ });
3640
+
3641
+ DropdownSelect_defineProperty(this, "toogleDropdown", async () => {
3642
+ await this.setState({
3643
+ show: true,
3644
+ searchValue: ''
3645
+ });
3646
+ this.focusFilter();
3647
+ });
3648
+
3649
+ DropdownSelect_defineProperty(this, "onSelect", item => {
3650
+ this.props.onSelect(item);
3651
+ this.hideDropdown();
3652
+ });
3653
+
3654
+ DropdownSelect_defineProperty(this, "onBackgroundScroll", e => {
3655
+ console.log('EEEEEEE', e);
3656
+ alert('y');
3657
+ });
3658
+
3659
+ document.addEventListener('touchmove', function (e) {});
3660
+ }
3582
3661
 
3583
3662
  componentDidMount() {
3584
3663
  window.addEventListener('keydown', this.onKeydown);
@@ -3588,12 +3667,6 @@ class DropdownSelect extends common/* Com */.up {
3588
3667
  window.removeEventListener('keydown', this.onKeydown);
3589
3668
  }
3590
3669
 
3591
- onChangeSearchValue = e => {
3592
- this.setState({
3593
- searchValue: e.target.value
3594
- });
3595
- };
3596
-
3597
3670
  renderEmpty() {
3598
3671
  return (0,preact_module.h)("div", {
3599
3672
  class: "dropdown_select_filter__empty"
@@ -3618,14 +3691,6 @@ class DropdownSelect extends common/* Com */.up {
3618
3691
  }, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
3619
3692
  }
3620
3693
 
3621
- toogleDropdown = async () => {
3622
- await this.setState({
3623
- show: true,
3624
- searchValue: ''
3625
- });
3626
- this.focusFilter();
3627
- };
3628
-
3629
3694
  focusFilter() {
3630
3695
  if (!this.filterRef.current) return;
3631
3696
  this.filterRef.current.focus();
@@ -3635,11 +3700,6 @@ class DropdownSelect extends common/* Com */.up {
3635
3700
  }, 100);
3636
3701
  }
3637
3702
 
3638
- onSelect = item => {
3639
- this.props.onSelect(item);
3640
- this.hideDropdown();
3641
- };
3642
-
3643
3703
  renderDropdown() {
3644
3704
  if (!this.state.show) return null;
3645
3705
  let items = this.getFilteredOptions();
@@ -3706,11 +3766,6 @@ class DropdownSelect extends common/* Com */.up {
3706
3766
  }, $items));
3707
3767
  }
3708
3768
 
3709
- onBackgroundScroll = e => {
3710
- console.log('EEEEEEE', e);
3711
- alert('y');
3712
- };
3713
-
3714
3769
  render() {
3715
3770
  let $name = (0,preact_module.h)("div", {
3716
3771
  class: "muted text-truncate",
@@ -3742,57 +3797,90 @@ class DropdownSelect extends common/* Com */.up {
3742
3797
 
3743
3798
  }
3744
3799
  ;// CONCATENATED MODULE: ./src/order/address_picker.js
3800
+ function address_picker_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3745
3801
 
3746
3802
 
3747
3803
 
3748
3804
 
3749
- class AddressPicker extends common/* Com */.up {
3750
- state = {
3751
- show: false,
3752
- searchValue: '',
3753
- addresses: []
3754
- };
3755
- filterRef = (0,preact_module/* createRef */.Vf)();
3756
- overlayRef = (0,preact_module/* createRef */.Vf)();
3757
3805
 
3806
+ class AddressPicker extends common/* Com */.up {
3758
3807
  constructor(props) {
3759
3808
  super(props);
3760
- document.addEventListener('touchmove', function (e) {});
3761
- }
3762
3809
 
3763
- onTouchMove = e => {
3764
- if (e.target === this.overlayRef.current) {
3765
- e.preventDefault();
3766
- e.stopPropagation();
3767
- }
3768
- };
3769
- hideDropdown = () => {
3770
- this.setState({
3810
+ address_picker_defineProperty(this, "state", {
3771
3811
  show: false,
3772
- searchValue: ''
3812
+ searchValue: '',
3813
+ addresses: []
3773
3814
  });
3774
- };
3775
- onKeydown = e => {
3776
- if (e.key === 'Escape') {
3777
- if (!this.state.show) return;
3778
- if (this.state.searchValue) this.setState({
3815
+
3816
+ address_picker_defineProperty(this, "filterRef", (0,preact_module/* createRef */.Vf)());
3817
+
3818
+ address_picker_defineProperty(this, "overlayRef", (0,preact_module/* createRef */.Vf)());
3819
+
3820
+ address_picker_defineProperty(this, "onTouchMove", e => {
3821
+ if (e.target === this.overlayRef.current) {
3822
+ e.preventDefault();
3823
+ e.stopPropagation();
3824
+ }
3825
+ });
3826
+
3827
+ address_picker_defineProperty(this, "hideDropdown", () => {
3828
+ this.setState({
3829
+ show: false,
3779
3830
  searchValue: ''
3780
- });else this.hideDropdown();
3781
- e.preventDefault();
3782
- e.stopPropagation();
3783
- }
3831
+ });
3832
+ });
3784
3833
 
3785
- if (e.key == 'Enter') {}
3786
- };
3787
- doSearch = util/* default.throttle */.Z.throttle(async () => {
3788
- let requestId = Date.now();
3789
- this.requestId = requestId;
3790
- let res = await this.props.store.suggest_addresses(this.state.searchValue);
3791
- if (this.requestId !== requestId) return;
3792
- this.setState({
3793
- addresses: util/* default.get */.Z.get(res, 'body.addresses', [])
3834
+ address_picker_defineProperty(this, "onKeydown", e => {
3835
+ if (e.key === 'Escape') {
3836
+ if (!this.state.show) return;
3837
+ if (this.state.searchValue) this.setState({
3838
+ searchValue: ''
3839
+ });else this.hideDropdown();
3840
+ e.preventDefault();
3841
+ e.stopPropagation();
3842
+ }
3843
+
3844
+ if (e.key == 'Enter') {}
3845
+ });
3846
+
3847
+ address_picker_defineProperty(this, "doSearch", util/* default.throttle */.Z.throttle(async () => {
3848
+ let requestId = Date.now();
3849
+ this.requestId = requestId;
3850
+ let res = await this.props.store.suggest_addresses(this.state.searchValue);
3851
+ if (this.requestId !== requestId) return;
3852
+ this.setState({
3853
+ addresses: util/* default.get */.Z.get(res, 'body.addresses', [])
3854
+ });
3855
+ }, 100));
3856
+
3857
+ address_picker_defineProperty(this, "onChangeSearchValue", e => {
3858
+ this.setState({
3859
+ searchValue: e.target.value
3860
+ });
3861
+ this.props.onChangeAddress(e.target.value);
3862
+ this.doSearch();
3863
+ });
3864
+
3865
+ address_picker_defineProperty(this, "toogleDropdown", async () => {
3866
+ await this.setState({
3867
+ show: true,
3868
+ searchValue: this.props.initAddress || ''
3869
+ });
3870
+ this.focusFilter();
3871
+ });
3872
+
3873
+ address_picker_defineProperty(this, "onSelect", item => {
3874
+ this.props.onSelect(item);
3875
+ this.hideDropdown();
3794
3876
  });
3795
- }, 100);
3877
+
3878
+ address_picker_defineProperty(this, "onBackgroundScroll", e => {
3879
+ console.log('EEEEEEE', e);
3880
+ });
3881
+
3882
+ document.addEventListener('touchmove', function (e) {});
3883
+ }
3796
3884
 
3797
3885
  componentDidMount() {
3798
3886
  window.addEventListener('keydown', this.onKeydown);
@@ -3802,14 +3890,6 @@ class AddressPicker extends common/* Com */.up {
3802
3890
  window.removeEventListener('keydown', this.onKeydown);
3803
3891
  }
3804
3892
 
3805
- onChangeSearchValue = e => {
3806
- this.setState({
3807
- searchValue: e.target.value
3808
- });
3809
- this.props.onChangeAddress(e.target.value);
3810
- this.doSearch();
3811
- };
3812
-
3813
3893
  renderEmpty() {
3814
3894
  return (0,preact_module.h)("div", {
3815
3895
  class: "dropdown_select_filter__empty"
@@ -3834,14 +3914,6 @@ class AddressPicker extends common/* Com */.up {
3834
3914
  }, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
3835
3915
  }
3836
3916
 
3837
- toogleDropdown = async () => {
3838
- await this.setState({
3839
- show: true,
3840
- searchValue: this.props.initAddress || ''
3841
- });
3842
- this.focusFilter();
3843
- };
3844
-
3845
3917
  focusFilter() {
3846
3918
  if (!this.filterRef.current) return;
3847
3919
  this.filterRef.current.focus();
@@ -3851,11 +3923,6 @@ class AddressPicker extends common/* Com */.up {
3851
3923
  }, 100);
3852
3924
  }
3853
3925
 
3854
- onSelect = item => {
3855
- this.props.onSelect(item);
3856
- this.hideDropdown();
3857
- };
3858
-
3859
3926
  renderDropdown() {
3860
3927
  if (!this.state.show) return null;
3861
3928
  let $items = util/* default.map */.Z.map(this.state.addresses, (addr, i) => {
@@ -3922,10 +3989,6 @@ class AddressPicker extends common/* Com */.up {
3922
3989
  }, $items));
3923
3990
  }
3924
3991
 
3925
- onBackgroundScroll = e => {
3926
- console.log('EEEEEEE', e);
3927
- };
3928
-
3929
3992
  render() {
3930
3993
  let $name = (0,preact_module.h)("div", {
3931
3994
  class: "text-truncate",
@@ -4010,6 +4073,8 @@ class Icon extends common/* Com */.up {
4010
4073
 
4011
4074
  }
4012
4075
  ;// CONCATENATED MODULE: ./src/order/order.js
4076
+ function order_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4077
+
4013
4078
 
4014
4079
 
4015
4080
 
@@ -4024,202 +4089,384 @@ var checkedimg = __webpack_require__(763);
4024
4089
  var ximg = __webpack_require__(2514);
4025
4090
 
4026
4091
  class order_Order extends common/* Com */.up {
4027
- state = {
4028
- loadProvince: true,
4029
- g_err: '',
4030
- fullname: '',
4031
- email: '',
4032
- phone: '',
4033
- loading: true,
4034
- order: {},
4035
- err: {},
4036
- selectedProvince: null,
4037
- selectedDistrict: null,
4038
- selectedWard: null,
4039
- street: '',
4040
- address: '',
4041
- sending: false,
4042
- step: ''
4043
- };
4044
-
4045
4092
  constructor(props) {
4046
4093
  super(props);
4047
- this.load();
4048
- }
4049
4094
 
4050
- async load() {
4051
- if (!this.props.order_id) return;
4052
- let orderout = await this.props.store.fetchOrder(this.props.order_id);
4053
- this.setState({
4054
- loading: false
4095
+ order_defineProperty(this, "state", {
4096
+ loadProvince: true,
4097
+ g_err: '',
4098
+ fullname: '',
4099
+ email: '',
4100
+ phone: '',
4101
+ loading: true,
4102
+ order: {},
4103
+ err: {},
4104
+ selectedProvince: null,
4105
+ selectedDistrict: null,
4106
+ selectedWard: null,
4107
+ street: '',
4108
+ address: '',
4109
+ sending: false,
4110
+ step: ''
4055
4111
  });
4056
4112
 
4057
- if (!orderout.error) {
4113
+ order_defineProperty(this, "renderMobileSuccess", order => {
4114
+ return (0,preact_module.h)("div", {
4115
+ class: "order",
4116
+ style: "height: 100% !important"
4117
+ }, (0,preact_module.h)("div", {
4118
+ style: "display: flex !important; align-items: center !important; padding-top: 40px !important; padding-bottom: 20px !important; flex-direction: column !important; height: 100% !important"
4119
+ }, (0,preact_module.h)("img", {
4120
+ style: "width: 60px !important; height: 60px !important;",
4121
+ width: "60",
4122
+ height: "60",
4123
+ src: checkedimg
4124
+ }), (0,preact_module.h)("div", {
4125
+ style: "margin-top: 20px !important; margin-bottom: 10px !important"
4126
+ }, (0,preact_module.h)("b", {
4127
+ style: "font-size: 18px !important;"
4128
+ }, "\u0110\u01A1n h\xE0ng c\u1EE7a b\u1EA1n \u0111\xE3 \u0111\u01B0\u1EE3c ghi nh\u1EADn")), (0,preact_module.h)("div", {
4129
+ class: "muted"
4130
+ }, "T\xF4i s\u1EBD li\xEAn h\u1EC7 l\u1EA1i v\u1EDBi b\u1EA1n khi \u0111\u01A1n h\xE0ng \u0111\u01B0\u1EE3c x\u1EED l\xFD"), (0,preact_module.h)("div", {
4131
+ style: "flex:1 !important"
4132
+ }), (0,preact_module.h)("div", {
4133
+ style: "margin-top: 20px !important; padding: 0px 20px 0 20px !important; width: 100% !important"
4134
+ }, (0,preact_module.h)("div", {
4135
+ class: "order_btn order__btn__light",
4136
+ onClick: this.close
4137
+ }, this.props.t('close')))));
4138
+ });
4139
+
4140
+ order_defineProperty(this, "onSelectProvince", async item => {
4058
4141
  this.setState({
4059
- order: orderout.body
4142
+ selectedProvince: item,
4143
+ err: {},
4144
+ g_err: ''
4060
4145
  });
4061
- } else {
4062
4146
  this.setState({
4063
- error: orderout.error
4147
+ loadDistrict: true
4148
+ });
4149
+ let out = await this.props.store.list_districts({
4150
+ id: item.id
4151
+ });
4152
+ this.setState({
4153
+ loadDistrict: false
4154
+ });
4155
+ if (!out.error) this.setState({
4156
+ districts: util/* default.get */.Z.get(out, 'body.addresses')
4064
4157
  });
4065
- }
4066
-
4067
- let user = this.props.store.matchUser();
4068
- let attributes = util/* default.get */.Z.get(this.props.store.matchUser(), 'attributes', []);
4069
- let fullname = util/* default.get */.Z.get(util/* default.find */.Z.find(attributes, att => att.key === 'fullname'), 'text');
4070
- let email = util/* default.get */.Z.get(util/* default.find */.Z.find(attributes, att => att.key === 'emails'), 'text');
4071
- let phone = util/* default.get */.Z.get(util/* default.find */.Z.find(attributes, att => att.key === 'phones'), 'text');
4072
- this.setState({
4073
- fullname,
4074
- email,
4075
- phone
4076
- });
4077
- await this.props.store.fetchShippingAddresses();
4078
- let out = await this.props.store.list_provinces();
4079
- this.setState({
4080
- loadProvince: false
4081
- });
4082
- if (!out.error) this.setState({
4083
- provinces: util/* default.get */.Z.get(out, 'body.addresses')
4084
4158
  });
4085
- }
4086
4159
 
4087
- isMobile() {
4088
- if (this.props.cid) return true;
4089
- if (this.props.isMobile) return true;
4090
- return this.props.store.isMobile();
4091
- }
4160
+ order_defineProperty(this, "onSelectDistrict", async item => {
4161
+ this.setState({
4162
+ selectedDistrict: item,
4163
+ err: {},
4164
+ g_err: ''
4165
+ });
4166
+ this.setState({
4167
+ loadWard: true
4168
+ });
4169
+ let out = await this.props.store.list_wards({
4170
+ id: item.id
4171
+ });
4172
+ this.setState({
4173
+ loadWard: false
4174
+ });
4175
+ if (!out.error) this.setState({
4176
+ wards: util/* default.get */.Z.get(out, 'body.addresses')
4177
+ });
4178
+ });
4092
4179
 
4093
- onChangeShippingAddress(id) {
4094
- this.setState({
4095
- shipping_address: id,
4180
+ order_defineProperty(this, "onSelectWard", item => this.setState({
4181
+ selectedWard: item,
4096
4182
  err: {},
4097
4183
  g_err: ''
4098
- });
4099
- }
4100
-
4101
- renderMobileSuccess = order => {
4102
- return (0,preact_module.h)("div", {
4103
- class: "order",
4104
- style: "height: 100% !important"
4105
- }, (0,preact_module.h)("div", {
4106
- style: "display: flex !important; align-items: center !important; padding-top: 40px !important; padding-bottom: 20px !important; flex-direction: column !important; height: 100% !important"
4107
- }, (0,preact_module.h)("img", {
4108
- style: "width: 60px !important; height: 60px !important;",
4109
- width: "60",
4110
- height: "60",
4111
- src: checkedimg
4112
- }), (0,preact_module.h)("div", {
4113
- style: "margin-top: 20px !important; margin-bottom: 10px !important"
4114
- }, (0,preact_module.h)("b", {
4115
- style: "font-size: 18px !important;"
4116
- }, "\u0110\u01A1n h\xE0ng c\u1EE7a b\u1EA1n \u0111\xE3 \u0111\u01B0\u1EE3c ghi nh\u1EADn")), (0,preact_module.h)("div", {
4117
- class: "muted"
4118
- }, "T\xF4i s\u1EBD li\xEAn h\u1EC7 l\u1EA1i v\u1EDBi b\u1EA1n khi \u0111\u01A1n h\xE0ng \u0111\u01B0\u1EE3c x\u1EED l\xFD"), (0,preact_module.h)("div", {
4119
- style: "flex:1 !important"
4120
- }), (0,preact_module.h)("div", {
4121
- style: "margin-top: 20px !important; padding: 0px 20px 0 20px !important; width: 100% !important"
4122
- }, (0,preact_module.h)("div", {
4123
- class: "order_btn order__btn__light",
4124
- onClick: this.close
4125
- }, this.props.t('close')))));
4126
- };
4184
+ }));
4127
4185
 
4128
- onChangeShipping(id) {
4129
- this.setState({
4130
- shipping: id,
4186
+ order_defineProperty(this, "onChangeFullname", e => this.setState({
4187
+ fullname: e.target.value,
4131
4188
  err: {},
4132
4189
  g_err: ''
4133
- });
4134
- }
4190
+ }));
4135
4191
 
4136
- onSelectProvince = async item => {
4137
- this.setState({
4138
- selectedProvince: item,
4192
+ order_defineProperty(this, "onChangeAddress", e => this.setState({
4193
+ address: e,
4139
4194
  err: {},
4140
4195
  g_err: ''
4196
+ }));
4197
+
4198
+ order_defineProperty(this, "onSelectAddress", addr => {
4199
+ if (!addr) return;
4200
+ this.setState({
4201
+ address: [util/* default.trim */.Z.trim(addr.address), util/* default.trim */.Z.trim(addr.street)].join(' ').trim(),
4202
+ street: addr.street,
4203
+ err: {},
4204
+ g_err: ''
4205
+ });
4206
+ this.onSelectWard({
4207
+ id: addr.ward_id,
4208
+ name: addr.ward
4209
+ });
4210
+ this.onSelectDistrict({
4211
+ id: addr.district_id,
4212
+ name: addr.district
4213
+ });
4214
+ this.onSelectProvince({
4215
+ id: addr.province_id,
4216
+ name: addr.province
4217
+ });
4141
4218
  });
4142
- this.setState({
4143
- loadDistrict: true
4144
- });
4145
- let out = await this.props.store.list_districts({
4146
- id: item.id
4147
- });
4148
- this.setState({
4149
- loadDistrict: false
4150
- });
4151
- if (!out.error) this.setState({
4152
- districts: util/* default.get */.Z.get(out, 'body.addresses')
4153
- });
4154
- };
4155
- onSelectDistrict = async item => {
4156
- this.setState({
4157
- selectedDistrict: item,
4219
+
4220
+ order_defineProperty(this, "onChangeEmail", e => this.setState({
4221
+ email: e.target.value,
4158
4222
  err: {},
4159
4223
  g_err: ''
4160
- });
4224
+ }));
4225
+
4226
+ order_defineProperty(this, "onChangePhone", e => this.setState({
4227
+ phone: e.target.value,
4228
+ err: {},
4229
+ g_err: ''
4230
+ }));
4231
+
4232
+ order_defineProperty(this, "onChangePaymentMethod", id => this.setState({
4233
+ pm: id
4234
+ }));
4235
+
4236
+ order_defineProperty(this, "onChangeQuantity", (item, text) => {
4237
+ let qty = parseInt(text) || 1;
4238
+ item.quantity = qty;
4239
+ this.forceUpdate();
4240
+ });
4241
+
4242
+ order_defineProperty(this, "confirm", async () => {
4243
+ this.setState({
4244
+ g_err: ''
4245
+ });
4246
+ let err = {};
4247
+
4248
+ if (!this.state.shipping) {
4249
+ this.setState({
4250
+ g_err: 'Mời bạn chọn địa chỉ giao hàng trước khi xác nhận'
4251
+ });
4252
+ }
4253
+
4254
+ if (this.state.shipping === 'shop') {
4255
+ if (!util/* default.isPhone */.Z.isPhone(this.state.phone)) {
4256
+ err.phone = true;
4257
+ }
4258
+
4259
+ if (!util/* default.trim */.Z.trim(this.state.fullname)) {
4260
+ err.name = true;
4261
+ }
4262
+
4263
+ if (!util/* default.trim */.Z.trim(this.state.email)) {
4264
+ err.email = true;
4265
+ }
4266
+ } else if (this.state.shipping_address == 'new') {
4267
+ if (!util/* default.isPhone */.Z.isPhone(this.state.phone)) {
4268
+ err.phone = true;
4269
+ }
4270
+
4271
+ if (!util/* default.trim */.Z.trim(this.state.fullname)) {
4272
+ err.name = true;
4273
+ }
4274
+
4275
+ if (!util/* default.trim */.Z.trim(this.state.address)) {
4276
+ err.address = true;
4277
+ }
4278
+
4279
+ if (util/* default.size */.Z.size(this.state.selectedWard) == 0) {
4280
+ err.ward = true;
4281
+ }
4282
+
4283
+ if (util/* default.size */.Z.size(this.state.selectedDistrict) == 0) {
4284
+ err.district = true;
4285
+ }
4286
+
4287
+ if (util/* default.size */.Z.size(this.state.selectedProvince) == 0) {
4288
+ err.province = true;
4289
+ }
4290
+ }
4291
+
4292
+ if (util/* default.size */.Z.size(err) > 0) {
4293
+ this.setState({
4294
+ err,
4295
+ g_err: this.props.t('input_shipping_info_err')
4296
+ });
4297
+ return;
4298
+ }
4299
+
4300
+ let user = this.props.store.matchUser();
4301
+ let ufullname = util/* default.getUserAttr */.Z.getUserAttr(user, 'fullname', 'text');
4302
+ let uemail = util/* default.getUserAttr */.Z.getUserAttr(user, 'emails', 'text');
4303
+ let uphone = util/* default.getUserAttr */.Z.getUserAttr(user, 'phones', 'text');
4304
+ let order = util/* default.cloneDeep */.Z.cloneDeep(this.state.order);
4305
+
4306
+ if (this.state.shipping === 'shop') {
4307
+ util/* default.set */.Z.set(order, 'shipping.pickup_at_shop', true);
4308
+ util/* default.set */.Z.set(order, 'shipping.address.phone', this.state.phone);
4309
+ util/* default.set */.Z.set(order, 'shipping.address.fullname', this.state.fullname);
4310
+ util/* default.set */.Z.set(order, 'shipping.address.email', this.state.email);
4311
+ } else {
4312
+ if (this.state.shipping_address == 'new') {
4313
+ let out = await this.props.store.createShippingAddress({
4314
+ address: this.state.address,
4315
+ country: 'Việt Nam',
4316
+ fullname: this.state.fullname,
4317
+ email: this.state.email,
4318
+ phone: this.state.phone,
4319
+ district: this.state.selectedDistrict.name,
4320
+ district_id: this.state.selectedDistrict.id,
4321
+ province: this.state.selectedProvince.name,
4322
+ province_id: this.state.selectedProvince.id,
4323
+ ward: this.state.selectedWard.name,
4324
+ street: this.state.street,
4325
+ ward_id: this.state.selectedWard.id
4326
+ });
4327
+ if (out.error) return this.setState({
4328
+ g_err: this.props.t('update_failed')
4329
+ });
4330
+ util/* default.set */.Z.set(order, 'shipping.address', out.body);
4331
+ } else {
4332
+ let addresses = this.props.store.matchShippingAddresses();
4333
+ let sa = util/* default.find */.Z.find(addresses, addr => addr.id === this.state.shipping_address);
4334
+
4335
+ if (!sa) {
4336
+ return this.setState({
4337
+ err,
4338
+ g_err: this.props.t('input_shipping_info_err')
4339
+ });
4340
+ }
4341
+
4342
+ util/* default.set */.Z.set(order, 'shipping.address', sa);
4343
+ }
4344
+ }
4345
+
4346
+ let changeduser = false;
4347
+
4348
+ if (!ufullname && this.state.fullname) {
4349
+ changeduser = true;
4350
+ util/* default.setUserAttr */.Z.setUserAttr(user, {
4351
+ key: 'fullname',
4352
+ text: this.state.fullname
4353
+ });
4354
+ }
4355
+
4356
+ if (!uemail && this.state.email) {
4357
+ changeduser = true;
4358
+ util/* default.setUserAttr */.Z.setUserAttr(user, {
4359
+ key: 'emails',
4360
+ text: this.state.email
4361
+ });
4362
+ }
4363
+
4364
+ if (!uphone && this.state.phone) {
4365
+ changeduser = true;
4366
+ util/* default.setUserAttr */.Z.setUserAttr(user, {
4367
+ key: 'phones',
4368
+ text: this.state.phone
4369
+ });
4370
+ }
4371
+
4372
+ if (changeduser) this.props.store.setUser(user);
4373
+ this.setState({
4374
+ sending: true
4375
+ });
4376
+ order.user_confirmation = 'confirmed';
4377
+ let out = await this.props.store.updateOrder(order);
4378
+ this.setState({
4379
+ sending: false
4380
+ });
4381
+
4382
+ if (out.error) {
4383
+ return this.setState({
4384
+ g_err: this.props.t('update_failed')
4385
+ });
4386
+ }
4387
+
4388
+ this.setState({
4389
+ step: 'success'
4390
+ });
4391
+ if (this.props.onResponse) this.props.onResponse('confirmed');
4392
+ });
4393
+
4394
+ order_defineProperty(this, "onCancel", () => {
4395
+ if (this.props.onResponse) this.props.onResponse('rejected');
4396
+ this.close();
4397
+ });
4398
+
4399
+ order_defineProperty(this, "close", () => {
4400
+ if (this.props.cid && !this.state.order.user_confirmation) {
4401
+ let order = util/* default.cloneDeep */.Z.cloneDeep(this.state.order);
4402
+ order.user_confirmation = 'rejected';
4403
+ this.props.store.updateOrder(order);
4404
+ }
4405
+
4406
+ if (this.props.onClose) this.props.onClose();
4407
+ });
4408
+
4409
+ this.load();
4410
+ }
4411
+
4412
+ async load() {
4413
+ if (!this.props.order_id) return;
4414
+ let orderout = await this.props.store.fetchOrder(this.props.order_id);
4161
4415
  this.setState({
4162
- loadWard: true
4416
+ loading: false
4163
4417
  });
4164
- let out = await this.props.store.list_wards({
4165
- id: item.id
4418
+
4419
+ if (!orderout.error) {
4420
+ this.setState({
4421
+ order: orderout.body
4422
+ });
4423
+ } else {
4424
+ this.setState({
4425
+ error: orderout.error
4426
+ });
4427
+ }
4428
+
4429
+ let user = this.props.store.matchUser();
4430
+ let attributes = util/* default.get */.Z.get(this.props.store.matchUser(), 'attributes', []);
4431
+ let fullname = util/* default.get */.Z.get(util/* default.find */.Z.find(attributes, att => att.key === 'fullname'), 'text');
4432
+ let email = util/* default.get */.Z.get(util/* default.find */.Z.find(attributes, att => att.key === 'emails'), 'text');
4433
+ let phone = util/* default.get */.Z.get(util/* default.find */.Z.find(attributes, att => att.key === 'phones'), 'text');
4434
+ this.setState({
4435
+ fullname,
4436
+ email,
4437
+ phone
4166
4438
  });
4439
+ await this.props.store.fetchShippingAddresses();
4440
+ let out = await this.props.store.list_provinces();
4167
4441
  this.setState({
4168
- loadWard: false
4442
+ loadProvince: false
4169
4443
  });
4170
4444
  if (!out.error) this.setState({
4171
- wards: util/* default.get */.Z.get(out, 'body.addresses')
4445
+ provinces: util/* default.get */.Z.get(out, 'body.addresses')
4172
4446
  });
4173
- };
4174
- onSelectWard = item => this.setState({
4175
- selectedWard: item,
4176
- err: {},
4177
- g_err: ''
4178
- });
4179
- onChangeFullname = e => this.setState({
4180
- fullname: e.target.value,
4181
- err: {},
4182
- g_err: ''
4183
- });
4184
- onChangeAddress = e => this.setState({
4185
- address: e,
4186
- err: {},
4187
- g_err: ''
4188
- });
4189
- onSelectAddress = addr => {
4190
- if (!addr) return;
4447
+ }
4448
+
4449
+ isMobile() {
4450
+ if (this.props.cid) return true;
4451
+ if (this.props.isMobile) return true;
4452
+ return this.props.store.isMobile();
4453
+ }
4454
+
4455
+ onChangeShippingAddress(id) {
4191
4456
  this.setState({
4192
- address: [util/* default.trim */.Z.trim(addr.address), util/* default.trim */.Z.trim(addr.street)].join(' ').trim(),
4193
- street: addr.street,
4457
+ shipping_address: id,
4194
4458
  err: {},
4195
4459
  g_err: ''
4196
4460
  });
4197
- this.onSelectWard({
4198
- id: addr.ward_id,
4199
- name: addr.ward
4200
- });
4201
- this.onSelectDistrict({
4202
- id: addr.district_id,
4203
- name: addr.district
4204
- });
4205
- this.onSelectProvince({
4206
- id: addr.province_id,
4207
- name: addr.province
4461
+ }
4462
+
4463
+ onChangeShipping(id) {
4464
+ this.setState({
4465
+ shipping: id,
4466
+ err: {},
4467
+ g_err: ''
4208
4468
  });
4209
- };
4210
- onChangeEmail = e => this.setState({
4211
- email: e.target.value,
4212
- err: {},
4213
- g_err: ''
4214
- });
4215
- onChangePhone = e => this.setState({
4216
- phone: e.target.value,
4217
- err: {},
4218
- g_err: ''
4219
- });
4220
- onChangePaymentMethod = id => this.setState({
4221
- pm: id
4222
- });
4469
+ }
4223
4470
 
4224
4471
  renderDesktopPaymentMethod(order) {
4225
4472
  return null;
@@ -4757,12 +5004,6 @@ class order_Order extends common/* Com */.up {
4757
5004
  }, this.props.t('product')), $products);
4758
5005
  }
4759
5006
 
4760
- onChangeQuantity = (item, text) => {
4761
- let qty = parseInt(text) || 1;
4762
- item.quantity = qty;
4763
- this.forceUpdate();
4764
- };
4765
-
4766
5007
  renderDesktopProducts(order) {
4767
5008
  let $products = null;
4768
5009
  let editmode = false;
@@ -5001,170 +5242,6 @@ class order_Order extends common/* Com */.up {
5001
5242
  return this.renderDesktop(order);
5002
5243
  }
5003
5244
 
5004
- confirm = async () => {
5005
- this.setState({
5006
- g_err: ''
5007
- });
5008
- let err = {};
5009
-
5010
- if (!this.state.shipping) {
5011
- this.setState({
5012
- g_err: 'Mời bạn chọn địa chỉ giao hàng trước khi xác nhận'
5013
- });
5014
- }
5015
-
5016
- if (this.state.shipping === 'shop') {
5017
- if (!util/* default.isPhone */.Z.isPhone(this.state.phone)) {
5018
- err.phone = true;
5019
- }
5020
-
5021
- if (!util/* default.trim */.Z.trim(this.state.fullname)) {
5022
- err.name = true;
5023
- }
5024
-
5025
- if (!util/* default.trim */.Z.trim(this.state.email)) {
5026
- err.email = true;
5027
- }
5028
- } else if (this.state.shipping_address == 'new') {
5029
- if (!util/* default.isPhone */.Z.isPhone(this.state.phone)) {
5030
- err.phone = true;
5031
- }
5032
-
5033
- if (!util/* default.trim */.Z.trim(this.state.fullname)) {
5034
- err.name = true;
5035
- }
5036
-
5037
- if (!util/* default.trim */.Z.trim(this.state.address)) {
5038
- err.address = true;
5039
- }
5040
-
5041
- if (util/* default.size */.Z.size(this.state.selectedWard) == 0) {
5042
- err.ward = true;
5043
- }
5044
-
5045
- if (util/* default.size */.Z.size(this.state.selectedDistrict) == 0) {
5046
- err.district = true;
5047
- }
5048
-
5049
- if (util/* default.size */.Z.size(this.state.selectedProvince) == 0) {
5050
- err.province = true;
5051
- }
5052
- }
5053
-
5054
- if (util/* default.size */.Z.size(err) > 0) {
5055
- this.setState({
5056
- err,
5057
- g_err: this.props.t('input_shipping_info_err')
5058
- });
5059
- return;
5060
- }
5061
-
5062
- let user = this.props.store.matchUser();
5063
- let ufullname = util/* default.getUserAttr */.Z.getUserAttr(user, 'fullname', 'text');
5064
- let uemail = util/* default.getUserAttr */.Z.getUserAttr(user, 'emails', 'text');
5065
- let uphone = util/* default.getUserAttr */.Z.getUserAttr(user, 'phones', 'text');
5066
- let order = util/* default.cloneDeep */.Z.cloneDeep(this.state.order);
5067
-
5068
- if (this.state.shipping === 'shop') {
5069
- util/* default.set */.Z.set(order, 'shipping.pickup_at_shop', true);
5070
- util/* default.set */.Z.set(order, 'shipping.address.phone', this.state.phone);
5071
- util/* default.set */.Z.set(order, 'shipping.address.fullname', this.state.fullname);
5072
- util/* default.set */.Z.set(order, 'shipping.address.email', this.state.email);
5073
- } else {
5074
- if (this.state.shipping_address == 'new') {
5075
- let out = await this.props.store.createShippingAddress({
5076
- address: this.state.address,
5077
- country: 'Việt Nam',
5078
- fullname: this.state.fullname,
5079
- email: this.state.email,
5080
- phone: this.state.phone,
5081
- district: this.state.selectedDistrict.name,
5082
- district_id: this.state.selectedDistrict.id,
5083
- province: this.state.selectedProvince.name,
5084
- province_id: this.state.selectedProvince.id,
5085
- ward: this.state.selectedWard.name,
5086
- street: this.state.street,
5087
- ward_id: this.state.selectedWard.id
5088
- });
5089
- if (out.error) return this.setState({
5090
- g_err: this.props.t('update_failed')
5091
- });
5092
- util/* default.set */.Z.set(order, 'shipping.address', out.body);
5093
- } else {
5094
- let addresses = this.props.store.matchShippingAddresses();
5095
- let sa = util/* default.find */.Z.find(addresses, addr => addr.id === this.state.shipping_address);
5096
-
5097
- if (!sa) {
5098
- return this.setState({
5099
- err,
5100
- g_err: this.props.t('input_shipping_info_err')
5101
- });
5102
- }
5103
-
5104
- util/* default.set */.Z.set(order, 'shipping.address', sa);
5105
- }
5106
- }
5107
-
5108
- let changeduser = false;
5109
-
5110
- if (!ufullname && this.state.fullname) {
5111
- changeduser = true;
5112
- util/* default.setUserAttr */.Z.setUserAttr(user, {
5113
- key: 'fullname',
5114
- text: this.state.fullname
5115
- });
5116
- }
5117
-
5118
- if (!uemail && this.state.email) {
5119
- changeduser = true;
5120
- util/* default.setUserAttr */.Z.setUserAttr(user, {
5121
- key: 'emails',
5122
- text: this.state.email
5123
- });
5124
- }
5125
-
5126
- if (!uphone && this.state.phone) {
5127
- changeduser = true;
5128
- util/* default.setUserAttr */.Z.setUserAttr(user, {
5129
- key: 'phones',
5130
- text: this.state.phone
5131
- });
5132
- }
5133
-
5134
- if (changeduser) this.props.store.setUser(user);
5135
- this.setState({
5136
- sending: true
5137
- });
5138
- order.user_confirmation = 'confirmed';
5139
- let out = await this.props.store.updateOrder(order);
5140
- this.setState({
5141
- sending: false
5142
- });
5143
-
5144
- if (out.error) {
5145
- return this.setState({
5146
- g_err: this.props.t('update_failed')
5147
- });
5148
- }
5149
-
5150
- this.setState({
5151
- step: 'success'
5152
- });
5153
- if (this.props.onResponse) this.props.onResponse('confirmed');
5154
- };
5155
- onCancel = () => {
5156
- if (this.props.onResponse) this.props.onResponse('rejected');
5157
- this.close();
5158
- };
5159
- close = () => {
5160
- if (this.props.cid && !this.state.order.user_confirmation) {
5161
- let order = util/* default.cloneDeep */.Z.cloneDeep(this.state.order);
5162
- order.user_confirmation = 'rejected';
5163
- this.props.store.updateOrder(order);
5164
- }
5165
-
5166
- if (this.props.onClose) this.props.onClose();
5167
- };
5168
5245
  }
5169
5246
  let ShippingProvider = {
5170
5247
  ghtk: {
@@ -5177,6 +5254,8 @@ let ShippingProvider = {
5177
5254
  }
5178
5255
  };
5179
5256
  ;// CONCATENATED MODULE: ./src/chatbox/Order.js
5257
+ function Order_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5258
+
5180
5259
 
5181
5260
 
5182
5261
 
@@ -5192,16 +5271,102 @@ let Order_defaultAvatar = __webpack_require__(4761);
5192
5271
  class Order extends common/* Com */.up {
5193
5272
  constructor(props) {
5194
5273
  super(props);
5274
+
5275
+ Order_defineProperty(this, "state", {
5276
+ hide: true,
5277
+ ratingHeight: 0,
5278
+ overlayOpacity: 0.3
5279
+ });
5280
+
5281
+ Order_defineProperty(this, "onResponse", response => {
5282
+ this.setState({
5283
+ response
5284
+ });
5285
+ });
5286
+
5287
+ Order_defineProperty(this, "confirm", () => {
5288
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5289
+ message: {
5290
+ format: 'plaintext',
5291
+ text: 'confirm',
5292
+ attachments: [{
5293
+ type: 'postback',
5294
+ postback: {
5295
+ payload: JSON.stringify({
5296
+ type: 'order_confirmation',
5297
+ status: 'confirmed'
5298
+ })
5299
+ }
5300
+ }]
5301
+ }
5302
+ });
5303
+ });
5304
+
5305
+ Order_defineProperty(this, "close", async () => {
5306
+ await util/* default.sleep */.Z.sleep(100);
5307
+
5308
+ if (this.state.response === 'confirmed') {
5309
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5310
+ message: {
5311
+ format: 'plaintext',
5312
+ text: this.props.t('confirm_order'),
5313
+ attachments: [{
5314
+ type: 'postback',
5315
+ postback: {
5316
+ payload: JSON.stringify({
5317
+ type: 'order_confirmation',
5318
+ status: 'confirmed'
5319
+ })
5320
+ }
5321
+ }]
5322
+ }
5323
+ });
5324
+ } else if (this.state.response === 'rejected') {
5325
+ this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5326
+ message: {
5327
+ format: 'plaintext',
5328
+ text: this.props.t('cancel_order'),
5329
+ attachments: [{
5330
+ type: 'postback',
5331
+ postback: {
5332
+ payload: JSON.stringify({
5333
+ type: 'order_confirmation',
5334
+ status: 'cancelled'
5335
+ })
5336
+ }
5337
+ }]
5338
+ }
5339
+ });
5340
+ } else {}
5341
+
5342
+ this.setState({
5343
+ response: ''
5344
+ });
5345
+ if (this.state.hide) return;
5346
+ if (!this.refRating.current) return;
5347
+ var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
5348
+ var h0 = parseFloat(popupStyle.height);
5349
+ this.animation.play(20, h0, h => {
5350
+ this.setState({
5351
+ ratingHeight: h,
5352
+ overlayOpacity: Math.min(1, (h - Order_POPUP_MIN_HEIGHT) / (Order_POPUP_HARD_MAX_HEIGHT - Order_POPUP_MIN_HEIGHT))
5353
+ });
5354
+
5355
+ if (h < Order_POPUP_MIN_HEIGHT + 10) {
5356
+ if (!this.state.hide) {
5357
+ this.setState({
5358
+ hide: true
5359
+ });
5360
+ }
5361
+ }
5362
+ });
5363
+ this.props.onClose();
5364
+ });
5365
+
5195
5366
  this.refRating = (0,preact_module/* createRef */.Vf)();
5196
5367
  this.refHandle = (0,preact_module/* createRef */.Vf)();
5197
5368
  }
5198
5369
 
5199
- state = {
5200
- hide: true,
5201
- ratingHeight: 0,
5202
- overlayOpacity: 0.3
5203
- };
5204
-
5205
5370
  componentDidMount() {
5206
5371
  this.mouseUp = e => this.onMouseUp(e);
5207
5372
 
@@ -5285,12 +5450,6 @@ class Order extends common/* Com */.up {
5285
5450
  }))));
5286
5451
  }
5287
5452
 
5288
- onResponse = response => {
5289
- this.setState({
5290
- response
5291
- });
5292
- };
5293
-
5294
5453
  open() {
5295
5454
  if (!this.state.hide) return;
5296
5455
  if (!this.props.order_id) return;
@@ -5308,84 +5467,6 @@ class Order extends common/* Com */.up {
5308
5467
  });
5309
5468
  }
5310
5469
 
5311
- confirm = () => {
5312
- this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5313
- message: {
5314
- format: 'plaintext',
5315
- text: 'confirm',
5316
- attachments: [{
5317
- type: 'postback',
5318
- postback: {
5319
- payload: JSON.stringify({
5320
- type: 'order_confirmation',
5321
- status: 'confirmed'
5322
- })
5323
- }
5324
- }]
5325
- }
5326
- });
5327
- };
5328
- close = async () => {
5329
- await util/* default.sleep */.Z.sleep(100);
5330
-
5331
- if (this.state.response === 'confirmed') {
5332
- this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5333
- message: {
5334
- format: 'plaintext',
5335
- text: this.props.t('confirm_order'),
5336
- attachments: [{
5337
- type: 'postback',
5338
- postback: {
5339
- payload: JSON.stringify({
5340
- type: 'order_confirmation',
5341
- status: 'confirmed'
5342
- })
5343
- }
5344
- }]
5345
- }
5346
- });
5347
- } else if (this.state.response === 'rejected') {
5348
- this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
5349
- message: {
5350
- format: 'plaintext',
5351
- text: this.props.t('cancel_order'),
5352
- attachments: [{
5353
- type: 'postback',
5354
- postback: {
5355
- payload: JSON.stringify({
5356
- type: 'order_confirmation',
5357
- status: 'cancelled'
5358
- })
5359
- }
5360
- }]
5361
- }
5362
- });
5363
- } else {}
5364
-
5365
- this.setState({
5366
- response: ''
5367
- });
5368
- if (this.state.hide) return;
5369
- if (!this.refRating.current) return;
5370
- var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
5371
- var h0 = parseFloat(popupStyle.height);
5372
- this.animation.play(20, h0, h => {
5373
- this.setState({
5374
- ratingHeight: h,
5375
- overlayOpacity: Math.min(1, (h - Order_POPUP_MIN_HEIGHT) / (Order_POPUP_HARD_MAX_HEIGHT - Order_POPUP_MIN_HEIGHT))
5376
- });
5377
-
5378
- if (h < Order_POPUP_MIN_HEIGHT + 10) {
5379
- if (!this.state.hide) {
5380
- this.setState({
5381
- hide: true
5382
- });
5383
- }
5384
- }
5385
- });
5386
- this.props.onClose();
5387
- };
5388
-
5389
5470
  onMouseDown(e) {
5390
5471
  this.mousePushed = true;
5391
5472
  this.animation.stop();
@@ -5442,6 +5523,8 @@ class Order extends common/* Com */.up {
5442
5523
 
5443
5524
  }
5444
5525
  ;// CONCATENATED MODULE: ./src/chatbox/Widget.js
5526
+ function Widget_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5527
+
5445
5528
 
5446
5529
 
5447
5530
 
@@ -5468,6 +5551,31 @@ const Widget_defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar
5468
5551
  class Widget extends common/* Com */.up {
5469
5552
  constructor(props) {
5470
5553
  super(props);
5554
+
5555
+ Widget_defineProperty(this, "onLink", (e, url) => {
5556
+ if (!url) return e.preventDefault();
5557
+ let noschemeurl = url.replace(/(^\w+:|^)\/\//, '');
5558
+
5559
+ if (noschemeurl.startsWith('widget.subiz.com.vn/orders/')) {
5560
+ let orderid = noschemeurl.substr('widget.subiz.com.vn/orders/'.length);
5561
+ orderid = orderid.split('/')[0];
5562
+ this.setState({
5563
+ showOrder: true,
5564
+ order_id: orderid
5565
+ });
5566
+ e.preventDefault();
5567
+ return;
5568
+ }
5569
+ });
5570
+
5571
+ Widget_defineProperty(this, "closeOrder", e => {
5572
+ this.setState({
5573
+ showOrder: false,
5574
+ order_id: ''
5575
+ });
5576
+ this.focusInput();
5577
+ });
5578
+
5471
5579
  this.userSent = {};
5472
5580
  this.setState({
5473
5581
  creating: false,
@@ -6064,29 +6172,6 @@ class Widget extends common/* Com */.up {
6064
6172
  }), $input);
6065
6173
  }
6066
6174
 
6067
- onLink = (e, url) => {
6068
- if (!url) return e.preventDefault();
6069
- let noschemeurl = url.replace(/(^\w+:|^)\/\//, '');
6070
-
6071
- if (noschemeurl.startsWith('widget.subiz.com.vn/orders/')) {
6072
- let orderid = noschemeurl.substr('widget.subiz.com.vn/orders/'.length);
6073
- orderid = orderid.split('/')[0];
6074
- this.setState({
6075
- showOrder: true,
6076
- order_id: orderid
6077
- });
6078
- e.preventDefault();
6079
- return;
6080
- }
6081
- };
6082
- closeOrder = e => {
6083
- this.setState({
6084
- showOrder: false,
6085
- order_id: ''
6086
- });
6087
- this.focusInput();
6088
- };
6089
-
6090
6175
  async onStartConvoClick() {
6091
6176
  var convo = this.props.store.matchConvo(this.props.cid) || {};
6092
6177
  if (convo.state === 'ended') return this.props.onGo({
@@ -6518,11 +6603,13 @@ class Main extends common/* Com */.up {
6518
6603
  }
6519
6604
 
6520
6605
  function restoreViewport() {
6606
+ if (document.body && document.body.classList) document.body.classList.remove('sbz_no_scroll');
6521
6607
  let metatag = document.getElementById('subiz-meta-viewport');
6522
6608
  if (metatag) metatag.remove();
6523
6609
  }
6524
6610
 
6525
6611
  function modifyViewport() {
6612
+ if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll');
6526
6613
  let metatag = document.createElement('meta');
6527
6614
  metatag.httpEquiv = 'X-UA-Compatible';
6528
6615
  metatag.name = 'viewport';