@subiz/widget-v4 4.0.49 → 4.0.53
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.
- package/assets/img/default.jpg +0 -0
- package/assets/less/message.less +101 -10
- package/compiled_src/chatbox/Event.js +6 -0
- package/compiled_src/chatbox/OrderAttachments.js +109 -0
- package/compiled_src/chatbox/ProductAttachments.js +9 -7
- package/compiled_src/chatbox/TextMessage.js +1 -1
- package/compiled_src/plugin.js +9 -3
- package/compiled_src/store/api.js +1 -0
- package/compiled_src/util/common.js +12 -1
- package/compiled_src/util/pubsub.js +6 -3
- package/dist/HASH +1 -1
- package/package.json +11 -12
- package/src/chatbox/Event.js +2 -0
- package/src/chatbox/OrderAttachments.js +107 -0
- package/src/chatbox/ProductAttachments.js +14 -8
- package/src/chatbox/TextMessage.js +1 -1
- package/src/plugin.js +9 -4
- package/src/store/api.js +2 -5
- package/src/store/store.js +9 -8
- package/src/util/common.js +6 -0
- package/dist/17cbc08f0e6.178.js +0 -1
- package/dist/17cbc08f0e6.213.js +0 -1
- package/dist/17cbc08f0e6.362.js +0 -1
- package/dist/17cbc08f0e6.605.js +0 -1
- package/dist/17cbc08f0e6.619.js +0 -1
- package/dist/17cbc08f0e6.678.js +0 -1
- package/dist/17cbc08f0e6.712.js +0 -1
- package/dist/17cbc08f0e6.782.js +0 -1
- package/dist/17cbc08f0e6.84.js +0 -1
- package/dist/17cbc08f0e6.app.js +0 -1
- package/dist/17cbc08f0e6.index.html +0 -21
- package/dist/17cbc08f0e6.library.html +0 -21
- package/dist/17cbc08f0e6.library.js +0 -1
- package/dist/17cbc08f0e6.preview.html +0 -759
- package/dist/17cbc08f0e6.preview.js +0 -1
- package/dist/assets/img/Facebook.64607ec.png +0 -0
- package/dist/assets/img/Zalo.6845707.png +0 -0
- package/dist/assets/img/award1a.1a58e10.png +0 -0
- package/dist/assets/img/award3a.3b74423.png +0 -0
- package/dist/assets/img/award4a.ed6ccd4.png +0 -0
- package/dist/assets/img/award5.39eb7ae.png +0 -0
- package/dist/assets/img/bubble_default.7d5e4ab.svg +0 -20
- package/dist/assets/img/convos_empty.2353007.svg +0 -72
- package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
- package/dist/assets/img/done_gray.d7e8203.svg +0 -4
- package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
- package/dist/assets/img/empty.29bed2d.svg +0 -23
- package/dist/assets/img/examplte_logo.f86535f.svg +0 -1
- package/dist/assets/img/external-link.90577cc.svg +0 -1
- package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
- package/dist/assets/img/image_default.be0698b.png +0 -0
- package/dist/assets/img/loading_static.8f403ae.svg +0 -10
- package/dist/assets/img/main-service1.d536cc2.png +0 -0
- package/dist/assets/img/main-service2.9b99549.png +0 -0
- package/dist/assets/img/rating--average.1ea492c.svg +0 -12
- package/dist/assets/img/rating--great.e3d712e.svg +0 -16
- package/dist/assets/img/rating--poor.2938a25.svg +0 -12
- package/dist/assets/img/send.6db52a9.svg +0 -3
- package/dist/assets/img/subiz-mono.877e9f5.svg +0 -3
|
Binary file
|
package/assets/less/message.less
CHANGED
|
@@ -148,13 +148,13 @@
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
a.message_error {
|
|
151
|
-
color
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
},
|
|
47
|
+
}, product.name);
|
|
47
48
|
let $subtitle = null;
|
|
48
|
-
|
|
49
|
+
let desc = product.description || product.long_description;
|
|
50
|
+
if (desc) $subtitle = (0, _preact.h)("div", {
|
|
49
51
|
class: "product_attachment__subtitle"
|
|
50
|
-
},
|
|
52
|
+
}, desc);
|
|
51
53
|
let $price = null;
|
|
52
54
|
|
|
53
|
-
if (product.
|
|
55
|
+
if (product.price) {
|
|
54
56
|
$price = (0, _preact.h)("div", {
|
|
55
57
|
class: "product_attachment__price"
|
|
56
|
-
}, product.
|
|
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.
|
|
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.
|
|
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));
|
|
@@ -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()).
|
|
34
|
+
let markedf = (await loadMarked()).marked;
|
|
35
35
|
|
|
36
36
|
marked = (obj, text) => markedf(text);
|
|
37
37
|
|
package/compiled_src/plugin.js
CHANGED
|
@@ -407,10 +407,16 @@ function downloadLanguage(store, locale, force) {
|
|
|
407
407
|
}
|
|
408
408
|
|
|
409
409
|
const getLocale = (plugin, loc) => {
|
|
410
|
-
|
|
410
|
+
if (!loc) loc = '';
|
|
411
411
|
|
|
412
|
-
|
|
413
|
-
|
|
412
|
+
let found = _index.default.find(plugin.locales, l => l.toLowerCase().trim() === loc.toLowerCase().trim());
|
|
413
|
+
|
|
414
|
+
if (found) return found;
|
|
415
|
+
found = _index.default.find(plugin.locales, l => {
|
|
416
|
+
l = l.replace('-', '_').split('_')[0].trim().toLowerCase();
|
|
417
|
+
let compareloc = loc.replace('-', '_').split('_')[0].trim().toLowerCase();
|
|
418
|
+
return l == compareloc;
|
|
419
|
+
});
|
|
414
420
|
if (found) return found;
|
|
415
421
|
return plugin.locale || 'en-US';
|
|
416
422
|
};
|
|
@@ -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;
|
|
@@ -167,7 +168,11 @@ function isObject(item) {
|
|
|
167
168
|
return item && typeof item === 'object' && !Array.isArray(item);
|
|
168
169
|
}
|
|
169
170
|
|
|
170
|
-
function merge(target
|
|
171
|
+
function merge(target) {
|
|
172
|
+
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
173
|
+
sources[_key - 1] = arguments[_key];
|
|
174
|
+
}
|
|
175
|
+
|
|
171
176
|
if (!sources.length) return target;
|
|
172
177
|
const source = sources.shift();
|
|
173
178
|
|
|
@@ -1125,6 +1130,12 @@ var sleep = ms => new Promise(res => setTimeout(res, ms));
|
|
|
1125
1130
|
|
|
1126
1131
|
exports.sleep = sleep;
|
|
1127
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
|
+
|
|
1128
1139
|
function replaceFileUrl(src) {
|
|
1129
1140
|
let fileurl = 'https://vcdn.subiz-cdn.com/file/';
|
|
1130
1141
|
if (!src) return '';
|
|
@@ -17,9 +17,12 @@ class Pubsub {
|
|
|
17
17
|
|
|
18
18
|
publish(topic, payload, payload2, payload3) {
|
|
19
19
|
this.listeners[topic] = filter(this.listeners[topic], sub => sub.obj._isMounted);
|
|
20
|
-
map(this.listeners[topic],
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
map(this.listeners[topic], _ref => {
|
|
21
|
+
let {
|
|
22
|
+
cb
|
|
23
|
+
} = _ref;
|
|
24
|
+
return cb(payload, payload2, payload3);
|
|
25
|
+
});
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
on2(obj, topic, cb) {
|
package/dist/HASH
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
17d750396cd
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subiz/widget-v4",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.53",
|
|
4
4
|
"main": "./compiled_src/lib.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npx webpack serve --config webpack.dev.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"lib": "rm -rf compiled_src && npx babel --out-dir=compiled_src src"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@babel/core": "^7.
|
|
12
|
+
"@babel/core": "^7.16.0",
|
|
13
13
|
"@googlemaps/js-api-loader": "^1.11.4",
|
|
14
14
|
"@subiz/ajax": "^3.0.12",
|
|
15
15
|
"@subiz/flow": "^1.0.9",
|
|
@@ -17,25 +17,24 @@
|
|
|
17
17
|
"@subiz/wsclient": "^3.1.7",
|
|
18
18
|
"babel-loader": "^8.2.3",
|
|
19
19
|
"cookie_js": "1.4.2",
|
|
20
|
-
"core-js": "^3.19.
|
|
20
|
+
"core-js": "^3.19.2",
|
|
21
21
|
"css-loader": "^5.2.6",
|
|
22
22
|
"file-loader": "^6.2.0",
|
|
23
23
|
"less": "^4.1.2",
|
|
24
24
|
"less-loader": "^10.2.0",
|
|
25
|
-
"marked": "^
|
|
26
|
-
"preact": "^10.
|
|
25
|
+
"marked": "^4.0.5",
|
|
26
|
+
"preact": "^10.6.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@babel/cli": "^7.
|
|
30
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
31
|
-
"@babel/plugin-transform-react-jsx": "^7.
|
|
32
|
-
"@babel/preset-env": "^7.
|
|
29
|
+
"@babel/cli": "^7.16.0",
|
|
30
|
+
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
31
|
+
"@babel/plugin-transform-react-jsx": "^7.16.0",
|
|
32
|
+
"@babel/preset-env": "^7.16.4",
|
|
33
33
|
"babel-plugin-syntax-jsx": "^6.18.0",
|
|
34
34
|
"html-webpack-plugin": "^5.5.0",
|
|
35
|
-
"
|
|
36
|
-
"webpack": "^5.60.0",
|
|
35
|
+
"webpack": "^5.64.4",
|
|
37
36
|
"webpack-bundle-analyzer": "^4.5.0",
|
|
38
37
|
"webpack-cli": "^4.9.1",
|
|
39
|
-
"webpack-dev-server": "^4.
|
|
38
|
+
"webpack-dev-server": "^4.6.0"
|
|
40
39
|
}
|
|
41
40
|
}
|
package/src/chatbox/Event.js
CHANGED
|
@@ -7,6 +7,7 @@ import FormAttachments from './FormAttachments.js'
|
|
|
7
7
|
import FormSubmitAttachments from './FormSubmitAttachments.js'
|
|
8
8
|
import GenericTemplateAttachments from './GenericTemplateAttachments.js'
|
|
9
9
|
import ProductAttachments from './ProductAttachments.js'
|
|
10
|
+
import OrderAttachments from './OrderAttachments.js'
|
|
10
11
|
//import FormSubmitAttachment from './formSubmitAttachment.js'
|
|
11
12
|
import VideoAttachments from './VideoAttachments.js'
|
|
12
13
|
import TextMessage from './TextMessage.js'
|
|
@@ -140,6 +141,7 @@ export default class Event extends Com {
|
|
|
140
141
|
<FormSubmitAttachments store={this.props.store} ev={ev} t={this.props.t} />
|
|
141
142
|
<GenericTemplateAttachments store={this.props.store} ev={ev} onSelect={(e) => this.choosePostbackBtn(e)} />
|
|
142
143
|
<ProductAttachments t={this.props.t} store={this.props.store} ev={ev} />
|
|
144
|
+
<OrderAttachments t={this.props.t} store={this.props.store} ev={ev} />
|
|
143
145
|
<QuickReplies store={this.props.store} ev={ev} onSelect={(e) => this.chooseQuickReply(e)} />
|
|
144
146
|
</div>
|
|
145
147
|
)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import sb from '../util/index.js'
|
|
2
|
+
import {Com} from '../common.js'
|
|
3
|
+
import {h, createRef, Fragment} from 'preact'
|
|
4
|
+
|
|
5
|
+
export default class ProductAttachments extends Com {
|
|
6
|
+
render() {
|
|
7
|
+
let byType = sb.get(this.props.ev, 'by.type')
|
|
8
|
+
if (byType === 'user') return null
|
|
9
|
+
// filter out all generic
|
|
10
|
+
|
|
11
|
+
let acc = this.props.store.matchAccount()
|
|
12
|
+
var attachments = sb.get(this.props.ev, 'data.message.attachments', [])
|
|
13
|
+
let orders = sb.filter(attachments, (att) => att.type === 'order' && att.order).map((att) => att.order)
|
|
14
|
+
|
|
15
|
+
if (orders.length === 0) return null
|
|
16
|
+
|
|
17
|
+
let $orders = sb.map(orders, (order, index) => {
|
|
18
|
+
let $note = null
|
|
19
|
+
if (order.note) {
|
|
20
|
+
$note = (
|
|
21
|
+
<div>
|
|
22
|
+
<div class='order_attachment__label'>{this.props.t('note')}</div>
|
|
23
|
+
<div class='order_attachment__text_truncate'>{order.note}</div>
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let $products = null
|
|
29
|
+
if (sb.size(order.items) > 0) {
|
|
30
|
+
$products = (
|
|
31
|
+
<div>
|
|
32
|
+
<div class='order_attachment__label'>{this.props.t('product')}</div>
|
|
33
|
+
{sb.map(order.items, (item) => {
|
|
34
|
+
let product = item.product || {}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div class='order_attachment__product'>
|
|
38
|
+
<img
|
|
39
|
+
class='order_attachment__product_img'
|
|
40
|
+
src={(sb.get(product, 'images.0'), require('../../assets/img/default.jpg'))}
|
|
41
|
+
/>
|
|
42
|
+
<div style='overflow: hidden !important;'>
|
|
43
|
+
<div class='order_attachment__product_name'>{product.name}</div>
|
|
44
|
+
<div class='order_attachment__product_desc'>{product.description || product.long_description}</div>
|
|
45
|
+
<div class='order_attachment__product_desc'>
|
|
46
|
+
{this.props.t('qty')} {item.quantity} · {sb.formatCurrency(product.price)}
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
)
|
|
51
|
+
})}
|
|
52
|
+
</div>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let $total = (
|
|
57
|
+
<div class='order_attachment__footer'>
|
|
58
|
+
<div>{this.props.t('total')}</div>{' '}
|
|
59
|
+
<div>
|
|
60
|
+
<b>{sb.formatCurrency(order.total)}</b>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
let addr = sb.get(order, 'shipping.address', {})
|
|
66
|
+
let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter((a) => a).join(', ')
|
|
67
|
+
let address = fulladdr
|
|
68
|
+
|
|
69
|
+
let phoneattr = sb.find(sb.get(order, 'user.attributes', []), (attr) => attr.key === 'phones') || {
|
|
70
|
+
key: 'phones',
|
|
71
|
+
text: '',
|
|
72
|
+
}
|
|
73
|
+
let phone = sb.get(order, 'shipping.address.phone', '').trim()
|
|
74
|
+
phone = phone || sb.trim(phoneattr.text)
|
|
75
|
+
if (phone) phone = this.props.t('phn') + ': ' + phone
|
|
76
|
+
|
|
77
|
+
let $shipto = null
|
|
78
|
+
if (address || phone) {
|
|
79
|
+
$shipto = (
|
|
80
|
+
<div>
|
|
81
|
+
<div class='order_attachment__label'>{this.props.t('ship_to')}</div>
|
|
82
|
+
<div class='order_attachment__text_truncate'>{address}</div>
|
|
83
|
+
<div class='order_attachment__text_truncate'>{phone}</div>
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<div class={`order_attachment order_attachment__${byType}`}>
|
|
90
|
+
<div class='order_attachment__header'>
|
|
91
|
+
{this.props.t('order')}
|
|
92
|
+
<span class='order_attachment__text_muted order_attachment__text_sm'>#{order.id}</span>
|
|
93
|
+
</div>
|
|
94
|
+
{$products}
|
|
95
|
+
{$shipto}
|
|
96
|
+
<div>
|
|
97
|
+
<div class='order_attachment__label'>{this.props.t('payment')}</div>
|
|
98
|
+
<div>COD</div>
|
|
99
|
+
</div>
|
|
100
|
+
{$note}
|
|
101
|
+
{$total}
|
|
102
|
+
</div>
|
|
103
|
+
)
|
|
104
|
+
})
|
|
105
|
+
return $orders
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -16,6 +16,9 @@ export default class ProductAttachments extends Com {
|
|
|
16
16
|
products = products.filter((product) => product.product && product.product.name)
|
|
17
17
|
|
|
18
18
|
if (products.length === 0) return null
|
|
19
|
+
|
|
20
|
+
let acc = this.props.store.matchAccount()
|
|
21
|
+
|
|
19
22
|
let $products = sb.map(products, (att, index) => {
|
|
20
23
|
let product = att.product
|
|
21
24
|
|
|
@@ -32,23 +35,26 @@ export default class ProductAttachments extends Com {
|
|
|
32
35
|
|
|
33
36
|
let $title = (
|
|
34
37
|
<a href={url} class='product_attachment__title' target='_blank'>
|
|
35
|
-
{
|
|
38
|
+
{product.name}
|
|
36
39
|
</a>
|
|
37
40
|
)
|
|
38
41
|
let $subtitle = null
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
let desc = product.description || product.long_description
|
|
43
|
+
if (desc) $subtitle = <div class='product_attachment__subtitle'>{desc}</div>
|
|
41
44
|
|
|
42
45
|
let $price = null
|
|
43
|
-
if (product.
|
|
44
|
-
$price =
|
|
46
|
+
if (product.price) {
|
|
47
|
+
$price = (
|
|
48
|
+
<div class='product_attachment__price'>
|
|
49
|
+
{product.currency || sb.get(acc, 'currency', '')} {sb.formatCurrency(product.price)}
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
45
52
|
}
|
|
46
|
-
|
|
47
53
|
return (
|
|
48
54
|
<div class={'product_attachment product_attachment__' + byType}>
|
|
49
55
|
<div>
|
|
50
|
-
<a href={this.props.store.replaceFileUrl(product.
|
|
51
|
-
<img class='product_attachment__img' src={this.props.store.replaceFileUrl(product.
|
|
56
|
+
<a href={this.props.store.replaceFileUrl(product.image)} target='_blank'>
|
|
57
|
+
<img class='product_attachment__img' src={this.props.store.replaceFileUrl(product.image)} />
|
|
52
58
|
</a>
|
|
53
59
|
</div>
|
|
54
60
|
{$title}
|