@subiz/widget-v4 4.1.54 → 4.1.56
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/cloudflare_worker.js +1 -0
- package/compiled_src/call/call.js +2 -2
- package/compiled_src/chatbox/DropdownSelect.js +2 -2
- package/compiled_src/chatbox/ImageAttachments.js +2 -2
- package/compiled_src/chatbox/MessageInput.js +2 -2
- package/compiled_src/chatbox/Order.js +2 -2
- package/compiled_src/chatbox/Rating.js +2 -2
- package/compiled_src/chatbox/Widget.js +2 -2
- package/compiled_src/contact/contact.js +2 -2
- package/compiled_src/lib.js +2 -2
- package/compiled_src/notif/notif.js +2 -2
- package/compiled_src/order/address_picker.js +2 -2
- package/compiled_src/order/order.js +2 -2
- package/compiled_src/popup/countdown.js +2 -2
- package/compiled_src/popup/popup.js +2 -2
- package/compiled_src/store/api.js +2 -2
- package/compiled_src/store/api_fake.js +2 -2
- package/compiled_src/store/store.js +2 -2
- package/compiled_src/util/common.js +0 -180
- package/dist/178.js +1 -1
- package/dist/18c7c220d13.178.js +1 -0
- package/dist/18c7c220d13.213.js +1 -0
- package/dist/18c7c220d13.335.js +1 -0
- package/dist/{18a02a9c54e.362.js → 18c7c220d13.362.js} +1 -1
- package/dist/18c7c220d13.605.js +1 -0
- package/dist/{18a02a9c54e.782.js → 18c7c220d13.782.js} +1 -1
- package/dist/18c7c220d13.841.js +1 -0
- package/dist/18c7c220d13.app.js +1 -0
- package/dist/{18a02a9c54e.index.html → 18c7c220d13.index.html} +4 -4
- package/dist/{18a02a9c54e.library.html → 18c7c220d13.library.html} +4 -4
- package/dist/18c7c220d13.library.js +1 -0
- package/dist/{18a02a9c54e.preview.html → 18c7c220d13.preview.html} +1 -1
- package/dist/18c7c220d13.preview.js +1 -0
- package/dist/18c7c220d13.screenshoot.js +1 -0
- package/dist/18c7c220d13.webview.js +1 -0
- package/dist/213.js +122 -106
- package/dist/335.js +27 -27
- package/dist/362.js +1 -1
- package/dist/605.js +52 -52
- package/dist/782.js +1 -1
- package/dist/{132.js → 841.js} +653 -644
- package/dist/HASH +1 -1
- package/dist/malicious-app.js +9 -3
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +483 -438
- package/malicious-app.js +1 -0
- package/package.json +7 -7
- package/src/util/common.js +180 -180
- package/dist/18a02a9c54e.132.js +0 -1
- package/dist/18a02a9c54e.178.js +0 -1
- package/dist/18a02a9c54e.213.js +0 -1
- package/dist/18a02a9c54e.335.js +0 -1
- package/dist/18a02a9c54e.441.js +0 -1
- package/dist/18a02a9c54e.605.js +0 -1
- package/dist/18a02a9c54e.app.js +0 -1
- package/dist/18a02a9c54e.library.js +0 -1
- package/dist/18a02a9c54e.preview.js +0 -1
- package/dist/18a02a9c54e.screenshoot.js +0 -1
- package/dist/18a02a9c54e.webview.js +0 -1
- package/dist/441.js +0 -2855
- /package/dist/{18a02a9c54e.678.js → 18c7c220d13.678.js} +0 -0
package/dist/{132.js → 841.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(self["webpackChunk_subiz_widget_v4"] = self["webpackChunk_subiz_widget_v4"] || []).push([[
|
|
1
|
+
(self["webpackChunk_subiz_widget_v4"] = self["webpackChunk_subiz_widget_v4"] || []).push([[841],{
|
|
2
2
|
|
|
3
|
-
/***/
|
|
3
|
+
/***/ 8841:
|
|
4
4
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
@@ -25,7 +25,7 @@ var preact_module = __webpack_require__(6400);
|
|
|
25
25
|
class Emoji extends common/* Com */.up {
|
|
26
26
|
render() {
|
|
27
27
|
var emojiCode = this.props.emojiCode;
|
|
28
|
-
if (util/* default
|
|
28
|
+
if (util/* default */.Z.size(emojiCode) < 3) return null;
|
|
29
29
|
var emojiText = emojiCode.replace(/:/g, '');
|
|
30
30
|
return (0,preact_module.h)("i", {
|
|
31
31
|
"data-tooltip": emojiCode,
|
|
@@ -51,11 +51,11 @@ class ChatButton extends common/* Com */.up {
|
|
|
51
51
|
this.loadGreeting();
|
|
52
52
|
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
53
53
|
this.props.store.onConvoEvent(this, ev => {
|
|
54
|
-
if (util/* default
|
|
55
|
-
let bytype = util/* default
|
|
54
|
+
if (util/* default */.Z.get(ev, 'type') !== 'message_sent') return;
|
|
55
|
+
let bytype = util/* default */.Z.get(ev, 'by.type');
|
|
56
56
|
if (bytype !== 'system' && bytype !== 'agent') return;
|
|
57
57
|
let isquickreplies = false;
|
|
58
|
-
util/* default
|
|
58
|
+
util/* default */.Z.map(util/* default */.Z.get(ev, 'data.message.attachments', []), att => {
|
|
59
59
|
if (!att) return;
|
|
60
60
|
if (att.type === 'quick_replies') {
|
|
61
61
|
isquickreplies = true;
|
|
@@ -69,30 +69,30 @@ class ChatButton extends common/* Com */.up {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
fixMissingSetting(chatbox) {
|
|
72
|
-
chatbox = util/* default
|
|
73
|
-
if (util/* default
|
|
72
|
+
chatbox = util/* default */.Z.cloneDeep(chatbox);
|
|
73
|
+
if (util/* default */.Z.get(chatbox, 'desktop_button.background_image_url')) {
|
|
74
74
|
chatbox.desktop_button.background_image_url = this.props.store.replaceFileUrl(chatbox.desktop_button.background_image_url);
|
|
75
75
|
}
|
|
76
|
-
if (util/* default
|
|
76
|
+
if (util/* default */.Z.get(chatbox, 'desktop_button.background_mask_url')) {
|
|
77
77
|
chatbox.desktop_button.background_mask_url = this.props.store.replaceFileUrl(chatbox.desktop_button.background_mask_url);
|
|
78
78
|
}
|
|
79
|
-
if (util/* default
|
|
79
|
+
if (util/* default */.Z.get(chatbox, 'mobile_button.background_image_url')) {
|
|
80
80
|
chatbox.mobile_button.background_image_url = this.props.store.replaceFileUrl(chatbox.mobile_button.background_image_url);
|
|
81
81
|
}
|
|
82
|
-
if (util/* default
|
|
82
|
+
if (util/* default */.Z.get(chatbox, 'mobile_button.background_mask_url')) {
|
|
83
83
|
chatbox.mobile_button.background_mask_url = this.props.store.replaceFileUrl(chatbox.mobile_button.background_mask_url);
|
|
84
84
|
}
|
|
85
85
|
return chatbox;
|
|
86
86
|
}
|
|
87
87
|
render() {
|
|
88
88
|
let accountSetting = this.props.plugin.chatbox;
|
|
89
|
-
let position = util/* default
|
|
89
|
+
let position = util/* default */.Z.get(accountSetting, 'desktop_button.position') || 'right';
|
|
90
90
|
if (this.props.store.isMobile()) {
|
|
91
|
-
position = util/* default
|
|
92
|
-
let hiddenButtonMobile = util/* default
|
|
91
|
+
position = util/* default */.Z.get(accountSetting, 'mobile_button.position') || position;
|
|
92
|
+
let hiddenButtonMobile = util/* default */.Z.get(accountSetting, 'mobile_button.hidden');
|
|
93
93
|
if (hiddenButtonMobile) return null;
|
|
94
94
|
}
|
|
95
|
-
let hiddenButtonDesktop = util/* default
|
|
95
|
+
let hiddenButtonDesktop = util/* default */.Z.get(accountSetting, 'desktop_button.hidden');
|
|
96
96
|
if (hiddenButtonDesktop) return null;
|
|
97
97
|
let cls = 'widget-layout widget-layout--' + position;
|
|
98
98
|
let opacity = this.state.opacity;
|
|
@@ -111,11 +111,11 @@ class ChatButton extends common/* Com */.up {
|
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
ShowGreeting() {
|
|
114
|
-
let greeting = util/* default
|
|
114
|
+
let greeting = util/* default */.Z.get(this.props.plugin, 'chatbox.greeting', {});
|
|
115
115
|
let agentM = this.props.store.matchAgent('*');
|
|
116
116
|
let byid = greeting.agent_id;
|
|
117
117
|
if (!byid) byid = randomAgent(agentM).id;
|
|
118
|
-
let text = this.props.t.i18n(util/* default
|
|
118
|
+
let text = this.props.t.i18n(util/* default */.Z.get(greeting, 'greeting', {})) || greeting.message;
|
|
119
119
|
this.setState({
|
|
120
120
|
previewEvent: {
|
|
121
121
|
by: {
|
|
@@ -139,9 +139,9 @@ class ChatButton extends common/* Com */.up {
|
|
|
139
139
|
}
|
|
140
140
|
loadGreeting() {
|
|
141
141
|
let accountSetting = this.props.plugin.chatbox;
|
|
142
|
-
if (new util/* default
|
|
143
|
-
let greeting = util/* default
|
|
144
|
-
let text = this.props.t.i18n(util/* default
|
|
142
|
+
if (new util/* default */.Z.Date().getTime() - this.props.store.matchClosePreviewAt() < Ms30Mins) return;
|
|
143
|
+
let greeting = util/* default */.Z.get(accountSetting, 'greeting', {});
|
|
144
|
+
let text = this.props.t.i18n(util/* default */.Z.get(greeting, 'greeting', {})) || greeting.message;
|
|
145
145
|
if (!text || !greeting.enabled) {
|
|
146
146
|
this.setState({
|
|
147
147
|
previewEvent: {}
|
|
@@ -152,8 +152,8 @@ class ChatButton extends common/* Com */.up {
|
|
|
152
152
|
}
|
|
153
153
|
onClick() {
|
|
154
154
|
let lastview = this.props.store.matchLastview();
|
|
155
|
-
if (util/* default
|
|
156
|
-
if (lastview.view !== 'list' || util/* default
|
|
155
|
+
if (util/* default */.Z.get(lastview, 'view')) {
|
|
156
|
+
if (lastview.view !== 'list' || util/* default */.Z.size(this.props.store.matchConvo('*')) > 0) {
|
|
157
157
|
return this.props.onClick && this.props.onClick(Object.assign({}, lastview.opts, {
|
|
158
158
|
view: lastview.view
|
|
159
159
|
}));
|
|
@@ -162,10 +162,10 @@ class ChatButton extends common/* Com */.up {
|
|
|
162
162
|
return this.onPreviewClick();
|
|
163
163
|
}
|
|
164
164
|
onPreviewClick(e) {
|
|
165
|
-
let cid = util/* default
|
|
165
|
+
let cid = util/* default */.Z.convoOfEv(this.state.previewEvent);
|
|
166
166
|
if (!cid) {
|
|
167
|
-
let convos = util/* default
|
|
168
|
-
let convo = util/* default
|
|
167
|
+
let convos = util/* default */.Z.map(this.props.store.matchConvo('*'));
|
|
168
|
+
let convo = util/* default */.Z.find(convos, convo => !util/* default */.Z.isConvoSeen(convo, this.props.store.matchUser().id));
|
|
169
169
|
if (!convo) convo = convos[0] || {};
|
|
170
170
|
cid = convo.id;
|
|
171
171
|
}
|
|
@@ -185,13 +185,13 @@ class ChatButton extends common/* Com */.up {
|
|
|
185
185
|
renderPreview() {
|
|
186
186
|
let account = this.props.store.matchAccount();
|
|
187
187
|
let accountSetting = this.props.plugin.chatbox;
|
|
188
|
-
let byid = util/* default
|
|
189
|
-
let agent = util/* default
|
|
190
|
-
agent.fullname = agent.fullname || util/* default
|
|
188
|
+
let byid = util/* default */.Z.get(this.state.previewEvent, 'by.display_id', util/* default */.Z.get(this.state.previewEvent, 'by.id'));
|
|
189
|
+
let agent = util/* default */.Z.cloneDeep(this.props.store.matchAgent(byid)) || {};
|
|
190
|
+
agent.fullname = agent.fullname || util/* default */.Z.get(account, 'name') || this.props.t('agent');
|
|
191
191
|
agent.avatar_url = agent.avatar_url || defaultAvatar;
|
|
192
|
-
let position = util/* default
|
|
192
|
+
let position = util/* default */.Z.get(accountSetting, 'desktop_button.position') || 'right';
|
|
193
193
|
if (this.props.store.isMobile()) {
|
|
194
|
-
position = util/* default
|
|
194
|
+
position = util/* default */.Z.get(accountSetting, 'mobile_button.position') || position;
|
|
195
195
|
}
|
|
196
196
|
if (accountSetting && accountSetting.hide_agent_profile) {
|
|
197
197
|
agent = Object.assign({}, account, {
|
|
@@ -202,7 +202,7 @@ class ChatButton extends common/* Com */.up {
|
|
|
202
202
|
let cls = 'widget-preview widget-preview--' + position;
|
|
203
203
|
if (!this.state.displayPreview) cls += ' widget-preview--hidden';
|
|
204
204
|
var tags = this.renderMessagePreview(this.state.previewEvent, this.props.t('sent_you_a_message'));
|
|
205
|
-
if (util/* default
|
|
205
|
+
if (util/* default */.Z.size(tags) === 0) cls += ' widget-preview--hidden';
|
|
206
206
|
return (0,preact_module.h)("div", {
|
|
207
207
|
class: cls
|
|
208
208
|
}, (0,preact_module.h)("div", {
|
|
@@ -245,16 +245,16 @@ class ChatButton extends common/* Com */.up {
|
|
|
245
245
|
renderButton() {
|
|
246
246
|
let accountSetting = this.props.plugin.chatbox;
|
|
247
247
|
accountSetting = this.fixMissingSetting(accountSetting);
|
|
248
|
-
let imgsrc = util/* default
|
|
249
|
-
let background = util/* default
|
|
250
|
-
let position = util/* default
|
|
251
|
-
let imgurl = util/* default
|
|
252
|
-
let maskurl = util/* default
|
|
248
|
+
let imgsrc = util/* default */.Z.get(accountSetting, 'desktop_button.background_image_url') || util/* default */.Z.get(accountSetting, 'desktop_button.background_mask_url') || defaultBubble;
|
|
249
|
+
let background = util/* default */.Z.get(accountSetting, 'background') || DEF_BG;
|
|
250
|
+
let position = util/* default */.Z.get(accountSetting, 'desktop_button.position') || 'right';
|
|
251
|
+
let imgurl = util/* default */.Z.get(accountSetting, 'desktop_button.background_image_url');
|
|
252
|
+
let maskurl = util/* default */.Z.get(accountSetting, 'desktop_button.background_mask_url');
|
|
253
253
|
if (this.props.store.isMobile()) {
|
|
254
|
-
imgsrc = util/* default
|
|
255
|
-
position = util/* default
|
|
256
|
-
let mobileimgurl = util/* default
|
|
257
|
-
let mobilemaskurl = util/* default
|
|
254
|
+
imgsrc = util/* default */.Z.get(accountSetting, 'mobile_button.background_image_url') || util/* default */.Z.get(accountSetting, 'mobile_button.background_mask_url') || imgsrc;
|
|
255
|
+
position = util/* default */.Z.get(accountSetting, 'mobile_button.position') || position;
|
|
256
|
+
let mobileimgurl = util/* default */.Z.get(accountSetting, 'mobile_button.background_image_url');
|
|
257
|
+
let mobilemaskurl = util/* default */.Z.get(accountSetting, 'mobile_button.background_mask_url');
|
|
258
258
|
if (mobileimgurl || mobilemaskurl) {
|
|
259
259
|
imgurl = mobileimgurl;
|
|
260
260
|
maskurl = mobilemaskurl;
|
|
@@ -350,14 +350,14 @@ class ChatButton extends common/* Com */.up {
|
|
|
350
350
|
}
|
|
351
351
|
renderMessagePreview(ev, defmsg) {
|
|
352
352
|
defmsg = defmsg || 'Sent you a message';
|
|
353
|
-
let message = util/* default
|
|
354
|
-
var format = util/* default
|
|
353
|
+
let message = util/* default */.Z.get(ev, 'data.message.text');
|
|
354
|
+
var format = util/* default */.Z.get(ev, 'data.message.format');
|
|
355
355
|
if (format === 'delta') return this.renderDeltaMessagePreview(ev, defmsg);
|
|
356
356
|
if (format && format !== 'plaintext') message = defmsg;
|
|
357
|
-
if (!message && util/* default
|
|
357
|
+
if (!message && util/* default */.Z.size(util/* default */.Z.get(ev, 'data.message.attachments')) > 0) message = defmsg;
|
|
358
358
|
if (!message) return null;
|
|
359
|
-
let byType = util/* default
|
|
360
|
-
var tags = util/* default
|
|
359
|
+
let byType = util/* default */.Z.get(ev, 'by.type');
|
|
360
|
+
var tags = util/* default */.Z.extractText(message).map(tag => {
|
|
361
361
|
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
362
362
|
emojiCode: tag.text,
|
|
363
363
|
byType: byType
|
|
@@ -368,17 +368,17 @@ class ChatButton extends common/* Com */.up {
|
|
|
368
368
|
}
|
|
369
369
|
renderDeltaMessagePreview(ev, defmsg) {
|
|
370
370
|
defmsg = defmsg || 'Sent you a message';
|
|
371
|
-
let message = util/* default
|
|
372
|
-
if (!message && util/* default
|
|
371
|
+
let message = util/* default */.Z.get(ev, 'data.message.quill_delta');
|
|
372
|
+
if (!message && util/* default */.Z.size(util/* default */.Z.get(ev, 'data.message.attachments')) > 0) message = defmsg;
|
|
373
373
|
if (!message) return;
|
|
374
|
-
let quilldeltas = util/* default
|
|
375
|
-
if (!quilldeltas || util/* default
|
|
376
|
-
let $deltas = util/* default
|
|
374
|
+
let quilldeltas = util/* default */.Z.parseJSON(message) || {};
|
|
375
|
+
if (!quilldeltas || util/* default */.Z.size(quilldeltas.ops) === 0) return null;
|
|
376
|
+
let $deltas = util/* default */.Z.map(quilldeltas.ops, delta => {
|
|
377
377
|
let html = '';
|
|
378
378
|
let insert = delta.insert;
|
|
379
379
|
let attributes = delta.attributes;
|
|
380
380
|
if (insert.dynamicField) {
|
|
381
|
-
return util/* default
|
|
381
|
+
return util/* default */.Z.get(insert, 'dynamicField.text', '');
|
|
382
382
|
}
|
|
383
383
|
if (insert.emoji) return (0,preact_module.h)(Emoji, {
|
|
384
384
|
emojiCode: `:${insert.emoji}:`
|
|
@@ -403,8 +403,8 @@ class ChatButton extends common/* Com */.up {
|
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
405
|
function randomAgent(agentM) {
|
|
406
|
-
var agents = util/* default
|
|
407
|
-
return agents[Math.floor(Math.random() * util/* default
|
|
406
|
+
var agents = util/* default */.Z.filter(agentM, ag => ag.type === 'agent');
|
|
407
|
+
return agents[Math.floor(Math.random() * util/* default */.Z.size(agents))] || {};
|
|
408
408
|
}
|
|
409
409
|
const Ms30Mins = 30 * 60 * 1000;
|
|
410
410
|
const DEF_BG_URL = 'https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5';
|
|
@@ -420,20 +420,20 @@ class PoweredBy extends common/* Com */.up {
|
|
|
420
420
|
render() {
|
|
421
421
|
if (this.props.store.isMobile()) return null;
|
|
422
422
|
let user = this.props.store.matchUser() || {};
|
|
423
|
-
var link = `https://subiz.com.vn/?utm_source
|
|
423
|
+
var link = `https://subiz.com.vn/?utm_source=${window.location.host || `id-${user.account_id}`}&utm_medium=widget&utm_campaign=widget_referral`;
|
|
424
424
|
return (0,preact_module.h)("div", {
|
|
425
425
|
class: "poweredby"
|
|
426
426
|
}, (0,preact_module.h)("a", {
|
|
427
427
|
href: link,
|
|
428
428
|
class: "poweredby--text",
|
|
429
429
|
target: "_blank",
|
|
430
|
-
|
|
430
|
+
title: "Subiz"
|
|
431
431
|
}, (0,preact_module.h)("img", {
|
|
432
432
|
width: "14",
|
|
433
433
|
height: "10",
|
|
434
434
|
class: "poweredby--subiz-logo",
|
|
435
435
|
src: logo,
|
|
436
|
-
alt: "power by"
|
|
436
|
+
alt: "power by subiz"
|
|
437
437
|
}), " Subiz"));
|
|
438
438
|
}
|
|
439
439
|
}
|
|
@@ -466,17 +466,17 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
466
466
|
})));
|
|
467
467
|
}
|
|
468
468
|
let agentM = this.props.store.matchAgent('*');
|
|
469
|
-
var agents = util/* default
|
|
470
|
-
if (this.props.agent_ids === undefined || util/* default
|
|
471
|
-
var agids = util/* default
|
|
472
|
-
agids = util/* default
|
|
469
|
+
var agents = util/* default */.Z.map(this.props.agent_ids, id => agentM[id]);
|
|
470
|
+
if (this.props.agent_ids === undefined || util/* default */.Z.size(this.props.agent_ids) === 0) {
|
|
471
|
+
var agids = util/* default */.Z.get(accountSetting, 'header.agent_ids', []);
|
|
472
|
+
agids = util/* default */.Z.filter(agids, id => !!agentM[id]);
|
|
473
473
|
if (agids.length !== 0) {
|
|
474
|
-
agents = util/* default
|
|
474
|
+
agents = util/* default */.Z.map(agids, id => agentM[id]);
|
|
475
475
|
} else {
|
|
476
|
-
agents = util/* default
|
|
476
|
+
agents = util/* default */.Z.filter(agentM, agent => agent.type === 'agent');
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
|
-
agents = util/* default
|
|
479
|
+
agents = util/* default */.Z.filter(agents, ag => !!ag);
|
|
480
480
|
if (agents.length === 0) {
|
|
481
481
|
return (0,preact_module.h)("div", {
|
|
482
482
|
class: `group-avatar group-avatar--${mode}`
|
|
@@ -590,7 +590,7 @@ class Header extends common/* Com */.up {
|
|
|
590
590
|
let renderSocial = false;
|
|
591
591
|
let renderTeam = false;
|
|
592
592
|
let accSetting = this.props.plugin.chatbox || {};
|
|
593
|
-
let layout = util/* default
|
|
593
|
+
let layout = util/* default */.Z.get(accSetting, 'header.layout');
|
|
594
594
|
let renderCollapsed = this.props.view !== 'list' && headerMode === 'collapsed';
|
|
595
595
|
let renderClassic = !renderCollapsed && layout === 'classic';
|
|
596
596
|
if (renderCollapsed || layout == 'classic') {
|
|
@@ -608,9 +608,9 @@ class Header extends common/* Com */.up {
|
|
|
608
608
|
let accSetting = this.props.plugin.chatbox || {};
|
|
609
609
|
let acc = this.props.store.matchAccount() || {};
|
|
610
610
|
let state = acc.is_online ? this.props.t('agent_online') : this.props.t('agent_offline');
|
|
611
|
-
let tagline = util/* default
|
|
611
|
+
let tagline = util/* default */.Z.get(accSetting, `tagline`, {});
|
|
612
612
|
let desc = this.props.t.i18n(tagline) || accSetting.introduction || state;
|
|
613
|
-
let agentIdsJoined = util/* default
|
|
613
|
+
let agentIdsJoined = util/* default */.Z.map(this.getAgentJoined(this.props.cid), agent => agent.id);
|
|
614
614
|
let cls = 'widget-header--inner widget-header--inner--collapsed';
|
|
615
615
|
if (!show) cls += ' widget-header--inner--hidden';
|
|
616
616
|
let $back = null;
|
|
@@ -636,8 +636,8 @@ class Header extends common/* Com */.up {
|
|
|
636
636
|
renderSocial(show) {
|
|
637
637
|
let accSetting = this.props.plugin.chatbox || {};
|
|
638
638
|
let acc = this.props.store.matchAccount() || {};
|
|
639
|
-
let links = util/* default
|
|
640
|
-
let $links = util/* default
|
|
639
|
+
let links = util/* default */.Z.get(accSetting, 'header.links') || [];
|
|
640
|
+
let $links = util/* default */.Z.map(links, link => {
|
|
641
641
|
if (!link.url || !link.type || link.type === 'subiz') return null;
|
|
642
642
|
if (link.type === 'email') {
|
|
643
643
|
return (0,preact_module.h)("div", null, (0,preact_module.h)("a", {
|
|
@@ -650,17 +650,16 @@ class Header extends common/* Com */.up {
|
|
|
650
650
|
return (0,preact_module.h)("div", null, (0,preact_module.h)("a", {
|
|
651
651
|
href: link.url,
|
|
652
652
|
target: "_blank",
|
|
653
|
-
title: link.url
|
|
654
|
-
rel: "noreferrer"
|
|
653
|
+
title: link.url
|
|
655
654
|
}, (0,preact_module.h)("i", {
|
|
656
655
|
class: `social__links-logo social__links-logo--${link.type}`
|
|
657
656
|
})));
|
|
658
657
|
});
|
|
659
658
|
const DEFTEAMINTO = `Chúng tôi sẵn sàng trợ giúp :wave:.
|
|
660
659
|
Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi của bạn`;
|
|
661
|
-
let tagline = util/* default
|
|
660
|
+
let tagline = util/* default */.Z.get(accSetting, `tagline`, {});
|
|
662
661
|
var teamintro = this.props.t.i18n(tagline) || accSetting.introduction || this.props.t('team_intro') || DEFTEAMINTO;
|
|
663
|
-
var tags = util/* default
|
|
662
|
+
var tags = util/* default */.Z.extractText(teamintro).map(tag => {
|
|
664
663
|
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
665
664
|
emojiCode: tag.text
|
|
666
665
|
});
|
|
@@ -681,7 +680,7 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
|
|
|
681
680
|
}, (0,preact_module.h)("img", {
|
|
682
681
|
alt: "logo",
|
|
683
682
|
class: "social__account_logo",
|
|
684
|
-
src: this.props.store.replaceFileUrl(util/* default
|
|
683
|
+
src: this.props.store.replaceFileUrl(util/* default */.Z.get(acc, 'logo_url'))
|
|
685
684
|
}), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
686
685
|
class: "social__introduction"
|
|
687
686
|
}, tags), (0,preact_module.h)("div", {
|
|
@@ -692,9 +691,9 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
|
|
|
692
691
|
let accSetting = this.props.plugin.chatbox || {};
|
|
693
692
|
const DEFTEAMINTO = `Chúng tôi sẵn sàng trợ giúp :wave:.
|
|
694
693
|
Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi của bạn`;
|
|
695
|
-
let tagline = util/* default
|
|
694
|
+
let tagline = util/* default */.Z.get(accSetting, `tagline`, {});
|
|
696
695
|
var teamintro = this.props.t.i18n(tagline) || accSetting.introduction || this.props.t('team_intro') || DEFTEAMINTO;
|
|
697
|
-
var tags = util/* default
|
|
696
|
+
var tags = util/* default */.Z.extractText(teamintro).map(tag => {
|
|
698
697
|
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
699
698
|
emojiCode: tag.text
|
|
700
699
|
});
|
|
@@ -728,19 +727,19 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
|
|
|
728
727
|
let accSetting = this.props.plugin.chatbox || {};
|
|
729
728
|
let acc = this.props.store.matchAccount() || {};
|
|
730
729
|
let agentsJoined = this.getAgentJoined(this.props.cid);
|
|
731
|
-
let caption = util/* default
|
|
730
|
+
let caption = util/* default */.Z.get(this.props.plugin, 'chatbox.caption', {});
|
|
732
731
|
let title = this.props.t.i18n(caption) || accSetting.title;
|
|
733
732
|
return getJoinedNameMember(agentsJoined) || title || acc.name || this.props.t('widget_title');
|
|
734
733
|
}
|
|
735
734
|
renderBackButton() {
|
|
736
735
|
let allconvos = this.props.store.matchConvo('*');
|
|
737
|
-
if (util/* default
|
|
736
|
+
if (util/* default */.Z.size(allconvos) === 0) return null;
|
|
738
737
|
var $unreadcount = null;
|
|
739
738
|
let user = this.props.store.matchUser();
|
|
740
739
|
let unreadcount = 0;
|
|
741
|
-
util/* default
|
|
740
|
+
util/* default */.Z.map(allconvos, convo => {
|
|
742
741
|
if (convo.id == this.props.cid) return;
|
|
743
|
-
if (!util/* default
|
|
742
|
+
if (!util/* default */.Z.isConvoSeen(convo, user.id)) unreadcount++;
|
|
744
743
|
});
|
|
745
744
|
if (unreadcount !== 0) {
|
|
746
745
|
$unreadcount = (0,preact_module.h)("span", {
|
|
@@ -779,19 +778,19 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
|
|
|
779
778
|
}
|
|
780
779
|
getAgentJoined(cid) {
|
|
781
780
|
var convo = this.props.store.matchConvo(cid) || {};
|
|
782
|
-
let joined = util/* default
|
|
781
|
+
let joined = util/* default */.Z.filter(convo.members, mem => mem.type === 'agent' && mem.membership === 'active');
|
|
783
782
|
return joined;
|
|
784
783
|
}
|
|
785
784
|
}
|
|
786
785
|
let getJoinedNameMember = agents => {
|
|
787
|
-
agents = util/* default
|
|
786
|
+
agents = util/* default */.Z.filter(agents, agent => util/* default */.Z.trim(agent.fullname));
|
|
788
787
|
if (!agents.length) return null;
|
|
789
|
-
return util/* default
|
|
788
|
+
return util/* default */.Z.map(agents, agent => agent.fullname).join(', ');
|
|
790
789
|
};
|
|
791
790
|
;// CONCATENATED MODULE: ./src/chatbox/MessageInput.js
|
|
792
791
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
793
|
-
function _toPropertyKey(
|
|
794
|
-
function _toPrimitive(
|
|
792
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
793
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
795
794
|
|
|
796
795
|
|
|
797
796
|
|
|
@@ -799,22 +798,22 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
799
798
|
class MessageInput extends common/* Com */.up {
|
|
800
799
|
constructor(props) {
|
|
801
800
|
super(props);
|
|
802
|
-
_defineProperty(this, "onEnter", util/* default
|
|
801
|
+
_defineProperty(this, "onEnter", util/* default */.Z.throttle(function () {
|
|
803
802
|
this.submitMessage();
|
|
804
803
|
}, 50));
|
|
805
804
|
this.refFileInput = (0,preact_module/* createRef */.Vf)();
|
|
806
805
|
this.refMessageInput = (0,preact_module/* createRef */.Vf)();
|
|
807
806
|
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
808
807
|
this.props.store.onConvoEvent(this, ev => {
|
|
809
|
-
var evcid = util/* default
|
|
808
|
+
var evcid = util/* default */.Z.convoOfEv(ev);
|
|
810
809
|
if (evcid !== this.props.cid) return;
|
|
811
810
|
this.forceUpdate();
|
|
812
811
|
});
|
|
813
812
|
this.focus();
|
|
814
|
-
this._forceUpdate = util/* default
|
|
813
|
+
this._forceUpdate = util/* default */.Z.throttle(() => {
|
|
815
814
|
this.forceUpdate();
|
|
816
815
|
}, 500);
|
|
817
|
-
this.resizeInput = util/* default
|
|
816
|
+
this.resizeInput = util/* default */.Z.throttle(function () {
|
|
818
817
|
const input = this.refMessageInput.current;
|
|
819
818
|
input.style.setProperty('height', '1em', 'important');
|
|
820
819
|
const height = Math.min(200, input.scrollHeight);
|
|
@@ -834,7 +833,7 @@ class MessageInput extends common/* Com */.up {
|
|
|
834
833
|
class: "message-input--button message-input--attachment-button",
|
|
835
834
|
onClick: e => this.selectFile(e)
|
|
836
835
|
}));
|
|
837
|
-
var msg = util/* default
|
|
836
|
+
var msg = util/* default */.Z.trim(this.refMessageInput.current && this.refMessageInput.current.value);
|
|
838
837
|
if (msg.length > 0) {
|
|
839
838
|
buttons = (0,preact_module.h)("div", {
|
|
840
839
|
class: "d-flex flex-row align-self-end"
|
|
@@ -873,30 +872,30 @@ class MessageInput extends common/* Com */.up {
|
|
|
873
872
|
}
|
|
874
873
|
hasUnfinishRequiredFormOrLock() {
|
|
875
874
|
let convo = this.props.store.matchConvo(this.props.cid);
|
|
876
|
-
if (util/* default
|
|
875
|
+
if (util/* default */.Z.get(convo, 'state') === 'ended') return false;
|
|
877
876
|
let events = this.props.store.listEvents(this.props.cid);
|
|
878
|
-
events = util/* default
|
|
879
|
-
let attachments = util/* default
|
|
880
|
-
let lock = util/* default
|
|
877
|
+
events = util/* default */.Z.orderBy(events, 'created', 'desc').filter(ev => ev.type === 'message_sent');
|
|
878
|
+
let attachments = util/* default */.Z.get(events[0], 'data.message.attachments', []);
|
|
879
|
+
let lock = util/* default */.Z.find(attachments, att => util/* default */.Z.get(att, 'lock_input'));
|
|
881
880
|
if (lock) return true;
|
|
882
881
|
var last_agent_sent;
|
|
883
882
|
for (let ev of events) {
|
|
884
|
-
if (util/* default
|
|
883
|
+
if (util/* default */.Z.get(ev, 'by.type') === 'user') continue;
|
|
885
884
|
last_agent_sent = ev;
|
|
886
885
|
break;
|
|
887
886
|
}
|
|
888
|
-
attachments = util/* default
|
|
889
|
-
let pendingForms = util/* default
|
|
887
|
+
attachments = util/* default */.Z.get(last_agent_sent, 'data.message.attachments', []);
|
|
888
|
+
let pendingForms = util/* default */.Z.filter(attachments, att => {
|
|
890
889
|
if (!att) return false;
|
|
891
890
|
if (att.type !== 'form' && att.type !== 'ask_info_form') return false;
|
|
892
891
|
var form = att.form;
|
|
893
892
|
if (!form) return false;
|
|
894
|
-
var state = util/* default
|
|
893
|
+
var state = util/* default */.Z.parseJSON(form.state) || {};
|
|
895
894
|
if (!state.require_finished && att.type !== 'ask_info_form') return false;
|
|
896
895
|
if (isSummited(att.form)) return false;
|
|
897
896
|
return true;
|
|
898
897
|
});
|
|
899
|
-
return util/* default
|
|
898
|
+
return util/* default */.Z.size(pendingForms) > 0;
|
|
900
899
|
}
|
|
901
900
|
renderEmojiPopup() {
|
|
902
901
|
if (!this.state.openEmoji) return null;
|
|
@@ -1000,10 +999,10 @@ class MessageInput extends common/* Com */.up {
|
|
|
1000
999
|
focus() {
|
|
1001
1000
|
if (this.props.disabled) return;
|
|
1002
1001
|
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
1003
|
-
util/* default
|
|
1002
|
+
util/* default */.Z.setTimeout(() => {
|
|
1004
1003
|
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
1005
1004
|
});
|
|
1006
|
-
util/* default
|
|
1005
|
+
util/* default */.Z.setTimeout(() => {
|
|
1007
1006
|
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
1008
1007
|
}, 100);
|
|
1009
1008
|
}
|
|
@@ -1053,9 +1052,9 @@ class MessageInput extends common/* Com */.up {
|
|
|
1053
1052
|
$input.value = '';
|
|
1054
1053
|
}
|
|
1055
1054
|
_sendFile(files) {
|
|
1056
|
-
if (util/* default
|
|
1055
|
+
if (util/* default */.Z.size(files) === 0) return;
|
|
1057
1056
|
if (this.props.disabled) return;
|
|
1058
|
-
let attachments = util/* default
|
|
1057
|
+
let attachments = util/* default */.Z.map(files, file => {
|
|
1059
1058
|
return {
|
|
1060
1059
|
type: 'file',
|
|
1061
1060
|
mimetype: file.type,
|
|
@@ -1069,7 +1068,7 @@ class MessageInput extends common/* Com */.up {
|
|
|
1069
1068
|
});
|
|
1070
1069
|
}
|
|
1071
1070
|
async submitMessage(msg) {
|
|
1072
|
-
msg = msg || util/* default
|
|
1071
|
+
msg = msg || util/* default */.Z.trim(this.refMessageInput.current.value) || '';
|
|
1073
1072
|
if (!msg) return;
|
|
1074
1073
|
if (this.props.disabled) return;
|
|
1075
1074
|
this.refMessageInput.current.value = '';
|
|
@@ -1088,7 +1087,7 @@ class MessageInput extends common/* Com */.up {
|
|
|
1088
1087
|
}
|
|
1089
1088
|
pasteImage(event) {
|
|
1090
1089
|
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) return;
|
|
1091
|
-
let now = new util/* default
|
|
1090
|
+
let now = new util/* default */.Z.Date();
|
|
1092
1091
|
let year = now.getFullYear();
|
|
1093
1092
|
let month = now.getMonth() + 1;
|
|
1094
1093
|
let date = now.getDate();
|
|
@@ -1110,24 +1109,124 @@ class MessageInput extends common/* Com */.up {
|
|
|
1110
1109
|
}
|
|
1111
1110
|
}
|
|
1112
1111
|
function isSummited(form) {
|
|
1113
|
-
let fields = util/* default
|
|
1114
|
-
return util/* default
|
|
1112
|
+
let fields = util/* default */.Z.get(form, 'fields') || [];
|
|
1113
|
+
return util/* default */.Z.find(fields, field => !!field.answered);
|
|
1115
1114
|
}
|
|
1116
1115
|
;// CONCATENATED MODULE: ./src/chatbox/ImageAttachments.js
|
|
1116
|
+
function ImageAttachments_defineProperty(obj, key, value) { key = ImageAttachments_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1117
|
+
function ImageAttachments_toPropertyKey(t) { var i = ImageAttachments_toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
1118
|
+
function ImageAttachments_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1117
1119
|
|
|
1118
1120
|
|
|
1119
1121
|
|
|
1120
1122
|
class ImageAttachment extends common/* Com */.up {
|
|
1121
1123
|
constructor(props) {
|
|
1122
1124
|
super(props);
|
|
1125
|
+
ImageAttachments_defineProperty(this, "containerRef", (0,preact_module/* createRef */.Vf)());
|
|
1126
|
+
this.setState({
|
|
1127
|
+
ready: false,
|
|
1128
|
+
errorIndecies: []
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
componentDidMount() {
|
|
1132
|
+
this.setImageFrameDimension();
|
|
1133
|
+
}
|
|
1134
|
+
setImageFrameDimension() {
|
|
1135
|
+
const MAX_HEIGHT = 240;
|
|
1136
|
+
const DEFAULT_MAX_WIDTH = 267;
|
|
1137
|
+
let $container = this.containerRef.current;
|
|
1138
|
+
this.frameWidth = $container ? $container.offsetWidth : DEFAULT_MAX_WIDTH;
|
|
1139
|
+
this.frameHeight = MAX_HEIGHT;
|
|
1140
|
+
this.setState({
|
|
1141
|
+
ready: true
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
onErrorImage(index) {
|
|
1145
|
+
let indecies = this.state.errorIndecies || [];
|
|
1146
|
+
indecies.push(index);
|
|
1147
|
+
indecies = [...indecies];
|
|
1148
|
+
this.setState({
|
|
1149
|
+
errorIndecies: indecies
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
calculateImageDimension(image) {
|
|
1153
|
+
if (!image.width || !image.height) return {
|
|
1154
|
+
width: this.frameWidth,
|
|
1155
|
+
height: this.frameHeight
|
|
1156
|
+
};
|
|
1157
|
+
let ratio = image.width / image.height - this.frameWidth / this.frameHeight;
|
|
1158
|
+
if (ratio >= 0) {
|
|
1159
|
+
let width = this.frameWidth;
|
|
1160
|
+
let height = image.height * this.frameWidth / image.width;
|
|
1161
|
+
height = Math.round(height);
|
|
1162
|
+
return {
|
|
1163
|
+
width,
|
|
1164
|
+
height
|
|
1165
|
+
};
|
|
1166
|
+
} else {
|
|
1167
|
+
let height = this.frameHeight;
|
|
1168
|
+
let width = image.width * this.frameHeight / image.height;
|
|
1169
|
+
width = Math.round(width);
|
|
1170
|
+
return {
|
|
1171
|
+
width,
|
|
1172
|
+
height
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
renderImage(image, index) {
|
|
1177
|
+
if (!this.state.ready) {
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
let byType = util/* default */.Z.get(this.props.ev, 'by.type');
|
|
1181
|
+
if (!image.width || !image.height) {
|
|
1182
|
+
return (0,preact_module.h)("div", {
|
|
1183
|
+
class: `image-attachment image-attachment--${byType}`
|
|
1184
|
+
}, (0,preact_module.h)("a", {
|
|
1185
|
+
href: this.props.store.replaceFileUrl(image.url),
|
|
1186
|
+
target: "_blank"
|
|
1187
|
+
}, (0,preact_module.h)("img", {
|
|
1188
|
+
alt: true,
|
|
1189
|
+
class: "image-attachment__img",
|
|
1190
|
+
src: this.props.store.replaceFileUrl(image.thumbnail_url || image.url),
|
|
1191
|
+
onload: e => this.props.onLoad && this.props.onLoad()
|
|
1192
|
+
})));
|
|
1193
|
+
}
|
|
1194
|
+
let {
|
|
1195
|
+
width,
|
|
1196
|
+
height
|
|
1197
|
+
} = this.calculateImageDimension(image);
|
|
1198
|
+
let url = this.props.store.replaceFileUrl(image.thumbnail_url || image.url);
|
|
1199
|
+
let trueUrl = this.props.store.replaceFileUrl(image.url);
|
|
1200
|
+
if (this.state.errorIndecies.includes(index)) {
|
|
1201
|
+
url = __webpack_require__(9270);
|
|
1202
|
+
trueUrl = url;
|
|
1203
|
+
}
|
|
1204
|
+
return (0,preact_module.h)("div", {
|
|
1205
|
+
class: `image-attachment image-attachment--${byType}`
|
|
1206
|
+
}, (0,preact_module.h)("a", {
|
|
1207
|
+
href: trueUrl,
|
|
1208
|
+
target: "_blank"
|
|
1209
|
+
}, (0,preact_module.h)("img", {
|
|
1210
|
+
alt: true,
|
|
1211
|
+
ref: el => {
|
|
1212
|
+
if (el) {
|
|
1213
|
+
el.style.setProperty('width', `${width}px`, 'important');
|
|
1214
|
+
el.style.setProperty('height', `${height}px`, 'important');
|
|
1215
|
+
}
|
|
1216
|
+
},
|
|
1217
|
+
class: "image-attachment__img",
|
|
1218
|
+
src: url,
|
|
1219
|
+
onload: e => this.props.onLoad && this.props.onLoad(),
|
|
1220
|
+
onerror: e => this.onErrorImage(index)
|
|
1221
|
+
})));
|
|
1123
1222
|
}
|
|
1124
1223
|
render() {
|
|
1125
|
-
var attachments = util/* default
|
|
1224
|
+
var attachments = util/* default */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
1126
1225
|
var images = [];
|
|
1127
|
-
let byType = util/* default
|
|
1128
|
-
util/* default
|
|
1226
|
+
let byType = util/* default */.Z.get(this.props.ev, 'by.type');
|
|
1227
|
+
util/* default */.Z.each(attachments, (att, i) => {
|
|
1129
1228
|
if (!att) return;
|
|
1130
|
-
if (!util/* default
|
|
1229
|
+
if (!util/* default */.Z.includes(att.mimetype, 'image')) return;
|
|
1131
1230
|
if (!att.url) return;
|
|
1132
1231
|
var uri = att.url;
|
|
1133
1232
|
if (!uri.startsWith('https://') && !uri.startsWith('http://') && !uri.startsWith('content://') && !uri.startsWith('data:')) {
|
|
@@ -1136,24 +1235,16 @@ class ImageAttachment extends common/* Com */.up {
|
|
|
1136
1235
|
images.push(att);
|
|
1137
1236
|
});
|
|
1138
1237
|
if (images.length === 0) return null;
|
|
1139
|
-
|
|
1140
|
-
class: `image-attachment image-attachment--${byType}`
|
|
1141
|
-
}, (0,preact_module.h)("a", {
|
|
1142
|
-
href: this.props.store.replaceFileUrl(image.thumbnail_url || image.url),
|
|
1143
|
-
target: "_blank"
|
|
1144
|
-
}, (0,preact_module.h)("img", {
|
|
1145
|
-
alt: true,
|
|
1146
|
-
class: "image-attachment__img",
|
|
1147
|
-
src: this.props.store.replaceFileUrl(image.thumbnail_url || image.url),
|
|
1148
|
-
onload: e => this.props.onLoad && this.props.onLoad()
|
|
1149
|
-
}))));
|
|
1238
|
+
let $images = util/* default */.Z.map(images, (image, index) => this.renderImage(image, index));
|
|
1150
1239
|
if (byType === 'agent') {
|
|
1151
1240
|
return (0,preact_module.h)("div", {
|
|
1152
|
-
class: "message-agent"
|
|
1241
|
+
class: "message-agent",
|
|
1242
|
+
ref: this.containerRef
|
|
1153
1243
|
}, $images);
|
|
1154
1244
|
} else {
|
|
1155
1245
|
return (0,preact_module.h)("div", {
|
|
1156
|
-
class: "message-user"
|
|
1246
|
+
class: "message-user message-user-images-container",
|
|
1247
|
+
ref: this.containerRef
|
|
1157
1248
|
}, $images);
|
|
1158
1249
|
}
|
|
1159
1250
|
}
|
|
@@ -1167,15 +1258,15 @@ class AudioAttachments extends common/* Com */.up {
|
|
|
1167
1258
|
super(props);
|
|
1168
1259
|
}
|
|
1169
1260
|
render() {
|
|
1170
|
-
let byType = util/* default
|
|
1171
|
-
var attachments = util/* default
|
|
1261
|
+
let byType = util/* default */.Z.get(this.props.ev, 'by.type');
|
|
1262
|
+
var attachments = util/* default */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
1172
1263
|
var audios = [];
|
|
1173
|
-
util/* default
|
|
1264
|
+
util/* default */.Z.each(attachments, (att, i) => {
|
|
1174
1265
|
if (!att) return;
|
|
1175
|
-
if (util/* default
|
|
1266
|
+
if (util/* default */.Z.includes(att.mimetype, 'audio')) audios.push(att);
|
|
1176
1267
|
});
|
|
1177
1268
|
if (audios.length === 0) return null;
|
|
1178
|
-
var $audios = util/* default
|
|
1269
|
+
var $audios = util/* default */.Z.map(audios, (audio, index) => {
|
|
1179
1270
|
return (0,preact_module.h)("div", {
|
|
1180
1271
|
key: index,
|
|
1181
1272
|
class: `audio-attachment audio-attachment--${byType}`
|
|
@@ -1198,18 +1289,18 @@ class AudioAttachments extends common/* Com */.up {
|
|
|
1198
1289
|
|
|
1199
1290
|
class FileAttachments extends common/* Com */.up {
|
|
1200
1291
|
render() {
|
|
1201
|
-
var byType = util/* default
|
|
1202
|
-
var attachments = util/* default
|
|
1292
|
+
var byType = util/* default */.Z.get(this.props.ev, 'by.type', 'agent');
|
|
1293
|
+
var attachments = util/* default */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
1203
1294
|
var files = [];
|
|
1204
|
-
util/* default
|
|
1295
|
+
util/* default */.Z.each(attachments, att => {
|
|
1205
1296
|
if (!att) return;
|
|
1206
1297
|
if (!att.url && !att._file) return;
|
|
1207
|
-
if (!util/* default
|
|
1298
|
+
if (!util/* default */.Z.includes(att.mimetype, 'video') && !util/* default */.Z.includes(att.mimetype, 'audio') && !util/* default */.Z.includes(att.mimetype, 'image') && att.type !== 'button' && att.type !== 'quick_replies' && att.type !== 'form' && att.type !== 'form_submit') {
|
|
1208
1299
|
files.push(att);
|
|
1209
1300
|
}
|
|
1210
1301
|
});
|
|
1211
1302
|
if (files.length === 0) return null;
|
|
1212
|
-
var $files = util/* default
|
|
1303
|
+
var $files = util/* default */.Z.map(files, (file, index) => {
|
|
1213
1304
|
return (0,preact_module.h)("div", {
|
|
1214
1305
|
key: index,
|
|
1215
1306
|
class: `file-attachment file-attachment--${byType}`
|
|
@@ -1237,8 +1328,8 @@ class Buttons extends common/* Com */.up {
|
|
|
1237
1328
|
super(props);
|
|
1238
1329
|
}
|
|
1239
1330
|
render() {
|
|
1240
|
-
if (util/* default
|
|
1241
|
-
var $buttons = util/* default
|
|
1331
|
+
if (util/* default */.Z.size(this.props.buttons) === 0) return null;
|
|
1332
|
+
var $buttons = util/* default */.Z.map(this.props.buttons, (button, index) => {
|
|
1242
1333
|
if (button.type === 'call_button') {
|
|
1243
1334
|
return (0,preact_module.h)("a", {
|
|
1244
1335
|
class: "url-button-attachment",
|
|
@@ -1282,13 +1373,13 @@ class ButtonAttachments extends common/* Com */.up {
|
|
|
1282
1373
|
super(props);
|
|
1283
1374
|
}
|
|
1284
1375
|
render() {
|
|
1285
|
-
let byType = util/* default
|
|
1376
|
+
let byType = util/* default */.Z.get(this.props.ev, 'by.type');
|
|
1286
1377
|
if (byType === 'user') return null;
|
|
1287
1378
|
let buttons = [];
|
|
1288
|
-
let attachments = util/* default
|
|
1289
|
-
util/* default
|
|
1290
|
-
if (!att || util/* default
|
|
1291
|
-
util/* default
|
|
1379
|
+
let attachments = util/* default */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
1380
|
+
util/* default */.Z.each(attachments, (att, i) => {
|
|
1381
|
+
if (!att || util/* default */.Z.get(att, 'type') !== 'button') return;
|
|
1382
|
+
util/* default */.Z.each(util/* default */.Z.get(att, 'buttons') || [], btn => buttons.push(btn));
|
|
1292
1383
|
});
|
|
1293
1384
|
return (0,preact_module.h)(Buttons, {
|
|
1294
1385
|
store: this.props.store,
|
|
@@ -1306,21 +1397,21 @@ class QuickReplies extends common/* Com */.up {
|
|
|
1306
1397
|
super(props);
|
|
1307
1398
|
}
|
|
1308
1399
|
render() {
|
|
1309
|
-
if (util/* default
|
|
1400
|
+
if (util/* default */.Z.get(this.props.ev, 'by.type') === 'user') return null;
|
|
1310
1401
|
let quickreplies = [];
|
|
1311
|
-
util/* default
|
|
1402
|
+
util/* default */.Z.map(util/* default */.Z.get(this.props.ev, 'data.message.attachments', []), att => {
|
|
1312
1403
|
if (!att) return;
|
|
1313
1404
|
if (att.type === 'quick_replies') {
|
|
1314
|
-
quickreplies = util/* default
|
|
1405
|
+
quickreplies = util/* default */.Z.get(att, 'quick_replies', []);
|
|
1315
1406
|
}
|
|
1316
1407
|
});
|
|
1317
|
-
quickreplies = util/* default
|
|
1408
|
+
quickreplies = util/* default */.Z.filter(quickreplies, r => r.title);
|
|
1318
1409
|
if (quickreplies.length === 0) return null;
|
|
1319
|
-
let cid = util/* default
|
|
1410
|
+
let cid = util/* default */.Z.convoOfEv(this.props.ev);
|
|
1320
1411
|
let convo = this.props.store.matchConvo(cid);
|
|
1321
|
-
if (util/* default
|
|
1322
|
-
let events = util/* default
|
|
1323
|
-
events = util/* default
|
|
1412
|
+
if (util/* default */.Z.get(convo, 'state') === 'ended') return null;
|
|
1413
|
+
let events = util/* default */.Z.map(this.props.store.listEvents(cid));
|
|
1414
|
+
events = util/* default */.Z.orderBy(events, 'created', 'asc').filter(ev => ev.type === 'message_sent');
|
|
1324
1415
|
let evindex = 0;
|
|
1325
1416
|
for (var i = 0; i < events.length; i++) {
|
|
1326
1417
|
if (events[i].id === this.props.ev.id) {
|
|
@@ -1329,9 +1420,9 @@ class QuickReplies extends common/* Com */.up {
|
|
|
1329
1420
|
}
|
|
1330
1421
|
}
|
|
1331
1422
|
for (var i = evindex + 1; i < events.length; i++) {
|
|
1332
|
-
if (util/* default
|
|
1423
|
+
if (util/* default */.Z.get(events[i], 'by.type') === 'user') return null;
|
|
1333
1424
|
}
|
|
1334
|
-
let $replies = util/* default
|
|
1425
|
+
let $replies = util/* default */.Z.map(quickreplies, r => (0,preact_module.h)("div", {
|
|
1335
1426
|
class: "message_quick_reply",
|
|
1336
1427
|
onClick: e => this.props.onSelect(r)
|
|
1337
1428
|
}, r.title));
|
|
@@ -1353,18 +1444,18 @@ class ListField extends common/* Com */.up {
|
|
|
1353
1444
|
});
|
|
1354
1445
|
}
|
|
1355
1446
|
render() {
|
|
1356
|
-
let fields = util/* default
|
|
1447
|
+
let fields = util/* default */.Z.filter(this.props.items, item => {
|
|
1357
1448
|
let search = this.state.search.toLowerCase();
|
|
1358
1449
|
let name = item || '';
|
|
1359
1450
|
return name.toLowerCase().indexOf(search) > -1;
|
|
1360
1451
|
});
|
|
1361
|
-
let $fields = util/* default
|
|
1452
|
+
let $fields = util/* default */.Z.map(fields, field => {
|
|
1362
1453
|
return (0,preact_module.h)("li", {
|
|
1363
1454
|
class: "custom-select--item-options",
|
|
1364
1455
|
onClick: () => this.add(field)
|
|
1365
1456
|
}, field);
|
|
1366
1457
|
});
|
|
1367
|
-
let $selected = util/* default
|
|
1458
|
+
let $selected = util/* default */.Z.map(this.props.selected, (item, i) => {
|
|
1368
1459
|
return (0,preact_module.h)("div", {
|
|
1369
1460
|
class: "custom-select--selected-item",
|
|
1370
1461
|
onClick: e => this.remove(e, i)
|
|
@@ -1445,16 +1536,16 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1445
1536
|
super(props);
|
|
1446
1537
|
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
1447
1538
|
let user = this.props.store.matchUser();
|
|
1448
|
-
let fields = util/* default
|
|
1449
|
-
let formData = util/* default
|
|
1539
|
+
let fields = util/* default */.Z.get(this.props.form, 'fields') || [];
|
|
1540
|
+
let formData = util/* default */.Z.map(fields, field => {
|
|
1450
1541
|
let is_required = field.is_required || false;
|
|
1451
|
-
var state = util/* default
|
|
1542
|
+
var state = util/* default */.Z.parseJSON(field.state) || {};
|
|
1452
1543
|
if (!is_required) is_required = state.require || false;
|
|
1453
|
-
var userattr = util/* default
|
|
1544
|
+
var userattr = util/* default */.Z.getUserAttr(user, field.name, state.type || 'text');
|
|
1454
1545
|
return {
|
|
1455
1546
|
name: field.name,
|
|
1456
1547
|
items: field.items,
|
|
1457
|
-
value: util/* default
|
|
1548
|
+
value: util/* default */.Z.parseJSON(field.answer) || util/* default */.Z.parseJSON(field.default_answer) || userattr,
|
|
1458
1549
|
is_required,
|
|
1459
1550
|
label: field.title,
|
|
1460
1551
|
type: field.input_type
|
|
@@ -1465,13 +1556,13 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1465
1556
|
});
|
|
1466
1557
|
}
|
|
1467
1558
|
isSummited() {
|
|
1468
|
-
let found = util/* default
|
|
1559
|
+
let found = util/* default */.Z.find(this.state.formData, field => !!field.answered);
|
|
1469
1560
|
if (found) return true;
|
|
1470
|
-
let convo = this.props.store.matchConvo(util/* default
|
|
1561
|
+
let convo = this.props.store.matchConvo(util/* default */.Z.convoOfEv(this.props.ev));
|
|
1471
1562
|
return convo.state === 'ended';
|
|
1472
1563
|
}
|
|
1473
1564
|
render() {
|
|
1474
|
-
if (util/* default
|
|
1565
|
+
if (util/* default */.Z.size(this.state.formData) === 0) return null;
|
|
1475
1566
|
let $fields = this.renderFields();
|
|
1476
1567
|
let $submitbutton = null;
|
|
1477
1568
|
if (!this.isSummited()) {
|
|
@@ -1490,11 +1581,11 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1490
1581
|
}
|
|
1491
1582
|
focus() {
|
|
1492
1583
|
if (this.props.store.isPreview) return;
|
|
1493
|
-
if (util/* default
|
|
1584
|
+
if (util/* default */.Z.size(this.state.formData) === 0) return;
|
|
1494
1585
|
let $field;
|
|
1495
1586
|
if (this.isFormFilled()) {
|
|
1496
1587
|
var keys = Object.keys(this.state.formData);
|
|
1497
|
-
var lastkey = keys[util/* default
|
|
1588
|
+
var lastkey = keys[util/* default */.Z.size(keys) - 1];
|
|
1498
1589
|
var lastfield = this.state.formData[lastkey];
|
|
1499
1590
|
$field = this['field.' + encode(lastfield.name)];
|
|
1500
1591
|
} else {
|
|
@@ -1505,20 +1596,20 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1505
1596
|
if ($field) $field.focus();
|
|
1506
1597
|
}
|
|
1507
1598
|
firstUnfilledField() {
|
|
1508
|
-
return util/* default
|
|
1599
|
+
return util/* default */.Z.find(this.state.formData, field => field.value == null || field.value === '');
|
|
1509
1600
|
}
|
|
1510
1601
|
isFormFilled() {
|
|
1511
|
-
return !util/* default
|
|
1602
|
+
return !util/* default */.Z.find(this.state.formData, field => field.value == null || field.value === '');
|
|
1512
1603
|
}
|
|
1513
1604
|
onInputChange(index, val) {
|
|
1514
|
-
let formData = util/* default
|
|
1605
|
+
let formData = util/* default */.Z.cloneDeep(this.state.formData);
|
|
1515
1606
|
formData[index].value = val;
|
|
1516
1607
|
this.setState({
|
|
1517
1608
|
formData
|
|
1518
1609
|
});
|
|
1519
1610
|
}
|
|
1520
1611
|
onListAddItem(index, val) {
|
|
1521
|
-
let formData = util/* default
|
|
1612
|
+
let formData = util/* default */.Z.cloneDeep(this.state.formData);
|
|
1522
1613
|
let field = formData[index];
|
|
1523
1614
|
field.value = field.value || [];
|
|
1524
1615
|
field.value.push(val);
|
|
@@ -1527,7 +1618,7 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1527
1618
|
});
|
|
1528
1619
|
}
|
|
1529
1620
|
onListRemoveItem(index, vindex) {
|
|
1530
|
-
let formData = util/* default
|
|
1621
|
+
let formData = util/* default */.Z.cloneDeep(this.state.formData);
|
|
1531
1622
|
let field = formData[index];
|
|
1532
1623
|
field.value = field.value || [];
|
|
1533
1624
|
field.value.splice(vindex, 1);
|
|
@@ -1536,9 +1627,9 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1536
1627
|
});
|
|
1537
1628
|
}
|
|
1538
1629
|
renderFields() {
|
|
1539
|
-
if (util/* default
|
|
1630
|
+
if (util/* default */.Z.size(this.state.formData) === 0) return null;
|
|
1540
1631
|
let $fields = null;
|
|
1541
|
-
$fields = util/* default
|
|
1632
|
+
$fields = util/* default */.Z.map(this.state.formData, (field, index) => {
|
|
1542
1633
|
let $field = null;
|
|
1543
1634
|
var errclass = field.error ? 'input--error' : '';
|
|
1544
1635
|
if (field.type === 'text') {
|
|
@@ -1614,7 +1705,7 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1614
1705
|
}, (0,preact_module.h)("div", null)));
|
|
1615
1706
|
} else if (field.type === 'list') {
|
|
1616
1707
|
let selected = field.value || [];
|
|
1617
|
-
let items = util/* default
|
|
1708
|
+
let items = util/* default */.Z.filter(util/* default */.Z.get(field, 'items', []), item => !selected.includes(item));
|
|
1618
1709
|
$field = (0,preact_module.h)(ListField, {
|
|
1619
1710
|
selected: selected,
|
|
1620
1711
|
items: items,
|
|
@@ -1652,15 +1743,15 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1652
1743
|
}
|
|
1653
1744
|
async submit() {
|
|
1654
1745
|
var hasError = false;
|
|
1655
|
-
util/* default
|
|
1656
|
-
if (field.is_required && (field.value === undefined || field.value === '' || util/* default
|
|
1746
|
+
util/* default */.Z.map(this.state.formData, field => {
|
|
1747
|
+
if (field.is_required && (field.value === undefined || field.value === '' || util/* default */.Z.size(field.value) === 0 && Array.isArray(field.value))) {
|
|
1657
1748
|
field.error = this.props.t('error_empty');
|
|
1658
1749
|
hasError = true;
|
|
1659
1750
|
} else {
|
|
1660
1751
|
field.error = '';
|
|
1661
1752
|
}
|
|
1662
1753
|
if (field.name === 'emails' && field.value) {
|
|
1663
|
-
if (!util/* default
|
|
1754
|
+
if (!util/* default */.Z.isEmail(field.value)) {
|
|
1664
1755
|
field.error = this.props.t('error_email_invalid');
|
|
1665
1756
|
hasError = true;
|
|
1666
1757
|
}
|
|
@@ -1669,32 +1760,32 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1669
1760
|
this.forceUpdate();
|
|
1670
1761
|
if (hasError) return;
|
|
1671
1762
|
let user = {};
|
|
1672
|
-
let formData = util/* default
|
|
1673
|
-
util/* default
|
|
1763
|
+
let formData = util/* default */.Z.cloneDeep(this.state.formData);
|
|
1764
|
+
util/* default */.Z.map(formData, field => {
|
|
1674
1765
|
var attr = {
|
|
1675
1766
|
key: field.name
|
|
1676
1767
|
};
|
|
1677
|
-
field.answered = new util/* default
|
|
1768
|
+
field.answered = new util/* default */.Z.Date().getTime();
|
|
1678
1769
|
if (field.type === 'number') {
|
|
1679
1770
|
attr.number = parseInt(field.value);
|
|
1680
|
-
field.answer = util/* default
|
|
1771
|
+
field.answer = util/* default */.Z.stringify(attr.number);
|
|
1681
1772
|
}
|
|
1682
1773
|
if (field.type === 'datetime') {
|
|
1683
|
-
attr.datetime = new util/* default
|
|
1684
|
-
field.answer = util/* default
|
|
1774
|
+
attr.datetime = new util/* default */.Z.Date(field.value).toISOString();
|
|
1775
|
+
field.answer = util/* default */.Z.stringify(attr.datetime);
|
|
1685
1776
|
}
|
|
1686
1777
|
if (field.type === 'list') {
|
|
1687
1778
|
attr.list = field.value;
|
|
1688
|
-
field.answer = util/* default
|
|
1779
|
+
field.answer = util/* default */.Z.stringify(attr.list);
|
|
1689
1780
|
}
|
|
1690
1781
|
if (field.type === 'text' || field.type === 'boolean') {
|
|
1691
1782
|
attr[field.type] = field.value;
|
|
1692
|
-
field.answer = util/* default
|
|
1783
|
+
field.answer = util/* default */.Z.stringify(field.value);
|
|
1693
1784
|
}
|
|
1694
|
-
util/* default
|
|
1785
|
+
util/* default */.Z.setUserAttr(user, attr);
|
|
1695
1786
|
});
|
|
1696
|
-
util/* default
|
|
1697
|
-
let ffield = util/* default
|
|
1787
|
+
util/* default */.Z.map(formData, field => {
|
|
1788
|
+
let ffield = util/* default */.Z.find(this.props.form.fields, ffield => ffield.name === field.name);
|
|
1698
1789
|
if (!ffield) return;
|
|
1699
1790
|
ffield.answered = field.answered;
|
|
1700
1791
|
});
|
|
@@ -1707,12 +1798,12 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1707
1798
|
type: 'form_submit',
|
|
1708
1799
|
form_submit: {
|
|
1709
1800
|
state: '{"user_id":"' + this.props.store.matchUser().id + '"}',
|
|
1710
|
-
form_message_id: util/* default
|
|
1801
|
+
form_message_id: util/* default */.Z.get(this.props.ev, 'id'),
|
|
1711
1802
|
fields: formData
|
|
1712
1803
|
}
|
|
1713
1804
|
}]
|
|
1714
1805
|
};
|
|
1715
|
-
let cid = util/* default
|
|
1806
|
+
let cid = util/* default */.Z.convoOfEv(this.props.ev);
|
|
1716
1807
|
this.props.store.sendConvoEvent(cid, 'message_sent', {
|
|
1717
1808
|
message
|
|
1718
1809
|
});
|
|
@@ -1732,17 +1823,17 @@ class FormAttachments extends common/* Com */.up {
|
|
|
1732
1823
|
super(props);
|
|
1733
1824
|
}
|
|
1734
1825
|
render() {
|
|
1735
|
-
let byType = util/* default
|
|
1826
|
+
let byType = util/* default */.Z.get(this.props.ev, 'by.type');
|
|
1736
1827
|
if (byType === 'user') return;
|
|
1737
1828
|
let forms = [];
|
|
1738
|
-
let attachments = util/* default
|
|
1739
|
-
util/* default
|
|
1829
|
+
let attachments = util/* default */.Z.get(this.props.ev, 'data.message.attachments') || [];
|
|
1830
|
+
util/* default */.Z.each(attachments, att => {
|
|
1740
1831
|
if (!att) return;
|
|
1741
1832
|
if (att.type !== 'form' && att.type !== 'ask_info_form') return;
|
|
1742
1833
|
att.form._type = att.type;
|
|
1743
1834
|
forms.push(att.form);
|
|
1744
1835
|
});
|
|
1745
|
-
let $forms = util/* default
|
|
1836
|
+
let $forms = util/* default */.Z.map(forms, (form, formIndex) => {
|
|
1746
1837
|
return (0,preact_module.h)(FormAttachment, {
|
|
1747
1838
|
store: this.props.store,
|
|
1748
1839
|
onSubmit: this.props.onSubmit,
|
|
@@ -1776,14 +1867,14 @@ class FormSubmitAttachments extends common/* Com */.up {
|
|
|
1776
1867
|
render() {
|
|
1777
1868
|
return null;
|
|
1778
1869
|
let submits = [];
|
|
1779
|
-
let attachments = util/* default
|
|
1780
|
-
util/* default
|
|
1870
|
+
let attachments = util/* default */.Z.get(this.props.ev, 'data.message.attachments') || [];
|
|
1871
|
+
util/* default */.Z.each(attachments, att => {
|
|
1781
1872
|
if (!att) return;
|
|
1782
1873
|
if (att.type !== 'form_submit') return;
|
|
1783
1874
|
if (!att.form_submit) return;
|
|
1784
1875
|
submits.push(att.form_submit);
|
|
1785
1876
|
});
|
|
1786
|
-
let $submits = util/* default
|
|
1877
|
+
let $submits = util/* default */.Z.map(submits, (submit, index) => (0,preact_module.h)("div", {
|
|
1787
1878
|
class: "info-message"
|
|
1788
1879
|
}, (0,preact_module.h)("span", null, this.props.tt('prechat_form_thanks'))));
|
|
1789
1880
|
return (0,preact_module.h)("div", null, $submits);
|
|
@@ -1855,13 +1946,13 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1855
1946
|
});
|
|
1856
1947
|
}
|
|
1857
1948
|
render() {
|
|
1858
|
-
let byType = util/* default
|
|
1949
|
+
let byType = util/* default */.Z.get(this.props.ev, 'by.type');
|
|
1859
1950
|
if (byType === 'user') return null;
|
|
1860
|
-
let attachments = util/* default
|
|
1861
|
-
let generics = util/* default
|
|
1951
|
+
let attachments = util/* default */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
1952
|
+
let generics = util/* default */.Z.filter(attachments, att => util/* default */.Z.get(att, 'type') === 'generic');
|
|
1862
1953
|
if (generics.length === 0) return null;
|
|
1863
|
-
var $generics = util/* default
|
|
1864
|
-
var $eles = util/* default
|
|
1954
|
+
var $generics = util/* default */.Z.map(generics, (gen, index) => {
|
|
1955
|
+
var $eles = util/* default */.Z.map(gen.elements, ele => {
|
|
1865
1956
|
let title = this.props.t.i18n(ele.i18n_title) || ele.title;
|
|
1866
1957
|
let subtitle = this.props.t.i18n(ele.i18n_subtitle) || ele.subtitle;
|
|
1867
1958
|
let $title = title ? (0,preact_module.h)("div", {
|
|
@@ -1888,7 +1979,7 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1888
1979
|
t: this.props.t
|
|
1889
1980
|
}));
|
|
1890
1981
|
});
|
|
1891
|
-
let elements = util/* default
|
|
1982
|
+
let elements = util/* default */.Z.get(attachments, '0.elements', []);
|
|
1892
1983
|
let leftNavigatorCls = 'generic-attachment-navigator generic-attachment-navigator--left';
|
|
1893
1984
|
let rightNavigatorCls = 'generic-attachment-navigator generic-attachment-navigator--right';
|
|
1894
1985
|
if (this.state.focusing === 0) leftNavigatorCls += ' generic-attachment-navigator--disabled';
|
|
@@ -1915,7 +2006,7 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1915
2006
|
bindDrag() {
|
|
1916
2007
|
if (!this.props.store.isMobile()) return;
|
|
1917
2008
|
let eles = document.getElementsByClassName('generic-attachment');
|
|
1918
|
-
util/* default
|
|
2009
|
+
util/* default */.Z.map(eles, ele => bind(ele, () => {}));
|
|
1919
2010
|
}
|
|
1920
2011
|
}
|
|
1921
2012
|
;// CONCATENATED MODULE: ./src/chatbox/ProductAttachments.js
|
|
@@ -1924,19 +2015,19 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1924
2015
|
|
|
1925
2016
|
class ProductAttachments extends common/* Com */.up {
|
|
1926
2017
|
render() {
|
|
1927
|
-
let byType = util/* default
|
|
2018
|
+
let byType = util/* default */.Z.get(this.props.ev, 'by.type');
|
|
1928
2019
|
if (byType === 'user') return null;
|
|
1929
|
-
let attachments = util/* default
|
|
1930
|
-
let products = util/* default
|
|
2020
|
+
let attachments = util/* default */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
2021
|
+
let products = util/* default */.Z.filter(attachments, att => util/* default */.Z.get(att, 'type') === 'product' || util/* default */.Z.get(att, 'type') === 'product_preview');
|
|
1931
2022
|
products = products.filter(product => product.product && product.product.name);
|
|
1932
2023
|
if (products.length === 0) return null;
|
|
1933
2024
|
let acc = this.props.store.matchAccount();
|
|
1934
|
-
let $products = util/* default
|
|
2025
|
+
let $products = util/* default */.Z.map(products, (att, index) => {
|
|
1935
2026
|
let product = att.product;
|
|
1936
2027
|
let $detailbtns = [];
|
|
1937
2028
|
let url = product.url || product.mobile_url;
|
|
1938
2029
|
if (this.props.store.isMobile()) url = product.mobile_url || product.url;
|
|
1939
|
-
if (url && util/* default
|
|
2030
|
+
if (url && util/* default */.Z.size(product.buttons) == 0) $detailbtns.push((0,preact_module.h)("a", {
|
|
1940
2031
|
class: "product_attachment__btn",
|
|
1941
2032
|
href: url,
|
|
1942
2033
|
target: "_blank"
|
|
@@ -1945,8 +2036,8 @@ class ProductAttachments extends common/* Com */.up {
|
|
|
1945
2036
|
class: "product_attachment__btn_external_link"
|
|
1946
2037
|
})));
|
|
1947
2038
|
console.log('P', product);
|
|
1948
|
-
if (util/* default
|
|
1949
|
-
$detailbtns = $detailbtns.concat(util/* default
|
|
2039
|
+
if (util/* default */.Z.size(product.buttons) > 0) {
|
|
2040
|
+
$detailbtns = $detailbtns.concat(util/* default */.Z.map(product.buttons, (button, index) => {
|
|
1950
2041
|
if (button.type === 'call_button') {
|
|
1951
2042
|
return (0,preact_module.h)("a", {
|
|
1952
2043
|
class: "product_attachment__btn",
|
|
@@ -1986,12 +2077,12 @@ class ProductAttachments extends common/* Com */.up {
|
|
|
1986
2077
|
if (desc) $subtitle = (0,preact_module.h)("div", {
|
|
1987
2078
|
class: "product_attachment__subtitle"
|
|
1988
2079
|
}, desc);
|
|
1989
|
-
let currency = product.currency || util/* default
|
|
2080
|
+
let currency = product.currency || util/* default */.Z.get(acc, 'currency', 'VND');
|
|
1990
2081
|
let $price = null;
|
|
1991
2082
|
if (product.price) {
|
|
1992
2083
|
$price = (0,preact_module.h)("div", {
|
|
1993
2084
|
class: "product_attachment__price"
|
|
1994
|
-
}, util/* default
|
|
2085
|
+
}, util/* default */.Z.formatCurrency(product.price, currency));
|
|
1995
2086
|
}
|
|
1996
2087
|
let imgsrc = this.props.store.replaceFileUrl(product.image);
|
|
1997
2088
|
if (!product.image) {
|
|
@@ -2018,14 +2109,14 @@ class ProductAttachments extends common/* Com */.up {
|
|
|
2018
2109
|
|
|
2019
2110
|
class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
2020
2111
|
render() {
|
|
2021
|
-
let byType = util/* default
|
|
2112
|
+
let byType = util/* default */.Z.get(this.props.ev, 'by.type');
|
|
2022
2113
|
if (byType === 'user') return null;
|
|
2023
2114
|
let acc = this.props.store.matchAccount();
|
|
2024
|
-
var attachments = util/* default
|
|
2025
|
-
let orders = util/* default
|
|
2115
|
+
var attachments = util/* default */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
2116
|
+
let orders = util/* default */.Z.filter(attachments, att => att.type === 'order' && att.order).map(att => att.order);
|
|
2026
2117
|
if (orders.length === 0) return null;
|
|
2027
|
-
let $orders = util/* default
|
|
2028
|
-
util/* default
|
|
2118
|
+
let $orders = util/* default */.Z.map(orders, (order, index) => {
|
|
2119
|
+
util/* default */.Z.calcOrderTotal(order);
|
|
2029
2120
|
let $note = null;
|
|
2030
2121
|
if (order.note) {
|
|
2031
2122
|
$note = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
@@ -2036,17 +2127,17 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2036
2127
|
}, order.note));
|
|
2037
2128
|
}
|
|
2038
2129
|
let $products = null;
|
|
2039
|
-
if (util/* default
|
|
2130
|
+
if (util/* default */.Z.size(order.items) > 0) {
|
|
2040
2131
|
$products = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
2041
2132
|
class: "order_attachment__label"
|
|
2042
|
-
}, this.props.t('product')), util/* default
|
|
2133
|
+
}, this.props.t('product')), util/* default */.Z.map(order.items, item => {
|
|
2043
2134
|
let product = item.product || {};
|
|
2044
2135
|
return (0,preact_module.h)("div", {
|
|
2045
2136
|
class: "order_attachment__product"
|
|
2046
2137
|
}, (0,preact_module.h)("img", {
|
|
2047
2138
|
class: "order_attachment__product_img",
|
|
2048
|
-
alt: '' + util/* default
|
|
2049
|
-
src: util/* default
|
|
2139
|
+
alt: '' + util/* default */.Z.get(product, 'id'),
|
|
2140
|
+
src: util/* default */.Z.get(product, 'image', __webpack_require__(9270))
|
|
2050
2141
|
}), (0,preact_module.h)("div", {
|
|
2051
2142
|
style: "overflow: hidden !important;"
|
|
2052
2143
|
}, (0,preact_module.h)("div", {
|
|
@@ -2054,9 +2145,9 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2054
2145
|
title: this.props.t.i18n(product.i18n_name) || product.name
|
|
2055
2146
|
}, this.props.t.i18n(product.i18n_name) || product.name), (0,preact_module.h)("div", {
|
|
2056
2147
|
class: "order_attachment__product_desc"
|
|
2057
|
-
}, util/* default
|
|
2148
|
+
}, util/* default */.Z.getProductPropName(product, ' / ')), (0,preact_module.h)("div", {
|
|
2058
2149
|
class: "order_attachment__product_desc"
|
|
2059
|
-
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default
|
|
2150
|
+
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default */.Z.formatCurrency(product.price))));
|
|
2060
2151
|
}));
|
|
2061
2152
|
}
|
|
2062
2153
|
let $total = (0,preact_module.h)("div", {
|
|
@@ -2065,19 +2156,19 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2065
2156
|
class: "d-flex align-items-center justify-content-between"
|
|
2066
2157
|
}, (0,preact_module.h)("div", null, this.props.t('total')), ' ', (0,preact_module.h)("div", null, (0,preact_module.h)("b", {
|
|
2067
2158
|
class: "order_attachment__total"
|
|
2068
|
-
}, util/* default
|
|
2069
|
-
let phoneattr = util/* default
|
|
2159
|
+
}, util/* default */.Z.formatCurrency(order.total)))));
|
|
2160
|
+
let phoneattr = util/* default */.Z.find(util/* default */.Z.get(order, 'user.attributes', []), attr => attr.key === 'phones') || {
|
|
2070
2161
|
key: 'phones',
|
|
2071
2162
|
text: ''
|
|
2072
2163
|
};
|
|
2073
|
-
let phone = util/* default
|
|
2074
|
-
phone = phone || util/* default
|
|
2164
|
+
let phone = util/* default */.Z.get(order, 'shipping.address.phone', '').trim();
|
|
2165
|
+
phone = phone || util/* default */.Z.trim(phoneattr.text);
|
|
2075
2166
|
if (phone) phone = this.props.t('phn') + ': ' + phone;
|
|
2076
2167
|
let $shipto = null;
|
|
2077
|
-
if (util/* default
|
|
2168
|
+
if (util/* default */.Z.displayOrderShippingAddress(order) || phone) {
|
|
2078
2169
|
$shipto = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
2079
2170
|
class: "order_attachment__label"
|
|
2080
|
-
}, this.props.t('ship_to')), (0,preact_module.h)("div", null, util/* default
|
|
2171
|
+
}, this.props.t('ship_to')), (0,preact_module.h)("div", null, util/* default */.Z.displayOrderShippingAddress(order)), (0,preact_module.h)("div", {
|
|
2081
2172
|
class: "order_attachment__text_truncate"
|
|
2082
2173
|
}, phone));
|
|
2083
2174
|
}
|
|
@@ -2089,11 +2180,11 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2089
2180
|
class: "d-flex align-items-center justify-content-between"
|
|
2090
2181
|
}, (0,preact_module.h)("div", {
|
|
2091
2182
|
class: "order_attachment__label no_margin"
|
|
2092
|
-
}, this.props.t('subtotal_before_tax')), ' ', (0,preact_module.h)("div", null, util/* default
|
|
2183
|
+
}, this.props.t('subtotal_before_tax')), ' ', (0,preact_module.h)("div", null, util/* default */.Z.formatCurrency(order._order_value))), (0,preact_module.h)("div", {
|
|
2093
2184
|
class: "d-flex align-items-center justify-content-between"
|
|
2094
2185
|
}, (0,preact_module.h)("div", {
|
|
2095
2186
|
class: "order_attachment__label no_margin"
|
|
2096
|
-
}, this.props.t('discount_before_tax')), ' ', (0,preact_module.h)("div", null, "-", util/* default
|
|
2187
|
+
}, this.props.t('discount_before_tax')), ' ', (0,preact_module.h)("div", null, "-", util/* default */.Z.formatCurrency(order._discount_before_tax))));
|
|
2097
2188
|
}
|
|
2098
2189
|
let $subtotal = (0,preact_module.h)("div", {
|
|
2099
2190
|
class: "d-flex align-items-center justify-content-between"
|
|
@@ -2101,12 +2192,12 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2101
2192
|
class: "order_attachment__label no_margin"
|
|
2102
2193
|
}, this.props.t('subtotal')), ' ', (0,preact_module.h)("div", {
|
|
2103
2194
|
style: ""
|
|
2104
|
-
}, util/* default
|
|
2195
|
+
}, util/* default */.Z.formatCurrency(order.subtotal)));
|
|
2105
2196
|
let $tax = null;
|
|
2106
2197
|
if (order.total_tax) {
|
|
2107
2198
|
let taxname = '';
|
|
2108
|
-
if (util/* default
|
|
2109
|
-
let tax = util/* default
|
|
2199
|
+
if (util/* default */.Z.size(order._taxM) === 1) {
|
|
2200
|
+
let tax = util/* default */.Z.get(order._taxM, '0.tax', {});
|
|
2110
2201
|
if (tax.name && tax.percentage) taxname = `(${tax.name} ${Math.round(tax.percentage || 0) / 100}%)`;
|
|
2111
2202
|
}
|
|
2112
2203
|
$tax = (0,preact_module.h)("div", {
|
|
@@ -2115,7 +2206,7 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2115
2206
|
class: "order_attachment__label no_margin"
|
|
2116
2207
|
}, this.props.t('tax'), " ", taxname), (0,preact_module.h)("div", {
|
|
2117
2208
|
style: ""
|
|
2118
|
-
}, util/* default
|
|
2209
|
+
}, util/* default */.Z.formatCurrency(order.total_tax)));
|
|
2119
2210
|
}
|
|
2120
2211
|
let $discount = null;
|
|
2121
2212
|
if (order.discount_type === 'percentage' && order.discount_percentage) {
|
|
@@ -2125,7 +2216,7 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2125
2216
|
class: "order_attachment__label no_margin"
|
|
2126
2217
|
}, this.props.t('discount_after_tax'), " (", Math.round(order.discount_percentage / 100), "%)"), ' ', (0,preact_module.h)("div", {
|
|
2127
2218
|
style: ""
|
|
2128
|
-
}, "-", util/* default
|
|
2219
|
+
}, "-", util/* default */.Z.formatCurrency(order._computed_discount)));
|
|
2129
2220
|
}
|
|
2130
2221
|
if (order.discount_type === 'amount' && order.discount_amount) {
|
|
2131
2222
|
$discount = (0,preact_module.h)("div", {
|
|
@@ -2134,17 +2225,17 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2134
2225
|
class: "order_attachment__label no_margin"
|
|
2135
2226
|
}, this.props.t('discount_after_tax')), ' ', (0,preact_module.h)("div", {
|
|
2136
2227
|
class: "no-shrink"
|
|
2137
|
-
}, "-", util/* default
|
|
2228
|
+
}, "-", util/* default */.Z.formatCurrency(order._computed_discount)));
|
|
2138
2229
|
}
|
|
2139
2230
|
let $shipping = null;
|
|
2140
|
-
if (util/* default
|
|
2231
|
+
if (util/* default */.Z.get(order, 'shipping.nominal_fee')) {
|
|
2141
2232
|
$shipping = (0,preact_module.h)("div", {
|
|
2142
2233
|
class: "d-flex align-items-center justify-content-between"
|
|
2143
2234
|
}, (0,preact_module.h)("div", {
|
|
2144
2235
|
class: "order_attachment__label no_margin"
|
|
2145
2236
|
}, this.props.t('shipping_fee')), ' ', (0,preact_module.h)("div", {
|
|
2146
2237
|
style: ""
|
|
2147
|
-
}, util/* default
|
|
2238
|
+
}, util/* default */.Z.formatCurrency(util/* default */.Z.get(order, 'shipping.nominal_fee', 0))));
|
|
2148
2239
|
}
|
|
2149
2240
|
let $adjustment = null;
|
|
2150
2241
|
if (order.adjustment) {
|
|
@@ -2154,7 +2245,7 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2154
2245
|
class: "order_attachment__label no_margin"
|
|
2155
2246
|
}, order.adjustment_description), ' ', (0,preact_module.h)("div", {
|
|
2156
2247
|
class: "no-shrink"
|
|
2157
|
-
}, util/* default
|
|
2248
|
+
}, util/* default */.Z.formatCurrency(order.adjustment)));
|
|
2158
2249
|
}
|
|
2159
2250
|
$subtotal = (0,preact_module.h)("div", {
|
|
2160
2251
|
class: "order_attachment__footer"
|
|
@@ -2168,7 +2259,7 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2168
2259
|
class: "order_attachment__header"
|
|
2169
2260
|
}, this.props.t('order'), (0,preact_module.h)("span", {
|
|
2170
2261
|
class: "order_attachment__text_muted order_attachment__text_sm"
|
|
2171
|
-
}, util/* default
|
|
2262
|
+
}, util/* default */.Z.getOrderDisplayName(order))), $products, $shipto, $note, $beforeTax, $subtotal, $total);
|
|
2172
2263
|
});
|
|
2173
2264
|
return $orders;
|
|
2174
2265
|
}
|
|
@@ -2182,15 +2273,15 @@ class VideoAttachments extends common/* Com */.up {
|
|
|
2182
2273
|
super(props);
|
|
2183
2274
|
}
|
|
2184
2275
|
render() {
|
|
2185
|
-
let byType = util/* default
|
|
2186
|
-
var attachments = util/* default
|
|
2276
|
+
let byType = util/* default */.Z.get(this.props.ev, 'by.type');
|
|
2277
|
+
var attachments = util/* default */.Z.get(this.props.ev, 'data.message.attachments', []);
|
|
2187
2278
|
var videos = [];
|
|
2188
|
-
util/* default
|
|
2279
|
+
util/* default */.Z.each(attachments, (att, i) => {
|
|
2189
2280
|
if (!att) return;
|
|
2190
|
-
if (util/* default
|
|
2281
|
+
if (util/* default */.Z.includes(att.mimetype, 'video')) videos.push(att);
|
|
2191
2282
|
});
|
|
2192
2283
|
if (videos.length === 0) return null;
|
|
2193
|
-
var $videos = util/* default
|
|
2284
|
+
var $videos = util/* default */.Z.map(videos, (video, index) => {
|
|
2194
2285
|
return (0,preact_module.h)("div", {
|
|
2195
2286
|
class: `video-attachment video-attachment--${byType}`
|
|
2196
2287
|
}, (0,preact_module.h)("video", {
|
|
@@ -2200,8 +2291,7 @@ class VideoAttachments extends common/* Com */.up {
|
|
|
2200
2291
|
height: "",
|
|
2201
2292
|
poster: this.props.store.replaceFileUrl(video.thumbnail_url),
|
|
2202
2293
|
controls: "controls",
|
|
2203
|
-
preload: "metadata"
|
|
2204
|
-
onclick: "this.play()"
|
|
2294
|
+
preload: "metadata"
|
|
2205
2295
|
}));
|
|
2206
2296
|
});
|
|
2207
2297
|
return (0,preact_module.h)("div", {
|
|
@@ -2209,73 +2299,23 @@ class VideoAttachments extends common/* Com */.up {
|
|
|
2209
2299
|
}, $videos);
|
|
2210
2300
|
}
|
|
2211
2301
|
}
|
|
2212
|
-
;// CONCATENATED MODULE: ./src/chatbox/ShadowDomRoot.js
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
class ShadowDomRoot extends common/* Com */.up {
|
|
2216
|
-
constructor(props) {
|
|
2217
|
-
super(props);
|
|
2218
|
-
this.ref = (0,preact_module/* createRef */.Vf)();
|
|
2219
|
-
}
|
|
2220
|
-
componentDidMount() {
|
|
2221
|
-
this.shadowRoot = this.ref.current.attachShadow({
|
|
2222
|
-
mode: 'open'
|
|
2223
|
-
});
|
|
2224
|
-
this.update(this.props.html);
|
|
2225
|
-
}
|
|
2226
|
-
update(html) {
|
|
2227
|
-
this.shadowRoot.innerHTML = `<style type="text/css">
|
|
2228
|
-
body { font-family: 'Inter', sans-serif!important; font-size: 14px!important; line-height: 20px; overflow-y: hidden; margin:0 }
|
|
2229
|
-
h{ font-size: 14/18px!important; }
|
|
2230
|
-
a { text-decoration: none;}
|
|
2231
|
-
img { max-width: 100%; display: block; margin: 10px auto; }
|
|
2232
|
-
* { white-space: normal }
|
|
2233
|
-
ul > li { margin-bottom: 5px }
|
|
2234
|
-
ul:last-child { margin-bottom: 0 }
|
|
2235
|
-
p { margin-bottom: 0; margin-top: 0;}
|
|
2236
|
-
</style>
|
|
2237
|
-
<div>${html}</div>`;
|
|
2238
|
-
let links = this.shadowRoot.querySelectorAll('a');
|
|
2239
|
-
for (var i = 0; i < links.length; i++) links[i].target = '_blank';
|
|
2240
|
-
}
|
|
2241
|
-
render() {
|
|
2242
|
-
return (0,preact_module.h)("div", {
|
|
2243
|
-
ref: this.ref,
|
|
2244
|
-
style: "white-space: normal !important"
|
|
2245
|
-
});
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
2302
|
;// CONCATENATED MODULE: ./src/chatbox/TextMessage.js
|
|
2249
2303
|
|
|
2250
|
-
let mustrerender = [];
|
|
2251
|
-
let marked = (obj, text) => {
|
|
2252
|
-
mustrerender.push(obj);
|
|
2253
|
-
return '';
|
|
2254
|
-
};
|
|
2255
|
-
const loadMarked = () => __webpack_require__.e(/* import() */ 441).then(__webpack_require__.bind(__webpack_require__, 7441));
|
|
2256
|
-
(async () => {
|
|
2257
|
-
let markedf = (await loadMarked()).marked;
|
|
2258
|
-
marked = (obj, text) => markedf(text);
|
|
2259
|
-
util/* default.map */.Z.map(mustrerender, obj => obj.forceUpdate());
|
|
2260
|
-
mustrerender = [];
|
|
2261
|
-
})();
|
|
2262
|
-
|
|
2263
2304
|
|
|
2264
2305
|
|
|
2265
2306
|
|
|
2266
2307
|
class TextMessage extends common/* Com */.up {
|
|
2267
2308
|
render() {
|
|
2268
|
-
var format = util/* default
|
|
2269
|
-
if (format === 'markdown') return this.renderMarkdown();
|
|
2309
|
+
var format = util/* default */.Z.get(this.props.ev, 'data.message.format', 'plaintext');
|
|
2270
2310
|
if (format === 'delta') return this.renderDelta();
|
|
2271
2311
|
return this.renderPlainText();
|
|
2272
2312
|
}
|
|
2273
2313
|
renderPlainText() {
|
|
2274
|
-
var text = util/* default
|
|
2275
|
-
text = util/* default
|
|
2276
|
-
if (util/* default
|
|
2277
|
-
let byType = util/* default
|
|
2278
|
-
var tags = util/* default
|
|
2314
|
+
var text = util/* default */.Z.get(this.props.ev, 'data.message.text');
|
|
2315
|
+
text = util/* default */.Z.trim(text);
|
|
2316
|
+
if (util/* default */.Z.size(text) === 0) return null;
|
|
2317
|
+
let byType = util/* default */.Z.get(this.props.ev, 'by.type');
|
|
2318
|
+
var tags = util/* default */.Z.extractText(text).map(tag => {
|
|
2279
2319
|
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
2280
2320
|
emojiCode: tag.text,
|
|
2281
2321
|
byType: byType
|
|
@@ -2299,7 +2339,7 @@ class TextMessage extends common/* Com */.up {
|
|
|
2299
2339
|
}, tag.text);
|
|
2300
2340
|
return tag.text;
|
|
2301
2341
|
});
|
|
2302
|
-
if (util/* default
|
|
2342
|
+
if (util/* default */.Z.size(tags) === 0) return null;
|
|
2303
2343
|
if (byType === 'agent') {
|
|
2304
2344
|
return (0,preact_module.h)("div", {
|
|
2305
2345
|
class: "message-agent message-text--agent"
|
|
@@ -2310,16 +2350,16 @@ class TextMessage extends common/* Com */.up {
|
|
|
2310
2350
|
}, tags);
|
|
2311
2351
|
}
|
|
2312
2352
|
renderDelta() {
|
|
2313
|
-
let deltas = util/* default
|
|
2314
|
-
let quilldeltas = util/* default
|
|
2353
|
+
let deltas = util/* default */.Z.get(this.props.ev, 'data.message.quill_delta') || util/* default */.Z.get(this.props.ev, 'data.message.text');
|
|
2354
|
+
let quilldeltas = util/* default */.Z.parseJSON(deltas) || {};
|
|
2315
2355
|
quilldeltas = trimQuillDelta(quilldeltas);
|
|
2316
|
-
if (!quilldeltas || util/* default
|
|
2317
|
-
let $deltas = util/* default
|
|
2356
|
+
if (!quilldeltas || util/* default */.Z.size(quilldeltas.ops) === 0) return null;
|
|
2357
|
+
let $deltas = util/* default */.Z.map(quilldeltas.ops, delta => {
|
|
2318
2358
|
let html = '';
|
|
2319
2359
|
let insert = delta.insert;
|
|
2320
2360
|
let attributes = delta.attributes;
|
|
2321
2361
|
if (insert.dynamicField) {
|
|
2322
|
-
return util/* default
|
|
2362
|
+
return util/* default */.Z.get(insert, 'dynamicField.text', '');
|
|
2323
2363
|
}
|
|
2324
2364
|
if (insert.mention) {
|
|
2325
2365
|
if (insert.mention.id == '*' || insert.mention.id == 'all') {
|
|
@@ -2328,7 +2368,7 @@ class TextMessage extends common/* Com */.up {
|
|
|
2328
2368
|
}, "@", this.$t('all'));
|
|
2329
2369
|
}
|
|
2330
2370
|
let ag = store.matchAgent(insert.mention.id);
|
|
2331
|
-
let name = util/* default
|
|
2371
|
+
let name = util/* default */.Z.getAgentDisplayName(ag, insert.mention.fullname);
|
|
2332
2372
|
return (0,preact_module.h)("span", {
|
|
2333
2373
|
class: "mention",
|
|
2334
2374
|
"data-agent-id": ag.id,
|
|
@@ -2339,7 +2379,7 @@ class TextMessage extends common/* Com */.up {
|
|
|
2339
2379
|
emojiCode: `:${insert.emoji}:`
|
|
2340
2380
|
});
|
|
2341
2381
|
if (typeof insert === 'string') {
|
|
2342
|
-
let $tags = util/* default
|
|
2382
|
+
let $tags = util/* default */.Z.extractText(insert).map((tag, i) => {
|
|
2343
2383
|
if (tag.type === 'link') {
|
|
2344
2384
|
return (0,preact_module.h)("a", {
|
|
2345
2385
|
href: absLink(tag.text),
|
|
@@ -2363,9 +2403,9 @@ class TextMessage extends common/* Com */.up {
|
|
|
2363
2403
|
}
|
|
2364
2404
|
return null;
|
|
2365
2405
|
});
|
|
2366
|
-
let byType = util/* default
|
|
2406
|
+
let byType = util/* default */.Z.get(this.ev, 'by.type');
|
|
2367
2407
|
if (byType !== 'user') byType = 'agent';
|
|
2368
|
-
if (util/* default
|
|
2408
|
+
if (util/* default */.Z.size($deltas) === 0) return null;
|
|
2369
2409
|
if (byType === 'agent') {
|
|
2370
2410
|
return (0,preact_module.h)("div", {
|
|
2371
2411
|
class: "message-agent message-text--agent"
|
|
@@ -2375,46 +2415,6 @@ class TextMessage extends common/* Com */.up {
|
|
|
2375
2415
|
class: "message-user message-text--user"
|
|
2376
2416
|
}, $deltas);
|
|
2377
2417
|
}
|
|
2378
|
-
renderMarkdown(text) {
|
|
2379
|
-
if (!text) text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
|
|
2380
|
-
if (util/* default.size */.Z.size(text) === 0) return null;
|
|
2381
|
-
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
2382
|
-
text = util/* default.trim */.Z.trim(text);
|
|
2383
|
-
if (util/* default.size */.Z.size(text) === 0) return null;
|
|
2384
|
-
if (byType === 'agent') {
|
|
2385
|
-
return (0,preact_module.h)("div", {
|
|
2386
|
-
class: "markdown-message message-agent message-text--agent"
|
|
2387
|
-
}, (0,preact_module.h)(ShadowDomRoot, {
|
|
2388
|
-
html: marked(this, text)
|
|
2389
|
-
}));
|
|
2390
|
-
}
|
|
2391
|
-
return (0,preact_module.h)("div", {
|
|
2392
|
-
class: "d-flex flex-column align-items-end"
|
|
2393
|
-
}, (0,preact_module.h)("div", {
|
|
2394
|
-
class: "markdown-message message-user message-text--user"
|
|
2395
|
-
}, (0,preact_module.h)(ShadowDomRoot, {
|
|
2396
|
-
html: marked(this, text)
|
|
2397
|
-
})));
|
|
2398
|
-
}
|
|
2399
|
-
}
|
|
2400
|
-
function deltaToMarkdown(deltas) {
|
|
2401
|
-
let output = '';
|
|
2402
|
-
sb.each(deltas, (delta, idx) => {
|
|
2403
|
-
let text = '';
|
|
2404
|
-
let insert = delta.insert;
|
|
2405
|
-
let attributes = delta.attributes;
|
|
2406
|
-
if (insert.emoji) text = emojiCodes[insert.emoji] || '';
|
|
2407
|
-
if (attributes) {
|
|
2408
|
-
if (attributes.italic && attributes.bold) text = `*__${insert}__*`;else if (attributes.italic) text = `*${insert}*`;else if (attributes.bold) text = `**${insert}**`;else text = insert;
|
|
2409
|
-
}
|
|
2410
|
-
if (insert.dynamicField) text = `${sb.get(insert, 'dynamicField.text', '')}`;
|
|
2411
|
-
if (!insert.emoji && !attributes && !insert.dynamicField) {
|
|
2412
|
-
text = insert || '';
|
|
2413
|
-
text = text.replace(/\n/g, '<br/>');
|
|
2414
|
-
}
|
|
2415
|
-
output += text;
|
|
2416
|
-
});
|
|
2417
|
-
return output;
|
|
2418
2418
|
}
|
|
2419
2419
|
const emojiCodes = {
|
|
2420
2420
|
like: '👍',
|
|
@@ -2463,8 +2463,8 @@ function absLink(url) {
|
|
|
2463
2463
|
}
|
|
2464
2464
|
;// CONCATENATED MODULE: ./src/chatbox/time.js
|
|
2465
2465
|
|
|
2466
|
-
var g_pub = new util/* default
|
|
2467
|
-
util/* default
|
|
2466
|
+
var g_pub = new util/* default */.Z.Pubsub();
|
|
2467
|
+
util/* default */.Z.setInterval(() => g_pub.publish('time'), 20 * 1000);
|
|
2468
2468
|
|
|
2469
2469
|
|
|
2470
2470
|
class Time extends common/* Com */.up {
|
|
@@ -2479,10 +2479,10 @@ class Time extends common/* Com */.up {
|
|
|
2479
2479
|
var t = '';
|
|
2480
2480
|
if (this.props.ago) {
|
|
2481
2481
|
if (this.props.short) {
|
|
2482
|
-
if (Math.abs(this.props.time - new util/* default
|
|
2483
|
-
let tim = new util/* default
|
|
2482
|
+
if (Math.abs(this.props.time - new util/* default */.Z.Date().getTime()) > 86400000 * 10) {
|
|
2483
|
+
let tim = new util/* default */.Z.Date(this.props.time);
|
|
2484
2484
|
let tzyear = tim.getFullYear();
|
|
2485
|
-
let locale = util/* default
|
|
2485
|
+
let locale = util/* default */.Z.get(navigator, 'languages.0', 'en-US');
|
|
2486
2486
|
let tzmonthname = tim.toLocaleDateString(locale, {
|
|
2487
2487
|
month: 'short'
|
|
2488
2488
|
});
|
|
@@ -2490,8 +2490,8 @@ class Time extends common/* Com */.up {
|
|
|
2490
2490
|
t = tzdate + ' ' + tzmonthname + ' ' + tzyear;
|
|
2491
2491
|
}
|
|
2492
2492
|
}
|
|
2493
|
-
if (!t && this.props.time > 0) t = ago(this.props.time, new util/* default
|
|
2494
|
-
} else t = util/* default
|
|
2493
|
+
if (!t && this.props.time > 0) t = ago(this.props.time, new util/* default */.Z.Date().getTime());
|
|
2494
|
+
} else t = util/* default */.Z.shortTime(this.props.time, this.props.tzoffset);
|
|
2495
2495
|
if (this.props.uppercase) t = t.toUpperCase();
|
|
2496
2496
|
if (t === this.state.t) return;
|
|
2497
2497
|
this.setState({
|
|
@@ -2602,7 +2602,7 @@ class InfoMessage extends common/* Com */.up {
|
|
|
2602
2602
|
}));
|
|
2603
2603
|
}
|
|
2604
2604
|
if (ev.type === 'conversation_rated') {
|
|
2605
|
-
var rating = util/* default
|
|
2605
|
+
var rating = util/* default */.Z.get(ev, 'data.conversation.ratings.0', {
|
|
2606
2606
|
no_rating: true,
|
|
2607
2607
|
rating: 0
|
|
2608
2608
|
});
|
|
@@ -2613,7 +2613,7 @@ class InfoMessage extends common/* Com */.up {
|
|
|
2613
2613
|
class: "info-message"
|
|
2614
2614
|
}, this.props.t('rated_as') + ' ' + this.props.t(getRateLang(rating.rating)).toLowerCase()));
|
|
2615
2615
|
}
|
|
2616
|
-
if (ev.type === 'conversation_state_updated' && util/* default
|
|
2616
|
+
if (ev.type === 'conversation_state_updated' && util/* default */.Z.get(ev, 'data.conversation.state') === 'ended') {
|
|
2617
2617
|
return (0,preact_module.h)("div", {
|
|
2618
2618
|
class: "convo-event"
|
|
2619
2619
|
}, $time, (0,preact_module.h)("div", {
|
|
@@ -2647,7 +2647,7 @@ class Event extends common/* Com */.up {
|
|
|
2647
2647
|
this.refForm = (0,preact_module/* createRef */.Vf)();
|
|
2648
2648
|
}
|
|
2649
2649
|
render() {
|
|
2650
|
-
var ev = util/* default
|
|
2650
|
+
var ev = util/* default */.Z.get(this.props.event, 'ev', {});
|
|
2651
2651
|
switch (ev.type) {
|
|
2652
2652
|
case 'conversation_joined':
|
|
2653
2653
|
break;
|
|
@@ -2656,7 +2656,7 @@ class Event extends common/* Com */.up {
|
|
|
2656
2656
|
case 'conversation_state_updated':
|
|
2657
2657
|
case 'conversation_rating_requested':
|
|
2658
2658
|
case 'conversation_rated':
|
|
2659
|
-
if (!util/* default
|
|
2659
|
+
if (!util/* default */.Z.startsWith(ev.id, 'ev')) return null;
|
|
2660
2660
|
return (0,preact_module.h)(InfoMessage, {
|
|
2661
2661
|
t: this.props.t,
|
|
2662
2662
|
store: this.props.store,
|
|
@@ -2669,7 +2669,7 @@ class Event extends common/* Com */.up {
|
|
|
2669
2669
|
this.refForm.current && this.refForm.current.focus();
|
|
2670
2670
|
}
|
|
2671
2671
|
chooseQuickReply(reply) {
|
|
2672
|
-
let ev = util/* default
|
|
2672
|
+
let ev = util/* default */.Z.get(this.props.event, 'ev', {});
|
|
2673
2673
|
let message = {
|
|
2674
2674
|
text: reply.title,
|
|
2675
2675
|
format: 'plaintext'
|
|
@@ -2686,7 +2686,7 @@ class Event extends common/* Com */.up {
|
|
|
2686
2686
|
this.props.onSend(message);
|
|
2687
2687
|
}
|
|
2688
2688
|
choosePostbackBtn(button) {
|
|
2689
|
-
let ev = util/* default
|
|
2689
|
+
let ev = util/* default */.Z.get(this.props.event, 'ev', {});
|
|
2690
2690
|
let message = {
|
|
2691
2691
|
text: button.title,
|
|
2692
2692
|
format: 'plaintext'
|
|
@@ -2703,13 +2703,13 @@ class Event extends common/* Com */.up {
|
|
|
2703
2703
|
this.props.onSend(message);
|
|
2704
2704
|
}
|
|
2705
2705
|
renderAgentAvatar(ev) {
|
|
2706
|
-
let bytype = util/* default
|
|
2707
|
-
let byid = util/* default
|
|
2706
|
+
let bytype = util/* default */.Z.get(ev, 'by.type');
|
|
2707
|
+
let byid = util/* default */.Z.get(ev, 'by.display_id', util/* default */.Z.get(ev, 'by.id'));
|
|
2708
2708
|
if (bytype === 'user') return null;
|
|
2709
2709
|
var senderName = this.getSenderName(ev);
|
|
2710
2710
|
let acc = this.props.store.matchAccount();
|
|
2711
2711
|
var uri = acc.logo_url || __webpack_require__(9895);
|
|
2712
|
-
if (util/* default
|
|
2712
|
+
if (util/* default */.Z.get(this.props, 'chatbox.hide_agent_profile')) {
|
|
2713
2713
|
return (0,preact_module.h)("div", {
|
|
2714
2714
|
class: "message-sender"
|
|
2715
2715
|
}, (0,preact_module.h)("img", {
|
|
@@ -2722,7 +2722,7 @@ class Event extends common/* Com */.up {
|
|
|
2722
2722
|
}
|
|
2723
2723
|
let agentM = this.props.store.matchAgent('*');
|
|
2724
2724
|
if (byid !== 'system' && bytype !== 'dummy' && bytype !== 'workflow') {
|
|
2725
|
-
uri = util/* default
|
|
2725
|
+
uri = util/* default */.Z.get(agentM[byid], 'avatar_url') || acc.logo_url || __webpack_require__(4761);
|
|
2726
2726
|
}
|
|
2727
2727
|
return (0,preact_module.h)("div", {
|
|
2728
2728
|
class: "message-sender"
|
|
@@ -2744,8 +2744,8 @@ class Event extends common/* Com */.up {
|
|
|
2744
2744
|
time: ev.created
|
|
2745
2745
|
}));
|
|
2746
2746
|
}
|
|
2747
|
-
let t = new util/* default
|
|
2748
|
-
if (util/* default
|
|
2747
|
+
let t = new util/* default */.Z.Date(ev.created).toLocaleString();
|
|
2748
|
+
if (util/* default */.Z.get(ev, 'by.type') !== 'user') {
|
|
2749
2749
|
let $sender = null;
|
|
2750
2750
|
if (this.props.event.mode === 'lead') $sender = this.renderAgentAvatar(ev);
|
|
2751
2751
|
return (0,preact_module.h)("div", {
|
|
@@ -2801,15 +2801,15 @@ class Event extends common/* Com */.up {
|
|
|
2801
2801
|
onSelect: e => this.chooseQuickReply(e)
|
|
2802
2802
|
}));
|
|
2803
2803
|
}
|
|
2804
|
-
if (util/* default
|
|
2805
|
-
util/* default
|
|
2804
|
+
if (util/* default */.Z.getMsgField(ev, 'idempotency') === ev.id && this.props.store.now() - ev.created < 900) {
|
|
2805
|
+
util/* default */.Z.setTimeout(() => this.setState({
|
|
2806
2806
|
refresh: this.state.refresh
|
|
2807
2807
|
}), 1000);
|
|
2808
2808
|
}
|
|
2809
2809
|
let $dot = (0,preact_module.h)("div", {
|
|
2810
2810
|
class: "sending_dot"
|
|
2811
2811
|
});
|
|
2812
|
-
if (this.props.store.now() - ev.created < 900 || util/* default
|
|
2812
|
+
if (this.props.store.now() - ev.created < 900 || util/* default */.Z.getMsgField(ev, 'idempotency') !== ev.id) {
|
|
2813
2813
|
$dot = (0,preact_module.h)("div", {
|
|
2814
2814
|
class: "sending_dot sending_dot__hide"
|
|
2815
2815
|
});
|
|
@@ -2873,7 +2873,7 @@ class Event extends common/* Com */.up {
|
|
|
2873
2873
|
})), $error);
|
|
2874
2874
|
}
|
|
2875
2875
|
renderUpdateConvo(ev) {
|
|
2876
|
-
var state = util/* default
|
|
2876
|
+
var state = util/* default */.Z.get(ev, 'data.conversation.state');
|
|
2877
2877
|
if (state === 'active') return null;
|
|
2878
2878
|
if (state === 'pending') return null;
|
|
2879
2879
|
return (0,preact_module.h)("div", {
|
|
@@ -2883,18 +2883,18 @@ class Event extends common/* Com */.up {
|
|
|
2883
2883
|
}));
|
|
2884
2884
|
}
|
|
2885
2885
|
resendMessage() {
|
|
2886
|
-
let cid = util/* default
|
|
2887
|
-
const message = util/* default
|
|
2886
|
+
let cid = util/* default */.Z.convoOfEv(this.props.event.ev);
|
|
2887
|
+
const message = util/* default */.Z.get(this.props.event, 'ev.data.message');
|
|
2888
2888
|
this.props.store.sendConvoEvent(cid, 'message_sent', {
|
|
2889
2889
|
message
|
|
2890
2890
|
});
|
|
2891
2891
|
}
|
|
2892
2892
|
getSenderName(ev) {
|
|
2893
|
-
let bytype = util/* default
|
|
2894
|
-
let byid = util/* default
|
|
2895
|
-
if (bytype === 'user') return util/* default
|
|
2893
|
+
let bytype = util/* default */.Z.get(ev, 'by.type');
|
|
2894
|
+
let byid = util/* default */.Z.get(ev, 'by.display_id', util/* default */.Z.get(ev, 'by.id'));
|
|
2895
|
+
if (bytype === 'user') return util/* default */.Z.getUserDisplayName(this.props.store.matchUser());
|
|
2896
2896
|
let acc = this.props.store.matchAccount();
|
|
2897
|
-
if (bytype === 'agent') return util/* default
|
|
2897
|
+
if (bytype === 'agent') return util/* default */.Z.getAgentDisplayName(acc, this.props.store.matchAgent(byid));
|
|
2898
2898
|
if (byid === 'system' || bytype === 'dummy' || bytype === 'workflow') return acc.name || 'system';
|
|
2899
2899
|
return '';
|
|
2900
2900
|
}
|
|
@@ -2941,7 +2941,7 @@ class Events extends common/* Com */.up {
|
|
|
2941
2941
|
this.props.store.onConvoEvent(this, ev => this.onEvent(ev));
|
|
2942
2942
|
this.loadConvo();
|
|
2943
2943
|
this.refBody = null;
|
|
2944
|
-
this.checkAndSeen = util/* default
|
|
2944
|
+
this.checkAndSeen = util/* default */.Z.throttle(() => {
|
|
2945
2945
|
if (this.props.isShow && this.isBottom() && this.props.store.browserVisibility === 'visible' && document.hasFocus()) {
|
|
2946
2946
|
this.props.store.seenConvo(this.props.cid);
|
|
2947
2947
|
}
|
|
@@ -2953,8 +2953,8 @@ class Events extends common/* Com */.up {
|
|
|
2953
2953
|
}
|
|
2954
2954
|
render() {
|
|
2955
2955
|
if (this.state.error) return this.renderError();
|
|
2956
|
-
let events = util/* default
|
|
2957
|
-
if (!this.state.loading && util/* default
|
|
2956
|
+
let events = util/* default */.Z.map(this.props.store.listEvents(this.props.cid));
|
|
2957
|
+
if (!this.state.loading && util/* default */.Z.size(events) === 0) {
|
|
2958
2958
|
return (0,preact_module.h)("div", {
|
|
2959
2959
|
ref: ref => this.refBody = ref,
|
|
2960
2960
|
class: "widget-body--events-container"
|
|
@@ -2968,13 +2968,13 @@ class Events extends common/* Com */.up {
|
|
|
2968
2968
|
store: this.props.store
|
|
2969
2969
|
}));
|
|
2970
2970
|
}
|
|
2971
|
-
events = util/* default
|
|
2971
|
+
events = util/* default */.Z.orderBy(events, 'created', 'asc');
|
|
2972
2972
|
let convo = this.props.store.matchConvo(this.props.cid);
|
|
2973
|
-
events = util/* default
|
|
2973
|
+
events = util/* default */.Z.map(events, ev => ({
|
|
2974
2974
|
ev: ev
|
|
2975
2975
|
}));
|
|
2976
2976
|
processEvents(convo, events);
|
|
2977
|
-
let $events = util/* default
|
|
2977
|
+
let $events = util/* default */.Z.map(events, ev => (0,preact_module.h)(Event, {
|
|
2978
2978
|
chatbox: this.props.chatbox,
|
|
2979
2979
|
onLink: this.props.onLink,
|
|
2980
2980
|
store: this.props.store,
|
|
@@ -2990,7 +2990,7 @@ class Events extends common/* Com */.up {
|
|
|
2990
2990
|
if (this.state.loading || this.props.creating) {
|
|
2991
2991
|
$loading = (0,preact_module.h)(Spinner, {
|
|
2992
2992
|
static: true,
|
|
2993
|
-
mode: util/* default
|
|
2993
|
+
mode: util/* default */.Z.get(this.props.chatbox, 'primary_color', 'dark'),
|
|
2994
2994
|
size: "120",
|
|
2995
2995
|
center: true
|
|
2996
2996
|
});
|
|
@@ -3029,23 +3029,23 @@ class Events extends common/* Com */.up {
|
|
|
3029
3029
|
}
|
|
3030
3030
|
focus() {
|
|
3031
3031
|
let events = this.props.store.listEvents(this.props.cid);
|
|
3032
|
-
events = util/* default
|
|
3032
|
+
events = util/* default */.Z.orderBy(util/* default */.Z.map(events), 'created', 'desc');
|
|
3033
3033
|
var last_agent_sent;
|
|
3034
3034
|
for (let ev of events) {
|
|
3035
|
-
if (util/* default
|
|
3036
|
-
if (util/* default
|
|
3035
|
+
if (util/* default */.Z.get(ev, 'type') !== 'message_sent') continue;
|
|
3036
|
+
if (util/* default */.Z.get(ev, 'by.type') === 'user') continue;
|
|
3037
3037
|
last_agent_sent = ev;
|
|
3038
3038
|
break;
|
|
3039
3039
|
}
|
|
3040
|
-
if (util/* default
|
|
3041
|
-
let attachments = util/* default
|
|
3040
|
+
if (util/* default */.Z.get(last_agent_sent, 'by.type') === 'user') last_agent_sent = null;
|
|
3041
|
+
let attachments = util/* default */.Z.get(last_agent_sent, 'data.message.attachments', []);
|
|
3042
3042
|
let convo = this.props.store.matchConvo(this.props.cid);
|
|
3043
|
-
let pendingForms = util/* default
|
|
3043
|
+
let pendingForms = util/* default */.Z.filter(attachments, att => {
|
|
3044
3044
|
if (!att) return false;
|
|
3045
3045
|
if (att.type !== 'form' && att.type !== 'ask_info_form') return false;
|
|
3046
3046
|
var form = att.form;
|
|
3047
3047
|
if (!form) return false;
|
|
3048
|
-
var state = util/* default
|
|
3048
|
+
var state = util/* default */.Z.parseJSON(form.state) || {};
|
|
3049
3049
|
if (!state.require_finished && att.type !== 'ask_info_form') return false;
|
|
3050
3050
|
if (Events_isSummited(att.form)) return false;
|
|
3051
3051
|
if (convo.state === 'ended') return false;
|
|
@@ -3053,10 +3053,10 @@ class Events extends common/* Com */.up {
|
|
|
3053
3053
|
});
|
|
3054
3054
|
}
|
|
3055
3055
|
onEvent(newev) {
|
|
3056
|
-
if (util/* default
|
|
3056
|
+
if (util/* default */.Z.convoOfEv(newev) !== this.props.cid) return;
|
|
3057
3057
|
let isBottom = this.isBottom();
|
|
3058
3058
|
var byme = false;
|
|
3059
|
-
if (util/* default
|
|
3059
|
+
if (util/* default */.Z.get(newev, 'type') === 'message_sent' && newev.id === util/* default */.Z.getMsgField(newev, 'idempotency')) byme = true;
|
|
3060
3060
|
if (byme || isBottom) this.scrollToBottom();
|
|
3061
3061
|
}
|
|
3062
3062
|
async loadConvo() {
|
|
@@ -3066,7 +3066,7 @@ class Events extends common/* Com */.up {
|
|
|
3066
3066
|
loading: true
|
|
3067
3067
|
});
|
|
3068
3068
|
let events = this.props.store.listEvents(this.props.cid);
|
|
3069
|
-
if (util/* default
|
|
3069
|
+
if (util/* default */.Z.size(events) === 0) {
|
|
3070
3070
|
let cid = this.props.cid;
|
|
3071
3071
|
let {
|
|
3072
3072
|
error
|
|
@@ -3090,7 +3090,7 @@ class Events extends common/* Com */.up {
|
|
|
3090
3090
|
error: false
|
|
3091
3091
|
});
|
|
3092
3092
|
this.scrollToBottom();
|
|
3093
|
-
util/* default
|
|
3093
|
+
util/* default */.Z.setTimeout(() => this.setState({
|
|
3094
3094
|
loading: false
|
|
3095
3095
|
}), 50);
|
|
3096
3096
|
}
|
|
@@ -3100,11 +3100,11 @@ class Events extends common/* Com */.up {
|
|
|
3100
3100
|
return $container.scrollHeight < $container.scrollTop + $container.offsetHeight + 50;
|
|
3101
3101
|
}
|
|
3102
3102
|
scrollToBottom() {
|
|
3103
|
-
util/* default
|
|
3103
|
+
util/* default */.Z.setTimeout(() => {
|
|
3104
3104
|
const $div = this.refBody;
|
|
3105
3105
|
if ($div) $div.scrollTop = $div.scrollHeight;
|
|
3106
3106
|
});
|
|
3107
|
-
util/* default
|
|
3107
|
+
util/* default */.Z.setTimeout(() => {
|
|
3108
3108
|
const $div = this.refBody;
|
|
3109
3109
|
if ($div) $div.scrollTop = $div.scrollHeight;
|
|
3110
3110
|
}, 200);
|
|
@@ -3122,13 +3122,13 @@ function processEvents(convo, events) {
|
|
|
3122
3122
|
let curEvent = events[i];
|
|
3123
3123
|
let lastEvent = events[i - 1];
|
|
3124
3124
|
if (visibleEvent(curEvent.ev)) {
|
|
3125
|
-
let elapsedSec = util/* default
|
|
3125
|
+
let elapsedSec = util/* default */.Z.unixSec(curEvent.ev.created) - util/* default */.Z.unixSec(lastEvent.ev.created);
|
|
3126
3126
|
if (elapsedSec > 120) curEvent.show_time = true;
|
|
3127
3127
|
}
|
|
3128
3128
|
}
|
|
3129
3129
|
for (var i = 0; i < events.length; i++) {
|
|
3130
3130
|
let curEvent = events[i];
|
|
3131
|
-
if (util/* default
|
|
3131
|
+
if (util/* default */.Z.get(curEvent, 'ev.type') === 'message_sent') {
|
|
3132
3132
|
curEvent.show_time = true;
|
|
3133
3133
|
break;
|
|
3134
3134
|
}
|
|
@@ -3138,7 +3138,7 @@ function processEvents(convo, events) {
|
|
|
3138
3138
|
let prevEvent = events[i - 1];
|
|
3139
3139
|
if (curEvent.ev.type === 'message_sent') {
|
|
3140
3140
|
curEvent.mode = 'lead';
|
|
3141
|
-
if (util/* default
|
|
3141
|
+
if (util/* default */.Z.get(prevEvent, 'ev.type') === 'message_sent' && util/* default */.Z.get(prevEvent, 'ev.by.id') === util/* default */.Z.get(curEvent, 'ev.by.id')) {
|
|
3142
3142
|
curEvent.mode = 'follow';
|
|
3143
3143
|
}
|
|
3144
3144
|
continue;
|
|
@@ -3146,12 +3146,12 @@ function processEvents(convo, events) {
|
|
|
3146
3146
|
}
|
|
3147
3147
|
}
|
|
3148
3148
|
function visibleEvent(ev) {
|
|
3149
|
-
let type = util/* default
|
|
3149
|
+
let type = util/* default */.Z.get(ev, 'type');
|
|
3150
3150
|
return type === 'message_sent' || type === 'conversation_state_updated';
|
|
3151
3151
|
}
|
|
3152
3152
|
function Events_isSummited(form) {
|
|
3153
|
-
let fields = util/* default
|
|
3154
|
-
return util/* default
|
|
3153
|
+
let fields = util/* default */.Z.get(form, 'fields') || [];
|
|
3154
|
+
return util/* default */.Z.find(fields, field => !!field.answered);
|
|
3155
3155
|
}
|
|
3156
3156
|
;// CONCATENATED MODULE: ./src/chatbox/Typing.js
|
|
3157
3157
|
|
|
@@ -3167,29 +3167,29 @@ class Typing extends common/* Com */.up {
|
|
|
3167
3167
|
ev: {}
|
|
3168
3168
|
});
|
|
3169
3169
|
this.props.store.onConvoEvent(this, ev => {
|
|
3170
|
-
if (util/* default
|
|
3170
|
+
if (util/* default */.Z.convoOfEv(ev) !== this.props.cid) return;
|
|
3171
3171
|
let user = this.props.store.matchUser();
|
|
3172
|
-
if (util/* default
|
|
3173
|
-
let oldby = util/* default
|
|
3174
|
-
if (oldby && util/* default
|
|
3175
|
-
if (util/* default
|
|
3176
|
-
if (this.timer) util/* default
|
|
3172
|
+
if (util/* default */.Z.get(ev, 'by.id') === user.id) return;
|
|
3173
|
+
let oldby = util/* default */.Z.get(this.state.ev, 'by.id');
|
|
3174
|
+
if (oldby && util/* default */.Z.get(ev, 'by.id') !== oldby) return;
|
|
3175
|
+
if (util/* default */.Z.get(ev, 'type') === 'message_sent') {
|
|
3176
|
+
if (this.timer) util/* default */.Z.clearTimeout(this.timer);
|
|
3177
3177
|
this.timer = null;
|
|
3178
3178
|
this.setState({
|
|
3179
3179
|
isShow: false
|
|
3180
3180
|
});
|
|
3181
3181
|
return;
|
|
3182
3182
|
}
|
|
3183
|
-
|
|
3183
|
+
if (util/* default */.Z.get(ev, 'type') !== 'conversation_typing') return;
|
|
3184
|
+
let ag = this.props.store.matchAgent(util/* default */.Z.get(ev, 'by.id')) || {};
|
|
3184
3185
|
if (ag.type == 'agent') return;
|
|
3185
|
-
if (util/* default.get */.Z.get(ev, 'type') !== 'conversation_typing') return;
|
|
3186
3186
|
this.setState({
|
|
3187
3187
|
ev: ev,
|
|
3188
3188
|
isShow: true
|
|
3189
3189
|
});
|
|
3190
|
-
if (this.timer) util/* default
|
|
3191
|
-
this.timer = util/* default
|
|
3192
|
-
if (util/* default
|
|
3190
|
+
if (this.timer) util/* default */.Z.clearTimeout(this.timer);
|
|
3191
|
+
this.timer = util/* default */.Z.setTimeout(() => {
|
|
3192
|
+
if (util/* default */.Z.convoOfEv(ev) !== this.props.cid) return;
|
|
3193
3193
|
this.timer = null;
|
|
3194
3194
|
this.setState({
|
|
3195
3195
|
isShow: false
|
|
@@ -3200,8 +3200,8 @@ class Typing extends common/* Com */.up {
|
|
|
3200
3200
|
render() {
|
|
3201
3201
|
let account = this.props.store.matchAccount();
|
|
3202
3202
|
var cls = this.state.isShow ? '' : 'typing--hidden';
|
|
3203
|
-
let byid = util/* default
|
|
3204
|
-
let agentName = util/* default
|
|
3203
|
+
let byid = util/* default */.Z.get(this.state.ev, 'by.display_id', util/* default */.Z.get(this.state.ev, 'by.id'));
|
|
3204
|
+
let agentName = util/* default */.Z.getAgentDisplayName(account, this.props.store.matchAgent(byid));
|
|
3205
3205
|
return (0,preact_module.h)("div", {
|
|
3206
3206
|
class: `typing ${cls}`
|
|
3207
3207
|
}, agentName, " ", this.props.t('typing'));
|
|
@@ -3220,7 +3220,7 @@ class Typing extends common/* Com */.up {
|
|
|
3220
3220
|
this.stop();
|
|
3221
3221
|
var t0;
|
|
3222
3222
|
var run = t => {
|
|
3223
|
-
if (!t) t = new util/* default
|
|
3223
|
+
if (!t) t = new util/* default */.Z.Date().getTime();
|
|
3224
3224
|
var deltaT = t - t0;
|
|
3225
3225
|
var [newy, done] = this.calcY(v, y0, deltaT);
|
|
3226
3226
|
cb(newy);
|
|
@@ -3228,7 +3228,7 @@ class Typing extends common/* Com */.up {
|
|
|
3228
3228
|
this.animationframe = window.requestAnimationFrame(run);
|
|
3229
3229
|
};
|
|
3230
3230
|
this.animationframe = window.requestAnimationFrame(t => {
|
|
3231
|
-
t0 = t || new util/* default
|
|
3231
|
+
t0 = t || new util/* default */.Z.Date().getTime();
|
|
3232
3232
|
run(t0);
|
|
3233
3233
|
});
|
|
3234
3234
|
}
|
|
@@ -3263,8 +3263,8 @@ function eqFloat(a, b) {
|
|
|
3263
3263
|
}
|
|
3264
3264
|
;// CONCATENATED MODULE: ./src/chatbox/Rating.js
|
|
3265
3265
|
function Rating_defineProperty(obj, key, value) { key = Rating_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3266
|
-
function Rating_toPropertyKey(
|
|
3267
|
-
function Rating_toPrimitive(
|
|
3266
|
+
function Rating_toPropertyKey(t) { var i = Rating_toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
3267
|
+
function Rating_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
3268
3268
|
|
|
3269
3269
|
|
|
3270
3270
|
const POPUP_MAX_HEIGHT = 400;
|
|
@@ -3290,7 +3290,7 @@ class Rating extends common/* Com */.up {
|
|
|
3290
3290
|
if (this.shoudDisplay()) this.open();
|
|
3291
3291
|
});
|
|
3292
3292
|
this.props.store.onConvoEvent(this, ev => {
|
|
3293
|
-
var cid = util/* default
|
|
3293
|
+
var cid = util/* default */.Z.convoOfEv(ev);
|
|
3294
3294
|
if (cid !== this.props.cid) return;
|
|
3295
3295
|
if (this.shoudDisplay()) this.open();
|
|
3296
3296
|
});
|
|
@@ -3399,12 +3399,12 @@ class Rating extends common/* Com */.up {
|
|
|
3399
3399
|
var rated;
|
|
3400
3400
|
var ended;
|
|
3401
3401
|
let user = this.props.store.matchUser();
|
|
3402
|
-
util/* default
|
|
3403
|
-
if (util/* default
|
|
3402
|
+
util/* default */.Z.map(this.props.store.listEvents(this.props.cid), ev => {
|
|
3403
|
+
if (util/* default */.Z.get(ev, 'type') === 'conversation_state_updated' && util/* default */.Z.get(ev, 'data.conversation.state') === 'ended') {
|
|
3404
3404
|
ended = ev;
|
|
3405
3405
|
}
|
|
3406
|
-
if (util/* default
|
|
3407
|
-
if (util/* default
|
|
3406
|
+
if (util/* default */.Z.get(ev, 'type') === 'conversation_rating_requested') requested = ev;
|
|
3407
|
+
if (util/* default */.Z.get(ev, 'type') === 'conversation_rated' && util/* default */.Z.get(ev, 'by.id') === user.id) rated = ev;
|
|
3408
3408
|
});
|
|
3409
3409
|
if (rated) return false;
|
|
3410
3410
|
let accountSetting = this.props.plugin.chatbox;
|
|
@@ -3445,7 +3445,7 @@ class Rating extends common/* Com */.up {
|
|
|
3445
3445
|
hide: false
|
|
3446
3446
|
});
|
|
3447
3447
|
if (!this.refRating.current) return;
|
|
3448
|
-
util/* default
|
|
3448
|
+
util/* default */.Z.setTimeout(() => {
|
|
3449
3449
|
if (this.refComment.current) this.refComment.current.focus();
|
|
3450
3450
|
}, 400);
|
|
3451
3451
|
this.refComment.current.value = '';
|
|
@@ -3528,8 +3528,8 @@ class Rating extends common/* Com */.up {
|
|
|
3528
3528
|
}
|
|
3529
3529
|
;// CONCATENATED MODULE: ./src/chatbox/DropdownSelect.js
|
|
3530
3530
|
function DropdownSelect_defineProperty(obj, key, value) { key = DropdownSelect_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3531
|
-
function DropdownSelect_toPropertyKey(
|
|
3532
|
-
function DropdownSelect_toPrimitive(
|
|
3531
|
+
function DropdownSelect_toPropertyKey(t) { var i = DropdownSelect_toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
3532
|
+
function DropdownSelect_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
3533
3533
|
|
|
3534
3534
|
|
|
3535
3535
|
|
|
@@ -3567,15 +3567,15 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3567
3567
|
});
|
|
3568
3568
|
DropdownSelect_defineProperty(this, "hasSearch", () => {
|
|
3569
3569
|
if (this.props.has_search) return true;
|
|
3570
|
-
return util/* default
|
|
3570
|
+
return util/* default */.Z.size(this.props.items) >= 10;
|
|
3571
3571
|
});
|
|
3572
3572
|
DropdownSelect_defineProperty(this, "getFilteredOptions", () => {
|
|
3573
3573
|
let items = this.props.items;
|
|
3574
3574
|
if (this.state.searchValue && this.hasSearch()) {
|
|
3575
|
-
items = util/* default
|
|
3576
|
-
let optionName = util/* default
|
|
3577
|
-
let optionDesc = util/* default
|
|
3578
|
-
let searchValue = util/* default
|
|
3575
|
+
items = util/* default */.Z.filter(items, item => {
|
|
3576
|
+
let optionName = util/* default */.Z.unicodeToAscii(item.name).toLowerCase().replace(/ /g, '');
|
|
3577
|
+
let optionDesc = util/* default */.Z.unicodeToAscii(item.desc).toLowerCase().replace(/ /g, '');
|
|
3578
|
+
let searchValue = util/* default */.Z.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g, '');
|
|
3579
3579
|
return optionName.indexOf(searchValue) != -1 || optionDesc.indexOf(searchValue) != -1;
|
|
3580
3580
|
});
|
|
3581
3581
|
}
|
|
@@ -3634,7 +3634,7 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3634
3634
|
focusFilter() {
|
|
3635
3635
|
if (!this.filterRef.current) return;
|
|
3636
3636
|
this.filterRef.current.focus();
|
|
3637
|
-
util/* default
|
|
3637
|
+
util/* default */.Z.setTimeout(() => {
|
|
3638
3638
|
if (!this.filterRef.current) return;
|
|
3639
3639
|
this.filterRef.current.focus();
|
|
3640
3640
|
}, 100);
|
|
@@ -3642,7 +3642,7 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3642
3642
|
renderDropdown() {
|
|
3643
3643
|
if (!this.state.show) return null;
|
|
3644
3644
|
let items = this.getFilteredOptions();
|
|
3645
|
-
let $items = util/* default
|
|
3645
|
+
let $items = util/* default */.Z.map(items, item => {
|
|
3646
3646
|
return (0,preact_module.h)("div", {
|
|
3647
3647
|
class: "dropdown_select__item",
|
|
3648
3648
|
onClick: _ => this.onSelect(item)
|
|
@@ -3703,10 +3703,10 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3703
3703
|
class: "muted text-truncate",
|
|
3704
3704
|
style: "flex: 1 !important;"
|
|
3705
3705
|
}, "Ch\u1ECDn m\u1ED9t ph\u1EA7n t\u1EED");
|
|
3706
|
-
if (util/* default
|
|
3706
|
+
if (util/* default */.Z.get(this.props, 'selected.name')) $name = (0,preact_module.h)("div", {
|
|
3707
3707
|
class: "text-truncate",
|
|
3708
3708
|
style: "flex: 1 !important;"
|
|
3709
|
-
}, util/* default
|
|
3709
|
+
}, util/* default */.Z.get(this.props, 'selected.name'));
|
|
3710
3710
|
let style = 'position: relative !important;';
|
|
3711
3711
|
if (this.props.full) {
|
|
3712
3712
|
style = '';
|
|
@@ -3727,8 +3727,8 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3727
3727
|
}
|
|
3728
3728
|
;// CONCATENATED MODULE: ./src/order/address_picker.js
|
|
3729
3729
|
function address_picker_defineProperty(obj, key, value) { key = address_picker_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3730
|
-
function address_picker_toPropertyKey(
|
|
3731
|
-
function address_picker_toPrimitive(
|
|
3730
|
+
function address_picker_toPropertyKey(t) { var i = address_picker_toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
3731
|
+
function address_picker_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
3732
3732
|
|
|
3733
3733
|
|
|
3734
3734
|
|
|
@@ -3766,13 +3766,13 @@ class AddressPicker extends common/* Com */.up {
|
|
|
3766
3766
|
}
|
|
3767
3767
|
if (e.key == 'Enter') {}
|
|
3768
3768
|
});
|
|
3769
|
-
address_picker_defineProperty(this, "doSearch", util/* default
|
|
3769
|
+
address_picker_defineProperty(this, "doSearch", util/* default */.Z.throttle(async () => {
|
|
3770
3770
|
let requestId = Date.now();
|
|
3771
3771
|
this.requestId = requestId;
|
|
3772
3772
|
let res = await this.props.store.suggest_addresses(this.state.searchValue);
|
|
3773
3773
|
if (this.requestId !== requestId) return;
|
|
3774
3774
|
this.setState({
|
|
3775
|
-
addresses: util/* default
|
|
3775
|
+
addresses: util/* default */.Z.get(res, 'body.addresses', [])
|
|
3776
3776
|
});
|
|
3777
3777
|
}, 100));
|
|
3778
3778
|
address_picker_defineProperty(this, "onChangeSearchValue", e => {
|
|
@@ -3829,14 +3829,14 @@ class AddressPicker extends common/* Com */.up {
|
|
|
3829
3829
|
focusFilter() {
|
|
3830
3830
|
if (!this.filterRef.current) return;
|
|
3831
3831
|
this.filterRef.current.focus();
|
|
3832
|
-
util/* default
|
|
3832
|
+
util/* default */.Z.setTimeout(() => {
|
|
3833
3833
|
if (!this.filterRef.current) return;
|
|
3834
3834
|
this.filterRef.current.focus();
|
|
3835
3835
|
}, 100);
|
|
3836
3836
|
}
|
|
3837
3837
|
renderDropdown() {
|
|
3838
3838
|
if (!this.state.show) return null;
|
|
3839
|
-
let $items = util/* default
|
|
3839
|
+
let $items = util/* default */.Z.map(this.state.addresses, (addr, i) => {
|
|
3840
3840
|
let label = [((addr.address || '') + ' ' + normalize(addr.street)).trim()].join(', ');
|
|
3841
3841
|
let desc = [normalize(addr.ward), normalize(addr.district), normalize(addr.province)].join(', ');
|
|
3842
3842
|
return (0,preact_module.h)("div", {
|
|
@@ -3938,7 +3938,7 @@ var $link = document.createElement('link');
|
|
|
3938
3938
|
$link.href = 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap';
|
|
3939
3939
|
$link.rel = 'stylesheet';
|
|
3940
3940
|
document.head.append($link);
|
|
3941
|
-
util/* default
|
|
3941
|
+
util/* default */.Z.preloadWebfonts(['Roboto'], [400, 500]);
|
|
3942
3942
|
|
|
3943
3943
|
let icon_defaultAvatar = __webpack_require__(4761);
|
|
3944
3944
|
|
|
@@ -3970,8 +3970,8 @@ class Icon extends common/* Com */.up {
|
|
|
3970
3970
|
}
|
|
3971
3971
|
;// CONCATENATED MODULE: ./src/order/order.js
|
|
3972
3972
|
function order_defineProperty(obj, key, value) { key = order_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3973
|
-
function order_toPropertyKey(
|
|
3974
|
-
function order_toPrimitive(
|
|
3973
|
+
function order_toPropertyKey(t) { var i = order_toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
3974
|
+
function order_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
3975
3975
|
|
|
3976
3976
|
|
|
3977
3977
|
|
|
@@ -4045,7 +4045,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4045
4045
|
loadDistrict: false
|
|
4046
4046
|
});
|
|
4047
4047
|
if (!out.error) this.setState({
|
|
4048
|
-
districts: util/* default
|
|
4048
|
+
districts: util/* default */.Z.get(out, 'body.addresses')
|
|
4049
4049
|
});
|
|
4050
4050
|
});
|
|
4051
4051
|
order_defineProperty(this, "onSelectDistrict", async item => {
|
|
@@ -4064,7 +4064,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4064
4064
|
loadWard: false
|
|
4065
4065
|
});
|
|
4066
4066
|
if (!out.error) this.setState({
|
|
4067
|
-
wards: util/* default
|
|
4067
|
+
wards: util/* default */.Z.get(out, 'body.addresses')
|
|
4068
4068
|
});
|
|
4069
4069
|
});
|
|
4070
4070
|
order_defineProperty(this, "onSelectWard", item => this.setState({
|
|
@@ -4085,7 +4085,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4085
4085
|
order_defineProperty(this, "onSelectAddress", addr => {
|
|
4086
4086
|
if (!addr) return;
|
|
4087
4087
|
this.setState({
|
|
4088
|
-
address: [util/* default
|
|
4088
|
+
address: [util/* default */.Z.trim(addr.address), util/* default */.Z.trim(addr.street)].join(' ').trim(),
|
|
4089
4089
|
street: addr.street,
|
|
4090
4090
|
err: {},
|
|
4091
4091
|
g_err: ''
|
|
@@ -4132,36 +4132,36 @@ class order_Order extends common/* Com */.up {
|
|
|
4132
4132
|
});
|
|
4133
4133
|
}
|
|
4134
4134
|
if (this.state.shipping === 'shop') {
|
|
4135
|
-
if (!util/* default
|
|
4135
|
+
if (!util/* default */.Z.isPhone(this.state.phone)) {
|
|
4136
4136
|
err.phone = true;
|
|
4137
4137
|
}
|
|
4138
|
-
if (!util/* default
|
|
4138
|
+
if (!util/* default */.Z.trim(this.state.fullname)) {
|
|
4139
4139
|
err.name = true;
|
|
4140
4140
|
}
|
|
4141
|
-
if (!util/* default
|
|
4141
|
+
if (!util/* default */.Z.trim(this.state.email)) {
|
|
4142
4142
|
err.email = true;
|
|
4143
4143
|
}
|
|
4144
4144
|
} else if (this.state.shipping_address == 'new') {
|
|
4145
|
-
if (!util/* default
|
|
4145
|
+
if (!util/* default */.Z.isPhone(this.state.phone)) {
|
|
4146
4146
|
err.phone = true;
|
|
4147
4147
|
}
|
|
4148
|
-
if (!util/* default
|
|
4148
|
+
if (!util/* default */.Z.trim(this.state.fullname)) {
|
|
4149
4149
|
err.name = true;
|
|
4150
4150
|
}
|
|
4151
|
-
if (!util/* default
|
|
4151
|
+
if (!util/* default */.Z.trim(this.state.address)) {
|
|
4152
4152
|
err.address = true;
|
|
4153
4153
|
}
|
|
4154
|
-
if (util/* default
|
|
4154
|
+
if (util/* default */.Z.size(this.state.selectedWard) == 0) {
|
|
4155
4155
|
err.ward = true;
|
|
4156
4156
|
}
|
|
4157
|
-
if (util/* default
|
|
4157
|
+
if (util/* default */.Z.size(this.state.selectedDistrict) == 0) {
|
|
4158
4158
|
err.district = true;
|
|
4159
4159
|
}
|
|
4160
|
-
if (util/* default
|
|
4160
|
+
if (util/* default */.Z.size(this.state.selectedProvince) == 0) {
|
|
4161
4161
|
err.province = true;
|
|
4162
4162
|
}
|
|
4163
4163
|
}
|
|
4164
|
-
if (util/* default
|
|
4164
|
+
if (util/* default */.Z.size(err) > 0) {
|
|
4165
4165
|
this.setState({
|
|
4166
4166
|
err,
|
|
4167
4167
|
g_err: this.props.t('input_shipping_info_err')
|
|
@@ -4169,15 +4169,15 @@ class order_Order extends common/* Com */.up {
|
|
|
4169
4169
|
return;
|
|
4170
4170
|
}
|
|
4171
4171
|
let user = this.props.store.matchUser();
|
|
4172
|
-
let ufullname = util/* default
|
|
4173
|
-
let uemail = util/* default
|
|
4174
|
-
let uphone = util/* default
|
|
4175
|
-
let order = util/* default
|
|
4172
|
+
let ufullname = util/* default */.Z.getUserAttr(user, 'fullname', 'text');
|
|
4173
|
+
let uemail = util/* default */.Z.getUserAttr(user, 'emails', 'text');
|
|
4174
|
+
let uphone = util/* default */.Z.getUserAttr(user, 'phones', 'text');
|
|
4175
|
+
let order = util/* default */.Z.cloneDeep(this.state.order);
|
|
4176
4176
|
if (this.state.shipping === 'shop') {
|
|
4177
|
-
util/* default
|
|
4178
|
-
util/* default
|
|
4179
|
-
util/* default
|
|
4180
|
-
util/* default
|
|
4177
|
+
util/* default */.Z.set(order, 'shipping.pickup_at_shop', true);
|
|
4178
|
+
util/* default */.Z.set(order, 'shipping.address.phone', this.state.phone);
|
|
4179
|
+
util/* default */.Z.set(order, 'shipping.address.fullname', this.state.fullname);
|
|
4180
|
+
util/* default */.Z.set(order, 'shipping.address.email', this.state.email);
|
|
4181
4181
|
} else {
|
|
4182
4182
|
if (this.state.shipping_address == 'new') {
|
|
4183
4183
|
let out = await this.props.store.createShippingAddress({
|
|
@@ -4197,37 +4197,37 @@ class order_Order extends common/* Com */.up {
|
|
|
4197
4197
|
if (out.error) return this.setState({
|
|
4198
4198
|
g_err: this.props.t('update_failed')
|
|
4199
4199
|
});
|
|
4200
|
-
util/* default
|
|
4200
|
+
util/* default */.Z.set(order, 'shipping.address', out.body);
|
|
4201
4201
|
} else {
|
|
4202
4202
|
let addresses = this.props.store.matchShippingAddresses();
|
|
4203
|
-
let sa = util/* default
|
|
4203
|
+
let sa = util/* default */.Z.find(addresses, addr => addr.id === this.state.shipping_address);
|
|
4204
4204
|
if (!sa) {
|
|
4205
4205
|
return this.setState({
|
|
4206
4206
|
err,
|
|
4207
4207
|
g_err: this.props.t('input_shipping_info_err')
|
|
4208
4208
|
});
|
|
4209
4209
|
}
|
|
4210
|
-
util/* default
|
|
4210
|
+
util/* default */.Z.set(order, 'shipping.address', sa);
|
|
4211
4211
|
}
|
|
4212
4212
|
}
|
|
4213
4213
|
let changeduser = false;
|
|
4214
4214
|
if (!ufullname && this.state.fullname) {
|
|
4215
4215
|
changeduser = true;
|
|
4216
|
-
util/* default
|
|
4216
|
+
util/* default */.Z.setUserAttr(user, {
|
|
4217
4217
|
key: 'fullname',
|
|
4218
4218
|
text: this.state.fullname
|
|
4219
4219
|
});
|
|
4220
4220
|
}
|
|
4221
4221
|
if (!uemail && this.state.email) {
|
|
4222
4222
|
changeduser = true;
|
|
4223
|
-
util/* default
|
|
4223
|
+
util/* default */.Z.setUserAttr(user, {
|
|
4224
4224
|
key: 'emails',
|
|
4225
4225
|
text: this.state.email
|
|
4226
4226
|
});
|
|
4227
4227
|
}
|
|
4228
4228
|
if (!uphone && this.state.phone) {
|
|
4229
4229
|
changeduser = true;
|
|
4230
|
-
util/* default
|
|
4230
|
+
util/* default */.Z.setUserAttr(user, {
|
|
4231
4231
|
key: 'phones',
|
|
4232
4232
|
text: this.state.phone
|
|
4233
4233
|
});
|
|
@@ -4254,7 +4254,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4254
4254
|
order_defineProperty(this, "onCancel", () => {
|
|
4255
4255
|
if (this.props.onResponse) this.props.onResponse('rejected');
|
|
4256
4256
|
if (this.props.cid && !this.state.order.user_confirmation) {
|
|
4257
|
-
let order = util/* default
|
|
4257
|
+
let order = util/* default */.Z.cloneDeep(this.state.order);
|
|
4258
4258
|
order.user_confirmation = 'rejected';
|
|
4259
4259
|
this.props.store.updateOrder(order);
|
|
4260
4260
|
}
|
|
@@ -4281,10 +4281,10 @@ class order_Order extends common/* Com */.up {
|
|
|
4281
4281
|
});
|
|
4282
4282
|
}
|
|
4283
4283
|
let user = this.props.store.matchUser();
|
|
4284
|
-
let attributes = util/* default
|
|
4285
|
-
let fullname = util/* default
|
|
4286
|
-
let email = util/* default
|
|
4287
|
-
let phone = util/* default
|
|
4284
|
+
let attributes = util/* default */.Z.get(this.props.store.matchUser(), 'attributes', []);
|
|
4285
|
+
let fullname = util/* default */.Z.get(util/* default */.Z.find(attributes, att => att.key === 'fullname'), 'text');
|
|
4286
|
+
let email = util/* default */.Z.get(util/* default */.Z.find(attributes, att => att.key === 'emails'), 'text');
|
|
4287
|
+
let phone = util/* default */.Z.get(util/* default */.Z.find(attributes, att => att.key === 'phones'), 'text');
|
|
4288
4288
|
this.setState({
|
|
4289
4289
|
fullname,
|
|
4290
4290
|
email,
|
|
@@ -4296,7 +4296,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4296
4296
|
loadProvince: false
|
|
4297
4297
|
});
|
|
4298
4298
|
if (!out.error) this.setState({
|
|
4299
|
-
provinces: util/* default
|
|
4299
|
+
provinces: util/* default */.Z.get(out, 'body.addresses')
|
|
4300
4300
|
});
|
|
4301
4301
|
}
|
|
4302
4302
|
isMobile() {
|
|
@@ -4326,7 +4326,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4326
4326
|
}
|
|
4327
4327
|
if (editmode) {
|
|
4328
4328
|
let pms = this.props.store.matchPaymentMethods();
|
|
4329
|
-
let $pms = util/* default
|
|
4329
|
+
let $pms = util/* default */.Z.map(pms, pm => {
|
|
4330
4330
|
let $name = pm.description;
|
|
4331
4331
|
if (pm.method == 'bank_transfer') {
|
|
4332
4332
|
$name = pm.description + ' ' + pm.bank_name + ' ' + pm.bank_branch;
|
|
@@ -4407,15 +4407,15 @@ class order_Order extends common/* Com */.up {
|
|
|
4407
4407
|
let user = this.props.store.matchUser();
|
|
4408
4408
|
if (editmode) {
|
|
4409
4409
|
let addresses = this.props.store.matchShippingAddresses();
|
|
4410
|
-
let provinces = util/* default
|
|
4410
|
+
let provinces = util/* default */.Z.map(this.state.provinces, province => ({
|
|
4411
4411
|
id: province.id,
|
|
4412
4412
|
name: province.province
|
|
4413
4413
|
}));
|
|
4414
|
-
let districts = util/* default
|
|
4414
|
+
let districts = util/* default */.Z.map(this.state.districts, district => ({
|
|
4415
4415
|
id: district.id,
|
|
4416
4416
|
name: district.district
|
|
4417
4417
|
}));
|
|
4418
|
-
let wards = util/* default
|
|
4418
|
+
let wards = util/* default */.Z.map(this.state.wards, ward => ({
|
|
4419
4419
|
id: ward.id,
|
|
4420
4420
|
name: ward.ward
|
|
4421
4421
|
}));
|
|
@@ -4424,7 +4424,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4424
4424
|
let ship_icon_active = false;
|
|
4425
4425
|
if (this.state.shipping === 'ship') {
|
|
4426
4426
|
ship_icon_active = true;
|
|
4427
|
-
let $preaddrs = util/* default
|
|
4427
|
+
let $preaddrs = util/* default */.Z.map(addresses, addr => {
|
|
4428
4428
|
let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
|
|
4429
4429
|
let $phone = null;
|
|
4430
4430
|
if (addr.phone) {
|
|
@@ -4556,7 +4556,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4556
4556
|
style: "flex: 1 !important; margin-left: 7px !important;"
|
|
4557
4557
|
})));
|
|
4558
4558
|
cls += ' ship_card__active';
|
|
4559
|
-
if (util/* default
|
|
4559
|
+
if (util/* default */.Z.size(addresses) == 0) {
|
|
4560
4560
|
$body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
4561
4561
|
class: 'mt-3 mb-2 '
|
|
4562
4562
|
}, this.props.t('input_shipping_info')), $new);
|
|
@@ -4634,13 +4634,13 @@ class order_Order extends common/* Com */.up {
|
|
|
4634
4634
|
class: "ml-2"
|
|
4635
4635
|
}, "Giao h\xE0ng cho t\xF4i"))), $body));
|
|
4636
4636
|
}
|
|
4637
|
-
let addr = util/* default
|
|
4637
|
+
let addr = util/* default */.Z.get(order, 'shipping.address') || {};
|
|
4638
4638
|
let fulladdr = [addr.address, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
|
|
4639
4639
|
let $phone = null;
|
|
4640
4640
|
if (addr.phone) $phone = (0,preact_module.h)("div", {
|
|
4641
4641
|
class: "mt-1 muted"
|
|
4642
4642
|
}, this.props.t('phn'), ":\xA0", addr.phone);
|
|
4643
|
-
if (util/* default
|
|
4643
|
+
if (util/* default */.Z.get(order, 'shipping.pickup_at_shop')) {
|
|
4644
4644
|
fulladdr = 'Nhận hàng tại cửa hàng';
|
|
4645
4645
|
}
|
|
4646
4646
|
let $addr = fulladdr ? (0,preact_module.h)("div", null, fulladdr) : (0,preact_module.h)("i", {
|
|
@@ -4659,28 +4659,28 @@ class order_Order extends common/* Com */.up {
|
|
|
4659
4659
|
if (order.deposit > 0) {
|
|
4660
4660
|
$deposit = (0,preact_module.h)("span", {
|
|
4661
4661
|
class: "muted"
|
|
4662
|
-
}, "(c\u1ECDc ", util/* default
|
|
4662
|
+
}, "(c\u1ECDc ", util/* default */.Z.formatCurrency(order.deposit), ")");
|
|
4663
4663
|
}
|
|
4664
4664
|
let $discount = null;
|
|
4665
4665
|
if (order.total_discount > 0) {
|
|
4666
4666
|
$discount = (0,preact_module.h)("div", {
|
|
4667
4667
|
class: "order_summary_line"
|
|
4668
|
-
}, (0,preact_module.h)("div", null, "Gi\u1EA3m gi\xE1"), (0,preact_module.h)("div", null, util/* default
|
|
4668
|
+
}, (0,preact_module.h)("div", null, "Gi\u1EA3m gi\xE1"), (0,preact_module.h)("div", null, util/* default */.Z.formatCurrency(order.total_discount)));
|
|
4669
4669
|
}
|
|
4670
4670
|
let $pay = null;
|
|
4671
4671
|
if ($deposit || order.payment_made) {
|
|
4672
4672
|
$pay = (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
|
|
4673
4673
|
class: "order_summary_line"
|
|
4674
|
-
}, (0,preact_module.h)("div", null, "B\u1EA1n \u0111\xE3 tr\u1EA3"), (0,preact_module.h)("div", null, $deposit, " ", util/* default
|
|
4674
|
+
}, (0,preact_module.h)("div", null, "B\u1EA1n \u0111\xE3 tr\u1EA3"), (0,preact_module.h)("div", null, $deposit, " ", util/* default */.Z.formatCurrency(order.payment_made))), (0,preact_module.h)("div", {
|
|
4675
4675
|
class: "order_summary_line"
|
|
4676
|
-
}, (0,preact_module.h)("div", null, "B\u1EA1n ch\u01B0a tr\u1EA3"), (0,preact_module.h)("div", null, util/* default
|
|
4676
|
+
}, (0,preact_module.h)("div", null, "B\u1EA1n ch\u01B0a tr\u1EA3"), (0,preact_module.h)("div", null, util/* default */.Z.formatCurrency((order.total || 0) - (order.payment_made || 0)))));
|
|
4677
4677
|
}
|
|
4678
4678
|
let $tax = (0,preact_module.h)("div", {
|
|
4679
4679
|
class: "order_summary_line"
|
|
4680
|
-
}, (0,preact_module.h)("div", null, "Ti\u1EC1n thu\u1EBF"), (0,preact_module.h)("div", null, util/* default
|
|
4680
|
+
}, (0,preact_module.h)("div", null, "Ti\u1EC1n thu\u1EBF"), (0,preact_module.h)("div", null, util/* default */.Z.formatCurrency(order.total_tax)));
|
|
4681
4681
|
let $ship = (0,preact_module.h)("div", {
|
|
4682
4682
|
class: "order_summary_line"
|
|
4683
|
-
}, (0,preact_module.h)("div", null, "Ph\xED v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", null, util/* default
|
|
4683
|
+
}, (0,preact_module.h)("div", null, "Ph\xED v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", null, util/* default */.Z.get(order, 'shipping.fee', 0), " d"));
|
|
4684
4684
|
let editmode = false;
|
|
4685
4685
|
if (!order.status || order.status == 'open') {
|
|
4686
4686
|
editmode = !order.user_confirmation;
|
|
@@ -4706,12 +4706,12 @@ class order_Order extends common/* Com */.up {
|
|
|
4706
4706
|
class: "order_label"
|
|
4707
4707
|
}, "T\xF3m t\u1EAFt"), (0,preact_module.h)("div", {
|
|
4708
4708
|
class: "order_summary_line"
|
|
4709
|
-
}, (0,preact_module.h)("div", null, "T\u1ED5ng ti\u1EC1n h\xE0ng"), (0,preact_module.h)("div", null, util/* default
|
|
4709
|
+
}, (0,preact_module.h)("div", null, "T\u1ED5ng ti\u1EC1n h\xE0ng"), (0,preact_module.h)("div", null, util/* default */.Z.formatCurrency(order.subtotal))), $tax, $discount, $ship, $note, (0,preact_module.h)("div", {
|
|
4710
4710
|
class: "order_summary_line",
|
|
4711
4711
|
style: "margin-top: 10px !important; padding-top: 15px !important; border-top: 1px solid #eee !important"
|
|
4712
4712
|
}, (0,preact_module.h)("div", null, "B\u1EA1n ph\u1EA3i tr\u1EA3"), (0,preact_module.h)("div", {
|
|
4713
4713
|
class: "order__total"
|
|
4714
|
-
}, util/* default
|
|
4714
|
+
}, util/* default */.Z.formatCurrency(order.total))), $pay));
|
|
4715
4715
|
}
|
|
4716
4716
|
renderStatusBadge(order) {
|
|
4717
4717
|
let status = order.status || 'open';
|
|
@@ -4722,9 +4722,9 @@ class order_Order extends common/* Com */.up {
|
|
|
4722
4722
|
}
|
|
4723
4723
|
renderShippingInfo(order) {
|
|
4724
4724
|
if (order.status != 'open' || order.user_confirmation) {}
|
|
4725
|
-
let shipping_provider = util/* default
|
|
4725
|
+
let shipping_provider = util/* default */.Z.get(order, 'shipping.shipping_provider');
|
|
4726
4726
|
if (!shipping_provider) return null;
|
|
4727
|
-
let shipping_code = util/* default
|
|
4727
|
+
let shipping_code = util/* default */.Z.get(order, 'shipping.shipping_code');
|
|
4728
4728
|
let $tracking_code = null;
|
|
4729
4729
|
if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
|
|
4730
4730
|
class: "muted",
|
|
@@ -4752,9 +4752,9 @@ class order_Order extends common/* Com */.up {
|
|
|
4752
4752
|
return null;
|
|
4753
4753
|
}
|
|
4754
4754
|
renderDesktopShippingInfo(order) {
|
|
4755
|
-
let shipping_provider = util/* default
|
|
4755
|
+
let shipping_provider = util/* default */.Z.get(order, 'shipping.shipping_provider');
|
|
4756
4756
|
if (!shipping_provider) return null;
|
|
4757
|
-
let shipping_code = util/* default
|
|
4757
|
+
let shipping_code = util/* default */.Z.get(order, 'shipping.shipping_code');
|
|
4758
4758
|
let $tracking_code = null;
|
|
4759
4759
|
if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
|
|
4760
4760
|
class: "muted",
|
|
@@ -4781,7 +4781,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4781
4781
|
}
|
|
4782
4782
|
renderProducts(order) {
|
|
4783
4783
|
let $products = null;
|
|
4784
|
-
$products = util/* default
|
|
4784
|
+
$products = util/* default */.Z.map(order.items, item => {
|
|
4785
4785
|
if (!item || !item.product) return null;
|
|
4786
4786
|
let product = item.product;
|
|
4787
4787
|
return (0,preact_module.h)("div", {
|
|
@@ -4789,7 +4789,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4789
4789
|
}, (0,preact_module.h)("img", {
|
|
4790
4790
|
class: "order_attachment__product_img",
|
|
4791
4791
|
alt: '' + product.id,
|
|
4792
|
-
src: util/* default
|
|
4792
|
+
src: util/* default */.Z.get(product, 'images.0') || __webpack_require__(9270)
|
|
4793
4793
|
}), (0,preact_module.h)("div", {
|
|
4794
4794
|
style: "overflow: hidden !important;"
|
|
4795
4795
|
}, (0,preact_module.h)("div", {
|
|
@@ -4798,7 +4798,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4798
4798
|
class: "order_attachment__product_desc"
|
|
4799
4799
|
}, product.description || product.long_description), (0,preact_module.h)("div", {
|
|
4800
4800
|
class: "order_attachment__product_desc"
|
|
4801
|
-
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default
|
|
4801
|
+
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default */.Z.formatCurrency(product.price))));
|
|
4802
4802
|
});
|
|
4803
4803
|
if (!this.isMobile()) return (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
4804
4804
|
class: "order_label"
|
|
@@ -4816,7 +4816,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4816
4816
|
editmode = !order.user_confirmation;
|
|
4817
4817
|
}
|
|
4818
4818
|
if (editmode) {
|
|
4819
|
-
$products = util/* default
|
|
4819
|
+
$products = util/* default */.Z.map(order.items, item => {
|
|
4820
4820
|
if (!item || !item.product) return null;
|
|
4821
4821
|
let product = item.product;
|
|
4822
4822
|
return (0,preact_module.h)("div", {
|
|
@@ -4824,7 +4824,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4824
4824
|
}, (0,preact_module.h)("img", {
|
|
4825
4825
|
class: "order_attachment__product_img",
|
|
4826
4826
|
alt: '' + product.id,
|
|
4827
|
-
src: util/* default
|
|
4827
|
+
src: util/* default */.Z.get(product, 'images.0') || __webpack_require__(9270)
|
|
4828
4828
|
}), (0,preact_module.h)("div", {
|
|
4829
4829
|
style: "overflow: hidden !important; flex: 1 !important"
|
|
4830
4830
|
}, (0,preact_module.h)("div", {
|
|
@@ -4833,7 +4833,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4833
4833
|
class: "order_attachment__product_desc"
|
|
4834
4834
|
}, product.description || product.long_description), (0,preact_module.h)("div", {
|
|
4835
4835
|
class: "order_attachment__product_desc"
|
|
4836
|
-
}, util/* default
|
|
4836
|
+
}, util/* default */.Z.formatCurrency(product.price))), (0,preact_module.h)("input", {
|
|
4837
4837
|
class: "form-control",
|
|
4838
4838
|
style: "text-align: center !important; font-weight: 400 !important; width: 50px !important",
|
|
4839
4839
|
value: item.quantity,
|
|
@@ -4841,10 +4841,10 @@ class order_Order extends common/* Com */.up {
|
|
|
4841
4841
|
type: "text"
|
|
4842
4842
|
}), (0,preact_module.h)("div", {
|
|
4843
4843
|
style: "width: 80px !important; text-align: right !important; "
|
|
4844
|
-
}, (0,preact_module.h)("b", null, util/* default
|
|
4844
|
+
}, (0,preact_module.h)("b", null, util/* default */.Z.formatCurrency(item.quantity * product.price))));
|
|
4845
4845
|
});
|
|
4846
4846
|
} else {
|
|
4847
|
-
$products = util/* default
|
|
4847
|
+
$products = util/* default */.Z.map(order.items, item => {
|
|
4848
4848
|
if (!item || !item.product) return null;
|
|
4849
4849
|
let product = item.product;
|
|
4850
4850
|
return (0,preact_module.h)("div", {
|
|
@@ -4852,7 +4852,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4852
4852
|
}, (0,preact_module.h)("img", {
|
|
4853
4853
|
class: "order_attachment__product_img",
|
|
4854
4854
|
alt: '' + product.id,
|
|
4855
|
-
src: util/* default
|
|
4855
|
+
src: util/* default */.Z.get(product, 'images.0') || __webpack_require__(9270)
|
|
4856
4856
|
}), (0,preact_module.h)("div", {
|
|
4857
4857
|
style: "overflow: hidden !important; flex: 1 !important"
|
|
4858
4858
|
}, (0,preact_module.h)("div", {
|
|
@@ -4861,11 +4861,11 @@ class order_Order extends common/* Com */.up {
|
|
|
4861
4861
|
class: "order_attachment__product_desc"
|
|
4862
4862
|
}, product.description || product.long_description), (0,preact_module.h)("div", {
|
|
4863
4863
|
class: "order_attachment__product_desc"
|
|
4864
|
-
}, util/* default
|
|
4864
|
+
}, util/* default */.Z.formatCurrency(product.price))), (0,preact_module.h)("div", {
|
|
4865
4865
|
style: "text-align: center !important; font-weight: 400 !important; width: 50px !important"
|
|
4866
4866
|
}, item.quantity), (0,preact_module.h)("div", {
|
|
4867
4867
|
style: "width: 80px !important; text-align: right !important; "
|
|
4868
|
-
}, (0,preact_module.h)("b", null, util/* default
|
|
4868
|
+
}, (0,preact_module.h)("b", null, util/* default */.Z.formatCurrency(item.total))));
|
|
4869
4869
|
});
|
|
4870
4870
|
}
|
|
4871
4871
|
return (0,preact_module.h)("div", {
|
|
@@ -5040,8 +5040,8 @@ let ShippingProvider = {
|
|
|
5040
5040
|
};
|
|
5041
5041
|
;// CONCATENATED MODULE: ./src/chatbox/Order.js
|
|
5042
5042
|
function Order_defineProperty(obj, key, value) { key = Order_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5043
|
-
function Order_toPropertyKey(
|
|
5044
|
-
function Order_toPrimitive(
|
|
5043
|
+
function Order_toPropertyKey(t) { var i = Order_toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
5044
|
+
function Order_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
5045
5045
|
|
|
5046
5046
|
|
|
5047
5047
|
|
|
@@ -5083,7 +5083,7 @@ class Order extends common/* Com */.up {
|
|
|
5083
5083
|
});
|
|
5084
5084
|
});
|
|
5085
5085
|
Order_defineProperty(this, "close", async () => {
|
|
5086
|
-
await util/* default
|
|
5086
|
+
await util/* default */.Z.sleep(100);
|
|
5087
5087
|
if (this.state.response === 'confirmed') {
|
|
5088
5088
|
this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
|
|
5089
5089
|
message: {
|
|
@@ -5184,7 +5184,7 @@ class Order extends common/* Com */.up {
|
|
|
5184
5184
|
render() {
|
|
5185
5185
|
if (this._show != this.props.show) {
|
|
5186
5186
|
this._show = this.props.show;
|
|
5187
|
-
util/* default
|
|
5187
|
+
util/* default */.Z.setTimeout(() => {
|
|
5188
5188
|
if (!this._show) this.close();else this.open();
|
|
5189
5189
|
});
|
|
5190
5190
|
}
|
|
@@ -5285,8 +5285,8 @@ class Order extends common/* Com */.up {
|
|
|
5285
5285
|
}
|
|
5286
5286
|
;// CONCATENATED MODULE: ./src/chatbox/Widget.js
|
|
5287
5287
|
function Widget_defineProperty(obj, key, value) { key = Widget_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5288
|
-
function Widget_toPropertyKey(
|
|
5289
|
-
function Widget_toPrimitive(
|
|
5288
|
+
function Widget_toPropertyKey(t) { var i = Widget_toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
5289
|
+
function Widget_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
5290
5290
|
|
|
5291
5291
|
|
|
5292
5292
|
|
|
@@ -5311,7 +5311,7 @@ class Widget extends common/* Com */.up {
|
|
|
5311
5311
|
super(props);
|
|
5312
5312
|
Widget_defineProperty(this, "msgInput", (0,preact_module/* createRef */.Vf)());
|
|
5313
5313
|
Widget_defineProperty(this, "sendMessage", async message => {
|
|
5314
|
-
let hasPostback = util/* default
|
|
5314
|
+
let hasPostback = util/* default */.Z.find(message.attachments, att => att.type === 'postback');
|
|
5315
5315
|
if (this.isFormRequired() && hasPostback) {
|
|
5316
5316
|
this.onStartConvoClick();
|
|
5317
5317
|
this.fillQuickReplyToQuestion(message);
|
|
@@ -5390,7 +5390,7 @@ class Widget extends common/* Com */.up {
|
|
|
5390
5390
|
clickedJoin: false,
|
|
5391
5391
|
quickReplyMessage: {}
|
|
5392
5392
|
});
|
|
5393
|
-
util/* default
|
|
5393
|
+
util/* default */.Z.setTimeout(() => {
|
|
5394
5394
|
this.events && this.events.focus();
|
|
5395
5395
|
if (!this.props.store.isMobile()) this.focusInput();
|
|
5396
5396
|
}, 100);
|
|
@@ -5401,10 +5401,10 @@ class Widget extends common/* Com */.up {
|
|
|
5401
5401
|
let form;
|
|
5402
5402
|
let accountSetting = this.props.plugin.chatbox || {};
|
|
5403
5403
|
let acc = this.props.store.matchAccount() || {};
|
|
5404
|
-
if (util/* default
|
|
5405
|
-
let offlineEnabled = util/* default
|
|
5404
|
+
if (util/* default */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
5405
|
+
let offlineEnabled = util/* default */.Z.get(accountSetting, 'offline_form.enabled');
|
|
5406
5406
|
if (this.isOffline(acc, accountSetting) && offlineEnabled) form = accountSetting.offline_form;
|
|
5407
|
-
if (!this.hasSentMessage(this.props.cid) && form && (util/* default
|
|
5407
|
+
if (!this.hasSentMessage(this.props.cid) && form && (util/* default */.Z.size(form.groups) || form.group_required)) return true;
|
|
5408
5408
|
let formRequired = this.isFormRequired();
|
|
5409
5409
|
return formRequired && !this.props.cid || formRequired && this.props.cid && this.state.clickedJoin;
|
|
5410
5410
|
}
|
|
@@ -5414,8 +5414,8 @@ class Widget extends common/* Com */.up {
|
|
|
5414
5414
|
let accountSetting = this.props.plugin.chatbox || {};
|
|
5415
5415
|
let acc = this.props.store.matchAccount() || {};
|
|
5416
5416
|
let submitLabel = this.props.t('prechat_form_btn');
|
|
5417
|
-
if (util/* default
|
|
5418
|
-
let offlineEnabled = util/* default
|
|
5417
|
+
if (util/* default */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
5418
|
+
let offlineEnabled = util/* default */.Z.get(accountSetting, 'offline_form.enabled');
|
|
5419
5419
|
if (this.isOffline(acc, accountSetting) && offlineEnabled) {
|
|
5420
5420
|
form = accountSetting.offline_form;
|
|
5421
5421
|
submitLabel = this.props.t('offline_form_btn');
|
|
@@ -5432,9 +5432,10 @@ class Widget extends common/* Com */.up {
|
|
|
5432
5432
|
}
|
|
5433
5433
|
let $body = null;
|
|
5434
5434
|
if (this.props.view === 'list') $body = this.renderConvoList();else if (showform) $body = this.renderForm(form, submitLabel);else $body = this.renderChat();
|
|
5435
|
-
let position = util/* default
|
|
5436
|
-
if (this.props.store.isMobile()) position = util/* default
|
|
5435
|
+
let position = util/* default */.Z.get(accountSetting, 'desktop_button.position') || 'right';
|
|
5436
|
+
if (this.props.store.isMobile()) position = util/* default */.Z.get(accountSetting, 'mobile_button.position', position);
|
|
5437
5437
|
let cls = 'widget-container widget-container--' + position;
|
|
5438
|
+
if (!this.props.store.isMobile() && util/* default */.Z.get(accountSetting, 'window_mode') === 'full') cls += ' widget-container--full';
|
|
5438
5439
|
if (!this.props.isShow) cls += ' widget-container--hide';
|
|
5439
5440
|
return (0,preact_module.h)("div", {
|
|
5440
5441
|
class: cls
|
|
@@ -5452,42 +5453,42 @@ class Widget extends common/* Com */.up {
|
|
|
5452
5453
|
}
|
|
5453
5454
|
async submitPrechatForm(form) {
|
|
5454
5455
|
var hasError = false;
|
|
5455
|
-
util/* default
|
|
5456
|
-
if (field.is_required && (field.value === undefined || field.value === '' || util/* default
|
|
5456
|
+
util/* default */.Z.map(this.state.formData, (field, key) => {
|
|
5457
|
+
if (field.is_required && (field.value === undefined || field.value === '' || util/* default */.Z.size(field.value) === 0 && Array.isArray(field.value))) {
|
|
5457
5458
|
field.error = this.props.t('error_empty');
|
|
5458
5459
|
hasError = true;
|
|
5459
5460
|
} else field.error = '';
|
|
5460
|
-
if (key.substr(5) === 'emails' && !util/* default
|
|
5461
|
+
if (key.substr(5) === 'emails' && !util/* default */.Z.isEmail(field.value) && field.is_required) {
|
|
5461
5462
|
field.error = this.props.t('error_email_invalid');
|
|
5462
5463
|
hasError = true;
|
|
5463
5464
|
}
|
|
5464
|
-
if (key.substr(5) === 'phones' && !util/* default
|
|
5465
|
+
if (key.substr(5) === 'phones' && !util/* default */.Z.isPhone(field.value) && field.is_required) {
|
|
5465
5466
|
field.error = this.props.t('error_phone_invalid');
|
|
5466
5467
|
hasError = true;
|
|
5467
5468
|
}
|
|
5468
5469
|
});
|
|
5469
5470
|
if (hasError) return this.forceUpdate();
|
|
5470
|
-
let data = util/* default
|
|
5471
|
-
let user = util/* default
|
|
5471
|
+
let data = util/* default */.Z.cloneDeep(this.state.formData);
|
|
5472
|
+
let user = util/* default */.Z.cloneDeep(this.props.store.matchUser());
|
|
5472
5473
|
let is_lead = false;
|
|
5473
|
-
util/* default
|
|
5474
|
+
util/* default */.Z.map(data, (field, key) => {
|
|
5474
5475
|
if (!key.startsWith('attr:')) return;
|
|
5475
5476
|
var attr = {
|
|
5476
5477
|
key: key.substr(5)
|
|
5477
5478
|
};
|
|
5478
5479
|
is_lead = is_lead || key == 'emails' || key == 'phones';
|
|
5479
5480
|
if (field.type === 'number') attr.number = parseInt(field.value);
|
|
5480
|
-
if (field.type === 'datetime') attr.datetime = new util/* default
|
|
5481
|
+
if (field.type === 'datetime') attr.datetime = new util/* default */.Z.Date(field.value).toISOString();
|
|
5481
5482
|
if (field.type === 'list') attr.text = field.value;
|
|
5482
5483
|
if (field.type === 'text' || field.type === 'boolean') attr[field.type] = field.value;
|
|
5483
|
-
util/* default
|
|
5484
|
+
util/* default */.Z.setUserAttr(user, attr);
|
|
5484
5485
|
});
|
|
5485
|
-
if (is_lead) util/* default
|
|
5486
|
+
if (is_lead) util/* default */.Z.setUserAttr(user, {
|
|
5486
5487
|
key: 'lead_source',
|
|
5487
5488
|
text: 'widget'
|
|
5488
5489
|
});
|
|
5489
|
-
let firstmsg = util/* default
|
|
5490
|
-
let groupid = util/* default
|
|
5490
|
+
let firstmsg = util/* default */.Z.get(data, 'question.value');
|
|
5491
|
+
let groupid = util/* default */.Z.get(data, 'group.value', '');
|
|
5491
5492
|
if (this.props.cid) {
|
|
5492
5493
|
this.props.store.setUser(user);
|
|
5493
5494
|
this.setState({
|
|
@@ -5499,7 +5500,7 @@ class Widget extends common/* Com */.up {
|
|
|
5499
5500
|
format: 'plaintext',
|
|
5500
5501
|
fields: [{
|
|
5501
5502
|
key: 'to_agent_group',
|
|
5502
|
-
value: util/* default
|
|
5503
|
+
value: util/* default */.Z.stringify(groupid)
|
|
5503
5504
|
}],
|
|
5504
5505
|
attachments: this.state.quickReplyMessage.attachments
|
|
5505
5506
|
}
|
|
@@ -5559,7 +5560,7 @@ class Widget extends common/* Com */.up {
|
|
|
5559
5560
|
formData['question'] = {
|
|
5560
5561
|
key: 'question',
|
|
5561
5562
|
is_required: true,
|
|
5562
|
-
label: this.props.t.i18n(util/* default
|
|
5563
|
+
label: this.props.t.i18n(util/* default */.Z.get(form, `i18n_question_label`, {})) || form.question_label,
|
|
5563
5564
|
type: 'text',
|
|
5564
5565
|
value: this.state.quickReplyMessage.text
|
|
5565
5566
|
};
|
|
@@ -5570,8 +5571,8 @@ class Widget extends common/* Com */.up {
|
|
|
5570
5571
|
}
|
|
5571
5572
|
onBooleanChange(key, e) {
|
|
5572
5573
|
this.wasFormInputed = true;
|
|
5573
|
-
let formData = util/* default
|
|
5574
|
-
let field = util/* default
|
|
5574
|
+
let formData = util/* default */.Z.cloneDeep(this.state.formData);
|
|
5575
|
+
let field = util/* default */.Z.find(formData, (_, fkkey) => fkkey === key);
|
|
5575
5576
|
if (!field) return;
|
|
5576
5577
|
field.value = e.target.checked;
|
|
5577
5578
|
this.setState({
|
|
@@ -5580,8 +5581,8 @@ class Widget extends common/* Com */.up {
|
|
|
5580
5581
|
}
|
|
5581
5582
|
onInputChange(key, val) {
|
|
5582
5583
|
this.wasFormInputed = true;
|
|
5583
|
-
let formData = util/* default
|
|
5584
|
-
let field = util/* default
|
|
5584
|
+
let formData = util/* default */.Z.cloneDeep(this.state.formData);
|
|
5585
|
+
let field = util/* default */.Z.find(formData, (_, fkkey) => fkkey === key);
|
|
5585
5586
|
if (!field) return;
|
|
5586
5587
|
field.value = val;
|
|
5587
5588
|
this.setState({
|
|
@@ -5590,8 +5591,8 @@ class Widget extends common/* Com */.up {
|
|
|
5590
5591
|
}
|
|
5591
5592
|
onListAddItem(key, val) {
|
|
5592
5593
|
this.wasFormInputed = true;
|
|
5593
|
-
let formData = util/* default
|
|
5594
|
-
let field = util/* default
|
|
5594
|
+
let formData = util/* default */.Z.cloneDeep(this.state.formData);
|
|
5595
|
+
let field = util/* default */.Z.find(formData, (_, fkkey) => fkkey === key);
|
|
5595
5596
|
if (!field) return;
|
|
5596
5597
|
field.value = field.value || [];
|
|
5597
5598
|
field.value.push(val);
|
|
@@ -5601,8 +5602,8 @@ class Widget extends common/* Com */.up {
|
|
|
5601
5602
|
}
|
|
5602
5603
|
onListRemoveItem(key, index) {
|
|
5603
5604
|
this.wasFormInputed = true;
|
|
5604
|
-
let formData = util/* default
|
|
5605
|
-
let field = util/* default
|
|
5605
|
+
let formData = util/* default */.Z.cloneDeep(this.state.formData);
|
|
5606
|
+
let field = util/* default */.Z.find(formData, (_, fkkey) => fkkey === key);
|
|
5606
5607
|
if (!field) return;
|
|
5607
5608
|
field.value = field.value || [];
|
|
5608
5609
|
field.value.splice(index, 1);
|
|
@@ -5611,11 +5612,11 @@ class Widget extends common/* Com */.up {
|
|
|
5611
5612
|
});
|
|
5612
5613
|
}
|
|
5613
5614
|
renderCheckboxField(field) {
|
|
5614
|
-
let items = util/* default
|
|
5615
|
+
let items = util/* default */.Z.get(field, 'def.items', []);
|
|
5615
5616
|
let values = [];
|
|
5616
5617
|
let value = field.value || '';
|
|
5617
5618
|
if (value) values = value.split(',');
|
|
5618
|
-
return (0,preact_module.h)("div", null, util/* default
|
|
5619
|
+
return (0,preact_module.h)("div", null, util/* default */.Z.map(items, item => {
|
|
5619
5620
|
return (0,preact_module.h)("div", {
|
|
5620
5621
|
class: "checkbox"
|
|
5621
5622
|
}, (0,preact_module.h)("input", {
|
|
@@ -5633,14 +5634,14 @@ class Widget extends common/* Com */.up {
|
|
|
5633
5634
|
}
|
|
5634
5635
|
toggleCheckboxField(key, v) {
|
|
5635
5636
|
this.wasFormInputed = true;
|
|
5636
|
-
let formData = util/* default
|
|
5637
|
-
let field = util/* default
|
|
5637
|
+
let formData = util/* default */.Z.cloneDeep(this.state.formData);
|
|
5638
|
+
let field = util/* default */.Z.find(formData, (f, fkkey) => f.key === key);
|
|
5638
5639
|
if (!field) return;
|
|
5639
5640
|
let value = field.value || '';
|
|
5640
5641
|
let values = [];
|
|
5641
5642
|
if (value) values = value.split(',');
|
|
5642
5643
|
if (values.includes(v)) {
|
|
5643
|
-
values = util/* default
|
|
5644
|
+
values = util/* default */.Z.filter(values, value => value !== v);
|
|
5644
5645
|
} else {
|
|
5645
5646
|
values.push(v);
|
|
5646
5647
|
}
|
|
@@ -5650,9 +5651,9 @@ class Widget extends common/* Com */.up {
|
|
|
5650
5651
|
});
|
|
5651
5652
|
}
|
|
5652
5653
|
renderRadioField(field) {
|
|
5653
|
-
let items = util/* default
|
|
5654
|
+
let items = util/* default */.Z.get(field, 'def.items', []);
|
|
5654
5655
|
let value = field.value || '';
|
|
5655
|
-
return (0,preact_module.h)("div", null, util/* default
|
|
5656
|
+
return (0,preact_module.h)("div", null, util/* default */.Z.map(items, item => {
|
|
5656
5657
|
return (0,preact_module.h)("div", {
|
|
5657
5658
|
class: "radio"
|
|
5658
5659
|
}, (0,preact_module.h)("input", {
|
|
@@ -5671,8 +5672,8 @@ class Widget extends common/* Com */.up {
|
|
|
5671
5672
|
}
|
|
5672
5673
|
toggleRadioField(key, v) {
|
|
5673
5674
|
this.wasFormInputed = true;
|
|
5674
|
-
let formData = util/* default
|
|
5675
|
-
let field = util/* default
|
|
5675
|
+
let formData = util/* default */.Z.cloneDeep(this.state.formData);
|
|
5676
|
+
let field = util/* default */.Z.find(formData, (f, fkkey) => f.key === key);
|
|
5676
5677
|
if (!field) return;
|
|
5677
5678
|
field.value = v;
|
|
5678
5679
|
this.setState({
|
|
@@ -5681,8 +5682,8 @@ class Widget extends common/* Com */.up {
|
|
|
5681
5682
|
}
|
|
5682
5683
|
selectDropdownField(key, v) {
|
|
5683
5684
|
this.wasFormInputed = true;
|
|
5684
|
-
let formData = util/* default
|
|
5685
|
-
let field = util/* default
|
|
5685
|
+
let formData = util/* default */.Z.cloneDeep(this.state.formData);
|
|
5686
|
+
let field = util/* default */.Z.find(formData, (f, fkkey) => f.key === key);
|
|
5686
5687
|
if (!field) return;
|
|
5687
5688
|
field.value = v;
|
|
5688
5689
|
this.setState({
|
|
@@ -5690,20 +5691,20 @@ class Widget extends common/* Com */.up {
|
|
|
5690
5691
|
});
|
|
5691
5692
|
}
|
|
5692
5693
|
renderDropdownField(field) {
|
|
5693
|
-
let items = util/* default
|
|
5694
|
+
let items = util/* default */.Z.get(field, 'def.items', []);
|
|
5694
5695
|
return (0,preact_module.h)("select", {
|
|
5695
5696
|
class: "form-control",
|
|
5696
5697
|
value: field.value,
|
|
5697
5698
|
onChange: e => this.selectDropdownField(field.key, e.target.value)
|
|
5698
5699
|
}, (0,preact_module.h)("option", {
|
|
5699
5700
|
value: ""
|
|
5700
|
-
}, "-- ", this.props.t('no_select'), " --"), util/* default
|
|
5701
|
+
}, "-- ", this.props.t('no_select'), " --"), util/* default */.Z.map(items, item => (0,preact_module.h)("option", {
|
|
5701
5702
|
value: item.value
|
|
5702
5703
|
}, this.props.t.i18n(item.i18n_label) || item.label || item.value)));
|
|
5703
5704
|
}
|
|
5704
5705
|
renderFields() {
|
|
5705
|
-
if (util/* default
|
|
5706
|
-
let $fields = util/* default
|
|
5706
|
+
if (util/* default */.Z.size(this.state.formData) === 0) return null;
|
|
5707
|
+
let $fields = util/* default */.Z.map(this.state.formData, (field, key) => {
|
|
5707
5708
|
if (this.state.quickReplyMessage.text && key === 'question') return null;
|
|
5708
5709
|
let $field = null;
|
|
5709
5710
|
var errclass = field.error ? 'input--error' : '';
|
|
@@ -5719,13 +5720,13 @@ class Widget extends common/* Com */.up {
|
|
|
5719
5720
|
row: "4",
|
|
5720
5721
|
class: "form-control"
|
|
5721
5722
|
});
|
|
5722
|
-
} else if (util/* default
|
|
5723
|
+
} else if (util/* default */.Z.get(field, 'def.select') === 'checkbox') {
|
|
5723
5724
|
$field = this.renderCheckboxField(field);
|
|
5724
|
-
} else if (util/* default
|
|
5725
|
+
} else if (util/* default */.Z.get(field, 'def.select') === 'radio') {
|
|
5725
5726
|
$field = this.renderRadioField(field);
|
|
5726
|
-
} else if (util/* default
|
|
5727
|
+
} else if (util/* default */.Z.get(field, 'def.select') === 'dropdown') {
|
|
5727
5728
|
$field = this.renderDropdownField(field);
|
|
5728
|
-
} else if (util/* default
|
|
5729
|
+
} else if (util/* default */.Z.get(field, 'def.multiple_line')) {
|
|
5729
5730
|
$field = (0,preact_module.h)("textarea", {
|
|
5730
5731
|
class: "form-control",
|
|
5731
5732
|
ref: ref => {
|
|
@@ -5772,7 +5773,7 @@ class Widget extends common/* Com */.up {
|
|
|
5772
5773
|
class: "checkbox--check"
|
|
5773
5774
|
}, (0,preact_module.h)("div", null)));
|
|
5774
5775
|
} else if (field.type === 'group') {
|
|
5775
|
-
$field = util/* default
|
|
5776
|
+
$field = util/* default */.Z.map(field.list, item => (0,preact_module.h)("div", {
|
|
5776
5777
|
class: "radio"
|
|
5777
5778
|
}, (0,preact_module.h)("input", {
|
|
5778
5779
|
type: "radio",
|
|
@@ -5789,8 +5790,8 @@ class Widget extends common/* Com */.up {
|
|
|
5789
5790
|
}))));
|
|
5790
5791
|
} else if (field.type === 'list') {
|
|
5791
5792
|
let selected = this.state.formData[key].value || [];
|
|
5792
|
-
let items = util/* default
|
|
5793
|
-
return !util/* default
|
|
5793
|
+
let items = util/* default */.Z.filter(util/* default */.Z.get(field, 'list', []), item => {
|
|
5794
|
+
return !util/* default */.Z.includes(selected, item);
|
|
5794
5795
|
});
|
|
5795
5796
|
$field = (0,preact_module.h)(ListField, {
|
|
5796
5797
|
selected: selected,
|
|
@@ -5838,8 +5839,8 @@ class Widget extends common/* Com */.up {
|
|
|
5838
5839
|
size: "16",
|
|
5839
5840
|
mode: "white"
|
|
5840
5841
|
}));
|
|
5841
|
-
let title = this.props.t.i18n(util/* default
|
|
5842
|
-
if (!title) title = util/* default
|
|
5842
|
+
let title = this.props.t.i18n(util/* default */.Z.get(form, `i18n_title`, {}));
|
|
5843
|
+
if (!title) title = util/* default */.Z.get(form, 'title', this.props.t('capture_lead_title'));
|
|
5843
5844
|
title = title.replace('↵', '');
|
|
5844
5845
|
return (0,preact_module.h)("div", {
|
|
5845
5846
|
class: "widget-body"
|
|
@@ -5870,15 +5871,15 @@ class Widget extends common/* Com */.up {
|
|
|
5870
5871
|
}
|
|
5871
5872
|
renderConvoList() {
|
|
5872
5873
|
let convoM = this.props.store.matchConvo('*');
|
|
5873
|
-
var convos = util/* default
|
|
5874
|
-
convos = util/* default
|
|
5875
|
-
convos = util/* default
|
|
5876
|
-
var $convos = util/* default
|
|
5877
|
-
let ags = util/* default
|
|
5874
|
+
var convos = util/* default */.Z.map(convoM, convo => this.props.store.matchConvo(convo.id));
|
|
5875
|
+
convos = util/* default */.Z.filter(convos, convo => !!convo);
|
|
5876
|
+
convos = util/* default */.Z.orderByF(convos, convo => util/* default */.Z.get(convo, 'last_message_sent.created', convo.actived), 'desc');
|
|
5877
|
+
var $convos = util/* default */.Z.map(convos, convo => {
|
|
5878
|
+
let ags = util/* default */.Z.filter(convo.members, m => {
|
|
5878
5879
|
return (m.type === 'agent' || m.type === 'bot') && m.membership === 'active';
|
|
5879
5880
|
});
|
|
5880
|
-
let agentids = util/* default
|
|
5881
|
-
agentids = agentids || util/* default
|
|
5881
|
+
let agentids = util/* default */.Z.map(ags, m => m.id);
|
|
5882
|
+
agentids = agentids || util/* default */.Z.agentsOfConvo(convo)[0];
|
|
5882
5883
|
return (0,preact_module.h)("div", {
|
|
5883
5884
|
class: "convo-list--item",
|
|
5884
5885
|
onClick: () => this.goToConvo(convo.id),
|
|
@@ -5895,7 +5896,7 @@ class Widget extends common/* Com */.up {
|
|
|
5895
5896
|
let $body = (0,preact_module.h)("div", {
|
|
5896
5897
|
class: "convo-list--list"
|
|
5897
5898
|
}, $convos);
|
|
5898
|
-
if (util/* default
|
|
5899
|
+
if (util/* default */.Z.size(convos) === 0) {
|
|
5899
5900
|
$body = (0,preact_module.h)("div", {
|
|
5900
5901
|
class: "convo-list--list"
|
|
5901
5902
|
}, (0,preact_module.h)("div", {
|
|
@@ -5931,19 +5932,19 @@ class Widget extends common/* Com */.up {
|
|
|
5931
5932
|
if (this.props.store.isPreview) return;
|
|
5932
5933
|
var $input = this.msgInput.current;
|
|
5933
5934
|
if (!$input) return;
|
|
5934
|
-
util/* default
|
|
5935
|
-
util/* default
|
|
5935
|
+
util/* default */.Z.setTimeout(() => $input && $input.blur());
|
|
5936
|
+
util/* default */.Z.setTimeout(() => $input && $input.blur(), 300);
|
|
5936
5937
|
}
|
|
5937
5938
|
focusInput() {
|
|
5938
5939
|
if (this.props.store.isPreview) return;
|
|
5939
5940
|
if (this.shouldShowForm()) {
|
|
5940
5941
|
let firstemptykey = '';
|
|
5941
|
-
util/* default
|
|
5942
|
+
util/* default */.Z.map(this.state.formData, (field, key) => {
|
|
5942
5943
|
if (field.type !== 'text') return;
|
|
5943
5944
|
if (firstemptykey) return;
|
|
5944
5945
|
if (!field.value) firstemptykey = key;
|
|
5945
5946
|
});
|
|
5946
|
-
util/* default
|
|
5947
|
+
util/* default */.Z.setTimeout(() => {
|
|
5947
5948
|
var $input = this['form_' + Widget_encode(firstemptykey)];
|
|
5948
5949
|
if (!$input) return;
|
|
5949
5950
|
$input.focus();
|
|
@@ -5952,8 +5953,8 @@ class Widget extends common/* Com */.up {
|
|
|
5952
5953
|
}
|
|
5953
5954
|
var $input = this.msgInput.current;
|
|
5954
5955
|
if (!$input) return;
|
|
5955
|
-
util/* default
|
|
5956
|
-
util/* default
|
|
5956
|
+
util/* default */.Z.setTimeout(() => $input.focus());
|
|
5957
|
+
util/* default */.Z.setTimeout(() => $input.focus(), 300);
|
|
5957
5958
|
}
|
|
5958
5959
|
onRate(rating) {
|
|
5959
5960
|
if (!this.props.cid) return;
|
|
@@ -5967,7 +5968,7 @@ class Widget extends common/* Com */.up {
|
|
|
5967
5968
|
fillQuickReplyToQuestion(message) {
|
|
5968
5969
|
let formData = this.state.formData;
|
|
5969
5970
|
if (formData) {
|
|
5970
|
-
util/* default
|
|
5971
|
+
util/* default */.Z.set(formData, 'question.value', message.text);
|
|
5971
5972
|
}
|
|
5972
5973
|
this.setState({
|
|
5973
5974
|
formData,
|
|
@@ -6060,8 +6061,8 @@ class Widget extends common/* Com */.up {
|
|
|
6060
6061
|
let form;
|
|
6061
6062
|
let accountSetting = this.props.plugin.chatbox || {};
|
|
6062
6063
|
let acc = this.props.store.matchAccount() || {};
|
|
6063
|
-
if (util/* default
|
|
6064
|
-
let offlineEnabled = util/* default
|
|
6064
|
+
if (util/* default */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
6065
|
+
let offlineEnabled = util/* default */.Z.get(accountSetting, 'offline_form.enabled');
|
|
6065
6066
|
if (this.isOffline(acc, accountSetting) && offlineEnabled) form = accountSetting.offline_form;
|
|
6066
6067
|
if (!form) return false;
|
|
6067
6068
|
let formData = this.fillForm(form);
|
|
@@ -6069,34 +6070,34 @@ class Widget extends common/* Com */.up {
|
|
|
6069
6070
|
if (convo.state === 'ended') return true;
|
|
6070
6071
|
if (convo.state && convo.state !== 'pending') delete formData.group;
|
|
6071
6072
|
let isAllFiledEmpty = true;
|
|
6072
|
-
util/* default
|
|
6073
|
+
util/* default */.Z.each(formData, field => {
|
|
6073
6074
|
if (field.value) isAllFiledEmpty = false;
|
|
6074
6075
|
});
|
|
6075
6076
|
if (isAllFiledEmpty && !this.userHasSent(this.props.cid)) return true;
|
|
6076
|
-
return !!util/* default
|
|
6077
|
+
return !!util/* default */.Z.find(formData, field => field.is_required && (field.value == null || field.value === ''));
|
|
6077
6078
|
}
|
|
6078
6079
|
renderConvoSummary(convo) {
|
|
6079
6080
|
let accountSetting = this.props.plugin.chatbox || {};
|
|
6080
6081
|
let agentM = this.props.store.matchAgent('*');
|
|
6081
|
-
let ags = util/* default
|
|
6082
|
+
let ags = util/* default */.Z.filter(convo.members, m => {
|
|
6082
6083
|
return (m.type === 'agent' || m.type === 'bot') && m.membership === 'active';
|
|
6083
6084
|
});
|
|
6084
|
-
let agentids = util/* default
|
|
6085
|
-
agentids = agentids || util/* default
|
|
6086
|
-
let agents = util/* default
|
|
6085
|
+
let agentids = util/* default */.Z.map(ags, m => m.id);
|
|
6086
|
+
agentids = agentids || util/* default */.Z.agentsOfConvo(convo)[0];
|
|
6087
|
+
let agents = util/* default */.Z.map(agentids, id => agentM[id] || {
|
|
6087
6088
|
avatar_url: Widget_defaultAvatar,
|
|
6088
6089
|
fullname: 'Offline Agent'
|
|
6089
6090
|
});
|
|
6090
|
-
var name = util/* default
|
|
6091
|
+
var name = util/* default */.Z.each(agents, ag => ag.fullname).join(', ');
|
|
6091
6092
|
if (accountSetting.hide_agent_profile || !name) name = this.props.store.matchAccount().name;
|
|
6092
6093
|
if (!name) name = this.props.t('agent');
|
|
6093
6094
|
var $you = null;
|
|
6094
6095
|
if (convo.lastSenderType === 'user') {
|
|
6095
6096
|
$you = (0,preact_module.h)("span", null, this.props.t('you'), ":");
|
|
6096
6097
|
}
|
|
6097
|
-
let seen = util/* default
|
|
6098
|
+
let seen = util/* default */.Z.isConvoSeen(convo, this.props.store.matchUser().id);
|
|
6098
6099
|
var lastmsg = this.renderMessagePreview(convo.last_message_sent);
|
|
6099
|
-
var time = util/* default
|
|
6100
|
+
var time = util/* default */.Z.getMs(util/* default */.Z.get(convo, 'last_message_sent.created')) || util/* default */.Z.getMs(convo.created);
|
|
6100
6101
|
let $unread = seen ? null : (0,preact_module.h)("div", {
|
|
6101
6102
|
class: "convo-list--item-unread"
|
|
6102
6103
|
});
|
|
@@ -6129,23 +6130,23 @@ class Widget extends common/* Com */.up {
|
|
|
6129
6130
|
}
|
|
6130
6131
|
agentsOfConvo(convo) {
|
|
6131
6132
|
let agentM = this.props.store.matchAgent('*');
|
|
6132
|
-
var agentids = util/* default
|
|
6133
|
-
return util/* default
|
|
6133
|
+
var agentids = util/* default */.Z.agentsOfConvo(convo, true);
|
|
6134
|
+
return util/* default */.Z.map(agentids, id => agentM[id] || {
|
|
6134
6135
|
avatar_url: Widget_defaultAvatar,
|
|
6135
6136
|
fullname: 'Offline Agent'
|
|
6136
6137
|
});
|
|
6137
6138
|
}
|
|
6138
6139
|
renderMessagePreview(ev) {
|
|
6139
6140
|
let defmsg = this.props.t('sent_you_a_message');
|
|
6140
|
-
let message = util/* default
|
|
6141
|
-
var format = util/* default
|
|
6141
|
+
let message = util/* default */.Z.get(ev, 'data.message.text');
|
|
6142
|
+
var format = util/* default */.Z.get(ev, 'data.message.format');
|
|
6142
6143
|
if (format !== 'plaintext') message = defmsg;
|
|
6143
|
-
if (!message && util/* default
|
|
6144
|
+
if (!message && util/* default */.Z.size(util/* default */.Z.get(ev, 'data.message.attachments')) > 0) message = defmsg;
|
|
6144
6145
|
if (!message) return null;
|
|
6145
|
-
let byType = util/* default
|
|
6146
|
+
let byType = util/* default */.Z.get(ev, 'by.type');
|
|
6146
6147
|
return (0,preact_module.h)("div", {
|
|
6147
6148
|
class: "convo-list--convo-last-mes"
|
|
6148
|
-
}, util/* default
|
|
6149
|
+
}, util/* default */.Z.map(util/* default */.Z.extractText(message), tag => {
|
|
6149
6150
|
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
6150
6151
|
emojiCode: tag.text,
|
|
6151
6152
|
byType: byType
|
|
@@ -6157,19 +6158,19 @@ class Widget extends common/* Com */.up {
|
|
|
6157
6158
|
var convo = this.props.store.matchConvo(cid) || {};
|
|
6158
6159
|
let user = this.props.store.matchUser();
|
|
6159
6160
|
if (this.userSent[cid]) return true;
|
|
6160
|
-
let joined = util/* default
|
|
6161
|
+
let joined = util/* default */.Z.find(convo.members, mem => mem.id === user.id && (mem.membership === 'active' || mem.last_sent > 0));
|
|
6161
6162
|
return joined;
|
|
6162
6163
|
}
|
|
6163
6164
|
hasSentMessage(cid) {
|
|
6164
6165
|
let convo = this.props.store.matchConvo(cid) || {};
|
|
6165
|
-
let joined = util/* default
|
|
6166
|
+
let joined = util/* default */.Z.find(convo.members, mem => {
|
|
6166
6167
|
if (mem.type === 'bot') return true;
|
|
6167
6168
|
return mem.last_sent;
|
|
6168
6169
|
});
|
|
6169
6170
|
return joined;
|
|
6170
6171
|
}
|
|
6171
6172
|
isOffline(acc, accSetting) {
|
|
6172
|
-
let enableWhen = util/* default
|
|
6173
|
+
let enableWhen = util/* default */.Z.get(accSetting, 'offline_form.enable_when');
|
|
6173
6174
|
let isonline = true;
|
|
6174
6175
|
if (enableWhen === 'all_agents_offline') isonline = acc.is_online;
|
|
6175
6176
|
if (enableWhen === 'out_of_bussiness_hour') isonline = acc.is_in_business_hour;
|
|
@@ -6179,8 +6180,8 @@ class Widget extends common/* Com */.up {
|
|
|
6179
6180
|
let form;
|
|
6180
6181
|
let accountSetting = this.props.plugin.chatbox || {};
|
|
6181
6182
|
let acc = this.props.store.matchAccount() || {};
|
|
6182
|
-
if (util/* default
|
|
6183
|
-
let offlineEnabled = util/* default
|
|
6183
|
+
if (util/* default */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
6184
|
+
let offlineEnabled = util/* default */.Z.get(accountSetting, 'offline_form.enabled');
|
|
6184
6185
|
if (this.isOffline(acc, accountSetting) && offlineEnabled) {
|
|
6185
6186
|
form = accountSetting.offline_form;
|
|
6186
6187
|
}
|
|
@@ -6190,23 +6191,23 @@ class Widget extends common/* Com */.up {
|
|
|
6190
6191
|
if (this.props.view === 'prechat_form') {
|
|
6191
6192
|
form = accountSetting.prechat_form;
|
|
6192
6193
|
}
|
|
6193
|
-
if (util/* default
|
|
6194
|
+
if (util/* default */.Z.size(form) === 0) return [];
|
|
6194
6195
|
var data = {};
|
|
6195
|
-
util/* default
|
|
6196
|
+
util/* default */.Z.each(form.fields, f => {
|
|
6196
6197
|
var newf = Object.assign({}, f);
|
|
6197
6198
|
if (f.type === 'list') {
|
|
6198
6199
|
newf.list = f.list;
|
|
6199
6200
|
}
|
|
6200
|
-
newf.label = this.props.t.i18n(util/* default
|
|
6201
|
+
newf.label = this.props.t.i18n(util/* default */.Z.get(f, `i18n_label`, {})) || f.label;
|
|
6201
6202
|
data['attr:' + f.key] = newf;
|
|
6202
6203
|
});
|
|
6203
|
-
if (form.group_required && util/* default
|
|
6204
|
+
if (form.group_required && util/* default */.Z.size(form.groups) > 0) {
|
|
6204
6205
|
data['group'] = {
|
|
6205
6206
|
key: 'group',
|
|
6206
6207
|
is_required: !!form.group_required,
|
|
6207
|
-
label: this.props.t.i18n(util/* default
|
|
6208
|
+
label: this.props.t.i18n(util/* default */.Z.get(form, `i18n_group_label`, {})) || form.group_label,
|
|
6208
6209
|
type: 'group',
|
|
6209
|
-
list: util/* default
|
|
6210
|
+
list: util/* default */.Z.map(form.groups, group => ({
|
|
6210
6211
|
value: group.id,
|
|
6211
6212
|
label: group.name
|
|
6212
6213
|
}))
|
|
@@ -6215,7 +6216,7 @@ class Widget extends common/* Com */.up {
|
|
|
6215
6216
|
data['question'] = {
|
|
6216
6217
|
key: 'question',
|
|
6217
6218
|
is_required: true,
|
|
6218
|
-
label: this.props.t.i18n(util/* default
|
|
6219
|
+
label: this.props.t.i18n(util/* default */.Z.get(form, `i18n_question_label`, {})) || form.question_label,
|
|
6219
6220
|
type: 'text'
|
|
6220
6221
|
};
|
|
6221
6222
|
if (this.isFormChanged(this.state.formData, data)) {
|
|
@@ -6229,38 +6230,44 @@ class Widget extends common/* Com */.up {
|
|
|
6229
6230
|
let newKeys = Object.keys(newForm);
|
|
6230
6231
|
if (oldKeys.length !== newKeys.length) return true;
|
|
6231
6232
|
for (let i = 0; i < oldKeys.length; i++) {
|
|
6232
|
-
if (util/* default
|
|
6233
|
-
if (util/* default
|
|
6234
|
-
if (util/* default
|
|
6233
|
+
if (util/* default */.Z.get(oldForm, `${oldKeys[i]}.label`) !== util/* default */.Z.get(newForm, `${newKeys[i]}.label`)) return true;
|
|
6234
|
+
if (util/* default */.Z.get(oldForm, `${oldKeys[i]}.is_required`) !== util/* default */.Z.get(newForm, `${newKeys[i]}.is_required`)) return true;
|
|
6235
|
+
if (util/* default */.Z.stringify(util/* default */.Z.get(oldForm, `${oldKeys[i]}.list`)) !== util/* default */.Z.stringify(util/* default */.Z.get(newForm, `${newKeys[i]}.list`))) {
|
|
6235
6236
|
return true;
|
|
6236
6237
|
}
|
|
6237
6238
|
}
|
|
6238
6239
|
return false;
|
|
6239
6240
|
}
|
|
6240
6241
|
fillForm(form) {
|
|
6241
|
-
if (util/* default
|
|
6242
|
+
if (util/* default */.Z.size(form) === 0) return [];
|
|
6242
6243
|
var data = {};
|
|
6243
6244
|
let user = this.props.store.matchUser();
|
|
6244
|
-
util/* default
|
|
6245
|
+
util/* default */.Z.each(form.fields, f => {
|
|
6245
6246
|
var newf = Object.assign({}, f);
|
|
6246
|
-
newf.value = util/* default
|
|
6247
|
+
newf.value = util/* default */.Z.getUserAttr(user, f.key, f.type);
|
|
6248
|
+
if (newf.key == 'emails' && !newf.value) {
|
|
6249
|
+
newf.value = util/* default */.Z.getUserAttr(user, 'related_email', 'text');
|
|
6250
|
+
}
|
|
6251
|
+
if (newf.key == 'phones' && !newf.value) {
|
|
6252
|
+
newf.value = util/* default */.Z.getUserAttr(user, 'related_phone', 'text');
|
|
6253
|
+
}
|
|
6247
6254
|
if (f.type === 'boolean' && !newf.value) newf.value = false;
|
|
6248
6255
|
if (f.type === 'datetime' && newf.value) {
|
|
6249
|
-
newf.value = new util/* default
|
|
6256
|
+
newf.value = new util/* default */.Z.Date(data.value).toLocaleDateString('en-CA');
|
|
6250
6257
|
}
|
|
6251
6258
|
if (f.type === 'list') {
|
|
6252
6259
|
newf.list = f.list;
|
|
6253
6260
|
}
|
|
6254
|
-
newf.label = this.props.t.i18n(util/* default
|
|
6261
|
+
newf.label = this.props.t.i18n(util/* default */.Z.get(f, `i18n_label`, {})) || f.label;
|
|
6255
6262
|
data['attr:' + f.key] = newf;
|
|
6256
6263
|
});
|
|
6257
|
-
if (form.group_required && util/* default
|
|
6264
|
+
if (form.group_required && util/* default */.Z.size(form.groups) > 0) {
|
|
6258
6265
|
data['group'] = {
|
|
6259
6266
|
key: 'group',
|
|
6260
6267
|
is_required: !!form.group_required,
|
|
6261
|
-
label: this.props.t.i18n(util/* default
|
|
6268
|
+
label: this.props.t.i18n(util/* default */.Z.get(form, `i18n_group_label`, {})) || form.group_label,
|
|
6262
6269
|
type: 'group',
|
|
6263
|
-
list: util/* default
|
|
6270
|
+
list: util/* default */.Z.map(form.groups, group => ({
|
|
6264
6271
|
value: group.id,
|
|
6265
6272
|
label: group.name
|
|
6266
6273
|
}))
|
|
@@ -6292,14 +6299,14 @@ class Main extends common/* Com */.up {
|
|
|
6292
6299
|
}
|
|
6293
6300
|
async refreshCSS() {
|
|
6294
6301
|
let plugins = this.props.store.matchPlugin();
|
|
6295
|
-
let found = util/* default
|
|
6302
|
+
let found = util/* default */.Z.find(plugins, plugin => plugin.id === this.props.plugin.id);
|
|
6296
6303
|
if (!found) return;
|
|
6297
6304
|
let css = (await main_promiseMainCSS).default.default.toString();
|
|
6298
|
-
var outcss = util/* default
|
|
6299
|
-
util/* default
|
|
6305
|
+
var outcss = util/* default */.Z.replaceCssVariable(css, found.chatbox);
|
|
6306
|
+
util/* default */.Z.setCss(this.props.plugin.id, this.$cssStyleDiv, outcss);
|
|
6300
6307
|
}
|
|
6301
6308
|
componentWillUnmount() {
|
|
6302
|
-
util/* default
|
|
6309
|
+
util/* default */.Z.setCss(this.props.plugin.id, this.$cssStyleDiv, '');
|
|
6303
6310
|
}
|
|
6304
6311
|
async componentDidMount() {
|
|
6305
6312
|
this.$cssStyleDiv = document.getElementById('subiz-style-for-' + this.props.plugin.id);
|
|
@@ -6335,7 +6342,7 @@ class Main extends common/* Com */.up {
|
|
|
6335
6342
|
}
|
|
6336
6343
|
render() {
|
|
6337
6344
|
if (!this.state.cssready) return null;
|
|
6338
|
-
if (util/* default
|
|
6345
|
+
if (util/* default */.Z.isUserBanned(this.props.store.matchUser())) return null;
|
|
6339
6346
|
if (!this.props.t) return null;
|
|
6340
6347
|
return (0,preact_module.h)("div", {
|
|
6341
6348
|
class: this.props.store.isMobile() ? 'mobile' : 'desktop'
|
|
@@ -6369,10 +6376,10 @@ class Main extends common/* Com */.up {
|
|
|
6369
6376
|
if ($widget.wasFormInputed) return;
|
|
6370
6377
|
if (ev.type !== 'message_sent') return;
|
|
6371
6378
|
if (!this.state.isShowWidget) return;
|
|
6372
|
-
let byType = util/* default
|
|
6373
|
-
let byid = util/* default
|
|
6379
|
+
let byType = util/* default */.Z.get(ev, 'by.type');
|
|
6380
|
+
let byid = util/* default */.Z.get(ev, 'by.id') || '';
|
|
6374
6381
|
if (!byid.startsWith('bb') || byType !== 'agent') return;
|
|
6375
|
-
let cid = util/* default
|
|
6382
|
+
let cid = util/* default */.Z.get(ev, 'data.message.conversation_id');
|
|
6376
6383
|
if (!cid) return;
|
|
6377
6384
|
this.showWidget({
|
|
6378
6385
|
cid,
|
|
@@ -6384,7 +6391,7 @@ class Main extends common/* Com */.up {
|
|
|
6384
6391
|
if (this.props.plugin._no_auto_expand) return;
|
|
6385
6392
|
if (this.props.store.matchHasManuallyClosed()) return;
|
|
6386
6393
|
let convoM = this.props.store.matchConvo('*');
|
|
6387
|
-
let redconvo = util/* default
|
|
6394
|
+
let redconvo = util/* default */.Z.find(convoM, convo => !util/* default */.Z.isConvoSeen(convo, this.props.store.matchUser().id));
|
|
6388
6395
|
if (!redconvo || !redconvo.id) return;
|
|
6389
6396
|
if (!this.state.isShowWidget) this.showWidget({
|
|
6390
6397
|
view: 'chat',
|
|
@@ -6402,14 +6409,14 @@ class Main extends common/* Com */.up {
|
|
|
6402
6409
|
this.refButton.current && this.refButton.current.ClearPreview();
|
|
6403
6410
|
if (!p.view) {
|
|
6404
6411
|
let lastview = this.props.store.matchLastview() || {};
|
|
6405
|
-
p.view = util/* default
|
|
6406
|
-
p.cid = util/* default
|
|
6412
|
+
p.view = util/* default */.Z.get(lastview, 'view');
|
|
6413
|
+
p.cid = util/* default */.Z.get(lastview, 'opts.cid');
|
|
6407
6414
|
}
|
|
6408
6415
|
p = p || {};
|
|
6409
6416
|
if (!p.view && !p.cid) {
|
|
6410
6417
|
let convoM = this.props.store.matchConvo('*');
|
|
6411
|
-
let redconvo = util/* default
|
|
6412
|
-
p.cid = util/* default
|
|
6418
|
+
let redconvo = util/* default */.Z.find(convoM, convo => !util/* default */.Z.isConvoSeen(convo, this.props.store.matchUser().id));
|
|
6419
|
+
p.cid = util/* default */.Z.get(redconvo, 'id', util/* default */.Z.get(convoM, '0.id'));
|
|
6413
6420
|
p.view = 'chat';
|
|
6414
6421
|
}
|
|
6415
6422
|
if (this.props.store.isMobile()) modifyViewport();
|
|
@@ -6447,11 +6454,13 @@ class Main extends common/* Com */.up {
|
|
|
6447
6454
|
}
|
|
6448
6455
|
function restoreViewport() {
|
|
6449
6456
|
if (document.body && document.body.classList) document.body.classList.remove('sbz_no_scroll');
|
|
6457
|
+
if (document.documentElement && document.documentElement.classList) document.documentElement.classList.remove('sbz_no_scroll');
|
|
6450
6458
|
let metatag = document.getElementById('subiz-meta-viewport');
|
|
6451
6459
|
if (metatag) metatag.remove();
|
|
6452
6460
|
}
|
|
6453
6461
|
function modifyViewport() {
|
|
6454
6462
|
if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll');
|
|
6463
|
+
if (document.documentElement && document.documentElement.classList) document.documentElement.classList.add('sbz_no_scroll');
|
|
6455
6464
|
let metatag = document.createElement('meta');
|
|
6456
6465
|
metatag.httpEquiv = 'X-UA-Compatible';
|
|
6457
6466
|
metatag.name = 'viewport';
|