@subiz/widget-v4 4.0.46 → 4.0.51

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 (92) hide show
  1. package/assets/img/default.jpg +0 -0
  2. package/assets/img/external-link.svg +1 -0
  3. package/assets/less/message.less +210 -42
  4. package/compiled_src/chatbox/ChatButton.js +12 -6
  5. package/compiled_src/chatbox/Event.js +22 -2
  6. package/compiled_src/chatbox/MessageInput.js +8 -3
  7. package/compiled_src/chatbox/OrderAttachments.js +113 -0
  8. package/compiled_src/chatbox/ProductAttachments.js +79 -0
  9. package/compiled_src/chatbox/TextMessage.js +1 -1
  10. package/compiled_src/chatbox/Widget.js +18 -3
  11. package/compiled_src/chatbox/main.js +5 -4
  12. package/compiled_src/chatbox/time.js +94 -7
  13. package/compiled_src/common.js +1 -1
  14. package/compiled_src/contact/contact.js +1 -1
  15. package/compiled_src/plugin.js +8 -2
  16. package/compiled_src/store/store.js +150 -5
  17. package/compiled_src/util/campaign.js +2 -2
  18. package/compiled_src/util/common.js +78 -49
  19. package/compiled_src/util/extractor.js +3 -3
  20. package/compiled_src/util/pubsub.js +6 -3
  21. package/dist/17d02a15859.178.js +1 -0
  22. package/dist/17d02a15859.213.js +1 -0
  23. package/dist/17d02a15859.362.js +1 -0
  24. package/dist/17d02a15859.441.js +1 -0
  25. package/dist/17d02a15859.605.js +1 -0
  26. package/dist/17d02a15859.619.js +1 -0
  27. package/dist/17d02a15859.678.js +1 -0
  28. package/dist/17d02a15859.712.js +1 -0
  29. package/dist/17d02a15859.782.js +1 -0
  30. package/dist/17d02a15859.app.js +1 -0
  31. package/dist/17d02a15859.index.html +21 -0
  32. package/dist/17d02a15859.library.html +21 -0
  33. package/dist/17d02a15859.library.js +1 -0
  34. package/dist/17d02a15859.preview.html +759 -0
  35. package/dist/17d02a15859.preview.js +1 -0
  36. package/dist/HASH +1 -1
  37. package/dist/assets/img/Facebook.64607ec.png +0 -0
  38. package/dist/assets/img/Zalo.6845707.png +0 -0
  39. package/dist/assets/img/award1a.1a58e10.png +0 -0
  40. package/dist/assets/img/award3a.3b74423.png +0 -0
  41. package/dist/assets/img/award4a.ed6ccd4.png +0 -0
  42. package/dist/assets/img/award5.39eb7ae.png +0 -0
  43. package/dist/assets/img/bubble_default.7d5e4ab.svg +20 -0
  44. package/dist/assets/img/convos_empty.2353007.svg +72 -0
  45. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  46. package/dist/assets/img/done_gray.d7e8203.svg +4 -0
  47. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  48. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  49. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  50. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  51. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  52. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  53. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  54. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  55. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  56. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  57. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  58. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  59. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  60. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  61. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  62. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  63. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  64. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  65. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  66. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  67. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  68. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  69. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  70. package/dist/assets/img/empty.29bed2d.svg +23 -0
  71. package/dist/assets/img/examplte_logo.f86535f.svg +1 -0
  72. package/dist/assets/img/external-link.90577cc.svg +1 -0
  73. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  74. package/dist/assets/img/image_default.be0698b.png +0 -0
  75. package/dist/assets/img/loading_static.8f403ae.svg +10 -0
  76. package/dist/assets/img/main-service1.d536cc2.png +0 -0
  77. package/dist/assets/img/main-service2.9b99549.png +0 -0
  78. package/dist/assets/img/rating--average.1ea492c.svg +12 -0
  79. package/dist/assets/img/rating--great.e3d712e.svg +16 -0
  80. package/dist/assets/img/rating--poor.2938a25.svg +12 -0
  81. package/dist/assets/img/send.6db52a9.svg +3 -0
  82. package/dist/assets/img/subiz-mono.877e9f5.svg +3 -0
  83. package/package.json +20 -19
  84. package/src/chatbox/ChatButton.js +10 -6
  85. package/src/chatbox/Event.js +72 -56
  86. package/src/chatbox/OrderAttachments.js +112 -0
  87. package/src/chatbox/ProductAttachments.js +70 -0
  88. package/src/chatbox/TextMessage.js +1 -1
  89. package/src/chatbox/main.js +6 -4
  90. package/src/plugin.js +9 -4
  91. package/src/store/store.js +146 -8
  92. package/src/util/common.js +6 -0
Binary file
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>
@@ -34,7 +34,7 @@
34
34
 
35
35
  .file-attachment--agent {
36
36
  background-color: @primary-color;
37
- width: fit-content;
37
+ width: fit-content;
38
38
  }
39
39
 
40
40
  .file-attachment--user {
@@ -46,7 +46,7 @@
46
46
  display: flex;
47
47
  flex-direction: row;
48
48
  align-items: center;
49
- width: fit-content;
49
+ width: fit-content;
50
50
  }
51
51
 
52
52
  .file-attachment--agent .file-attachment--filename {
@@ -55,7 +55,7 @@
55
55
  text-overflow: ellipsis;
56
56
  white-space: nowrap;
57
57
  overflow: hidden;
58
- max-width: 200px;
58
+ max-width: 200px;
59
59
  }
60
60
 
61
61
  .file-attachment--user .file-attachment--filename {
@@ -64,7 +64,7 @@
64
64
  text-overflow: ellipsis;
65
65
  overflow: hidden;
66
66
  white-space: nowrap;
67
- max-width: 200px;
67
+ max-width: 200px;
68
68
  }
69
69
 
70
70
  .file-attachment--download {
@@ -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
 
@@ -392,7 +392,6 @@ a.message_error {
392
392
  }
393
393
  }
394
394
 
395
-
396
395
  .message_quick_replies {
397
396
  display: flex;
398
397
  flex-wrap: wrap;
@@ -405,7 +404,7 @@ a.message_error {
405
404
  border: 1px solid @primary-color;
406
405
  margin-right: 10px;
407
406
  margin-top: 10px;
408
- color: @primary-color;
407
+ .color(@primary-color);
409
408
  border-radius: 5px;
410
409
  user-select: none;
411
410
  overflow: hidden;
@@ -447,9 +446,9 @@ a.message_error {
447
446
  display: inline-block;
448
447
  vertical-align: top;
449
448
 
450
- &:last-child {
451
- margin-right: 0;
452
- }
449
+ &:last-child {
450
+ margin-right: 0;
451
+ }
453
452
  .generic-attachment--element-img {
454
453
  width: 100%;
455
454
  height: 150px;
@@ -500,38 +499,207 @@ a.message_error {
500
499
  }
501
500
 
502
501
  .generic-attachment-navigator {
503
- position: absolute;
504
- top: 50%;
505
- transform: translateY(-50%);
506
- cursor: pointer;
507
- width: 20px;
508
- font-size: 80px;
509
- display: flex;
510
- align-items: center;
511
- justify-content: center;
512
- color: rgba(255, 255, 255, 0.85);
513
- text-shadow: 0 10px 25px rgba(0, 0, 0, 0.75);
514
- z-index: 999;
515
- user-select: none;
516
-
517
- &:hover {
518
- text-shadow: 0 10px 20px rgba(0, 0, 0, 0.75);
519
- color: rgba(255, 255, 255, 1);
520
- }
521
-
522
- &.generic-attachment-navigator--disabled {
523
- display: none;
524
- }
525
-
526
- &.generic-attachment-navigator--left {
527
- left: 2px;
528
- }
529
-
530
- &.generic-attachment-navigator--right {
531
- right: 2px;
532
- }
502
+ position: absolute;
503
+ top: 50%;
504
+ transform: translateY(-50%);
505
+ cursor: pointer;
506
+ width: 20px;
507
+ font-size: 80px;
508
+ display: flex;
509
+ align-items: center;
510
+ justify-content: center;
511
+ .color(rgba(255, 255, 255, 0.85));
512
+ text-shadow: 0 10px 25px rgba(0, 0, 0, 0.75);
513
+ z-index: 999;
514
+ user-select: none;
515
+
516
+ &:hover {
517
+ text-shadow: 0 10px 20px rgba(0, 0, 0, 0.75);
518
+ .color(rgba(255, 255, 255, 1));
519
+ }
520
+
521
+ &.generic-attachment-navigator--disabled {
522
+ display: none;
523
+ }
524
+
525
+ &.generic-attachment-navigator--left {
526
+ left: 2px;
527
+ }
528
+
529
+ &.generic-attachment-navigator--right {
530
+ right: 2px;
531
+ }
533
532
  }
534
533
 
535
534
  .generic-attachment-navigator-icon {
536
- font-size: 80px;
535
+ font-size: 80px;
536
+ }
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
+
630
+ .product_attachment {
631
+ margin-top: 10px;
632
+
633
+ border: 1px solid #d8d8d8;
634
+ background: white;
635
+ border-radius: 7px;
636
+ overflow: hidden;
637
+ width: 200px;
638
+ display: inline-block;
639
+ vertical-align: top;
640
+ transition: all 0.1s;
641
+ }
642
+
643
+ .product_attachment.product_attachment__user {
644
+ margin-right: 50px;
645
+
646
+ align-self: flex-end;
647
+
648
+ margin-right: 0;
649
+ margin-left: 50px;
650
+ align-self: flex-start;
651
+ }
652
+
653
+ .product_attachment__img {
654
+ width: 200px;
655
+ height: 200px;
656
+ border-bottom: 1px solid #d8d8d8;
657
+ object-fit: cover;
658
+ display: block;
659
+ }
660
+
661
+ .product_attachment__price {
662
+ padding-left: 10px;
663
+ }
664
+
665
+ .product_attachment__btns {
666
+ margin-top: 5px;
667
+ }
668
+ .product_attachment__btn {
669
+ border-top: 1px solid #d8d8d8;
670
+ display: flex;
671
+ padding: 8px 10px;
672
+ align-items: center;
673
+ .color(@black);
674
+ justify-content: center;
675
+ cursor: pointer;
676
+ text-transform: capitalize;
677
+ &:last-child {
678
+ margin-right: 0;
679
+ }
680
+ &:hover {
681
+ .color(@primary-color);
682
+ }
683
+ }
684
+
685
+ a.product_attachment__title {
686
+ display: block;
687
+ padding: 8px 10px 0 10px;
688
+ font-weight: 500;
689
+ .color(@black);
690
+
691
+ word-break: break-all;
692
+ }
693
+
694
+ .product_attachment__subtitle {
695
+ padding: 5px 10px;
696
+ .color(#aaa);
697
+ padding-top: 0;
698
+ }
699
+
700
+ .product_attachment__btn_external_link {
701
+ width: 16px;
702
+ height: 16px;
703
+ margin-left: 5px;
704
+ margin-top: -2px;
537
705
  }
@@ -91,20 +91,26 @@ class ChatButton extends _common.Com {
91
91
 
92
92
  if (hiddenButtonDesktop) return null;
93
93
  let cls = 'widget-layout widget-layout--' + position;
94
- if (!this.props.isShow) cls += ' widget-layout--hidden';
94
+ let opacity = this.state.opacity;
95
+
96
+ if (!this.props.isShow) {
97
+ cls += ' widget-layout--hidden';
98
+ opacity = 0;
99
+ }
100
+
95
101
  return (0, _preact.h)("div", {
96
102
  class: cls,
97
- style: 'opacity: ' + this.state.opacity + ' !important'
103
+ style: 'opacity: ' + opacity + ' !important'
98
104
  }, this.renderPreview(), this.renderButton());
99
105
  }
100
106
 
101
- clearPreview() {
107
+ ClearPreview() {
102
108
  this.setState({
103
109
  previewEvent: {}
104
110
  });
105
111
  }
106
112
 
107
- showGreeting() {
113
+ ShowGreeting() {
108
114
  let greeting = _index.default.get(this.props.plugin, 'chatbox.greeting', {});
109
115
 
110
116
  let agentM = this.props.store.matchAgent('*');
@@ -128,7 +134,7 @@ class ChatButton extends _common.Com {
128
134
  });
129
135
  }
130
136
 
131
- hideGreeting() {
137
+ HideGreeting() {
132
138
  this.setState({
133
139
  previewEvent: {}
134
140
  });
@@ -147,7 +153,7 @@ class ChatButton extends _common.Com {
147
153
  return;
148
154
  }
149
155
 
150
- this.showGreeting();
156
+ this.ShowGreeting();
151
157
  }
152
158
 
153
159
  onClick() {
@@ -21,6 +21,10 @@ var _FormSubmitAttachments = _interopRequireDefault(require("./FormSubmitAttachm
21
21
 
22
22
  var _GenericTemplateAttachments = _interopRequireDefault(require("./GenericTemplateAttachments.js"));
23
23
 
24
+ var _ProductAttachments = _interopRequireDefault(require("./ProductAttachments.js"));
25
+
26
+ var _OrderAttachments = _interopRequireDefault(require("./OrderAttachments.js"));
27
+
24
28
  var _VideoAttachments = _interopRequireDefault(require("./VideoAttachments.js"));
25
29
 
26
30
  var _TextMessage = _interopRequireDefault(require("./TextMessage.js"));
@@ -153,11 +157,14 @@ class Event extends _common.Com {
153
157
  }));
154
158
  }
155
159
 
160
+ let t = new _index.default.Date(ev.created).toLocaleString();
161
+
156
162
  if (_index.default.get(ev, 'by.type') !== 'user') {
157
163
  let $sender = null;
158
164
  if (this.props.event.mode === 'lead') $sender = this.renderAgentAvatar(ev);
159
165
  return (0, _preact.h)("div", {
160
- class: "convo-event agent-message"
166
+ class: "convo-event agent-message",
167
+ title: t
161
168
  }, $time, $sender, (0, _preact.h)(_TextMessage.default, {
162
169
  store: this.props.store,
163
170
  ev: ev
@@ -190,6 +197,14 @@ class Event extends _common.Com {
190
197
  store: this.props.store,
191
198
  ev: ev,
192
199
  onSelect: e => this.choosePostbackBtn(e)
200
+ }), (0, _preact.h)(_ProductAttachments.default, {
201
+ t: this.props.t,
202
+ store: this.props.store,
203
+ ev: ev
204
+ }), (0, _preact.h)(_OrderAttachments.default, {
205
+ t: this.props.t,
206
+ store: this.props.store,
207
+ ev: ev
193
208
  }), (0, _preact.h)(_QuickReplies.default, {
194
209
  store: this.props.store,
195
210
  ev: ev,
@@ -232,7 +247,8 @@ class Event extends _common.Com {
232
247
  }
233
248
 
234
249
  return (0, _preact.h)("div", {
235
- class: "convo-event user-message"
250
+ class: "convo-event user-message",
251
+ title: t
236
252
  }, $time, $sender, (0, _preact.h)("div", {
237
253
  class: "message-user__container"
238
254
  }, $dot, (0, _preact.h)(_TextMessage.default, {
@@ -259,6 +275,10 @@ class Event extends _common.Com {
259
275
  onSubmit: this.props.onFormSubmit,
260
276
  ref: this.refForm,
261
277
  ev: ev
278
+ }), (0, _preact.h)(_ProductAttachments.default, {
279
+ t: this.props.t,
280
+ store: this.props.store,
281
+ ev: ev
262
282
  }), (0, _preact.h)(_FormSubmitAttachments.default, {
263
283
  store: this.props.store,
264
284
  ev: ev
@@ -17,8 +17,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
17
17
 
18
18
  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; }
19
19
 
20
- var dayjs = require('dayjs');
21
-
22
20
  class MessageInput extends _common.Com {
23
21
  constructor(props) {
24
22
  super(props);
@@ -340,7 +338,14 @@ class MessageInput extends _common.Com {
340
338
 
341
339
  pasteImage(event) {
342
340
  if (!window.File || !window.FileReader || !window.FileList || !window.Blob) return;
343
- const name = `Paste-image-${dayjs(new _index.default.Date()).format('YYYY-MM-DD-HH-mm-ss')}`;
341
+ let now = new _index.default.Date();
342
+ let year = now.getFullYear();
343
+ let month = now.getMonth() + 1;
344
+ let date = now.getDate();
345
+ let hour = now.getHours();
346
+ let min = now.getMinutes();
347
+ let sec = now.getSeconds();
348
+ const name = `Paste-image-${year}-${month}-${date}-${hour}-${min}-${sec}`;
344
349
  let blob = null;
345
350
  const copiedData = event.clipboardData.items[0];
346
351
 
@@ -0,0 +1,113 @@
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
+ let price = this.props.store.getPrice(product, 'price', order.currency);
48
+ return (0, _preact.h)("div", {
49
+ class: "order_attachment__product"
50
+ }, (0, _preact.h)("img", {
51
+ class: "order_attachment__product_img",
52
+ src: (_index.default.get(product, 'images.0'), require('../../assets/img/default.jpg'))
53
+ }), (0, _preact.h)("div", {
54
+ style: "overflow: hidden !important;"
55
+ }, (0, _preact.h)("div", {
56
+ class: "order_attachment__product_name"
57
+ }, this.props.t.i18n(product.name)), (0, _preact.h)("div", {
58
+ class: "order_attachment__product_desc"
59
+ }, this.props.t.i18n(product.short_description) || this.props.t.i18n(product.description)), (0, _preact.h)("div", {
60
+ class: "order_attachment__product_desc"
61
+ }, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", _index.default.formatCurrency(price))));
62
+ }));
63
+ }
64
+
65
+ let {
66
+ total
67
+ } = this.props.store.getOrderTotal(order);
68
+ let $total = (0, _preact.h)("div", {
69
+ class: "order_attachment__footer"
70
+ }, (0, _preact.h)("div", null, this.props.t('total')), ' ', (0, _preact.h)("div", null, (0, _preact.h)("b", null, _index.default.formatCurrency(total))));
71
+
72
+ let addr = _index.default.get(order, 'shipping.address', {});
73
+
74
+ let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
75
+ let address = fulladdr;
76
+ let phoneattr = _index.default.find(_index.default.get(order, 'user.attributes', []), attr => attr.key === 'phones') || {
77
+ key: 'phones',
78
+ text: ''
79
+ };
80
+
81
+ let phone = _index.default.get(order, 'shipping.address.phone', '').trim();
82
+
83
+ phone = phone || _index.default.trim(phoneattr.text);
84
+ if (phone) phone = this.props.t('phn') + ': ' + phone;
85
+ let $shipto = null;
86
+
87
+ if (address || phone) {
88
+ $shipto = (0, _preact.h)("div", null, (0, _preact.h)("div", {
89
+ class: "order_attachment__label"
90
+ }, this.props.t('ship_to')), (0, _preact.h)("div", {
91
+ class: "order_attachment__text_truncate"
92
+ }, address), (0, _preact.h)("div", {
93
+ class: "order_attachment__text_truncate"
94
+ }, phone));
95
+ }
96
+
97
+ return (0, _preact.h)("div", {
98
+ class: `order_attachment order_attachment__${byType}`
99
+ }, (0, _preact.h)("div", {
100
+ class: "order_attachment__header"
101
+ }, this.props.t('order'), (0, _preact.h)("span", {
102
+ class: "order_attachment__text_muted order_attachment__text_sm"
103
+ }, "#", order.id)), $products, $shipto, (0, _preact.h)("div", null, (0, _preact.h)("div", {
104
+ class: "order_attachment__label"
105
+ }, this.props.t('payment')), (0, _preact.h)("div", null, "COD")), $note, $total);
106
+ });
107
+
108
+ return $orders;
109
+ }
110
+
111
+ }
112
+
113
+ exports.default = ProductAttachments;
@@ -0,0 +1,79 @@
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
+
22
+ let attachments = _index.default.get(this.props.ev, 'data.message.attachments', []);
23
+
24
+ let products = _index.default.filter(attachments, att => _index.default.get(att, 'type') === 'product' || _index.default.get(att, 'type') === 'product_preview');
25
+
26
+ products = products.filter(product => product.product && product.product.name);
27
+ if (products.length === 0) return null;
28
+ let acc = this.props.store.matchAccount();
29
+
30
+ let $products = _index.default.map(products, (att, index) => {
31
+ let product = att.product;
32
+ let $detailbtn = null;
33
+ let url = product.url || product.mobile_url;
34
+ if (this.props.store.isMobile()) url = product.mobile_url || product.url;
35
+ if (url) $detailbtn = (0, _preact.h)("a", {
36
+ class: "product_attachment__btn",
37
+ href: url,
38
+ target: "_blank"
39
+ }, this.props.t('detail'), (0, _preact.h)("img", {
40
+ src: require('../../assets/img/external-link.svg'),
41
+ class: "product_attachment__btn_external_link"
42
+ }));
43
+ let $title = (0, _preact.h)("a", {
44
+ href: url,
45
+ class: "product_attachment__title",
46
+ target: "_blank"
47
+ }, this.props.t.i18n(product.name));
48
+ let $subtitle = null;
49
+ let desc = this.props.t.i18n(product.short_description) || this.props.t.i18n(product.description);
50
+ if (desc) $subtitle = (0, _preact.h)("div", {
51
+ class: "product_attachment__subtitle"
52
+ }, desc);
53
+ let $price = null;
54
+
55
+ if (product.price) {
56
+ $price = (0, _preact.h)("div", {
57
+ class: "product_attachment__price"
58
+ }, product.currency || _index.default.get(acc, 'currency', ''), " ", _index.default.formatCurrency(product.price));
59
+ }
60
+
61
+ return (0, _preact.h)("div", {
62
+ class: 'product_attachment product_attachment__' + byType
63
+ }, (0, _preact.h)("div", null, (0, _preact.h)("a", {
64
+ href: this.props.store.replaceFileUrl(product.images[0]),
65
+ target: "_blank"
66
+ }, (0, _preact.h)("img", {
67
+ class: "product_attachment__img",
68
+ src: this.props.store.replaceFileUrl(product.images[0])
69
+ }))), $title, $subtitle, $price, (0, _preact.h)("div", {
70
+ class: "product_attachment__btns"
71
+ }, $detailbtn));
72
+ });
73
+
74
+ return $products;
75
+ }
76
+
77
+ }
78
+
79
+ exports.default = ProductAttachments;
@@ -31,7 +31,7 @@ let marked = (obj, text) => {
31
31
  const loadMarked = () => Promise.resolve().then(() => _interopRequireWildcard(require('marked')));
32
32
 
33
33
  (async () => {
34
- let markedf = (await loadMarked()).default;
34
+ let markedf = (await loadMarked()).marked;
35
35
 
36
36
  marked = (obj, text) => markedf(text);
37
37
 
@@ -699,7 +699,20 @@ class Widget extends _common.Com {
699
699
  }
700
700
 
701
701
  renderConvoSummary(convo) {
702
- var agents = this.agentsOfConvo(convo);
702
+ let agentM = this.props.store.matchAgent('*');
703
+
704
+ let ags = _index.default.filter(convo.members, m => {
705
+ return (m.type === 'agent' || m.type === 'bot') && m.membership === 'active';
706
+ });
707
+
708
+ let agentids = _index.default.map(ags, m => m.id);
709
+
710
+ agentids = agentids || _index.default.agentsOfConvo(convo)[0];
711
+
712
+ let agents = _index.default.map(agentids, id => agentM[id] || {
713
+ avatar_url: defaultAvatar,
714
+ fullname: 'Offline Agent'
715
+ });
703
716
 
704
717
  var name = _index.default.each(agents, ag => ag.fullname).join(', ');
705
718
 
@@ -720,11 +733,13 @@ class Widget extends _common.Com {
720
733
  message: _index.default.get(convo, 'last_message')
721
734
  }
722
735
  });
723
- var time = new _index.default.Date(_index.default.getMs(convo.last_event.created) || _index.default.getMs(convo.created));
736
+
737
+ var time = _index.default.getMs(_index.default.get(convo, 'last_message_sent.created')) || _index.default.getMs(_index.default.get(convo, 'last_sent.created')) || _index.default.getMs(convo.created);
738
+
724
739
  var $tim = (0, _preact.h)(_time.default, {
725
740
  ago: true,
726
741
  time: time,
727
- key: new _index.default.Date().getTime(),
742
+ key: time,
728
743
  short: true
729
744
  });
730
745
  let $unread = seen ? null : (0, _preact.h)("div", {