@subiz/widget-v4 4.1.49 → 4.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled_src/lib.js +8 -0
- package/compiled_src/plugin.js +2 -1
- package/dist/178.js +1 -1
- package/dist/18c1a2c5a7f.178.js +1 -0
- package/dist/18c1a2c5a7f.213.js +1 -0
- package/dist/18c1a2c5a7f.335.js +1 -0
- package/dist/{18a02a9c54e.362.js → 18c1a2c5a7f.362.js} +1 -1
- package/dist/18c1a2c5a7f.605.js +1 -0
- package/dist/{18a02a9c54e.782.js → 18c1a2c5a7f.782.js} +1 -1
- package/dist/18c1a2c5a7f.841.js +1 -0
- package/dist/18c1a2c5a7f.app.js +1 -0
- package/dist/{18a02a9c54e.index.html → 18c1a2c5a7f.index.html} +4 -4
- package/dist/{18a02a9c54e.library.html → 18c1a2c5a7f.library.html} +4 -4
- package/dist/18c1a2c5a7f.library.js +1 -0
- package/dist/{18a02a9c54e.preview.html → 18c1a2c5a7f.preview.html} +1 -1
- package/dist/18c1a2c5a7f.preview.js +1 -0
- package/dist/18c1a2c5a7f.screenshoot.js +1 -0
- package/dist/18c1a2c5a7f.webview.js +1 -0
- package/dist/213.js +118 -102
- package/dist/335.js +25 -25
- package/dist/362.js +1 -1
- package/dist/605.js +50 -50
- package/dist/782.js +1 -1
- package/dist/{132.js → 841.js} +637 -628
- package/dist/HASH +1 -1
- package/dist/malicious-app.js +8 -3
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +452 -430
- package/package.json +11 -12
- package/src/lib.js +3 -0
- package/src/plugin.js +2 -1
- 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 → 18c1a2c5a7f.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,14 +778,14 @@ 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; }
|
|
@@ -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(arg) { var key = ImageAttachments_toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
1118
|
+
function ImageAttachments_toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
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", {
|
|
@@ -2209,73 +2300,23 @@ class VideoAttachments extends common/* Com */.up {
|
|
|
2209
2300
|
}, $videos);
|
|
2210
2301
|
}
|
|
2211
2302
|
}
|
|
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
2303
|
;// CONCATENATED MODULE: ./src/chatbox/TextMessage.js
|
|
2249
2304
|
|
|
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
2305
|
|
|
2264
2306
|
|
|
2265
2307
|
|
|
2266
2308
|
class TextMessage extends common/* Com */.up {
|
|
2267
2309
|
render() {
|
|
2268
|
-
var format = util/* default
|
|
2269
|
-
if (format === 'markdown') return this.renderMarkdown();
|
|
2310
|
+
var format = util/* default */.Z.get(this.props.ev, 'data.message.format', 'plaintext');
|
|
2270
2311
|
if (format === 'delta') return this.renderDelta();
|
|
2271
2312
|
return this.renderPlainText();
|
|
2272
2313
|
}
|
|
2273
2314
|
renderPlainText() {
|
|
2274
|
-
var text = util/* default
|
|
2275
|
-
text = util/* default
|
|
2276
|
-
if (util/* default
|
|
2277
|
-
let byType = util/* default
|
|
2278
|
-
var tags = util/* default
|
|
2315
|
+
var text = util/* default */.Z.get(this.props.ev, 'data.message.text');
|
|
2316
|
+
text = util/* default */.Z.trim(text);
|
|
2317
|
+
if (util/* default */.Z.size(text) === 0) return null;
|
|
2318
|
+
let byType = util/* default */.Z.get(this.props.ev, 'by.type');
|
|
2319
|
+
var tags = util/* default */.Z.extractText(text).map(tag => {
|
|
2279
2320
|
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
2280
2321
|
emojiCode: tag.text,
|
|
2281
2322
|
byType: byType
|
|
@@ -2299,7 +2340,7 @@ class TextMessage extends common/* Com */.up {
|
|
|
2299
2340
|
}, tag.text);
|
|
2300
2341
|
return tag.text;
|
|
2301
2342
|
});
|
|
2302
|
-
if (util/* default
|
|
2343
|
+
if (util/* default */.Z.size(tags) === 0) return null;
|
|
2303
2344
|
if (byType === 'agent') {
|
|
2304
2345
|
return (0,preact_module.h)("div", {
|
|
2305
2346
|
class: "message-agent message-text--agent"
|
|
@@ -2310,16 +2351,16 @@ class TextMessage extends common/* Com */.up {
|
|
|
2310
2351
|
}, tags);
|
|
2311
2352
|
}
|
|
2312
2353
|
renderDelta() {
|
|
2313
|
-
let deltas = util/* default
|
|
2314
|
-
let quilldeltas = util/* default
|
|
2354
|
+
let deltas = util/* default */.Z.get(this.props.ev, 'data.message.quill_delta') || util/* default */.Z.get(this.props.ev, 'data.message.text');
|
|
2355
|
+
let quilldeltas = util/* default */.Z.parseJSON(deltas) || {};
|
|
2315
2356
|
quilldeltas = trimQuillDelta(quilldeltas);
|
|
2316
|
-
if (!quilldeltas || util/* default
|
|
2317
|
-
let $deltas = util/* default
|
|
2357
|
+
if (!quilldeltas || util/* default */.Z.size(quilldeltas.ops) === 0) return null;
|
|
2358
|
+
let $deltas = util/* default */.Z.map(quilldeltas.ops, delta => {
|
|
2318
2359
|
let html = '';
|
|
2319
2360
|
let insert = delta.insert;
|
|
2320
2361
|
let attributes = delta.attributes;
|
|
2321
2362
|
if (insert.dynamicField) {
|
|
2322
|
-
return util/* default
|
|
2363
|
+
return util/* default */.Z.get(insert, 'dynamicField.text', '');
|
|
2323
2364
|
}
|
|
2324
2365
|
if (insert.mention) {
|
|
2325
2366
|
if (insert.mention.id == '*' || insert.mention.id == 'all') {
|
|
@@ -2328,7 +2369,7 @@ class TextMessage extends common/* Com */.up {
|
|
|
2328
2369
|
}, "@", this.$t('all'));
|
|
2329
2370
|
}
|
|
2330
2371
|
let ag = store.matchAgent(insert.mention.id);
|
|
2331
|
-
let name = util/* default
|
|
2372
|
+
let name = util/* default */.Z.getAgentDisplayName(ag, insert.mention.fullname);
|
|
2332
2373
|
return (0,preact_module.h)("span", {
|
|
2333
2374
|
class: "mention",
|
|
2334
2375
|
"data-agent-id": ag.id,
|
|
@@ -2339,7 +2380,7 @@ class TextMessage extends common/* Com */.up {
|
|
|
2339
2380
|
emojiCode: `:${insert.emoji}:`
|
|
2340
2381
|
});
|
|
2341
2382
|
if (typeof insert === 'string') {
|
|
2342
|
-
let $tags = util/* default
|
|
2383
|
+
let $tags = util/* default */.Z.extractText(insert).map((tag, i) => {
|
|
2343
2384
|
if (tag.type === 'link') {
|
|
2344
2385
|
return (0,preact_module.h)("a", {
|
|
2345
2386
|
href: absLink(tag.text),
|
|
@@ -2363,9 +2404,9 @@ class TextMessage extends common/* Com */.up {
|
|
|
2363
2404
|
}
|
|
2364
2405
|
return null;
|
|
2365
2406
|
});
|
|
2366
|
-
let byType = util/* default
|
|
2407
|
+
let byType = util/* default */.Z.get(this.ev, 'by.type');
|
|
2367
2408
|
if (byType !== 'user') byType = 'agent';
|
|
2368
|
-
if (util/* default
|
|
2409
|
+
if (util/* default */.Z.size($deltas) === 0) return null;
|
|
2369
2410
|
if (byType === 'agent') {
|
|
2370
2411
|
return (0,preact_module.h)("div", {
|
|
2371
2412
|
class: "message-agent message-text--agent"
|
|
@@ -2375,46 +2416,6 @@ class TextMessage extends common/* Com */.up {
|
|
|
2375
2416
|
class: "message-user message-text--user"
|
|
2376
2417
|
}, $deltas);
|
|
2377
2418
|
}
|
|
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
2419
|
}
|
|
2419
2420
|
const emojiCodes = {
|
|
2420
2421
|
like: '👍',
|
|
@@ -2463,8 +2464,8 @@ function absLink(url) {
|
|
|
2463
2464
|
}
|
|
2464
2465
|
;// CONCATENATED MODULE: ./src/chatbox/time.js
|
|
2465
2466
|
|
|
2466
|
-
var g_pub = new util/* default
|
|
2467
|
-
util/* default
|
|
2467
|
+
var g_pub = new util/* default */.Z.Pubsub();
|
|
2468
|
+
util/* default */.Z.setInterval(() => g_pub.publish('time'), 20 * 1000);
|
|
2468
2469
|
|
|
2469
2470
|
|
|
2470
2471
|
class Time extends common/* Com */.up {
|
|
@@ -2479,10 +2480,10 @@ class Time extends common/* Com */.up {
|
|
|
2479
2480
|
var t = '';
|
|
2480
2481
|
if (this.props.ago) {
|
|
2481
2482
|
if (this.props.short) {
|
|
2482
|
-
if (Math.abs(this.props.time - new util/* default
|
|
2483
|
-
let tim = new util/* default
|
|
2483
|
+
if (Math.abs(this.props.time - new util/* default */.Z.Date().getTime()) > 86400000 * 10) {
|
|
2484
|
+
let tim = new util/* default */.Z.Date(this.props.time);
|
|
2484
2485
|
let tzyear = tim.getFullYear();
|
|
2485
|
-
let locale = util/* default
|
|
2486
|
+
let locale = util/* default */.Z.get(navigator, 'languages.0', 'en-US');
|
|
2486
2487
|
let tzmonthname = tim.toLocaleDateString(locale, {
|
|
2487
2488
|
month: 'short'
|
|
2488
2489
|
});
|
|
@@ -2490,8 +2491,8 @@ class Time extends common/* Com */.up {
|
|
|
2490
2491
|
t = tzdate + ' ' + tzmonthname + ' ' + tzyear;
|
|
2491
2492
|
}
|
|
2492
2493
|
}
|
|
2493
|
-
if (!t && this.props.time > 0) t = ago(this.props.time, new util/* default
|
|
2494
|
-
} else t = util/* default
|
|
2494
|
+
if (!t && this.props.time > 0) t = ago(this.props.time, new util/* default */.Z.Date().getTime());
|
|
2495
|
+
} else t = util/* default */.Z.shortTime(this.props.time, this.props.tzoffset);
|
|
2495
2496
|
if (this.props.uppercase) t = t.toUpperCase();
|
|
2496
2497
|
if (t === this.state.t) return;
|
|
2497
2498
|
this.setState({
|
|
@@ -2602,7 +2603,7 @@ class InfoMessage extends common/* Com */.up {
|
|
|
2602
2603
|
}));
|
|
2603
2604
|
}
|
|
2604
2605
|
if (ev.type === 'conversation_rated') {
|
|
2605
|
-
var rating = util/* default
|
|
2606
|
+
var rating = util/* default */.Z.get(ev, 'data.conversation.ratings.0', {
|
|
2606
2607
|
no_rating: true,
|
|
2607
2608
|
rating: 0
|
|
2608
2609
|
});
|
|
@@ -2613,7 +2614,7 @@ class InfoMessage extends common/* Com */.up {
|
|
|
2613
2614
|
class: "info-message"
|
|
2614
2615
|
}, this.props.t('rated_as') + ' ' + this.props.t(getRateLang(rating.rating)).toLowerCase()));
|
|
2615
2616
|
}
|
|
2616
|
-
if (ev.type === 'conversation_state_updated' && util/* default
|
|
2617
|
+
if (ev.type === 'conversation_state_updated' && util/* default */.Z.get(ev, 'data.conversation.state') === 'ended') {
|
|
2617
2618
|
return (0,preact_module.h)("div", {
|
|
2618
2619
|
class: "convo-event"
|
|
2619
2620
|
}, $time, (0,preact_module.h)("div", {
|
|
@@ -2647,7 +2648,7 @@ class Event extends common/* Com */.up {
|
|
|
2647
2648
|
this.refForm = (0,preact_module/* createRef */.Vf)();
|
|
2648
2649
|
}
|
|
2649
2650
|
render() {
|
|
2650
|
-
var ev = util/* default
|
|
2651
|
+
var ev = util/* default */.Z.get(this.props.event, 'ev', {});
|
|
2651
2652
|
switch (ev.type) {
|
|
2652
2653
|
case 'conversation_joined':
|
|
2653
2654
|
break;
|
|
@@ -2656,7 +2657,7 @@ class Event extends common/* Com */.up {
|
|
|
2656
2657
|
case 'conversation_state_updated':
|
|
2657
2658
|
case 'conversation_rating_requested':
|
|
2658
2659
|
case 'conversation_rated':
|
|
2659
|
-
if (!util/* default
|
|
2660
|
+
if (!util/* default */.Z.startsWith(ev.id, 'ev')) return null;
|
|
2660
2661
|
return (0,preact_module.h)(InfoMessage, {
|
|
2661
2662
|
t: this.props.t,
|
|
2662
2663
|
store: this.props.store,
|
|
@@ -2669,7 +2670,7 @@ class Event extends common/* Com */.up {
|
|
|
2669
2670
|
this.refForm.current && this.refForm.current.focus();
|
|
2670
2671
|
}
|
|
2671
2672
|
chooseQuickReply(reply) {
|
|
2672
|
-
let ev = util/* default
|
|
2673
|
+
let ev = util/* default */.Z.get(this.props.event, 'ev', {});
|
|
2673
2674
|
let message = {
|
|
2674
2675
|
text: reply.title,
|
|
2675
2676
|
format: 'plaintext'
|
|
@@ -2686,7 +2687,7 @@ class Event extends common/* Com */.up {
|
|
|
2686
2687
|
this.props.onSend(message);
|
|
2687
2688
|
}
|
|
2688
2689
|
choosePostbackBtn(button) {
|
|
2689
|
-
let ev = util/* default
|
|
2690
|
+
let ev = util/* default */.Z.get(this.props.event, 'ev', {});
|
|
2690
2691
|
let message = {
|
|
2691
2692
|
text: button.title,
|
|
2692
2693
|
format: 'plaintext'
|
|
@@ -2703,13 +2704,13 @@ class Event extends common/* Com */.up {
|
|
|
2703
2704
|
this.props.onSend(message);
|
|
2704
2705
|
}
|
|
2705
2706
|
renderAgentAvatar(ev) {
|
|
2706
|
-
let bytype = util/* default
|
|
2707
|
-
let byid = util/* default
|
|
2707
|
+
let bytype = util/* default */.Z.get(ev, 'by.type');
|
|
2708
|
+
let byid = util/* default */.Z.get(ev, 'by.display_id', util/* default */.Z.get(ev, 'by.id'));
|
|
2708
2709
|
if (bytype === 'user') return null;
|
|
2709
2710
|
var senderName = this.getSenderName(ev);
|
|
2710
2711
|
let acc = this.props.store.matchAccount();
|
|
2711
2712
|
var uri = acc.logo_url || __webpack_require__(9895);
|
|
2712
|
-
if (util/* default
|
|
2713
|
+
if (util/* default */.Z.get(this.props, 'chatbox.hide_agent_profile')) {
|
|
2713
2714
|
return (0,preact_module.h)("div", {
|
|
2714
2715
|
class: "message-sender"
|
|
2715
2716
|
}, (0,preact_module.h)("img", {
|
|
@@ -2722,7 +2723,7 @@ class Event extends common/* Com */.up {
|
|
|
2722
2723
|
}
|
|
2723
2724
|
let agentM = this.props.store.matchAgent('*');
|
|
2724
2725
|
if (byid !== 'system' && bytype !== 'dummy' && bytype !== 'workflow') {
|
|
2725
|
-
uri = util/* default
|
|
2726
|
+
uri = util/* default */.Z.get(agentM[byid], 'avatar_url') || acc.logo_url || __webpack_require__(4761);
|
|
2726
2727
|
}
|
|
2727
2728
|
return (0,preact_module.h)("div", {
|
|
2728
2729
|
class: "message-sender"
|
|
@@ -2744,8 +2745,8 @@ class Event extends common/* Com */.up {
|
|
|
2744
2745
|
time: ev.created
|
|
2745
2746
|
}));
|
|
2746
2747
|
}
|
|
2747
|
-
let t = new util/* default
|
|
2748
|
-
if (util/* default
|
|
2748
|
+
let t = new util/* default */.Z.Date(ev.created).toLocaleString();
|
|
2749
|
+
if (util/* default */.Z.get(ev, 'by.type') !== 'user') {
|
|
2749
2750
|
let $sender = null;
|
|
2750
2751
|
if (this.props.event.mode === 'lead') $sender = this.renderAgentAvatar(ev);
|
|
2751
2752
|
return (0,preact_module.h)("div", {
|
|
@@ -2801,15 +2802,15 @@ class Event extends common/* Com */.up {
|
|
|
2801
2802
|
onSelect: e => this.chooseQuickReply(e)
|
|
2802
2803
|
}));
|
|
2803
2804
|
}
|
|
2804
|
-
if (util/* default
|
|
2805
|
-
util/* default
|
|
2805
|
+
if (util/* default */.Z.getMsgField(ev, 'idempotency') === ev.id && this.props.store.now() - ev.created < 900) {
|
|
2806
|
+
util/* default */.Z.setTimeout(() => this.setState({
|
|
2806
2807
|
refresh: this.state.refresh
|
|
2807
2808
|
}), 1000);
|
|
2808
2809
|
}
|
|
2809
2810
|
let $dot = (0,preact_module.h)("div", {
|
|
2810
2811
|
class: "sending_dot"
|
|
2811
2812
|
});
|
|
2812
|
-
if (this.props.store.now() - ev.created < 900 || util/* default
|
|
2813
|
+
if (this.props.store.now() - ev.created < 900 || util/* default */.Z.getMsgField(ev, 'idempotency') !== ev.id) {
|
|
2813
2814
|
$dot = (0,preact_module.h)("div", {
|
|
2814
2815
|
class: "sending_dot sending_dot__hide"
|
|
2815
2816
|
});
|
|
@@ -2873,7 +2874,7 @@ class Event extends common/* Com */.up {
|
|
|
2873
2874
|
})), $error);
|
|
2874
2875
|
}
|
|
2875
2876
|
renderUpdateConvo(ev) {
|
|
2876
|
-
var state = util/* default
|
|
2877
|
+
var state = util/* default */.Z.get(ev, 'data.conversation.state');
|
|
2877
2878
|
if (state === 'active') return null;
|
|
2878
2879
|
if (state === 'pending') return null;
|
|
2879
2880
|
return (0,preact_module.h)("div", {
|
|
@@ -2883,18 +2884,18 @@ class Event extends common/* Com */.up {
|
|
|
2883
2884
|
}));
|
|
2884
2885
|
}
|
|
2885
2886
|
resendMessage() {
|
|
2886
|
-
let cid = util/* default
|
|
2887
|
-
const message = util/* default
|
|
2887
|
+
let cid = util/* default */.Z.convoOfEv(this.props.event.ev);
|
|
2888
|
+
const message = util/* default */.Z.get(this.props.event, 'ev.data.message');
|
|
2888
2889
|
this.props.store.sendConvoEvent(cid, 'message_sent', {
|
|
2889
2890
|
message
|
|
2890
2891
|
});
|
|
2891
2892
|
}
|
|
2892
2893
|
getSenderName(ev) {
|
|
2893
|
-
let bytype = util/* default
|
|
2894
|
-
let byid = util/* default
|
|
2895
|
-
if (bytype === 'user') return util/* default
|
|
2894
|
+
let bytype = util/* default */.Z.get(ev, 'by.type');
|
|
2895
|
+
let byid = util/* default */.Z.get(ev, 'by.display_id', util/* default */.Z.get(ev, 'by.id'));
|
|
2896
|
+
if (bytype === 'user') return util/* default */.Z.getUserDisplayName(this.props.store.matchUser());
|
|
2896
2897
|
let acc = this.props.store.matchAccount();
|
|
2897
|
-
if (bytype === 'agent') return util/* default
|
|
2898
|
+
if (bytype === 'agent') return util/* default */.Z.getAgentDisplayName(acc, this.props.store.matchAgent(byid));
|
|
2898
2899
|
if (byid === 'system' || bytype === 'dummy' || bytype === 'workflow') return acc.name || 'system';
|
|
2899
2900
|
return '';
|
|
2900
2901
|
}
|
|
@@ -2941,7 +2942,7 @@ class Events extends common/* Com */.up {
|
|
|
2941
2942
|
this.props.store.onConvoEvent(this, ev => this.onEvent(ev));
|
|
2942
2943
|
this.loadConvo();
|
|
2943
2944
|
this.refBody = null;
|
|
2944
|
-
this.checkAndSeen = util/* default
|
|
2945
|
+
this.checkAndSeen = util/* default */.Z.throttle(() => {
|
|
2945
2946
|
if (this.props.isShow && this.isBottom() && this.props.store.browserVisibility === 'visible' && document.hasFocus()) {
|
|
2946
2947
|
this.props.store.seenConvo(this.props.cid);
|
|
2947
2948
|
}
|
|
@@ -2953,8 +2954,8 @@ class Events extends common/* Com */.up {
|
|
|
2953
2954
|
}
|
|
2954
2955
|
render() {
|
|
2955
2956
|
if (this.state.error) return this.renderError();
|
|
2956
|
-
let events = util/* default
|
|
2957
|
-
if (!this.state.loading && util/* default
|
|
2957
|
+
let events = util/* default */.Z.map(this.props.store.listEvents(this.props.cid));
|
|
2958
|
+
if (!this.state.loading && util/* default */.Z.size(events) === 0) {
|
|
2958
2959
|
return (0,preact_module.h)("div", {
|
|
2959
2960
|
ref: ref => this.refBody = ref,
|
|
2960
2961
|
class: "widget-body--events-container"
|
|
@@ -2968,13 +2969,13 @@ class Events extends common/* Com */.up {
|
|
|
2968
2969
|
store: this.props.store
|
|
2969
2970
|
}));
|
|
2970
2971
|
}
|
|
2971
|
-
events = util/* default
|
|
2972
|
+
events = util/* default */.Z.orderBy(events, 'created', 'asc');
|
|
2972
2973
|
let convo = this.props.store.matchConvo(this.props.cid);
|
|
2973
|
-
events = util/* default
|
|
2974
|
+
events = util/* default */.Z.map(events, ev => ({
|
|
2974
2975
|
ev: ev
|
|
2975
2976
|
}));
|
|
2976
2977
|
processEvents(convo, events);
|
|
2977
|
-
let $events = util/* default
|
|
2978
|
+
let $events = util/* default */.Z.map(events, ev => (0,preact_module.h)(Event, {
|
|
2978
2979
|
chatbox: this.props.chatbox,
|
|
2979
2980
|
onLink: this.props.onLink,
|
|
2980
2981
|
store: this.props.store,
|
|
@@ -2990,7 +2991,7 @@ class Events extends common/* Com */.up {
|
|
|
2990
2991
|
if (this.state.loading || this.props.creating) {
|
|
2991
2992
|
$loading = (0,preact_module.h)(Spinner, {
|
|
2992
2993
|
static: true,
|
|
2993
|
-
mode: util/* default
|
|
2994
|
+
mode: util/* default */.Z.get(this.props.chatbox, 'primary_color', 'dark'),
|
|
2994
2995
|
size: "120",
|
|
2995
2996
|
center: true
|
|
2996
2997
|
});
|
|
@@ -3029,23 +3030,23 @@ class Events extends common/* Com */.up {
|
|
|
3029
3030
|
}
|
|
3030
3031
|
focus() {
|
|
3031
3032
|
let events = this.props.store.listEvents(this.props.cid);
|
|
3032
|
-
events = util/* default
|
|
3033
|
+
events = util/* default */.Z.orderBy(util/* default */.Z.map(events), 'created', 'desc');
|
|
3033
3034
|
var last_agent_sent;
|
|
3034
3035
|
for (let ev of events) {
|
|
3035
|
-
if (util/* default
|
|
3036
|
-
if (util/* default
|
|
3036
|
+
if (util/* default */.Z.get(ev, 'type') !== 'message_sent') continue;
|
|
3037
|
+
if (util/* default */.Z.get(ev, 'by.type') === 'user') continue;
|
|
3037
3038
|
last_agent_sent = ev;
|
|
3038
3039
|
break;
|
|
3039
3040
|
}
|
|
3040
|
-
if (util/* default
|
|
3041
|
-
let attachments = util/* default
|
|
3041
|
+
if (util/* default */.Z.get(last_agent_sent, 'by.type') === 'user') last_agent_sent = null;
|
|
3042
|
+
let attachments = util/* default */.Z.get(last_agent_sent, 'data.message.attachments', []);
|
|
3042
3043
|
let convo = this.props.store.matchConvo(this.props.cid);
|
|
3043
|
-
let pendingForms = util/* default
|
|
3044
|
+
let pendingForms = util/* default */.Z.filter(attachments, att => {
|
|
3044
3045
|
if (!att) return false;
|
|
3045
3046
|
if (att.type !== 'form' && att.type !== 'ask_info_form') return false;
|
|
3046
3047
|
var form = att.form;
|
|
3047
3048
|
if (!form) return false;
|
|
3048
|
-
var state = util/* default
|
|
3049
|
+
var state = util/* default */.Z.parseJSON(form.state) || {};
|
|
3049
3050
|
if (!state.require_finished && att.type !== 'ask_info_form') return false;
|
|
3050
3051
|
if (Events_isSummited(att.form)) return false;
|
|
3051
3052
|
if (convo.state === 'ended') return false;
|
|
@@ -3053,10 +3054,10 @@ class Events extends common/* Com */.up {
|
|
|
3053
3054
|
});
|
|
3054
3055
|
}
|
|
3055
3056
|
onEvent(newev) {
|
|
3056
|
-
if (util/* default
|
|
3057
|
+
if (util/* default */.Z.convoOfEv(newev) !== this.props.cid) return;
|
|
3057
3058
|
let isBottom = this.isBottom();
|
|
3058
3059
|
var byme = false;
|
|
3059
|
-
if (util/* default
|
|
3060
|
+
if (util/* default */.Z.get(newev, 'type') === 'message_sent' && newev.id === util/* default */.Z.getMsgField(newev, 'idempotency')) byme = true;
|
|
3060
3061
|
if (byme || isBottom) this.scrollToBottom();
|
|
3061
3062
|
}
|
|
3062
3063
|
async loadConvo() {
|
|
@@ -3066,7 +3067,7 @@ class Events extends common/* Com */.up {
|
|
|
3066
3067
|
loading: true
|
|
3067
3068
|
});
|
|
3068
3069
|
let events = this.props.store.listEvents(this.props.cid);
|
|
3069
|
-
if (util/* default
|
|
3070
|
+
if (util/* default */.Z.size(events) === 0) {
|
|
3070
3071
|
let cid = this.props.cid;
|
|
3071
3072
|
let {
|
|
3072
3073
|
error
|
|
@@ -3090,7 +3091,7 @@ class Events extends common/* Com */.up {
|
|
|
3090
3091
|
error: false
|
|
3091
3092
|
});
|
|
3092
3093
|
this.scrollToBottom();
|
|
3093
|
-
util/* default
|
|
3094
|
+
util/* default */.Z.setTimeout(() => this.setState({
|
|
3094
3095
|
loading: false
|
|
3095
3096
|
}), 50);
|
|
3096
3097
|
}
|
|
@@ -3100,11 +3101,11 @@ class Events extends common/* Com */.up {
|
|
|
3100
3101
|
return $container.scrollHeight < $container.scrollTop + $container.offsetHeight + 50;
|
|
3101
3102
|
}
|
|
3102
3103
|
scrollToBottom() {
|
|
3103
|
-
util/* default
|
|
3104
|
+
util/* default */.Z.setTimeout(() => {
|
|
3104
3105
|
const $div = this.refBody;
|
|
3105
3106
|
if ($div) $div.scrollTop = $div.scrollHeight;
|
|
3106
3107
|
});
|
|
3107
|
-
util/* default
|
|
3108
|
+
util/* default */.Z.setTimeout(() => {
|
|
3108
3109
|
const $div = this.refBody;
|
|
3109
3110
|
if ($div) $div.scrollTop = $div.scrollHeight;
|
|
3110
3111
|
}, 200);
|
|
@@ -3122,13 +3123,13 @@ function processEvents(convo, events) {
|
|
|
3122
3123
|
let curEvent = events[i];
|
|
3123
3124
|
let lastEvent = events[i - 1];
|
|
3124
3125
|
if (visibleEvent(curEvent.ev)) {
|
|
3125
|
-
let elapsedSec = util/* default
|
|
3126
|
+
let elapsedSec = util/* default */.Z.unixSec(curEvent.ev.created) - util/* default */.Z.unixSec(lastEvent.ev.created);
|
|
3126
3127
|
if (elapsedSec > 120) curEvent.show_time = true;
|
|
3127
3128
|
}
|
|
3128
3129
|
}
|
|
3129
3130
|
for (var i = 0; i < events.length; i++) {
|
|
3130
3131
|
let curEvent = events[i];
|
|
3131
|
-
if (util/* default
|
|
3132
|
+
if (util/* default */.Z.get(curEvent, 'ev.type') === 'message_sent') {
|
|
3132
3133
|
curEvent.show_time = true;
|
|
3133
3134
|
break;
|
|
3134
3135
|
}
|
|
@@ -3138,7 +3139,7 @@ function processEvents(convo, events) {
|
|
|
3138
3139
|
let prevEvent = events[i - 1];
|
|
3139
3140
|
if (curEvent.ev.type === 'message_sent') {
|
|
3140
3141
|
curEvent.mode = 'lead';
|
|
3141
|
-
if (util/* default
|
|
3142
|
+
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
3143
|
curEvent.mode = 'follow';
|
|
3143
3144
|
}
|
|
3144
3145
|
continue;
|
|
@@ -3146,12 +3147,12 @@ function processEvents(convo, events) {
|
|
|
3146
3147
|
}
|
|
3147
3148
|
}
|
|
3148
3149
|
function visibleEvent(ev) {
|
|
3149
|
-
let type = util/* default
|
|
3150
|
+
let type = util/* default */.Z.get(ev, 'type');
|
|
3150
3151
|
return type === 'message_sent' || type === 'conversation_state_updated';
|
|
3151
3152
|
}
|
|
3152
3153
|
function Events_isSummited(form) {
|
|
3153
|
-
let fields = util/* default
|
|
3154
|
-
return util/* default
|
|
3154
|
+
let fields = util/* default */.Z.get(form, 'fields') || [];
|
|
3155
|
+
return util/* default */.Z.find(fields, field => !!field.answered);
|
|
3155
3156
|
}
|
|
3156
3157
|
;// CONCATENATED MODULE: ./src/chatbox/Typing.js
|
|
3157
3158
|
|
|
@@ -3167,29 +3168,29 @@ class Typing extends common/* Com */.up {
|
|
|
3167
3168
|
ev: {}
|
|
3168
3169
|
});
|
|
3169
3170
|
this.props.store.onConvoEvent(this, ev => {
|
|
3170
|
-
if (util/* default
|
|
3171
|
+
if (util/* default */.Z.convoOfEv(ev) !== this.props.cid) return;
|
|
3171
3172
|
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
|
|
3173
|
+
if (util/* default */.Z.get(ev, 'by.id') === user.id) return;
|
|
3174
|
+
let oldby = util/* default */.Z.get(this.state.ev, 'by.id');
|
|
3175
|
+
if (oldby && util/* default */.Z.get(ev, 'by.id') !== oldby) return;
|
|
3176
|
+
if (util/* default */.Z.get(ev, 'type') === 'message_sent') {
|
|
3177
|
+
if (this.timer) util/* default */.Z.clearTimeout(this.timer);
|
|
3177
3178
|
this.timer = null;
|
|
3178
3179
|
this.setState({
|
|
3179
3180
|
isShow: false
|
|
3180
3181
|
});
|
|
3181
3182
|
return;
|
|
3182
3183
|
}
|
|
3183
|
-
|
|
3184
|
+
if (util/* default */.Z.get(ev, 'type') !== 'conversation_typing') return;
|
|
3185
|
+
let ag = this.props.store.matchAgent(util/* default */.Z.get(ev, 'by.id')) || {};
|
|
3184
3186
|
if (ag.type == 'agent') return;
|
|
3185
|
-
if (util/* default.get */.Z.get(ev, 'type') !== 'conversation_typing') return;
|
|
3186
3187
|
this.setState({
|
|
3187
3188
|
ev: ev,
|
|
3188
3189
|
isShow: true
|
|
3189
3190
|
});
|
|
3190
|
-
if (this.timer) util/* default
|
|
3191
|
-
this.timer = util/* default
|
|
3192
|
-
if (util/* default
|
|
3191
|
+
if (this.timer) util/* default */.Z.clearTimeout(this.timer);
|
|
3192
|
+
this.timer = util/* default */.Z.setTimeout(() => {
|
|
3193
|
+
if (util/* default */.Z.convoOfEv(ev) !== this.props.cid) return;
|
|
3193
3194
|
this.timer = null;
|
|
3194
3195
|
this.setState({
|
|
3195
3196
|
isShow: false
|
|
@@ -3200,8 +3201,8 @@ class Typing extends common/* Com */.up {
|
|
|
3200
3201
|
render() {
|
|
3201
3202
|
let account = this.props.store.matchAccount();
|
|
3202
3203
|
var cls = this.state.isShow ? '' : 'typing--hidden';
|
|
3203
|
-
let byid = util/* default
|
|
3204
|
-
let agentName = util/* default
|
|
3204
|
+
let byid = util/* default */.Z.get(this.state.ev, 'by.display_id', util/* default */.Z.get(this.state.ev, 'by.id'));
|
|
3205
|
+
let agentName = util/* default */.Z.getAgentDisplayName(account, this.props.store.matchAgent(byid));
|
|
3205
3206
|
return (0,preact_module.h)("div", {
|
|
3206
3207
|
class: `typing ${cls}`
|
|
3207
3208
|
}, agentName, " ", this.props.t('typing'));
|
|
@@ -3220,7 +3221,7 @@ class Typing extends common/* Com */.up {
|
|
|
3220
3221
|
this.stop();
|
|
3221
3222
|
var t0;
|
|
3222
3223
|
var run = t => {
|
|
3223
|
-
if (!t) t = new util/* default
|
|
3224
|
+
if (!t) t = new util/* default */.Z.Date().getTime();
|
|
3224
3225
|
var deltaT = t - t0;
|
|
3225
3226
|
var [newy, done] = this.calcY(v, y0, deltaT);
|
|
3226
3227
|
cb(newy);
|
|
@@ -3228,7 +3229,7 @@ class Typing extends common/* Com */.up {
|
|
|
3228
3229
|
this.animationframe = window.requestAnimationFrame(run);
|
|
3229
3230
|
};
|
|
3230
3231
|
this.animationframe = window.requestAnimationFrame(t => {
|
|
3231
|
-
t0 = t || new util/* default
|
|
3232
|
+
t0 = t || new util/* default */.Z.Date().getTime();
|
|
3232
3233
|
run(t0);
|
|
3233
3234
|
});
|
|
3234
3235
|
}
|
|
@@ -3290,7 +3291,7 @@ class Rating extends common/* Com */.up {
|
|
|
3290
3291
|
if (this.shoudDisplay()) this.open();
|
|
3291
3292
|
});
|
|
3292
3293
|
this.props.store.onConvoEvent(this, ev => {
|
|
3293
|
-
var cid = util/* default
|
|
3294
|
+
var cid = util/* default */.Z.convoOfEv(ev);
|
|
3294
3295
|
if (cid !== this.props.cid) return;
|
|
3295
3296
|
if (this.shoudDisplay()) this.open();
|
|
3296
3297
|
});
|
|
@@ -3399,12 +3400,12 @@ class Rating extends common/* Com */.up {
|
|
|
3399
3400
|
var rated;
|
|
3400
3401
|
var ended;
|
|
3401
3402
|
let user = this.props.store.matchUser();
|
|
3402
|
-
util/* default
|
|
3403
|
-
if (util/* default
|
|
3403
|
+
util/* default */.Z.map(this.props.store.listEvents(this.props.cid), ev => {
|
|
3404
|
+
if (util/* default */.Z.get(ev, 'type') === 'conversation_state_updated' && util/* default */.Z.get(ev, 'data.conversation.state') === 'ended') {
|
|
3404
3405
|
ended = ev;
|
|
3405
3406
|
}
|
|
3406
|
-
if (util/* default
|
|
3407
|
-
if (util/* default
|
|
3407
|
+
if (util/* default */.Z.get(ev, 'type') === 'conversation_rating_requested') requested = ev;
|
|
3408
|
+
if (util/* default */.Z.get(ev, 'type') === 'conversation_rated' && util/* default */.Z.get(ev, 'by.id') === user.id) rated = ev;
|
|
3408
3409
|
});
|
|
3409
3410
|
if (rated) return false;
|
|
3410
3411
|
let accountSetting = this.props.plugin.chatbox;
|
|
@@ -3445,7 +3446,7 @@ class Rating extends common/* Com */.up {
|
|
|
3445
3446
|
hide: false
|
|
3446
3447
|
});
|
|
3447
3448
|
if (!this.refRating.current) return;
|
|
3448
|
-
util/* default
|
|
3449
|
+
util/* default */.Z.setTimeout(() => {
|
|
3449
3450
|
if (this.refComment.current) this.refComment.current.focus();
|
|
3450
3451
|
}, 400);
|
|
3451
3452
|
this.refComment.current.value = '';
|
|
@@ -3567,15 +3568,15 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3567
3568
|
});
|
|
3568
3569
|
DropdownSelect_defineProperty(this, "hasSearch", () => {
|
|
3569
3570
|
if (this.props.has_search) return true;
|
|
3570
|
-
return util/* default
|
|
3571
|
+
return util/* default */.Z.size(this.props.items) >= 10;
|
|
3571
3572
|
});
|
|
3572
3573
|
DropdownSelect_defineProperty(this, "getFilteredOptions", () => {
|
|
3573
3574
|
let items = this.props.items;
|
|
3574
3575
|
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
|
|
3576
|
+
items = util/* default */.Z.filter(items, item => {
|
|
3577
|
+
let optionName = util/* default */.Z.unicodeToAscii(item.name).toLowerCase().replace(/ /g, '');
|
|
3578
|
+
let optionDesc = util/* default */.Z.unicodeToAscii(item.desc).toLowerCase().replace(/ /g, '');
|
|
3579
|
+
let searchValue = util/* default */.Z.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g, '');
|
|
3579
3580
|
return optionName.indexOf(searchValue) != -1 || optionDesc.indexOf(searchValue) != -1;
|
|
3580
3581
|
});
|
|
3581
3582
|
}
|
|
@@ -3634,7 +3635,7 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3634
3635
|
focusFilter() {
|
|
3635
3636
|
if (!this.filterRef.current) return;
|
|
3636
3637
|
this.filterRef.current.focus();
|
|
3637
|
-
util/* default
|
|
3638
|
+
util/* default */.Z.setTimeout(() => {
|
|
3638
3639
|
if (!this.filterRef.current) return;
|
|
3639
3640
|
this.filterRef.current.focus();
|
|
3640
3641
|
}, 100);
|
|
@@ -3642,7 +3643,7 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3642
3643
|
renderDropdown() {
|
|
3643
3644
|
if (!this.state.show) return null;
|
|
3644
3645
|
let items = this.getFilteredOptions();
|
|
3645
|
-
let $items = util/* default
|
|
3646
|
+
let $items = util/* default */.Z.map(items, item => {
|
|
3646
3647
|
return (0,preact_module.h)("div", {
|
|
3647
3648
|
class: "dropdown_select__item",
|
|
3648
3649
|
onClick: _ => this.onSelect(item)
|
|
@@ -3703,10 +3704,10 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3703
3704
|
class: "muted text-truncate",
|
|
3704
3705
|
style: "flex: 1 !important;"
|
|
3705
3706
|
}, "Ch\u1ECDn m\u1ED9t ph\u1EA7n t\u1EED");
|
|
3706
|
-
if (util/* default
|
|
3707
|
+
if (util/* default */.Z.get(this.props, 'selected.name')) $name = (0,preact_module.h)("div", {
|
|
3707
3708
|
class: "text-truncate",
|
|
3708
3709
|
style: "flex: 1 !important;"
|
|
3709
|
-
}, util/* default
|
|
3710
|
+
}, util/* default */.Z.get(this.props, 'selected.name'));
|
|
3710
3711
|
let style = 'position: relative !important;';
|
|
3711
3712
|
if (this.props.full) {
|
|
3712
3713
|
style = '';
|
|
@@ -3766,13 +3767,13 @@ class AddressPicker extends common/* Com */.up {
|
|
|
3766
3767
|
}
|
|
3767
3768
|
if (e.key == 'Enter') {}
|
|
3768
3769
|
});
|
|
3769
|
-
address_picker_defineProperty(this, "doSearch", util/* default
|
|
3770
|
+
address_picker_defineProperty(this, "doSearch", util/* default */.Z.throttle(async () => {
|
|
3770
3771
|
let requestId = Date.now();
|
|
3771
3772
|
this.requestId = requestId;
|
|
3772
3773
|
let res = await this.props.store.suggest_addresses(this.state.searchValue);
|
|
3773
3774
|
if (this.requestId !== requestId) return;
|
|
3774
3775
|
this.setState({
|
|
3775
|
-
addresses: util/* default
|
|
3776
|
+
addresses: util/* default */.Z.get(res, 'body.addresses', [])
|
|
3776
3777
|
});
|
|
3777
3778
|
}, 100));
|
|
3778
3779
|
address_picker_defineProperty(this, "onChangeSearchValue", e => {
|
|
@@ -3829,14 +3830,14 @@ class AddressPicker extends common/* Com */.up {
|
|
|
3829
3830
|
focusFilter() {
|
|
3830
3831
|
if (!this.filterRef.current) return;
|
|
3831
3832
|
this.filterRef.current.focus();
|
|
3832
|
-
util/* default
|
|
3833
|
+
util/* default */.Z.setTimeout(() => {
|
|
3833
3834
|
if (!this.filterRef.current) return;
|
|
3834
3835
|
this.filterRef.current.focus();
|
|
3835
3836
|
}, 100);
|
|
3836
3837
|
}
|
|
3837
3838
|
renderDropdown() {
|
|
3838
3839
|
if (!this.state.show) return null;
|
|
3839
|
-
let $items = util/* default
|
|
3840
|
+
let $items = util/* default */.Z.map(this.state.addresses, (addr, i) => {
|
|
3840
3841
|
let label = [((addr.address || '') + ' ' + normalize(addr.street)).trim()].join(', ');
|
|
3841
3842
|
let desc = [normalize(addr.ward), normalize(addr.district), normalize(addr.province)].join(', ');
|
|
3842
3843
|
return (0,preact_module.h)("div", {
|
|
@@ -3938,7 +3939,7 @@ var $link = document.createElement('link');
|
|
|
3938
3939
|
$link.href = 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap';
|
|
3939
3940
|
$link.rel = 'stylesheet';
|
|
3940
3941
|
document.head.append($link);
|
|
3941
|
-
util/* default
|
|
3942
|
+
util/* default */.Z.preloadWebfonts(['Roboto'], [400, 500]);
|
|
3942
3943
|
|
|
3943
3944
|
let icon_defaultAvatar = __webpack_require__(4761);
|
|
3944
3945
|
|
|
@@ -4045,7 +4046,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4045
4046
|
loadDistrict: false
|
|
4046
4047
|
});
|
|
4047
4048
|
if (!out.error) this.setState({
|
|
4048
|
-
districts: util/* default
|
|
4049
|
+
districts: util/* default */.Z.get(out, 'body.addresses')
|
|
4049
4050
|
});
|
|
4050
4051
|
});
|
|
4051
4052
|
order_defineProperty(this, "onSelectDistrict", async item => {
|
|
@@ -4064,7 +4065,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4064
4065
|
loadWard: false
|
|
4065
4066
|
});
|
|
4066
4067
|
if (!out.error) this.setState({
|
|
4067
|
-
wards: util/* default
|
|
4068
|
+
wards: util/* default */.Z.get(out, 'body.addresses')
|
|
4068
4069
|
});
|
|
4069
4070
|
});
|
|
4070
4071
|
order_defineProperty(this, "onSelectWard", item => this.setState({
|
|
@@ -4085,7 +4086,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4085
4086
|
order_defineProperty(this, "onSelectAddress", addr => {
|
|
4086
4087
|
if (!addr) return;
|
|
4087
4088
|
this.setState({
|
|
4088
|
-
address: [util/* default
|
|
4089
|
+
address: [util/* default */.Z.trim(addr.address), util/* default */.Z.trim(addr.street)].join(' ').trim(),
|
|
4089
4090
|
street: addr.street,
|
|
4090
4091
|
err: {},
|
|
4091
4092
|
g_err: ''
|
|
@@ -4132,36 +4133,36 @@ class order_Order extends common/* Com */.up {
|
|
|
4132
4133
|
});
|
|
4133
4134
|
}
|
|
4134
4135
|
if (this.state.shipping === 'shop') {
|
|
4135
|
-
if (!util/* default
|
|
4136
|
+
if (!util/* default */.Z.isPhone(this.state.phone)) {
|
|
4136
4137
|
err.phone = true;
|
|
4137
4138
|
}
|
|
4138
|
-
if (!util/* default
|
|
4139
|
+
if (!util/* default */.Z.trim(this.state.fullname)) {
|
|
4139
4140
|
err.name = true;
|
|
4140
4141
|
}
|
|
4141
|
-
if (!util/* default
|
|
4142
|
+
if (!util/* default */.Z.trim(this.state.email)) {
|
|
4142
4143
|
err.email = true;
|
|
4143
4144
|
}
|
|
4144
4145
|
} else if (this.state.shipping_address == 'new') {
|
|
4145
|
-
if (!util/* default
|
|
4146
|
+
if (!util/* default */.Z.isPhone(this.state.phone)) {
|
|
4146
4147
|
err.phone = true;
|
|
4147
4148
|
}
|
|
4148
|
-
if (!util/* default
|
|
4149
|
+
if (!util/* default */.Z.trim(this.state.fullname)) {
|
|
4149
4150
|
err.name = true;
|
|
4150
4151
|
}
|
|
4151
|
-
if (!util/* default
|
|
4152
|
+
if (!util/* default */.Z.trim(this.state.address)) {
|
|
4152
4153
|
err.address = true;
|
|
4153
4154
|
}
|
|
4154
|
-
if (util/* default
|
|
4155
|
+
if (util/* default */.Z.size(this.state.selectedWard) == 0) {
|
|
4155
4156
|
err.ward = true;
|
|
4156
4157
|
}
|
|
4157
|
-
if (util/* default
|
|
4158
|
+
if (util/* default */.Z.size(this.state.selectedDistrict) == 0) {
|
|
4158
4159
|
err.district = true;
|
|
4159
4160
|
}
|
|
4160
|
-
if (util/* default
|
|
4161
|
+
if (util/* default */.Z.size(this.state.selectedProvince) == 0) {
|
|
4161
4162
|
err.province = true;
|
|
4162
4163
|
}
|
|
4163
4164
|
}
|
|
4164
|
-
if (util/* default
|
|
4165
|
+
if (util/* default */.Z.size(err) > 0) {
|
|
4165
4166
|
this.setState({
|
|
4166
4167
|
err,
|
|
4167
4168
|
g_err: this.props.t('input_shipping_info_err')
|
|
@@ -4169,15 +4170,15 @@ class order_Order extends common/* Com */.up {
|
|
|
4169
4170
|
return;
|
|
4170
4171
|
}
|
|
4171
4172
|
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
|
|
4173
|
+
let ufullname = util/* default */.Z.getUserAttr(user, 'fullname', 'text');
|
|
4174
|
+
let uemail = util/* default */.Z.getUserAttr(user, 'emails', 'text');
|
|
4175
|
+
let uphone = util/* default */.Z.getUserAttr(user, 'phones', 'text');
|
|
4176
|
+
let order = util/* default */.Z.cloneDeep(this.state.order);
|
|
4176
4177
|
if (this.state.shipping === 'shop') {
|
|
4177
|
-
util/* default
|
|
4178
|
-
util/* default
|
|
4179
|
-
util/* default
|
|
4180
|
-
util/* default
|
|
4178
|
+
util/* default */.Z.set(order, 'shipping.pickup_at_shop', true);
|
|
4179
|
+
util/* default */.Z.set(order, 'shipping.address.phone', this.state.phone);
|
|
4180
|
+
util/* default */.Z.set(order, 'shipping.address.fullname', this.state.fullname);
|
|
4181
|
+
util/* default */.Z.set(order, 'shipping.address.email', this.state.email);
|
|
4181
4182
|
} else {
|
|
4182
4183
|
if (this.state.shipping_address == 'new') {
|
|
4183
4184
|
let out = await this.props.store.createShippingAddress({
|
|
@@ -4197,37 +4198,37 @@ class order_Order extends common/* Com */.up {
|
|
|
4197
4198
|
if (out.error) return this.setState({
|
|
4198
4199
|
g_err: this.props.t('update_failed')
|
|
4199
4200
|
});
|
|
4200
|
-
util/* default
|
|
4201
|
+
util/* default */.Z.set(order, 'shipping.address', out.body);
|
|
4201
4202
|
} else {
|
|
4202
4203
|
let addresses = this.props.store.matchShippingAddresses();
|
|
4203
|
-
let sa = util/* default
|
|
4204
|
+
let sa = util/* default */.Z.find(addresses, addr => addr.id === this.state.shipping_address);
|
|
4204
4205
|
if (!sa) {
|
|
4205
4206
|
return this.setState({
|
|
4206
4207
|
err,
|
|
4207
4208
|
g_err: this.props.t('input_shipping_info_err')
|
|
4208
4209
|
});
|
|
4209
4210
|
}
|
|
4210
|
-
util/* default
|
|
4211
|
+
util/* default */.Z.set(order, 'shipping.address', sa);
|
|
4211
4212
|
}
|
|
4212
4213
|
}
|
|
4213
4214
|
let changeduser = false;
|
|
4214
4215
|
if (!ufullname && this.state.fullname) {
|
|
4215
4216
|
changeduser = true;
|
|
4216
|
-
util/* default
|
|
4217
|
+
util/* default */.Z.setUserAttr(user, {
|
|
4217
4218
|
key: 'fullname',
|
|
4218
4219
|
text: this.state.fullname
|
|
4219
4220
|
});
|
|
4220
4221
|
}
|
|
4221
4222
|
if (!uemail && this.state.email) {
|
|
4222
4223
|
changeduser = true;
|
|
4223
|
-
util/* default
|
|
4224
|
+
util/* default */.Z.setUserAttr(user, {
|
|
4224
4225
|
key: 'emails',
|
|
4225
4226
|
text: this.state.email
|
|
4226
4227
|
});
|
|
4227
4228
|
}
|
|
4228
4229
|
if (!uphone && this.state.phone) {
|
|
4229
4230
|
changeduser = true;
|
|
4230
|
-
util/* default
|
|
4231
|
+
util/* default */.Z.setUserAttr(user, {
|
|
4231
4232
|
key: 'phones',
|
|
4232
4233
|
text: this.state.phone
|
|
4233
4234
|
});
|
|
@@ -4254,7 +4255,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4254
4255
|
order_defineProperty(this, "onCancel", () => {
|
|
4255
4256
|
if (this.props.onResponse) this.props.onResponse('rejected');
|
|
4256
4257
|
if (this.props.cid && !this.state.order.user_confirmation) {
|
|
4257
|
-
let order = util/* default
|
|
4258
|
+
let order = util/* default */.Z.cloneDeep(this.state.order);
|
|
4258
4259
|
order.user_confirmation = 'rejected';
|
|
4259
4260
|
this.props.store.updateOrder(order);
|
|
4260
4261
|
}
|
|
@@ -4281,10 +4282,10 @@ class order_Order extends common/* Com */.up {
|
|
|
4281
4282
|
});
|
|
4282
4283
|
}
|
|
4283
4284
|
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
|
|
4285
|
+
let attributes = util/* default */.Z.get(this.props.store.matchUser(), 'attributes', []);
|
|
4286
|
+
let fullname = util/* default */.Z.get(util/* default */.Z.find(attributes, att => att.key === 'fullname'), 'text');
|
|
4287
|
+
let email = util/* default */.Z.get(util/* default */.Z.find(attributes, att => att.key === 'emails'), 'text');
|
|
4288
|
+
let phone = util/* default */.Z.get(util/* default */.Z.find(attributes, att => att.key === 'phones'), 'text');
|
|
4288
4289
|
this.setState({
|
|
4289
4290
|
fullname,
|
|
4290
4291
|
email,
|
|
@@ -4296,7 +4297,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4296
4297
|
loadProvince: false
|
|
4297
4298
|
});
|
|
4298
4299
|
if (!out.error) this.setState({
|
|
4299
|
-
provinces: util/* default
|
|
4300
|
+
provinces: util/* default */.Z.get(out, 'body.addresses')
|
|
4300
4301
|
});
|
|
4301
4302
|
}
|
|
4302
4303
|
isMobile() {
|
|
@@ -4326,7 +4327,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4326
4327
|
}
|
|
4327
4328
|
if (editmode) {
|
|
4328
4329
|
let pms = this.props.store.matchPaymentMethods();
|
|
4329
|
-
let $pms = util/* default
|
|
4330
|
+
let $pms = util/* default */.Z.map(pms, pm => {
|
|
4330
4331
|
let $name = pm.description;
|
|
4331
4332
|
if (pm.method == 'bank_transfer') {
|
|
4332
4333
|
$name = pm.description + ' ' + pm.bank_name + ' ' + pm.bank_branch;
|
|
@@ -4407,15 +4408,15 @@ class order_Order extends common/* Com */.up {
|
|
|
4407
4408
|
let user = this.props.store.matchUser();
|
|
4408
4409
|
if (editmode) {
|
|
4409
4410
|
let addresses = this.props.store.matchShippingAddresses();
|
|
4410
|
-
let provinces = util/* default
|
|
4411
|
+
let provinces = util/* default */.Z.map(this.state.provinces, province => ({
|
|
4411
4412
|
id: province.id,
|
|
4412
4413
|
name: province.province
|
|
4413
4414
|
}));
|
|
4414
|
-
let districts = util/* default
|
|
4415
|
+
let districts = util/* default */.Z.map(this.state.districts, district => ({
|
|
4415
4416
|
id: district.id,
|
|
4416
4417
|
name: district.district
|
|
4417
4418
|
}));
|
|
4418
|
-
let wards = util/* default
|
|
4419
|
+
let wards = util/* default */.Z.map(this.state.wards, ward => ({
|
|
4419
4420
|
id: ward.id,
|
|
4420
4421
|
name: ward.ward
|
|
4421
4422
|
}));
|
|
@@ -4424,7 +4425,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4424
4425
|
let ship_icon_active = false;
|
|
4425
4426
|
if (this.state.shipping === 'ship') {
|
|
4426
4427
|
ship_icon_active = true;
|
|
4427
|
-
let $preaddrs = util/* default
|
|
4428
|
+
let $preaddrs = util/* default */.Z.map(addresses, addr => {
|
|
4428
4429
|
let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
|
|
4429
4430
|
let $phone = null;
|
|
4430
4431
|
if (addr.phone) {
|
|
@@ -4556,7 +4557,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4556
4557
|
style: "flex: 1 !important; margin-left: 7px !important;"
|
|
4557
4558
|
})));
|
|
4558
4559
|
cls += ' ship_card__active';
|
|
4559
|
-
if (util/* default
|
|
4560
|
+
if (util/* default */.Z.size(addresses) == 0) {
|
|
4560
4561
|
$body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
4561
4562
|
class: 'mt-3 mb-2 '
|
|
4562
4563
|
}, this.props.t('input_shipping_info')), $new);
|
|
@@ -4634,13 +4635,13 @@ class order_Order extends common/* Com */.up {
|
|
|
4634
4635
|
class: "ml-2"
|
|
4635
4636
|
}, "Giao h\xE0ng cho t\xF4i"))), $body));
|
|
4636
4637
|
}
|
|
4637
|
-
let addr = util/* default
|
|
4638
|
+
let addr = util/* default */.Z.get(order, 'shipping.address') || {};
|
|
4638
4639
|
let fulladdr = [addr.address, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
|
|
4639
4640
|
let $phone = null;
|
|
4640
4641
|
if (addr.phone) $phone = (0,preact_module.h)("div", {
|
|
4641
4642
|
class: "mt-1 muted"
|
|
4642
4643
|
}, this.props.t('phn'), ":\xA0", addr.phone);
|
|
4643
|
-
if (util/* default
|
|
4644
|
+
if (util/* default */.Z.get(order, 'shipping.pickup_at_shop')) {
|
|
4644
4645
|
fulladdr = 'Nhận hàng tại cửa hàng';
|
|
4645
4646
|
}
|
|
4646
4647
|
let $addr = fulladdr ? (0,preact_module.h)("div", null, fulladdr) : (0,preact_module.h)("i", {
|
|
@@ -4659,28 +4660,28 @@ class order_Order extends common/* Com */.up {
|
|
|
4659
4660
|
if (order.deposit > 0) {
|
|
4660
4661
|
$deposit = (0,preact_module.h)("span", {
|
|
4661
4662
|
class: "muted"
|
|
4662
|
-
}, "(c\u1ECDc ", util/* default
|
|
4663
|
+
}, "(c\u1ECDc ", util/* default */.Z.formatCurrency(order.deposit), ")");
|
|
4663
4664
|
}
|
|
4664
4665
|
let $discount = null;
|
|
4665
4666
|
if (order.total_discount > 0) {
|
|
4666
4667
|
$discount = (0,preact_module.h)("div", {
|
|
4667
4668
|
class: "order_summary_line"
|
|
4668
|
-
}, (0,preact_module.h)("div", null, "Gi\u1EA3m gi\xE1"), (0,preact_module.h)("div", null, util/* default
|
|
4669
|
+
}, (0,preact_module.h)("div", null, "Gi\u1EA3m gi\xE1"), (0,preact_module.h)("div", null, util/* default */.Z.formatCurrency(order.total_discount)));
|
|
4669
4670
|
}
|
|
4670
4671
|
let $pay = null;
|
|
4671
4672
|
if ($deposit || order.payment_made) {
|
|
4672
4673
|
$pay = (0,preact_module.h)(preact_module/* Fragment */.HY, null, (0,preact_module.h)("div", {
|
|
4673
4674
|
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
|
|
4675
|
+
}, (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
4676
|
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
|
|
4677
|
+
}, (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
4678
|
}
|
|
4678
4679
|
let $tax = (0,preact_module.h)("div", {
|
|
4679
4680
|
class: "order_summary_line"
|
|
4680
|
-
}, (0,preact_module.h)("div", null, "Ti\u1EC1n thu\u1EBF"), (0,preact_module.h)("div", null, util/* default
|
|
4681
|
+
}, (0,preact_module.h)("div", null, "Ti\u1EC1n thu\u1EBF"), (0,preact_module.h)("div", null, util/* default */.Z.formatCurrency(order.total_tax)));
|
|
4681
4682
|
let $ship = (0,preact_module.h)("div", {
|
|
4682
4683
|
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
|
|
4684
|
+
}, (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
4685
|
let editmode = false;
|
|
4685
4686
|
if (!order.status || order.status == 'open') {
|
|
4686
4687
|
editmode = !order.user_confirmation;
|
|
@@ -4706,12 +4707,12 @@ class order_Order extends common/* Com */.up {
|
|
|
4706
4707
|
class: "order_label"
|
|
4707
4708
|
}, "T\xF3m t\u1EAFt"), (0,preact_module.h)("div", {
|
|
4708
4709
|
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
|
|
4710
|
+
}, (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
4711
|
class: "order_summary_line",
|
|
4711
4712
|
style: "margin-top: 10px !important; padding-top: 15px !important; border-top: 1px solid #eee !important"
|
|
4712
4713
|
}, (0,preact_module.h)("div", null, "B\u1EA1n ph\u1EA3i tr\u1EA3"), (0,preact_module.h)("div", {
|
|
4713
4714
|
class: "order__total"
|
|
4714
|
-
}, util/* default
|
|
4715
|
+
}, util/* default */.Z.formatCurrency(order.total))), $pay));
|
|
4715
4716
|
}
|
|
4716
4717
|
renderStatusBadge(order) {
|
|
4717
4718
|
let status = order.status || 'open';
|
|
@@ -4722,9 +4723,9 @@ class order_Order extends common/* Com */.up {
|
|
|
4722
4723
|
}
|
|
4723
4724
|
renderShippingInfo(order) {
|
|
4724
4725
|
if (order.status != 'open' || order.user_confirmation) {}
|
|
4725
|
-
let shipping_provider = util/* default
|
|
4726
|
+
let shipping_provider = util/* default */.Z.get(order, 'shipping.shipping_provider');
|
|
4726
4727
|
if (!shipping_provider) return null;
|
|
4727
|
-
let shipping_code = util/* default
|
|
4728
|
+
let shipping_code = util/* default */.Z.get(order, 'shipping.shipping_code');
|
|
4728
4729
|
let $tracking_code = null;
|
|
4729
4730
|
if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
|
|
4730
4731
|
class: "muted",
|
|
@@ -4752,9 +4753,9 @@ class order_Order extends common/* Com */.up {
|
|
|
4752
4753
|
return null;
|
|
4753
4754
|
}
|
|
4754
4755
|
renderDesktopShippingInfo(order) {
|
|
4755
|
-
let shipping_provider = util/* default
|
|
4756
|
+
let shipping_provider = util/* default */.Z.get(order, 'shipping.shipping_provider');
|
|
4756
4757
|
if (!shipping_provider) return null;
|
|
4757
|
-
let shipping_code = util/* default
|
|
4758
|
+
let shipping_code = util/* default */.Z.get(order, 'shipping.shipping_code');
|
|
4758
4759
|
let $tracking_code = null;
|
|
4759
4760
|
if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
|
|
4760
4761
|
class: "muted",
|
|
@@ -4781,7 +4782,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4781
4782
|
}
|
|
4782
4783
|
renderProducts(order) {
|
|
4783
4784
|
let $products = null;
|
|
4784
|
-
$products = util/* default
|
|
4785
|
+
$products = util/* default */.Z.map(order.items, item => {
|
|
4785
4786
|
if (!item || !item.product) return null;
|
|
4786
4787
|
let product = item.product;
|
|
4787
4788
|
return (0,preact_module.h)("div", {
|
|
@@ -4789,7 +4790,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4789
4790
|
}, (0,preact_module.h)("img", {
|
|
4790
4791
|
class: "order_attachment__product_img",
|
|
4791
4792
|
alt: '' + product.id,
|
|
4792
|
-
src: util/* default
|
|
4793
|
+
src: util/* default */.Z.get(product, 'images.0') || __webpack_require__(9270)
|
|
4793
4794
|
}), (0,preact_module.h)("div", {
|
|
4794
4795
|
style: "overflow: hidden !important;"
|
|
4795
4796
|
}, (0,preact_module.h)("div", {
|
|
@@ -4798,7 +4799,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4798
4799
|
class: "order_attachment__product_desc"
|
|
4799
4800
|
}, product.description || product.long_description), (0,preact_module.h)("div", {
|
|
4800
4801
|
class: "order_attachment__product_desc"
|
|
4801
|
-
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default
|
|
4802
|
+
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default */.Z.formatCurrency(product.price))));
|
|
4802
4803
|
});
|
|
4803
4804
|
if (!this.isMobile()) return (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
4804
4805
|
class: "order_label"
|
|
@@ -4816,7 +4817,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4816
4817
|
editmode = !order.user_confirmation;
|
|
4817
4818
|
}
|
|
4818
4819
|
if (editmode) {
|
|
4819
|
-
$products = util/* default
|
|
4820
|
+
$products = util/* default */.Z.map(order.items, item => {
|
|
4820
4821
|
if (!item || !item.product) return null;
|
|
4821
4822
|
let product = item.product;
|
|
4822
4823
|
return (0,preact_module.h)("div", {
|
|
@@ -4824,7 +4825,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4824
4825
|
}, (0,preact_module.h)("img", {
|
|
4825
4826
|
class: "order_attachment__product_img",
|
|
4826
4827
|
alt: '' + product.id,
|
|
4827
|
-
src: util/* default
|
|
4828
|
+
src: util/* default */.Z.get(product, 'images.0') || __webpack_require__(9270)
|
|
4828
4829
|
}), (0,preact_module.h)("div", {
|
|
4829
4830
|
style: "overflow: hidden !important; flex: 1 !important"
|
|
4830
4831
|
}, (0,preact_module.h)("div", {
|
|
@@ -4833,7 +4834,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4833
4834
|
class: "order_attachment__product_desc"
|
|
4834
4835
|
}, product.description || product.long_description), (0,preact_module.h)("div", {
|
|
4835
4836
|
class: "order_attachment__product_desc"
|
|
4836
|
-
}, util/* default
|
|
4837
|
+
}, util/* default */.Z.formatCurrency(product.price))), (0,preact_module.h)("input", {
|
|
4837
4838
|
class: "form-control",
|
|
4838
4839
|
style: "text-align: center !important; font-weight: 400 !important; width: 50px !important",
|
|
4839
4840
|
value: item.quantity,
|
|
@@ -4841,10 +4842,10 @@ class order_Order extends common/* Com */.up {
|
|
|
4841
4842
|
type: "text"
|
|
4842
4843
|
}), (0,preact_module.h)("div", {
|
|
4843
4844
|
style: "width: 80px !important; text-align: right !important; "
|
|
4844
|
-
}, (0,preact_module.h)("b", null, util/* default
|
|
4845
|
+
}, (0,preact_module.h)("b", null, util/* default */.Z.formatCurrency(item.quantity * product.price))));
|
|
4845
4846
|
});
|
|
4846
4847
|
} else {
|
|
4847
|
-
$products = util/* default
|
|
4848
|
+
$products = util/* default */.Z.map(order.items, item => {
|
|
4848
4849
|
if (!item || !item.product) return null;
|
|
4849
4850
|
let product = item.product;
|
|
4850
4851
|
return (0,preact_module.h)("div", {
|
|
@@ -4852,7 +4853,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4852
4853
|
}, (0,preact_module.h)("img", {
|
|
4853
4854
|
class: "order_attachment__product_img",
|
|
4854
4855
|
alt: '' + product.id,
|
|
4855
|
-
src: util/* default
|
|
4856
|
+
src: util/* default */.Z.get(product, 'images.0') || __webpack_require__(9270)
|
|
4856
4857
|
}), (0,preact_module.h)("div", {
|
|
4857
4858
|
style: "overflow: hidden !important; flex: 1 !important"
|
|
4858
4859
|
}, (0,preact_module.h)("div", {
|
|
@@ -4861,11 +4862,11 @@ class order_Order extends common/* Com */.up {
|
|
|
4861
4862
|
class: "order_attachment__product_desc"
|
|
4862
4863
|
}, product.description || product.long_description), (0,preact_module.h)("div", {
|
|
4863
4864
|
class: "order_attachment__product_desc"
|
|
4864
|
-
}, util/* default
|
|
4865
|
+
}, util/* default */.Z.formatCurrency(product.price))), (0,preact_module.h)("div", {
|
|
4865
4866
|
style: "text-align: center !important; font-weight: 400 !important; width: 50px !important"
|
|
4866
4867
|
}, item.quantity), (0,preact_module.h)("div", {
|
|
4867
4868
|
style: "width: 80px !important; text-align: right !important; "
|
|
4868
|
-
}, (0,preact_module.h)("b", null, util/* default
|
|
4869
|
+
}, (0,preact_module.h)("b", null, util/* default */.Z.formatCurrency(item.total))));
|
|
4869
4870
|
});
|
|
4870
4871
|
}
|
|
4871
4872
|
return (0,preact_module.h)("div", {
|
|
@@ -5083,7 +5084,7 @@ class Order extends common/* Com */.up {
|
|
|
5083
5084
|
});
|
|
5084
5085
|
});
|
|
5085
5086
|
Order_defineProperty(this, "close", async () => {
|
|
5086
|
-
await util/* default
|
|
5087
|
+
await util/* default */.Z.sleep(100);
|
|
5087
5088
|
if (this.state.response === 'confirmed') {
|
|
5088
5089
|
this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
|
|
5089
5090
|
message: {
|
|
@@ -5184,7 +5185,7 @@ class Order extends common/* Com */.up {
|
|
|
5184
5185
|
render() {
|
|
5185
5186
|
if (this._show != this.props.show) {
|
|
5186
5187
|
this._show = this.props.show;
|
|
5187
|
-
util/* default
|
|
5188
|
+
util/* default */.Z.setTimeout(() => {
|
|
5188
5189
|
if (!this._show) this.close();else this.open();
|
|
5189
5190
|
});
|
|
5190
5191
|
}
|
|
@@ -5311,7 +5312,7 @@ class Widget extends common/* Com */.up {
|
|
|
5311
5312
|
super(props);
|
|
5312
5313
|
Widget_defineProperty(this, "msgInput", (0,preact_module/* createRef */.Vf)());
|
|
5313
5314
|
Widget_defineProperty(this, "sendMessage", async message => {
|
|
5314
|
-
let hasPostback = util/* default
|
|
5315
|
+
let hasPostback = util/* default */.Z.find(message.attachments, att => att.type === 'postback');
|
|
5315
5316
|
if (this.isFormRequired() && hasPostback) {
|
|
5316
5317
|
this.onStartConvoClick();
|
|
5317
5318
|
this.fillQuickReplyToQuestion(message);
|
|
@@ -5390,7 +5391,7 @@ class Widget extends common/* Com */.up {
|
|
|
5390
5391
|
clickedJoin: false,
|
|
5391
5392
|
quickReplyMessage: {}
|
|
5392
5393
|
});
|
|
5393
|
-
util/* default
|
|
5394
|
+
util/* default */.Z.setTimeout(() => {
|
|
5394
5395
|
this.events && this.events.focus();
|
|
5395
5396
|
if (!this.props.store.isMobile()) this.focusInput();
|
|
5396
5397
|
}, 100);
|
|
@@ -5401,10 +5402,10 @@ class Widget extends common/* Com */.up {
|
|
|
5401
5402
|
let form;
|
|
5402
5403
|
let accountSetting = this.props.plugin.chatbox || {};
|
|
5403
5404
|
let acc = this.props.store.matchAccount() || {};
|
|
5404
|
-
if (util/* default
|
|
5405
|
-
let offlineEnabled = util/* default
|
|
5405
|
+
if (util/* default */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
5406
|
+
let offlineEnabled = util/* default */.Z.get(accountSetting, 'offline_form.enabled');
|
|
5406
5407
|
if (this.isOffline(acc, accountSetting) && offlineEnabled) form = accountSetting.offline_form;
|
|
5407
|
-
if (!this.hasSentMessage(this.props.cid) && form && (util/* default
|
|
5408
|
+
if (!this.hasSentMessage(this.props.cid) && form && (util/* default */.Z.size(form.groups) || form.group_required)) return true;
|
|
5408
5409
|
let formRequired = this.isFormRequired();
|
|
5409
5410
|
return formRequired && !this.props.cid || formRequired && this.props.cid && this.state.clickedJoin;
|
|
5410
5411
|
}
|
|
@@ -5414,8 +5415,8 @@ class Widget extends common/* Com */.up {
|
|
|
5414
5415
|
let accountSetting = this.props.plugin.chatbox || {};
|
|
5415
5416
|
let acc = this.props.store.matchAccount() || {};
|
|
5416
5417
|
let submitLabel = this.props.t('prechat_form_btn');
|
|
5417
|
-
if (util/* default
|
|
5418
|
-
let offlineEnabled = util/* default
|
|
5418
|
+
if (util/* default */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
5419
|
+
let offlineEnabled = util/* default */.Z.get(accountSetting, 'offline_form.enabled');
|
|
5419
5420
|
if (this.isOffline(acc, accountSetting) && offlineEnabled) {
|
|
5420
5421
|
form = accountSetting.offline_form;
|
|
5421
5422
|
submitLabel = this.props.t('offline_form_btn');
|
|
@@ -5432,8 +5433,8 @@ class Widget extends common/* Com */.up {
|
|
|
5432
5433
|
}
|
|
5433
5434
|
let $body = null;
|
|
5434
5435
|
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
|
|
5436
|
+
let position = util/* default */.Z.get(accountSetting, 'desktop_button.position') || 'right';
|
|
5437
|
+
if (this.props.store.isMobile()) position = util/* default */.Z.get(accountSetting, 'mobile_button.position', position);
|
|
5437
5438
|
let cls = 'widget-container widget-container--' + position;
|
|
5438
5439
|
if (!this.props.isShow) cls += ' widget-container--hide';
|
|
5439
5440
|
return (0,preact_module.h)("div", {
|
|
@@ -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';
|