@subiz/widget-v4 4.0.50 → 4.0.55

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 (61) hide show
  1. package/assets/img/default.jpg +0 -0
  2. package/assets/less/message.less +101 -10
  3. package/compiled_src/chatbox/Event.js +6 -0
  4. package/compiled_src/chatbox/OrderAttachments.js +109 -0
  5. package/compiled_src/chatbox/ProductAttachments.js +9 -7
  6. package/compiled_src/notif/notif.js +6 -2
  7. package/compiled_src/plugin.js +1 -1
  8. package/compiled_src/store/api.js +1 -0
  9. package/compiled_src/util/campaign.js +6 -1
  10. package/compiled_src/util/common.js +7 -0
  11. package/dist/{17cbc0a3e5f.178.js → 17d7ef81b7a.178.js} +1 -1
  12. package/dist/{17cbc0a3e5f.213.js → 17d7ef81b7a.213.js} +0 -0
  13. package/dist/{17cbc0a3e5f.362.js → 17d7ef81b7a.362.js} +1 -1
  14. package/dist/17d7ef81b7a.441.js +1 -0
  15. package/dist/17d7ef81b7a.605.js +1 -0
  16. package/dist/{17cbc0a3e5f.619.js → 17d7ef81b7a.619.js} +1 -1
  17. package/dist/{17cbc0a3e5f.678.js → 17d7ef81b7a.678.js} +0 -0
  18. package/dist/17d7ef81b7a.74.js +1 -0
  19. package/dist/{17cbc0a3e5f.782.js → 17d7ef81b7a.782.js} +1 -1
  20. package/dist/17d7ef81b7a.app.js +1 -0
  21. package/dist/{17cbc0a3e5f.index.html → 17d7ef81b7a.index.html} +1 -1
  22. package/dist/{17cbc0a3e5f.library.html → 17d7ef81b7a.library.html} +1 -1
  23. package/dist/17d7ef81b7a.library.js +1 -0
  24. package/dist/{17cbc0a3e5f.preview.html → 17d7ef81b7a.preview.html} +1 -1
  25. package/dist/17d7ef81b7a.preview.js +1 -0
  26. package/dist/17d7ef81b7a.screenshoot.js +1 -0
  27. package/dist/17d7ef84382.178.js +406 -0
  28. package/dist/17d7ef84382.213.js +3223 -0
  29. package/dist/17d7ef84382.362.js +107 -0
  30. package/dist/17d7ef84382.441.js +2706 -0
  31. package/dist/17d7ef84382.605.js +391 -0
  32. package/dist/17d7ef84382.619.js +777 -0
  33. package/dist/17d7ef84382.678.js +107 -0
  34. package/dist/17d7ef84382.74.js +4732 -0
  35. package/dist/17d7ef84382.782.js +107 -0
  36. package/dist/17d7ef84382.screenshoot.js +5719 -0
  37. package/dist/HASH +1 -1
  38. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  39. package/dist/screenshoot.html +7 -0
  40. package/package.json +12 -12
  41. package/screenshoot.html +15 -0
  42. package/screenshoot.js +28 -0
  43. package/src/chatbox/Event.js +2 -0
  44. package/src/chatbox/OrderAttachments.js +107 -0
  45. package/src/chatbox/ProductAttachments.js +14 -8
  46. package/src/notif/notif.js +36 -27
  47. package/src/plugin.js +1 -1
  48. package/src/store/api.js +2 -5
  49. package/src/store/store.js +9 -8
  50. package/src/util/campaign.js +14 -11
  51. package/src/util/common.js +6 -0
  52. package/take.js +36 -0
  53. package/webpack.dev.js +7 -0
  54. package/webpack.prod.js +12 -2
  55. package/webpack.screenshoot.js +28 -0
  56. package/dist/17cbc0a3e5f.605.js +0 -1
  57. package/dist/17cbc0a3e5f.712.js +0 -1
  58. package/dist/17cbc0a3e5f.84.js +0 -1
  59. package/dist/17cbc0a3e5f.app.js +0 -1
  60. package/dist/17cbc0a3e5f.library.js +0 -1
  61. package/dist/17cbc0a3e5f.preview.js +0 -1
Binary file
@@ -148,13 +148,13 @@
148
148
  }
149
149
 
150
150
  a.message_error {
151
- color: @red;
151
+ .color(@red);
152
152
  display: block;
153
153
  text-align: end;
154
154
  font-size: 13px;
155
155
  margin-bottom: 10px;
156
156
  &:hover {
157
- color: @red;
157
+ .color(@red);
158
158
  }
159
159
  }
160
160
 
@@ -404,7 +404,7 @@ a.message_error {
404
404
  border: 1px solid @primary-color;
405
405
  margin-right: 10px;
406
406
  margin-top: 10px;
407
- color: @primary-color;
407
+ .color(@primary-color);
408
408
  border-radius: 5px;
409
409
  user-select: none;
410
410
  overflow: hidden;
@@ -508,14 +508,14 @@ a.message_error {
508
508
  display: flex;
509
509
  align-items: center;
510
510
  justify-content: center;
511
- color: rgba(255, 255, 255, 0.85);
511
+ .color(rgba(255, 255, 255, 0.85));
512
512
  text-shadow: 0 10px 25px rgba(0, 0, 0, 0.75);
513
513
  z-index: 999;
514
514
  user-select: none;
515
515
 
516
516
  &:hover {
517
517
  text-shadow: 0 10px 20px rgba(0, 0, 0, 0.75);
518
- color: rgba(255, 255, 255, 1);
518
+ .color(rgba(255, 255, 255, 1));
519
519
  }
520
520
 
521
521
  &.generic-attachment-navigator--disabled {
@@ -535,6 +535,98 @@ a.message_error {
535
535
  font-size: 80px;
536
536
  }
537
537
 
538
+ .order_attachment__product_img {
539
+ width: 40px;
540
+ height: 40px;
541
+ margin-right: 10px;
542
+ border-radius: 5px;
543
+ flex-shrink: 0;
544
+ display: block;
545
+ object-fit: contain;
546
+ background: whitesmoke;
547
+ }
548
+
549
+ .order_attachment__product_name {
550
+ text-overflow: ellipsis;
551
+ white-space: nowrap;
552
+ overflow: hidden;
553
+ .color(black);
554
+ }
555
+
556
+ .order_attachment__header {
557
+ padding-bottom: 5px;
558
+ border-bottom: 1px solid #ccc;
559
+ margin-bottom: 5px;
560
+ display: flex;
561
+ align-items: center;
562
+ justify-content: space-between;
563
+ }
564
+
565
+ .order_attachment__product_desc {
566
+ text-overflow: ellipsis;
567
+ white-space: nowrap;
568
+ overflow: hidden;
569
+ .color(#999);
570
+ font-size: 13px;
571
+ }
572
+
573
+ .order_attachment__product {
574
+ display: flex;
575
+ align-items: center;
576
+ margin-top: 5px;
577
+ margin-bottom: 5;
578
+ }
579
+
580
+ .order_attachment__text_sm {
581
+ font-size: 13px;
582
+ }
583
+
584
+ .order_attachment__text_muted {
585
+ .color(@text-muted);
586
+ }
587
+
588
+ .order_attachment__text_truncate {
589
+ text-overflow: ellipsis;
590
+ white-space: nowrap;
591
+ overflow: hidden;
592
+ }
593
+
594
+ .order_attachment {
595
+ margin-top: 10px;
596
+ .color(black);
597
+ border: 1px solid #aaa;
598
+ background: white;
599
+ border-radius: 8px;
600
+ width: 220px;
601
+ overflow-y: auto;
602
+ overflow-x: hidden;
603
+ padding: 10px;
604
+ }
605
+ .order_attachment__footer {
606
+ margin-top: 10px;
607
+ padding-top: 10px;
608
+ display: flex;
609
+ justify-content: space-between;
610
+ border-top: 1px solid #ccc;
611
+ line-height: 1;
612
+ }
613
+
614
+ .order_attachment__label {
615
+ font-size: 13px;
616
+ .color(#777);
617
+ margin-top: 10px;
618
+ }
619
+
620
+ .order_attachment.order_attachment__user {
621
+ margin-right: 50px;
622
+
623
+ align-self: flex-end;
624
+
625
+ margin-right: 0;
626
+ margin-left: 50px;
627
+ align-self: flex-start;
628
+ }
629
+
538
630
  .product_attachment {
539
631
  margin-top: 10px;
540
632
 
@@ -567,7 +659,6 @@ a.message_error {
567
659
  }
568
660
 
569
661
  .product_attachment__price {
570
- color: #aaa;
571
662
  padding-left: 10px;
572
663
  }
573
664
 
@@ -579,7 +670,7 @@ a.message_error {
579
670
  display: flex;
580
671
  padding: 8px 10px;
581
672
  align-items: center;
582
- color: @black;
673
+ .color(@black);
583
674
  justify-content: center;
584
675
  cursor: pointer;
585
676
  text-transform: capitalize;
@@ -587,7 +678,7 @@ a.message_error {
587
678
  margin-right: 0;
588
679
  }
589
680
  &:hover {
590
- color: @primary-color;
681
+ .color(@primary-color);
591
682
  }
592
683
  }
593
684
 
@@ -595,14 +686,14 @@ a.product_attachment__title {
595
686
  display: block;
596
687
  padding: 8px 10px 0 10px;
597
688
  font-weight: 500;
598
- color: @black;
689
+ .color(@black);
599
690
 
600
691
  word-break: break-all;
601
692
  }
602
693
 
603
694
  .product_attachment__subtitle {
604
695
  padding: 5px 10px;
605
- color: #ddd;
696
+ .color(#aaa);
606
697
  padding-top: 0;
607
698
  }
608
699
 
@@ -23,6 +23,8 @@ var _GenericTemplateAttachments = _interopRequireDefault(require("./GenericTempl
23
23
 
24
24
  var _ProductAttachments = _interopRequireDefault(require("./ProductAttachments.js"));
25
25
 
26
+ var _OrderAttachments = _interopRequireDefault(require("./OrderAttachments.js"));
27
+
26
28
  var _VideoAttachments = _interopRequireDefault(require("./VideoAttachments.js"));
27
29
 
28
30
  var _TextMessage = _interopRequireDefault(require("./TextMessage.js"));
@@ -199,6 +201,10 @@ class Event extends _common.Com {
199
201
  t: this.props.t,
200
202
  store: this.props.store,
201
203
  ev: ev
204
+ }), (0, _preact.h)(_OrderAttachments.default, {
205
+ t: this.props.t,
206
+ store: this.props.store,
207
+ ev: ev
202
208
  }), (0, _preact.h)(_QuickReplies.default, {
203
209
  store: this.props.store,
204
210
  ev: ev,
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _index = _interopRequireDefault(require("../util/index.js"));
9
+
10
+ var _common = require("../common.js");
11
+
12
+ var _preact = require("preact");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ class ProductAttachments extends _common.Com {
17
+ render() {
18
+ let byType = _index.default.get(this.props.ev, 'by.type');
19
+
20
+ if (byType === 'user') return null;
21
+ let acc = this.props.store.matchAccount();
22
+
23
+ var attachments = _index.default.get(this.props.ev, 'data.message.attachments', []);
24
+
25
+ let orders = _index.default.filter(attachments, att => att.type === 'order' && att.order).map(att => att.order);
26
+
27
+ if (orders.length === 0) return null;
28
+
29
+ let $orders = _index.default.map(orders, (order, index) => {
30
+ let $note = null;
31
+
32
+ if (order.note) {
33
+ $note = (0, _preact.h)("div", null, (0, _preact.h)("div", {
34
+ class: "order_attachment__label"
35
+ }, this.props.t('note')), (0, _preact.h)("div", {
36
+ class: "order_attachment__text_truncate"
37
+ }, order.note));
38
+ }
39
+
40
+ let $products = null;
41
+
42
+ if (_index.default.size(order.items) > 0) {
43
+ $products = (0, _preact.h)("div", null, (0, _preact.h)("div", {
44
+ class: "order_attachment__label"
45
+ }, this.props.t('product')), _index.default.map(order.items, item => {
46
+ let product = item.product || {};
47
+ return (0, _preact.h)("div", {
48
+ class: "order_attachment__product"
49
+ }, (0, _preact.h)("img", {
50
+ class: "order_attachment__product_img",
51
+ src: (_index.default.get(product, 'images.0'), require('../../assets/img/default.jpg'))
52
+ }), (0, _preact.h)("div", {
53
+ style: "overflow: hidden !important;"
54
+ }, (0, _preact.h)("div", {
55
+ class: "order_attachment__product_name"
56
+ }, product.name), (0, _preact.h)("div", {
57
+ class: "order_attachment__product_desc"
58
+ }, product.description || product.long_description), (0, _preact.h)("div", {
59
+ class: "order_attachment__product_desc"
60
+ }, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", _index.default.formatCurrency(product.price))));
61
+ }));
62
+ }
63
+
64
+ let $total = (0, _preact.h)("div", {
65
+ class: "order_attachment__footer"
66
+ }, (0, _preact.h)("div", null, this.props.t('total')), ' ', (0, _preact.h)("div", null, (0, _preact.h)("b", null, _index.default.formatCurrency(order.total))));
67
+
68
+ let addr = _index.default.get(order, 'shipping.address', {});
69
+
70
+ let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
71
+ let address = fulladdr;
72
+ let phoneattr = _index.default.find(_index.default.get(order, 'user.attributes', []), attr => attr.key === 'phones') || {
73
+ key: 'phones',
74
+ text: ''
75
+ };
76
+
77
+ let phone = _index.default.get(order, 'shipping.address.phone', '').trim();
78
+
79
+ phone = phone || _index.default.trim(phoneattr.text);
80
+ if (phone) phone = this.props.t('phn') + ': ' + phone;
81
+ let $shipto = null;
82
+
83
+ if (address || phone) {
84
+ $shipto = (0, _preact.h)("div", null, (0, _preact.h)("div", {
85
+ class: "order_attachment__label"
86
+ }, this.props.t('ship_to')), (0, _preact.h)("div", {
87
+ class: "order_attachment__text_truncate"
88
+ }, address), (0, _preact.h)("div", {
89
+ class: "order_attachment__text_truncate"
90
+ }, phone));
91
+ }
92
+
93
+ return (0, _preact.h)("div", {
94
+ class: `order_attachment order_attachment__${byType}`
95
+ }, (0, _preact.h)("div", {
96
+ class: "order_attachment__header"
97
+ }, this.props.t('order'), (0, _preact.h)("span", {
98
+ class: "order_attachment__text_muted order_attachment__text_sm"
99
+ }, "#", order.id)), $products, $shipto, (0, _preact.h)("div", null, (0, _preact.h)("div", {
100
+ class: "order_attachment__label"
101
+ }, this.props.t('payment')), (0, _preact.h)("div", null, "COD")), $note, $total);
102
+ });
103
+
104
+ return $orders;
105
+ }
106
+
107
+ }
108
+
109
+ exports.default = ProductAttachments;
@@ -25,6 +25,7 @@ class ProductAttachments extends _common.Com {
25
25
 
26
26
  products = products.filter(product => product.product && product.product.name);
27
27
  if (products.length === 0) return null;
28
+ let acc = this.props.store.matchAccount();
28
29
 
29
30
  let $products = _index.default.map(products, (att, index) => {
30
31
  let product = att.product;
@@ -43,27 +44,28 @@ class ProductAttachments extends _common.Com {
43
44
  href: url,
44
45
  class: "product_attachment__title",
45
46
  target: "_blank"
46
- }, this.props.t.i18n(product.name));
47
+ }, product.name);
47
48
  let $subtitle = null;
48
- if (product.short_description) $subtitle = (0, _preact.h)("div", {
49
+ let desc = product.description || product.long_description;
50
+ if (desc) $subtitle = (0, _preact.h)("div", {
49
51
  class: "product_attachment__subtitle"
50
- }, product.short_description);
52
+ }, desc);
51
53
  let $price = null;
52
54
 
53
- if (product.sale_price) {
55
+ if (product.price) {
54
56
  $price = (0, _preact.h)("div", {
55
57
  class: "product_attachment__price"
56
- }, product.sale_price, " VND");
58
+ }, product.currency || _index.default.get(acc, 'currency', ''), " ", _index.default.formatCurrency(product.price));
57
59
  }
58
60
 
59
61
  return (0, _preact.h)("div", {
60
62
  class: 'product_attachment product_attachment__' + byType
61
63
  }, (0, _preact.h)("div", null, (0, _preact.h)("a", {
62
- href: this.props.store.replaceFileUrl(product.images[0]),
64
+ href: this.props.store.replaceFileUrl(product.image),
63
65
  target: "_blank"
64
66
  }, (0, _preact.h)("img", {
65
67
  class: "product_attachment__img",
66
- src: this.props.store.replaceFileUrl(product.images[0])
68
+ src: this.props.store.replaceFileUrl(product.image)
67
69
  }))), $title, $subtitle, $price, (0, _preact.h)("div", {
68
70
  class: "product_attachment__btns"
69
71
  }, $detailbtn));
@@ -154,6 +154,10 @@ class Notif extends _common.Com {
154
154
 
155
155
  let i18n_message = i18n_messages[Math.floor(Math.random() * _index.default.size(i18n_messages))];
156
156
 
157
+ let fallbackmsgs = _index.default.get(this.props, 'plugin.notification.message_quill_deltas', []);
158
+
159
+ let fallbackmessage = fallbackmsgs[Math.floor(Math.random() * _index.default.size(fallbackmsgs))];
160
+
157
161
  let i18n_title = _index.default.get(this.props, 'plugin.notification.i18n_title_quill_delta');
158
162
 
159
163
  return this.setState({
@@ -161,8 +165,8 @@ class Notif extends _common.Com {
161
165
  last_show: _index.default.Date.now(),
162
166
  timestamp: timestamp,
163
167
  user: user,
164
- title: this.props.t.i18n(i18n_title),
165
- message: this.props.t.i18n(i18n_message)
168
+ title: this.props.t.i18n(i18n_title) || _index.default.get(this.props, 'plugin.notification.title_quill_delta'),
169
+ message: this.props.t.i18n(i18n_message) || fallbackmessage
166
170
  });
167
171
  }
168
172
 
@@ -411,7 +411,7 @@ const getLocale = (plugin, loc) => {
411
411
 
412
412
  let found = _index.default.find(plugin.locales, l => l.toLowerCase().trim() === loc.toLowerCase().trim());
413
413
 
414
- if (found) return loc;
414
+ if (found) return found;
415
415
  found = _index.default.find(plugin.locales, l => {
416
416
  l = l.replace('-', '_').split('_')[0].trim().toLowerCase();
417
417
  let compareloc = loc.replace('-', '_').split('_')[0].trim().toLowerCase();
@@ -157,6 +157,7 @@ class _default {
157
157
  data: {
158
158
  product: {
159
159
  url: pageUrl,
160
+ name: pageTitle,
160
161
  title: pageTitle
161
162
  }
162
163
  }
@@ -41,7 +41,12 @@ function trackAreaClicked(selector, cb) {
41
41
  common.map(selector.split('\n'), selector => {
42
42
  selector = common.trim(selector);
43
43
  if (!selector) return;
44
- let doms = document.querySelectorAll(selector);
44
+ let doms = [];
45
+
46
+ try {
47
+ doms = document.querySelectorAll(selector);
48
+ } catch (e) {}
49
+
45
50
  common.map(doms, dom => {
46
51
  if (!dom) return;
47
52
  dom.addEventListener('click', cb, false);
@@ -15,6 +15,7 @@ exports.diffYear = diffYear;
15
15
  exports.each = each;
16
16
  exports.filter = filter;
17
17
  exports.find = find;
18
+ exports.formatCurrency = formatCurrency;
18
19
  exports.getAgentDisplayName = getAgentDisplayName;
19
20
  exports.getDayName = getDayName;
20
21
  exports.getIntegrationId = getIntegrationId;
@@ -1129,6 +1130,12 @@ var sleep = ms => new Promise(res => setTimeout(res, ms));
1129
1130
 
1130
1131
  exports.sleep = sleep;
1131
1132
 
1133
+ function formatCurrency(val) {
1134
+ if (!val) return 0;
1135
+ val = Math.round(val);
1136
+ return val.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
1137
+ }
1138
+
1132
1139
  function replaceFileUrl(src) {
1133
1140
  let fileurl = 'https://vcdn.subiz-cdn.com/file/';
1134
1141
  if (!src) return '';