@subiz/widget-v4 4.0.63 → 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 (55) hide show
  1. package/babel.config.js +2 -4
  2. package/compiled_src/bot.js +7 -1
  3. package/compiled_src/call/call.js +15 -12
  4. package/compiled_src/chatbox/DropdownSelect.js +75 -66
  5. package/compiled_src/chatbox/MessageInput.js +7 -4
  6. package/compiled_src/chatbox/Order.js +94 -90
  7. package/compiled_src/chatbox/Rating.js +10 -7
  8. package/compiled_src/chatbox/Widget.js +27 -23
  9. package/compiled_src/contact/contact.js +9 -6
  10. package/compiled_src/lib.js +14 -9
  11. package/compiled_src/notif/notif.js +15 -12
  12. package/compiled_src/order/address_picker.js +71 -63
  13. package/compiled_src/order/order.js +330 -316
  14. package/compiled_src/popup/countdown.js +7 -4
  15. package/compiled_src/popup/popup.js +12 -9
  16. package/compiled_src/store/api.js +110 -80
  17. package/compiled_src/store/api_fake.js +82 -55
  18. package/compiled_src/store/store.js +170 -133
  19. package/dist/132.js +633 -588
  20. package/dist/17ee31b89ac.132.js +1 -0
  21. package/dist/{17e757ccadd.178.js → 17ee31b89ac.178.js} +0 -0
  22. package/dist/17ee31b89ac.213.js +1 -0
  23. package/dist/17ee31b89ac.335.js +1 -0
  24. package/dist/{17e757ccadd.362.js → 17ee31b89ac.362.js} +1 -1
  25. package/dist/17ee31b89ac.441.js +1 -0
  26. package/dist/17ee31b89ac.605.js +1 -0
  27. package/dist/{17e757ccadd.678.js → 17ee31b89ac.678.js} +0 -0
  28. package/dist/{17e757ccadd.782.js → 17ee31b89ac.782.js} +1 -1
  29. package/dist/17ee31b89ac.app.js +1 -0
  30. package/dist/{17e757ccadd.index.html → 17ee31b89ac.index.html} +1 -1
  31. package/dist/{17e757ccadd.library.html → 17ee31b89ac.library.html} +1 -1
  32. package/dist/17ee31b89ac.library.js +1 -0
  33. package/dist/{17e757ccadd.preview.html → 17ee31b89ac.preview.html} +1 -1
  34. package/dist/17ee31b89ac.preview.js +1 -0
  35. package/dist/17ee31b89ac.screenshoot.js +1 -0
  36. package/dist/213.js +19 -13
  37. package/dist/335.js +9 -6
  38. package/dist/362.js +1 -1
  39. package/dist/441.js +2 -2
  40. package/dist/605.js +15 -12
  41. package/dist/782.js +1 -1
  42. package/dist/HASH +1 -1
  43. package/dist/screenshoot.html +1 -1
  44. package/dist/screenshoot.js +372 -273
  45. package/package.json +12 -12
  46. package/src/bot.js +2 -1
  47. package/dist/17e757ccadd.132.js +0 -1
  48. package/dist/17e757ccadd.213.js +0 -1
  49. package/dist/17e757ccadd.335.js +0 -1
  50. package/dist/17e757ccadd.441.js +0 -1
  51. package/dist/17e757ccadd.605.js +0 -1
  52. package/dist/17e757ccadd.app.js +0 -1
  53. package/dist/17e757ccadd.library.js +0 -1
  54. package/dist/17e757ccadd.preview.js +0 -1
  55. package/dist/17e757ccadd.screenshoot.js +0 -1
package/dist/132.js CHANGED
@@ -805,6 +805,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
805
 
806
806
  let getJoinedNameMember = agents => util/* default.map */.Z.map(agents, agent => agent.name).join(', ');
807
807
  ;// CONCATENATED MODULE: ./src/chatbox/MessageInput.js
808
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
809
+
808
810
 
809
811
 
810
812
 
@@ -812,6 +814,11 @@ let getJoinedNameMember = agents => util/* default.map */.Z.map(agents, agent =>
812
814
  class MessageInput extends common/* Com */.up {
813
815
  constructor(props) {
814
816
  super(props);
817
+
818
+ _defineProperty(this, "onEnter", util/* default.throttle */.Z.throttle(function () {
819
+ this.submitMessage();
820
+ }, 50));
821
+
815
822
  this.refFileInput = (0,preact_module/* createRef */.Vf)();
816
823
  this.refMessageInput = (0,preact_module/* createRef */.Vf)();
817
824
  this.props.store.onUpdate(this, _ => this.forceUpdate());
@@ -1049,10 +1056,6 @@ class MessageInput extends common/* Com */.up {
1049
1056
  input.focus();
1050
1057
  }
1051
1058
 
1052
- onEnter = util/* default.throttle */.Z.throttle(function () {
1053
- this.submitMessage();
1054
- }, 50);
1055
-
1056
1059
  onKeydown(e) {
1057
1060
  if (e.keyCode === 13 && e.shiftKey === false) {
1058
1061
  this.onEnter();
@@ -3236,6 +3239,8 @@ function eqFloat(a, b) {
3236
3239
  return Math.abs(a - b) <= 0.001;
3237
3240
  }
3238
3241
  ;// CONCATENATED MODULE: ./src/chatbox/Rating.js
3242
+ 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; }
3243
+
3239
3244
 
3240
3245
 
3241
3246
  const POPUP_MAX_HEIGHT = 400;
@@ -3246,18 +3251,19 @@ const POPUP_MIN_HEIGHT = 0;
3246
3251
  class Rating extends common/* Com */.up {
3247
3252
  constructor(props) {
3248
3253
  super(props);
3254
+
3255
+ Rating_defineProperty(this, "state", {
3256
+ hide: true,
3257
+ ratingHeight: 0,
3258
+ overlayOpacity: 0.3,
3259
+ comment: ''
3260
+ });
3261
+
3249
3262
  this.refComment = (0,preact_module/* createRef */.Vf)();
3250
3263
  this.refRating = (0,preact_module/* createRef */.Vf)();
3251
3264
  this.refHandle = (0,preact_module/* createRef */.Vf)();
3252
3265
  }
3253
3266
 
3254
- state = {
3255
- hide: true,
3256
- ratingHeight: 0,
3257
- overlayOpacity: 0.3,
3258
- comment: ''
3259
- };
3260
-
3261
3267
  componentDidMount() {
3262
3268
  this.props.store.onUpdate(this, () => {
3263
3269
  if (this.shoudDisplay()) this.open();
@@ -3522,63 +3528,96 @@ class Rating extends common/* Com */.up {
3522
3528
 
3523
3529
  }
3524
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; }
3525
3532
 
3526
3533
 
3527
3534
 
3528
3535
 
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
3536
 
3537
+ class DropdownSelect extends common/* Com */.up {
3537
3538
  constructor(props) {
3538
3539
  super(props);
3539
- document.addEventListener('touchmove', function (e) {});
3540
- }
3541
3540
 
3542
- onTouchMove = e => {
3543
- if (e.target === this.overlayRef.current) {
3544
- e.preventDefault();
3545
- e.stopPropagation();
3546
- }
3547
- };
3548
- hideDropdown = () => {
3549
- this.setState({
3541
+ DropdownSelect_defineProperty(this, "state", {
3550
3542
  show: false,
3551
3543
  searchValue: ''
3552
3544
  });
3553
- };
3554
- onKeydown = e => {
3555
- if (e.key === 'Escape') {
3556
- if (!this.state.show) return;
3557
- if (this.state.searchValue) this.setState({
3545
+
3546
+ DropdownSelect_defineProperty(this, "filterRef", (0,preact_module/* createRef */.Vf)());
3547
+
3548
+ DropdownSelect_defineProperty(this, "overlayRef", (0,preact_module/* createRef */.Vf)());
3549
+
3550
+ DropdownSelect_defineProperty(this, "onTouchMove", e => {
3551
+ if (e.target === this.overlayRef.current) {
3552
+ e.preventDefault();
3553
+ e.stopPropagation();
3554
+ }
3555
+ });
3556
+
3557
+ DropdownSelect_defineProperty(this, "hideDropdown", () => {
3558
+ this.setState({
3559
+ show: false,
3558
3560
  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
3561
  });
3578
- }
3562
+ });
3579
3563
 
3580
- return items;
3581
- };
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
+ });
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
+ });
3579
+
3580
+ DropdownSelect_defineProperty(this, "getFilteredOptions", () => {
3581
+ let items = this.props.items;
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
+ }
3591
+
3592
+ return items;
3593
+ });
3594
+
3595
+ DropdownSelect_defineProperty(this, "onChangeSearchValue", e => {
3596
+ this.setState({
3597
+ searchValue: e.target.value
3598
+ });
3599
+ });
3600
+
3601
+ DropdownSelect_defineProperty(this, "toogleDropdown", async () => {
3602
+ await this.setState({
3603
+ show: true,
3604
+ searchValue: ''
3605
+ });
3606
+ this.focusFilter();
3607
+ });
3608
+
3609
+ DropdownSelect_defineProperty(this, "onSelect", item => {
3610
+ this.props.onSelect(item);
3611
+ this.hideDropdown();
3612
+ });
3613
+
3614
+ DropdownSelect_defineProperty(this, "onBackgroundScroll", e => {
3615
+ console.log('EEEEEEE', e);
3616
+ alert('y');
3617
+ });
3618
+
3619
+ document.addEventListener('touchmove', function (e) {});
3620
+ }
3582
3621
 
3583
3622
  componentDidMount() {
3584
3623
  window.addEventListener('keydown', this.onKeydown);
@@ -3588,12 +3627,6 @@ class DropdownSelect extends common/* Com */.up {
3588
3627
  window.removeEventListener('keydown', this.onKeydown);
3589
3628
  }
3590
3629
 
3591
- onChangeSearchValue = e => {
3592
- this.setState({
3593
- searchValue: e.target.value
3594
- });
3595
- };
3596
-
3597
3630
  renderEmpty() {
3598
3631
  return (0,preact_module.h)("div", {
3599
3632
  class: "dropdown_select_filter__empty"
@@ -3618,14 +3651,6 @@ class DropdownSelect extends common/* Com */.up {
3618
3651
  }, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
3619
3652
  }
3620
3653
 
3621
- toogleDropdown = async () => {
3622
- await this.setState({
3623
- show: true,
3624
- searchValue: ''
3625
- });
3626
- this.focusFilter();
3627
- };
3628
-
3629
3654
  focusFilter() {
3630
3655
  if (!this.filterRef.current) return;
3631
3656
  this.filterRef.current.focus();
@@ -3635,11 +3660,6 @@ class DropdownSelect extends common/* Com */.up {
3635
3660
  }, 100);
3636
3661
  }
3637
3662
 
3638
- onSelect = item => {
3639
- this.props.onSelect(item);
3640
- this.hideDropdown();
3641
- };
3642
-
3643
3663
  renderDropdown() {
3644
3664
  if (!this.state.show) return null;
3645
3665
  let items = this.getFilteredOptions();
@@ -3706,11 +3726,6 @@ class DropdownSelect extends common/* Com */.up {
3706
3726
  }, $items));
3707
3727
  }
3708
3728
 
3709
- onBackgroundScroll = e => {
3710
- console.log('EEEEEEE', e);
3711
- alert('y');
3712
- };
3713
-
3714
3729
  render() {
3715
3730
  let $name = (0,preact_module.h)("div", {
3716
3731
  class: "muted text-truncate",
@@ -3742,57 +3757,90 @@ class DropdownSelect extends common/* Com */.up {
3742
3757
 
3743
3758
  }
3744
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; }
3745
3761
 
3746
3762
 
3747
3763
 
3748
3764
 
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
3765
 
3766
+ class AddressPicker extends common/* Com */.up {
3758
3767
  constructor(props) {
3759
3768
  super(props);
3760
- document.addEventListener('touchmove', function (e) {});
3761
- }
3762
3769
 
3763
- onTouchMove = e => {
3764
- if (e.target === this.overlayRef.current) {
3765
- e.preventDefault();
3766
- e.stopPropagation();
3767
- }
3768
- };
3769
- hideDropdown = () => {
3770
- this.setState({
3770
+ address_picker_defineProperty(this, "state", {
3771
3771
  show: false,
3772
- searchValue: ''
3772
+ searchValue: '',
3773
+ addresses: []
3773
3774
  });
3774
- };
3775
- onKeydown = e => {
3776
- if (e.key === 'Escape') {
3777
- if (!this.state.show) return;
3778
- if (this.state.searchValue) this.setState({
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
+ }
3785
+ });
3786
+
3787
+ address_picker_defineProperty(this, "hideDropdown", () => {
3788
+ this.setState({
3789
+ show: false,
3779
3790
  searchValue: ''
3780
- });else this.hideDropdown();
3781
- e.preventDefault();
3782
- e.stopPropagation();
3783
- }
3791
+ });
3792
+ });
3784
3793
 
3785
- if (e.key == 'Enter') {}
3786
- };
3787
- doSearch = util/* default.throttle */.Z.throttle(async () => {
3788
- let requestId = Date.now();
3789
- this.requestId = requestId;
3790
- let res = await this.props.store.suggest_addresses(this.state.searchValue);
3791
- if (this.requestId !== requestId) return;
3792
- this.setState({
3793
- addresses: util/* default.get */.Z.get(res, 'body.addresses', [])
3794
+ 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') {}
3805
+ });
3806
+
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;
3812
+ this.setState({
3813
+ addresses: util/* default.get */.Z.get(res, 'body.addresses', [])
3814
+ });
3815
+ }, 100));
3816
+
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();
3823
+ });
3824
+
3825
+ address_picker_defineProperty(this, "toogleDropdown", async () => {
3826
+ await this.setState({
3827
+ show: true,
3828
+ searchValue: this.props.initAddress || ''
3829
+ });
3830
+ this.focusFilter();
3831
+ });
3832
+
3833
+ address_picker_defineProperty(this, "onSelect", item => {
3834
+ this.props.onSelect(item);
3835
+ this.hideDropdown();
3836
+ });
3837
+
3838
+ address_picker_defineProperty(this, "onBackgroundScroll", e => {
3839
+ console.log('EEEEEEE', e);
3794
3840
  });
3795
- }, 100);
3841
+
3842
+ document.addEventListener('touchmove', function (e) {});
3843
+ }
3796
3844
 
3797
3845
  componentDidMount() {
3798
3846
  window.addEventListener('keydown', this.onKeydown);
@@ -3802,14 +3850,6 @@ class AddressPicker extends common/* Com */.up {
3802
3850
  window.removeEventListener('keydown', this.onKeydown);
3803
3851
  }
3804
3852
 
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
3853
  renderEmpty() {
3814
3854
  return (0,preact_module.h)("div", {
3815
3855
  class: "dropdown_select_filter__empty"
@@ -3834,14 +3874,6 @@ class AddressPicker extends common/* Com */.up {
3834
3874
  }, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
3835
3875
  }
3836
3876
 
3837
- toogleDropdown = async () => {
3838
- await this.setState({
3839
- show: true,
3840
- searchValue: this.props.initAddress || ''
3841
- });
3842
- this.focusFilter();
3843
- };
3844
-
3845
3877
  focusFilter() {
3846
3878
  if (!this.filterRef.current) return;
3847
3879
  this.filterRef.current.focus();
@@ -3851,11 +3883,6 @@ class AddressPicker extends common/* Com */.up {
3851
3883
  }, 100);
3852
3884
  }
3853
3885
 
3854
- onSelect = item => {
3855
- this.props.onSelect(item);
3856
- this.hideDropdown();
3857
- };
3858
-
3859
3886
  renderDropdown() {
3860
3887
  if (!this.state.show) return null;
3861
3888
  let $items = util/* default.map */.Z.map(this.state.addresses, (addr, i) => {
@@ -3922,10 +3949,6 @@ class AddressPicker extends common/* Com */.up {
3922
3949
  }, $items));
3923
3950
  }
3924
3951
 
3925
- onBackgroundScroll = e => {
3926
- console.log('EEEEEEE', e);
3927
- };
3928
-
3929
3952
  render() {
3930
3953
  let $name = (0,preact_module.h)("div", {
3931
3954
  class: "text-truncate",
@@ -4010,6 +4033,8 @@ class Icon extends common/* Com */.up {
4010
4033
 
4011
4034
  }
4012
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
+
4013
4038
 
4014
4039
 
4015
4040
 
@@ -4024,202 +4049,384 @@ var checkedimg = __webpack_require__(763);
4024
4049
  var ximg = __webpack_require__(2514);
4025
4050
 
4026
4051
  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
4052
  constructor(props) {
4046
4053
  super(props);
4047
- this.load();
4048
- }
4049
4054
 
4050
- async load() {
4051
- if (!this.props.order_id) return;
4052
- let orderout = await this.props.store.fetchOrder(this.props.order_id);
4053
- this.setState({
4054
- loading: false
4055
+ 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: ''
4055
4071
  });
4056
4072
 
4057
- if (!orderout.error) {
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 => {
4058
4101
  this.setState({
4059
- order: orderout.body
4102
+ selectedProvince: item,
4103
+ err: {},
4104
+ g_err: ''
4060
4105
  });
4061
- } else {
4062
4106
  this.setState({
4063
- error: orderout.error
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')
4064
4117
  });
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
4118
  });
4085
- }
4086
4119
 
4087
- isMobile() {
4088
- if (this.props.cid) return true;
4089
- if (this.props.isMobile) return true;
4090
- return this.props.store.isMobile();
4091
- }
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
+ });
4092
4139
 
4093
- onChangeShippingAddress(id) {
4094
- this.setState({
4095
- shipping_address: id,
4140
+ order_defineProperty(this, "onSelectWard", item => this.setState({
4141
+ selectedWard: item,
4096
4142
  err: {},
4097
4143
  g_err: ''
4098
- });
4099
- }
4144
+ }));
4100
4145
 
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
- };
4146
+ order_defineProperty(this, "onChangeFullname", e => this.setState({
4147
+ fullname: e.target.value,
4148
+ err: {},
4149
+ g_err: ''
4150
+ }));
4127
4151
 
4128
- onChangeShipping(id) {
4129
- this.setState({
4130
- shipping: id,
4152
+ order_defineProperty(this, "onChangeAddress", e => this.setState({
4153
+ address: e,
4131
4154
  err: {},
4132
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
+ });
4133
4178
  });
4134
- }
4135
4179
 
4136
- onSelectProvince = async item => {
4137
- this.setState({
4138
- selectedProvince: item,
4180
+ order_defineProperty(this, "onChangeEmail", e => this.setState({
4181
+ email: e.target.value,
4139
4182
  err: {},
4140
4183
  g_err: ''
4141
- });
4142
- this.setState({
4143
- loadDistrict: true
4144
- });
4145
- let out = await this.props.store.list_districts({
4146
- id: item.id
4147
- });
4148
- this.setState({
4149
- loadDistrict: false
4150
- });
4151
- if (!out.error) this.setState({
4152
- districts: util/* default.get */.Z.get(out, 'body.addresses')
4153
- });
4154
- };
4155
- onSelectDistrict = async item => {
4156
- this.setState({
4157
- selectedDistrict: item,
4184
+ }));
4185
+
4186
+ order_defineProperty(this, "onChangePhone", e => this.setState({
4187
+ phone: e.target.value,
4158
4188
  err: {},
4159
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
4160
4403
  });
4161
- this.setState({
4162
- loadWard: true
4163
- });
4164
- let out = await this.props.store.list_wards({
4165
- id: item.id
4166
- });
4167
- this.setState({
4168
- loadWard: false
4169
- });
4170
4404
  if (!out.error) this.setState({
4171
- wards: util/* default.get */.Z.get(out, 'body.addresses')
4405
+ provinces: util/* default.get */.Z.get(out, 'body.addresses')
4172
4406
  });
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;
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) {
4191
4416
  this.setState({
4192
- address: [util/* default.trim */.Z.trim(addr.address), util/* default.trim */.Z.trim(addr.street)].join(' ').trim(),
4193
- street: addr.street,
4417
+ shipping_address: id,
4194
4418
  err: {},
4195
4419
  g_err: ''
4196
4420
  });
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
4421
+ }
4422
+
4423
+ onChangeShipping(id) {
4424
+ this.setState({
4425
+ shipping: id,
4426
+ err: {},
4427
+ g_err: ''
4208
4428
  });
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
- });
4429
+ }
4223
4430
 
4224
4431
  renderDesktopPaymentMethod(order) {
4225
4432
  return null;
@@ -4757,12 +4964,6 @@ class order_Order extends common/* Com */.up {
4757
4964
  }, this.props.t('product')), $products);
4758
4965
  }
4759
4966
 
4760
- onChangeQuantity = (item, text) => {
4761
- let qty = parseInt(text) || 1;
4762
- item.quantity = qty;
4763
- this.forceUpdate();
4764
- };
4765
-
4766
4967
  renderDesktopProducts(order) {
4767
4968
  let $products = null;
4768
4969
  let editmode = false;
@@ -5001,170 +5202,6 @@ class order_Order extends common/* Com */.up {
5001
5202
  return this.renderDesktop(order);
5002
5203
  }
5003
5204
 
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
5205
  }
5169
5206
  let ShippingProvider = {
5170
5207
  ghtk: {
@@ -5177,6 +5214,8 @@ let ShippingProvider = {
5177
5214
  }
5178
5215
  };
5179
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
+
5180
5219
 
5181
5220
 
5182
5221
 
@@ -5192,16 +5231,102 @@ let Order_defaultAvatar = __webpack_require__(4761);
5192
5231
  class Order extends common/* Com */.up {
5193
5232
  constructor(props) {
5194
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
+
5195
5326
  this.refRating = (0,preact_module/* createRef */.Vf)();
5196
5327
  this.refHandle = (0,preact_module/* createRef */.Vf)();
5197
5328
  }
5198
5329
 
5199
- state = {
5200
- hide: true,
5201
- ratingHeight: 0,
5202
- overlayOpacity: 0.3
5203
- };
5204
-
5205
5330
  componentDidMount() {
5206
5331
  this.mouseUp = e => this.onMouseUp(e);
5207
5332
 
@@ -5285,12 +5410,6 @@ class Order extends common/* Com */.up {
5285
5410
  }))));
5286
5411
  }
5287
5412
 
5288
- onResponse = response => {
5289
- this.setState({
5290
- response
5291
- });
5292
- };
5293
-
5294
5413
  open() {
5295
5414
  if (!this.state.hide) return;
5296
5415
  if (!this.props.order_id) return;
@@ -5308,84 +5427,6 @@ class Order extends common/* Com */.up {
5308
5427
  });
5309
5428
  }
5310
5429
 
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
5430
  onMouseDown(e) {
5390
5431
  this.mousePushed = true;
5391
5432
  this.animation.stop();
@@ -5442,6 +5483,8 @@ class Order extends common/* Com */.up {
5442
5483
 
5443
5484
  }
5444
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
+
5445
5488
 
5446
5489
 
5447
5490
 
@@ -5468,6 +5511,31 @@ const Widget_defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar
5468
5511
  class Widget extends common/* Com */.up {
5469
5512
  constructor(props) {
5470
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
+
5471
5539
  this.userSent = {};
5472
5540
  this.setState({
5473
5541
  creating: false,
@@ -6064,29 +6132,6 @@ class Widget extends common/* Com */.up {
6064
6132
  }), $input);
6065
6133
  }
6066
6134
 
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
6135
  async onStartConvoClick() {
6091
6136
  var convo = this.props.store.matchConvo(this.props.cid) || {};
6092
6137
  if (convo.state === 'ended') return this.props.onGo({