@subiz/widget-v4 4.1.61 → 4.1.63
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/README.md +10 -0
- package/app.js +2 -6
- package/assets/less/widget.less +16 -7
- package/dist/{213.js → 132.js} +121 -121
- package/dist/18dd22fb422.132.js +1 -0
- package/dist/18dd22fb422.27.js +1 -0
- package/dist/18dd22fb422.278.js +1 -0
- package/dist/18dd22fb422.459.js +1 -0
- package/dist/{18d5e97bf55.605.js → 18dd22fb422.490.js} +1 -1
- package/dist/18dd22fb422.497.js +1 -0
- package/dist/18dd22fb422.74.js +1 -0
- package/dist/18dd22fb422.997.js +1 -0
- package/dist/18dd22fb422.app.js +1 -0
- package/dist/{18d5e97bf55.index.html → 18dd22fb422.index.html} +1 -1
- package/dist/{18d5e97bf55.library.html → 18dd22fb422.library.html} +1 -1
- package/dist/18dd22fb422.library.js +1 -0
- package/dist/{18d5e97bf55.preview.html → 18dd22fb422.preview.html} +1 -1
- package/dist/18dd22fb422.preview.js +1 -0
- package/dist/18dd22fb422.screenshoot.js +1 -0
- package/dist/18dd22fb422.webview.js +1 -0
- package/dist/{782.js → 27.js} +6 -6
- package/dist/{178.js → 278.js} +54 -54
- package/dist/{362.js → 459.js} +6 -6
- package/dist/{605.js → 490.js} +57 -57
- package/dist/{841.js → 497.js} +688 -677
- package/dist/{335.js → 74.js} +30 -30
- package/dist/{678.js → 997.js} +6 -6
- package/dist/HASH +1 -1
- package/dist/malicious-app.js +4 -8
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +291 -291
- package/malicious-app.js +4 -8
- package/package.json +6 -6
- package/src/chatbox/Widget.js +56 -32
- package/src/store/api.js +17 -0
- package/src/store/api_fake.js +3 -0
- package/src/store/store.js +16 -50
- package/dist/18d5e97bf55.178.js +0 -1
- package/dist/18d5e97bf55.213.js +0 -1
- package/dist/18d5e97bf55.335.js +0 -1
- package/dist/18d5e97bf55.362.js +0 -1
- package/dist/18d5e97bf55.678.js +0 -1
- package/dist/18d5e97bf55.782.js +0 -1
- package/dist/18d5e97bf55.841.js +0 -1
- package/dist/18d5e97bf55.app.js +0 -1
- package/dist/18d5e97bf55.library.js +0 -1
- package/dist/18d5e97bf55.preview.js +0 -1
- package/dist/18d5e97bf55.screenshoot.js +0 -1
- package/dist/18d5e97bf55.webview.js +0 -1
package/dist/{841.js → 497.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([[497],{
|
|
2
2
|
|
|
3
|
-
/***/
|
|
3
|
+
/***/ 1497:
|
|
4
4
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
@@ -13,19 +13,19 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
// EXTERNAL MODULE: ./src/util/index.js + 3 modules
|
|
16
|
-
var util = __webpack_require__(
|
|
16
|
+
var util = __webpack_require__(1405);
|
|
17
17
|
// EXTERNAL MODULE: ./src/common.js
|
|
18
|
-
var common = __webpack_require__(
|
|
18
|
+
var common = __webpack_require__(2840);
|
|
19
19
|
// EXTERNAL MODULE: ./node_modules/preact/dist/preact.module.js
|
|
20
|
-
var preact_module = __webpack_require__(
|
|
20
|
+
var preact_module = __webpack_require__(172);
|
|
21
21
|
;// CONCATENATED MODULE: ./src/chatbox/Emoji.js
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
class Emoji extends common/* Com */.
|
|
25
|
+
class Emoji extends common/* Com */.Mw {
|
|
26
26
|
render() {
|
|
27
27
|
var emojiCode = this.props.emojiCode;
|
|
28
|
-
if (util/* default */.
|
|
28
|
+
if (util/* default */.A.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,
|
|
@@ -36,11 +36,11 @@ class Emoji extends common/* Com */.up {
|
|
|
36
36
|
;// CONCATENATED MODULE: ./src/chatbox/ChatButton.js
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
var defaultBubble = __webpack_require__(
|
|
40
|
-
let defaultAvatar = __webpack_require__(
|
|
39
|
+
var defaultBubble = __webpack_require__(1108);
|
|
40
|
+
let defaultAvatar = __webpack_require__(2538);
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
class ChatButton extends common/* Com */.
|
|
43
|
+
class ChatButton extends common/* Com */.Mw {
|
|
44
44
|
constructor(props) {
|
|
45
45
|
super(props);
|
|
46
46
|
this.setState({
|
|
@@ -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 */.A.get(ev, 'type') !== 'message_sent') return;
|
|
55
|
+
let bytype = util/* default */.A.get(ev, 'by.type');
|
|
56
56
|
if (bytype !== 'system' && bytype !== 'agent') return;
|
|
57
57
|
let isquickreplies = false;
|
|
58
|
-
util/* default */.
|
|
58
|
+
util/* default */.A.map(util/* default */.A.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 */.A.cloneDeep(chatbox);
|
|
73
|
+
if (util/* default */.A.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 */.A.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 */.A.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 */.A.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 */.A.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 */.A.get(accountSetting, 'mobile_button.position') || position;
|
|
92
|
+
let hiddenButtonMobile = util/* default */.A.get(accountSetting, 'mobile_button.hidden');
|
|
93
93
|
if (hiddenButtonMobile) return null;
|
|
94
94
|
}
|
|
95
|
-
let hiddenButtonDesktop = util/* default */.
|
|
95
|
+
let hiddenButtonDesktop = util/* default */.A.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;
|
|
@@ -112,14 +112,14 @@ class ChatButton extends common/* Com */.up {
|
|
|
112
112
|
}
|
|
113
113
|
ShowGreeting() {
|
|
114
114
|
if (this.props.store.isMobile()) {
|
|
115
|
-
let accid = util/* default */.
|
|
115
|
+
let accid = util/* default */.A.get(this.props.plugin, 'chatbox.account_id', {});
|
|
116
116
|
if (accid === 'acqjeefqeaoiagyfprap') return;
|
|
117
117
|
}
|
|
118
|
-
let greeting = util/* default */.
|
|
118
|
+
let greeting = util/* default */.A.get(this.props.plugin, 'chatbox.greeting', {});
|
|
119
119
|
let agentM = this.props.store.matchAgent('*');
|
|
120
120
|
let byid = greeting.agent_id;
|
|
121
121
|
if (!byid) byid = randomAgent(agentM).id;
|
|
122
|
-
let text = this.props.t.i18n(util/* default */.
|
|
122
|
+
let text = this.props.t.i18n(util/* default */.A.get(greeting, 'greeting', {})) || greeting.message;
|
|
123
123
|
this.setState({
|
|
124
124
|
previewEvent: {
|
|
125
125
|
by: {
|
|
@@ -143,9 +143,9 @@ class ChatButton extends common/* Com */.up {
|
|
|
143
143
|
}
|
|
144
144
|
loadGreeting() {
|
|
145
145
|
let accountSetting = this.props.plugin.chatbox;
|
|
146
|
-
if (new util/* default */.
|
|
147
|
-
let greeting = util/* default */.
|
|
148
|
-
let text = this.props.t.i18n(util/* default */.
|
|
146
|
+
if (new util/* default */.A.Date().getTime() - this.props.store.matchClosePreviewAt() < Ms30Mins) return;
|
|
147
|
+
let greeting = util/* default */.A.get(accountSetting, 'greeting', {});
|
|
148
|
+
let text = this.props.t.i18n(util/* default */.A.get(greeting, 'greeting', {})) || greeting.message;
|
|
149
149
|
if (!text || !greeting.enabled) {
|
|
150
150
|
this.setState({
|
|
151
151
|
previewEvent: {}
|
|
@@ -156,8 +156,8 @@ class ChatButton extends common/* Com */.up {
|
|
|
156
156
|
}
|
|
157
157
|
onClick() {
|
|
158
158
|
let lastview = this.props.store.matchLastview();
|
|
159
|
-
if (util/* default */.
|
|
160
|
-
if (lastview.view !== 'list' || util/* default */.
|
|
159
|
+
if (util/* default */.A.get(lastview, 'view')) {
|
|
160
|
+
if (lastview.view !== 'list' || util/* default */.A.size(this.props.store.matchConvo('*')) > 0) {
|
|
161
161
|
return this.props.onClick && this.props.onClick(Object.assign({}, lastview.opts, {
|
|
162
162
|
view: lastview.view
|
|
163
163
|
}));
|
|
@@ -166,10 +166,10 @@ class ChatButton extends common/* Com */.up {
|
|
|
166
166
|
return this.onPreviewClick();
|
|
167
167
|
}
|
|
168
168
|
onPreviewClick(e) {
|
|
169
|
-
let cid = util/* default */.
|
|
169
|
+
let cid = util/* default */.A.convoOfEv(this.state.previewEvent);
|
|
170
170
|
if (!cid) {
|
|
171
|
-
let convos = util/* default */.
|
|
172
|
-
let convo = util/* default */.
|
|
171
|
+
let convos = util/* default */.A.map(this.props.store.matchConvo('*'));
|
|
172
|
+
let convo = util/* default */.A.find(convos, convo => !util/* default */.A.isConvoSeen(convo, this.props.store.matchUser().id));
|
|
173
173
|
if (!convo) convo = convos[0] || {};
|
|
174
174
|
cid = convo.id;
|
|
175
175
|
}
|
|
@@ -189,24 +189,24 @@ class ChatButton extends common/* Com */.up {
|
|
|
189
189
|
renderPreview() {
|
|
190
190
|
let account = this.props.store.matchAccount();
|
|
191
191
|
let accountSetting = this.props.plugin.chatbox;
|
|
192
|
-
let byid = util/* default */.
|
|
193
|
-
let agent = util/* default */.
|
|
194
|
-
agent.fullname = agent.fullname || util/* default */.
|
|
192
|
+
let byid = util/* default */.A.get(this.state.previewEvent, 'by.display_id', util/* default */.A.get(this.state.previewEvent, 'by.id'));
|
|
193
|
+
let agent = util/* default */.A.cloneDeep(this.props.store.matchAgent(byid)) || {};
|
|
194
|
+
agent.fullname = agent.fullname || util/* default */.A.get(account, 'name') || this.props.t('agent');
|
|
195
195
|
agent.avatar_url = agent.avatar_url || defaultAvatar;
|
|
196
|
-
let position = util/* default */.
|
|
196
|
+
let position = util/* default */.A.get(accountSetting, 'desktop_button.position') || 'right';
|
|
197
197
|
if (this.props.store.isMobile()) {
|
|
198
|
-
position = util/* default */.
|
|
198
|
+
position = util/* default */.A.get(accountSetting, 'mobile_button.position') || position;
|
|
199
199
|
}
|
|
200
200
|
if (accountSetting && accountSetting.hide_agent_profile) {
|
|
201
201
|
agent = Object.assign({}, account, {
|
|
202
|
-
avatar_url: account.logo_url || __webpack_require__(
|
|
202
|
+
avatar_url: account.logo_url || __webpack_require__(3582),
|
|
203
203
|
fullname: account.name || this.props.t('agent')
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
let cls = 'widget-preview widget-preview--' + position;
|
|
207
207
|
if (!this.state.displayPreview) cls += ' widget-preview--hidden';
|
|
208
208
|
var tags = this.renderMessagePreview(this.state.previewEvent, this.props.t('sent_you_a_message'));
|
|
209
|
-
if (util/* default */.
|
|
209
|
+
if (util/* default */.A.size(tags) === 0) cls += ' widget-preview--hidden';
|
|
210
210
|
return (0,preact_module.h)("div", {
|
|
211
211
|
class: cls
|
|
212
212
|
}, (0,preact_module.h)("div", {
|
|
@@ -249,16 +249,20 @@ class ChatButton extends common/* Com */.up {
|
|
|
249
249
|
renderButton() {
|
|
250
250
|
let accountSetting = this.props.plugin.chatbox;
|
|
251
251
|
accountSetting = this.fixMissingSetting(accountSetting);
|
|
252
|
-
let imgsrc = util/* default */.
|
|
253
|
-
let background = util/* default */.
|
|
254
|
-
let position = util/* default */.
|
|
255
|
-
let imgurl = util/* default */.
|
|
256
|
-
let maskurl = util/* default */.
|
|
252
|
+
let imgsrc = util/* default */.A.get(accountSetting, 'desktop_button.background_image_url') || util/* default */.A.get(accountSetting, 'desktop_button.background_mask_url') || defaultBubble;
|
|
253
|
+
let background = util/* default */.A.get(accountSetting, 'background') || DEF_BG;
|
|
254
|
+
let position = util/* default */.A.get(accountSetting, 'desktop_button.position') || 'right';
|
|
255
|
+
let imgurl = util/* default */.A.get(accountSetting, 'desktop_button.background_image_url');
|
|
256
|
+
let maskurl = util/* default */.A.get(accountSetting, 'desktop_button.background_mask_url');
|
|
257
|
+
let imgwidth = util/* default */.A.get(accountSetting, 'desktop_button.width') || 70;
|
|
258
|
+
let imgheight = util/* default */.A.get(accountSetting, 'desktop_button.height') || 70;
|
|
257
259
|
if (this.props.store.isMobile()) {
|
|
258
|
-
imgsrc = util/* default */.
|
|
259
|
-
position = util/* default */.
|
|
260
|
-
let mobileimgurl = util/* default */.
|
|
261
|
-
let mobilemaskurl = util/* default */.
|
|
260
|
+
imgsrc = util/* default */.A.get(accountSetting, 'mobile_button.background_image_url') || util/* default */.A.get(accountSetting, 'mobile_button.background_mask_url') || imgsrc;
|
|
261
|
+
position = util/* default */.A.get(accountSetting, 'mobile_button.position') || position;
|
|
262
|
+
let mobileimgurl = util/* default */.A.get(accountSetting, 'mobile_button.background_image_url');
|
|
263
|
+
let mobilemaskurl = util/* default */.A.get(accountSetting, 'mobile_button.background_mask_url');
|
|
264
|
+
imgwidth = util/* default */.A.get(accountSetting, 'mobile_button.width') || 70;
|
|
265
|
+
imgheight = util/* default */.A.get(accountSetting, 'mobile_button.height') || 70;
|
|
262
266
|
if (mobileimgurl || mobilemaskurl) {
|
|
263
267
|
imgurl = mobileimgurl;
|
|
264
268
|
maskurl = mobilemaskurl;
|
|
@@ -277,8 +281,9 @@ class ChatButton extends common/* Com */.up {
|
|
|
277
281
|
-o-mask-image: url("${encodeURI(DEF_BG_URL)}") !important;
|
|
278
282
|
-moz-mask-image: url("${encodeURI(DEF_BG_URL)}") !important;
|
|
279
283
|
mask-image: url("${encodeURI(DEF_BG_URL)}") !important;
|
|
280
|
-
height:
|
|
281
|
-
width:
|
|
284
|
+
height: ${imgheight}px !important;
|
|
285
|
+
width: ${imgwidth}px !important;
|
|
286
|
+
background: ${background} !important;
|
|
282
287
|
background: ${background} !important;
|
|
283
288
|
mask-size: cover !important;
|
|
284
289
|
-webkit-mask-size: cover !important;
|
|
@@ -313,8 +318,8 @@ class ChatButton extends common/* Com */.up {
|
|
|
313
318
|
-o-mask-image: url("${encodeURI(maskurl)}") !important;
|
|
314
319
|
-moz-mask-image: url("${encodeURI(maskurl)}") !important;
|
|
315
320
|
mask-image: url("${encodeURI(maskurl)}") !important;
|
|
316
|
-
height:
|
|
317
|
-
width:
|
|
321
|
+
height: ${imgheight}px !important;
|
|
322
|
+
width: ${imgwidth}px !important;
|
|
318
323
|
background: ${background} !important;
|
|
319
324
|
-webkit-mask-size: cover !important;
|
|
320
325
|
-o-mask-size: cover !important;
|
|
@@ -323,11 +328,17 @@ class ChatButton extends common/* Com */.up {
|
|
|
323
328
|
`;
|
|
324
329
|
}
|
|
325
330
|
let cls = 'chat-button chat-button--' + position;
|
|
331
|
+
let whiteBgStyle = `
|
|
332
|
+
width: ${imgwidth - 4}px !important;
|
|
333
|
+
height: ${imgheight - 4}px !important;
|
|
334
|
+
|
|
335
|
+
`;
|
|
326
336
|
return (0,preact_module.h)("div", {
|
|
327
337
|
class: cls,
|
|
328
338
|
onClick: e => this.onClick(e)
|
|
329
339
|
}, (0,preact_module.h)("div", {
|
|
330
|
-
class: whitebgcls
|
|
340
|
+
class: whitebgcls,
|
|
341
|
+
style: whiteBgStyle
|
|
331
342
|
}), (0,preact_module.h)("div", {
|
|
332
343
|
class: "chat-button--img-container",
|
|
333
344
|
style: imgcontainerstyle
|
|
@@ -354,14 +365,14 @@ class ChatButton extends common/* Com */.up {
|
|
|
354
365
|
}
|
|
355
366
|
renderMessagePreview(ev, defmsg) {
|
|
356
367
|
defmsg = defmsg || 'Sent you a message';
|
|
357
|
-
let message = util/* default */.
|
|
358
|
-
var format = util/* default */.
|
|
368
|
+
let message = util/* default */.A.get(ev, 'data.message.text');
|
|
369
|
+
var format = util/* default */.A.get(ev, 'data.message.format');
|
|
359
370
|
if (format === 'delta') return this.renderDeltaMessagePreview(ev, defmsg);
|
|
360
371
|
if (format && format !== 'plaintext') message = defmsg;
|
|
361
|
-
if (!message && util/* default */.
|
|
372
|
+
if (!message && util/* default */.A.size(util/* default */.A.get(ev, 'data.message.attachments')) > 0) message = defmsg;
|
|
362
373
|
if (!message) return null;
|
|
363
|
-
let byType = util/* default */.
|
|
364
|
-
var tags = util/* default */.
|
|
374
|
+
let byType = util/* default */.A.get(ev, 'by.type');
|
|
375
|
+
var tags = util/* default */.A.extractText(message).map(tag => {
|
|
365
376
|
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
366
377
|
emojiCode: tag.text,
|
|
367
378
|
byType: byType
|
|
@@ -372,17 +383,17 @@ class ChatButton extends common/* Com */.up {
|
|
|
372
383
|
}
|
|
373
384
|
renderDeltaMessagePreview(ev, defmsg) {
|
|
374
385
|
defmsg = defmsg || 'Sent you a message';
|
|
375
|
-
let message = util/* default */.
|
|
376
|
-
if (!message && util/* default */.
|
|
386
|
+
let message = util/* default */.A.get(ev, 'data.message.quill_delta');
|
|
387
|
+
if (!message && util/* default */.A.size(util/* default */.A.get(ev, 'data.message.attachments')) > 0) message = defmsg;
|
|
377
388
|
if (!message) return;
|
|
378
|
-
let quilldeltas = util/* default */.
|
|
379
|
-
if (!quilldeltas || util/* default */.
|
|
380
|
-
let $deltas = util/* default */.
|
|
389
|
+
let quilldeltas = util/* default */.A.parseJSON(message) || {};
|
|
390
|
+
if (!quilldeltas || util/* default */.A.size(quilldeltas.ops) === 0) return null;
|
|
391
|
+
let $deltas = util/* default */.A.map(quilldeltas.ops, delta => {
|
|
381
392
|
let html = '';
|
|
382
393
|
let insert = delta.insert;
|
|
383
394
|
let attributes = delta.attributes;
|
|
384
395
|
if (insert.dynamicField) {
|
|
385
|
-
return util/* default */.
|
|
396
|
+
return util/* default */.A.get(insert, 'dynamicField.text', '');
|
|
386
397
|
}
|
|
387
398
|
if (insert.emoji) return (0,preact_module.h)(Emoji, {
|
|
388
399
|
emojiCode: `:${insert.emoji}:`
|
|
@@ -407,17 +418,17 @@ class ChatButton extends common/* Com */.up {
|
|
|
407
418
|
}
|
|
408
419
|
}
|
|
409
420
|
function randomAgent(agentM) {
|
|
410
|
-
var agents = util/* default */.
|
|
411
|
-
return agents[Math.floor(Math.random() * util/* default */.
|
|
421
|
+
var agents = util/* default */.A.filter(agentM, ag => ag.type === 'agent');
|
|
422
|
+
return agents[Math.floor(Math.random() * util/* default */.A.size(agents))] || {};
|
|
412
423
|
}
|
|
413
424
|
const Ms30Mins = 30 * 60 * 1000;
|
|
414
425
|
const DEF_BG_URL = 'https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5';
|
|
415
426
|
const DEF_BG = 'linear-gradient(280.16deg, #0053d3 22.03%, #0265ff 78.2%)';
|
|
416
427
|
;// CONCATENATED MODULE: ./src/chatbox/PoweredBy.js
|
|
417
|
-
var logo = __webpack_require__(
|
|
428
|
+
var logo = __webpack_require__(9529);
|
|
418
429
|
|
|
419
430
|
|
|
420
|
-
class PoweredBy extends common/* Com */.
|
|
431
|
+
class PoweredBy extends common/* Com */.Mw {
|
|
421
432
|
constructor(props) {
|
|
422
433
|
super(props);
|
|
423
434
|
}
|
|
@@ -445,7 +456,7 @@ class PoweredBy extends common/* Com */.up {
|
|
|
445
456
|
|
|
446
457
|
|
|
447
458
|
|
|
448
|
-
class AgentsAvatar extends common/* Com */.
|
|
459
|
+
class AgentsAvatar extends common/* Com */.Mw {
|
|
449
460
|
constructor(props) {
|
|
450
461
|
super(props);
|
|
451
462
|
}
|
|
@@ -466,21 +477,21 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
466
477
|
height: 35,
|
|
467
478
|
alt: "agent avatar left",
|
|
468
479
|
class: "avatar group-avatar--agent-left",
|
|
469
|
-
src: this.props.store.replaceFileUrl(acc.logo_url) || __webpack_require__(
|
|
480
|
+
src: this.props.store.replaceFileUrl(acc.logo_url) || __webpack_require__(3582)
|
|
470
481
|
})));
|
|
471
482
|
}
|
|
472
483
|
let agentM = this.props.store.matchAgent('*');
|
|
473
|
-
var agents = util/* default */.
|
|
474
|
-
if (this.props.agent_ids === undefined || util/* default */.
|
|
475
|
-
var agids = util/* default */.
|
|
476
|
-
agids = util/* default */.
|
|
484
|
+
var agents = util/* default */.A.map(this.props.agent_ids, id => agentM[id]);
|
|
485
|
+
if (this.props.agent_ids === undefined || util/* default */.A.size(this.props.agent_ids) === 0) {
|
|
486
|
+
var agids = util/* default */.A.get(accountSetting, 'header.agent_ids', []);
|
|
487
|
+
agids = util/* default */.A.filter(agids, id => !!agentM[id]);
|
|
477
488
|
if (agids.length !== 0) {
|
|
478
|
-
agents = util/* default */.
|
|
489
|
+
agents = util/* default */.A.map(agids, id => agentM[id]);
|
|
479
490
|
} else {
|
|
480
|
-
agents = util/* default */.
|
|
491
|
+
agents = util/* default */.A.filter(agentM, agent => agent.type === 'agent');
|
|
481
492
|
}
|
|
482
493
|
}
|
|
483
|
-
agents = util/* default */.
|
|
494
|
+
agents = util/* default */.A.filter(agents, ag => !!ag);
|
|
484
495
|
if (agents.length === 0) {
|
|
485
496
|
return (0,preact_module.h)("div", {
|
|
486
497
|
class: `group-avatar group-avatar--${mode}`
|
|
@@ -493,7 +504,7 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
493
504
|
height: 35,
|
|
494
505
|
alt: "agent avatar left",
|
|
495
506
|
class: "avatar group-avatar--agent-left",
|
|
496
|
-
src: this.props.store.replaceFileUrl(acc.logo_url) || __webpack_require__(
|
|
507
|
+
src: this.props.store.replaceFileUrl(acc.logo_url) || __webpack_require__(3582)
|
|
497
508
|
})));
|
|
498
509
|
}
|
|
499
510
|
if (agents.length === 1) {
|
|
@@ -510,7 +521,7 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
510
521
|
height: 35,
|
|
511
522
|
class: `avatar ${groupClass}`,
|
|
512
523
|
alt: "agent avatar",
|
|
513
|
-
src: this.props.store.replaceFileUrl(agent.avatar_url) || __webpack_require__(
|
|
524
|
+
src: this.props.store.replaceFileUrl(agent.avatar_url) || __webpack_require__(2538)
|
|
514
525
|
})));
|
|
515
526
|
}
|
|
516
527
|
if (agents.length === 2) {
|
|
@@ -527,7 +538,7 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
527
538
|
height: 35,
|
|
528
539
|
alt: "agent avatar left",
|
|
529
540
|
class: "avatar group-avatar--agent-left",
|
|
530
|
-
src: this.props.store.replaceFileUrl(leftAgent.avatar_url) || __webpack_require__(
|
|
541
|
+
src: this.props.store.replaceFileUrl(leftAgent.avatar_url) || __webpack_require__(2538)
|
|
531
542
|
})), (0,preact_module.h)("div", {
|
|
532
543
|
class: "d-inline-block pos-relative",
|
|
533
544
|
"data-tooltip": rightAgent.fullname || acc.name,
|
|
@@ -537,7 +548,7 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
537
548
|
width: 35,
|
|
538
549
|
height: 35,
|
|
539
550
|
class: "avatar group-avatar--agent-right",
|
|
540
|
-
src: this.props.store.replaceFileUrl(rightAgent.avatar_url) || __webpack_require__(
|
|
551
|
+
src: this.props.store.replaceFileUrl(rightAgent.avatar_url) || __webpack_require__(2538)
|
|
541
552
|
})));
|
|
542
553
|
}
|
|
543
554
|
let leftAgent = agents[0];
|
|
@@ -554,7 +565,7 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
554
565
|
height: 35,
|
|
555
566
|
alt: "agent avatar left",
|
|
556
567
|
class: "avatar group-avatar--agent-left",
|
|
557
|
-
src: this.props.store.replaceFileUrl(leftAgent.avatar_url) || __webpack_require__(
|
|
568
|
+
src: this.props.store.replaceFileUrl(leftAgent.avatar_url) || __webpack_require__(2538)
|
|
558
569
|
})), (0,preact_module.h)("div", {
|
|
559
570
|
class: "d-inline-block pos-relative",
|
|
560
571
|
"data-tooltip": middleAgent.fullname || acc.name,
|
|
@@ -564,7 +575,7 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
564
575
|
width: 35,
|
|
565
576
|
height: 35,
|
|
566
577
|
class: "avatar group-avatar--agent-middle",
|
|
567
|
-
src: this.props.store.replaceFileUrl(middleAgent.avatar_url) || __webpack_require__(
|
|
578
|
+
src: this.props.store.replaceFileUrl(middleAgent.avatar_url) || __webpack_require__(2538)
|
|
568
579
|
})), (0,preact_module.h)("div", {
|
|
569
580
|
class: "d-inline-block pos-relative",
|
|
570
581
|
"data-tooltip": rightAgent.fullname || acc.name,
|
|
@@ -574,7 +585,7 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
574
585
|
height: 35,
|
|
575
586
|
alt: "agent avatar right",
|
|
576
587
|
class: "avatar group-avatar--agent-right",
|
|
577
|
-
src: this.props.store.replaceFileUrl(rightAgent.avatar_url) || __webpack_require__(
|
|
588
|
+
src: this.props.store.replaceFileUrl(rightAgent.avatar_url) || __webpack_require__(2538)
|
|
578
589
|
})));
|
|
579
590
|
}
|
|
580
591
|
}
|
|
@@ -584,7 +595,7 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
584
595
|
|
|
585
596
|
|
|
586
597
|
|
|
587
|
-
class Header extends common/* Com */.
|
|
598
|
+
class Header extends common/* Com */.Mw {
|
|
588
599
|
constructor(props) {
|
|
589
600
|
super(props);
|
|
590
601
|
}
|
|
@@ -594,7 +605,7 @@ class Header extends common/* Com */.up {
|
|
|
594
605
|
let renderSocial = false;
|
|
595
606
|
let renderTeam = false;
|
|
596
607
|
let accSetting = this.props.plugin.chatbox || {};
|
|
597
|
-
let layout = util/* default */.
|
|
608
|
+
let layout = util/* default */.A.get(accSetting, 'header.layout');
|
|
598
609
|
let renderCollapsed = this.props.view !== 'list' && headerMode === 'collapsed';
|
|
599
610
|
let renderClassic = !renderCollapsed && layout === 'classic';
|
|
600
611
|
if (renderCollapsed || layout == 'classic') {
|
|
@@ -612,9 +623,9 @@ class Header extends common/* Com */.up {
|
|
|
612
623
|
let accSetting = this.props.plugin.chatbox || {};
|
|
613
624
|
let acc = this.props.store.matchAccount() || {};
|
|
614
625
|
let state = acc.is_online ? this.props.t('agent_online') : this.props.t('agent_offline');
|
|
615
|
-
let tagline = util/* default */.
|
|
626
|
+
let tagline = util/* default */.A.get(accSetting, `tagline`, {});
|
|
616
627
|
let desc = this.props.t.i18n(tagline) || accSetting.introduction || state;
|
|
617
|
-
let agentIdsJoined = util/* default */.
|
|
628
|
+
let agentIdsJoined = util/* default */.A.map(this.getAgentJoined(this.props.cid), agent => agent.id);
|
|
618
629
|
let cls = 'widget-header--inner widget-header--inner--collapsed';
|
|
619
630
|
if (!show) cls += ' widget-header--inner--hidden';
|
|
620
631
|
let $back = null;
|
|
@@ -640,8 +651,8 @@ class Header extends common/* Com */.up {
|
|
|
640
651
|
renderSocial(show) {
|
|
641
652
|
let accSetting = this.props.plugin.chatbox || {};
|
|
642
653
|
let acc = this.props.store.matchAccount() || {};
|
|
643
|
-
let links = util/* default */.
|
|
644
|
-
let $links = util/* default */.
|
|
654
|
+
let links = util/* default */.A.get(accSetting, 'header.links') || [];
|
|
655
|
+
let $links = util/* default */.A.map(links, link => {
|
|
645
656
|
if (!link.url || !link.type || link.type === 'subiz') return null;
|
|
646
657
|
if (link.type === 'email') {
|
|
647
658
|
return (0,preact_module.h)("div", null, (0,preact_module.h)("a", {
|
|
@@ -661,9 +672,9 @@ class Header extends common/* Com */.up {
|
|
|
661
672
|
});
|
|
662
673
|
const DEFTEAMINTO = `Chúng tôi sẵn sàng trợ giúp :wave:.
|
|
663
674
|
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`;
|
|
664
|
-
let tagline = util/* default */.
|
|
675
|
+
let tagline = util/* default */.A.get(accSetting, `tagline`, {});
|
|
665
676
|
var teamintro = this.props.t.i18n(tagline) || accSetting.introduction || this.props.t('team_intro') || DEFTEAMINTO;
|
|
666
|
-
var tags = util/* default */.
|
|
677
|
+
var tags = util/* default */.A.extractText(teamintro).map(tag => {
|
|
667
678
|
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
668
679
|
emojiCode: tag.text
|
|
669
680
|
});
|
|
@@ -684,7 +695,7 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
|
|
|
684
695
|
}, (0,preact_module.h)("img", {
|
|
685
696
|
alt: "logo",
|
|
686
697
|
class: "social__account_logo",
|
|
687
|
-
src: this.props.store.replaceFileUrl(util/* default */.
|
|
698
|
+
src: this.props.store.replaceFileUrl(util/* default */.A.get(acc, 'logo_url'))
|
|
688
699
|
}), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
689
700
|
class: "social__introduction"
|
|
690
701
|
}, tags), (0,preact_module.h)("div", {
|
|
@@ -695,9 +706,9 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
|
|
|
695
706
|
let accSetting = this.props.plugin.chatbox || {};
|
|
696
707
|
const DEFTEAMINTO = `Chúng tôi sẵn sàng trợ giúp :wave:.
|
|
697
708
|
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`;
|
|
698
|
-
let tagline = util/* default */.
|
|
709
|
+
let tagline = util/* default */.A.get(accSetting, `tagline`, {});
|
|
699
710
|
var teamintro = this.props.t.i18n(tagline) || accSetting.introduction || this.props.t('team_intro') || DEFTEAMINTO;
|
|
700
|
-
var tags = util/* default */.
|
|
711
|
+
var tags = util/* default */.A.extractText(teamintro).map(tag => {
|
|
701
712
|
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
702
713
|
emojiCode: tag.text
|
|
703
714
|
});
|
|
@@ -731,19 +742,19 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
|
|
|
731
742
|
let accSetting = this.props.plugin.chatbox || {};
|
|
732
743
|
let acc = this.props.store.matchAccount() || {};
|
|
733
744
|
let agentsJoined = this.getAgentJoined(this.props.cid);
|
|
734
|
-
let caption = util/* default */.
|
|
745
|
+
let caption = util/* default */.A.get(this.props.plugin, 'chatbox.caption', {});
|
|
735
746
|
let title = this.props.t.i18n(caption) || accSetting.title;
|
|
736
747
|
return getJoinedNameMember(agentsJoined) || title || acc.name || this.props.t('widget_title');
|
|
737
748
|
}
|
|
738
749
|
renderBackButton() {
|
|
739
750
|
let allconvos = this.props.store.matchConvo('*');
|
|
740
|
-
if (util/* default */.
|
|
751
|
+
if (util/* default */.A.size(allconvos) === 0) return null;
|
|
741
752
|
var $unreadcount = null;
|
|
742
753
|
let user = this.props.store.matchUser();
|
|
743
754
|
let unreadcount = 0;
|
|
744
|
-
util/* default */.
|
|
755
|
+
util/* default */.A.map(allconvos, convo => {
|
|
745
756
|
if (convo.id == this.props.cid) return;
|
|
746
|
-
if (!util/* default */.
|
|
757
|
+
if (!util/* default */.A.isConvoSeen(convo, user.id)) unreadcount++;
|
|
747
758
|
});
|
|
748
759
|
if (unreadcount !== 0) {
|
|
749
760
|
$unreadcount = (0,preact_module.h)("span", {
|
|
@@ -782,14 +793,14 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
|
|
|
782
793
|
}
|
|
783
794
|
getAgentJoined(cid) {
|
|
784
795
|
var convo = this.props.store.matchConvo(cid) || {};
|
|
785
|
-
let joined = util/* default */.
|
|
796
|
+
let joined = util/* default */.A.filter(convo.members, mem => mem.type === 'agent' && mem.membership === 'active');
|
|
786
797
|
return joined;
|
|
787
798
|
}
|
|
788
799
|
}
|
|
789
800
|
let getJoinedNameMember = agents => {
|
|
790
|
-
agents = util/* default */.
|
|
801
|
+
agents = util/* default */.A.filter(agents, agent => util/* default */.A.trim(agent.fullname));
|
|
791
802
|
if (!agents.length) return null;
|
|
792
|
-
return util/* default */.
|
|
803
|
+
return util/* default */.A.map(agents, agent => agent.fullname).join(', ');
|
|
793
804
|
};
|
|
794
805
|
;// CONCATENATED MODULE: ./src/chatbox/MessageInput.js
|
|
795
806
|
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,25 +810,25 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
799
810
|
|
|
800
811
|
|
|
801
812
|
|
|
802
|
-
class MessageInput extends common/* Com */.
|
|
813
|
+
class MessageInput extends common/* Com */.Mw {
|
|
803
814
|
constructor(props) {
|
|
804
815
|
super(props);
|
|
805
|
-
_defineProperty(this, "onEnter", util/* default */.
|
|
816
|
+
_defineProperty(this, "onEnter", util/* default */.A.throttle(function () {
|
|
806
817
|
this.submitMessage();
|
|
807
818
|
}, 50));
|
|
808
|
-
this.refFileInput = (0,preact_module/* createRef */.
|
|
809
|
-
this.refMessageInput = (0,preact_module/* createRef */.
|
|
819
|
+
this.refFileInput = (0,preact_module/* createRef */._3)();
|
|
820
|
+
this.refMessageInput = (0,preact_module/* createRef */._3)();
|
|
810
821
|
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
811
822
|
this.props.store.onConvoEvent(this, ev => {
|
|
812
|
-
var evcid = util/* default */.
|
|
823
|
+
var evcid = util/* default */.A.convoOfEv(ev);
|
|
813
824
|
if (evcid !== this.props.cid) return;
|
|
814
825
|
this.forceUpdate();
|
|
815
826
|
});
|
|
816
827
|
this.focus();
|
|
817
|
-
this._forceUpdate = util/* default */.
|
|
828
|
+
this._forceUpdate = util/* default */.A.throttle(() => {
|
|
818
829
|
this.forceUpdate();
|
|
819
830
|
}, 500);
|
|
820
|
-
this.resizeInput = util/* default */.
|
|
831
|
+
this.resizeInput = util/* default */.A.throttle(function () {
|
|
821
832
|
const input = this.refMessageInput.current;
|
|
822
833
|
input.style.setProperty('height', '1em', 'important');
|
|
823
834
|
const height = Math.min(200, input.scrollHeight);
|
|
@@ -837,7 +848,7 @@ class MessageInput extends common/* Com */.up {
|
|
|
837
848
|
class: "message-input--button message-input--attachment-button",
|
|
838
849
|
onClick: e => this.selectFile(e)
|
|
839
850
|
}));
|
|
840
|
-
var msg = util/* default */.
|
|
851
|
+
var msg = util/* default */.A.trim(this.refMessageInput.current && this.refMessageInput.current.value);
|
|
841
852
|
if (msg.length > 0) {
|
|
842
853
|
buttons = (0,preact_module.h)("div", {
|
|
843
854
|
class: "d-flex flex-row align-self-end"
|
|
@@ -876,30 +887,30 @@ class MessageInput extends common/* Com */.up {
|
|
|
876
887
|
}
|
|
877
888
|
hasUnfinishRequiredFormOrLock() {
|
|
878
889
|
let convo = this.props.store.matchConvo(this.props.cid);
|
|
879
|
-
if (util/* default */.
|
|
890
|
+
if (util/* default */.A.get(convo, 'state') === 'ended') return false;
|
|
880
891
|
let events = this.props.store.listEvents(this.props.cid);
|
|
881
|
-
events = util/* default */.
|
|
882
|
-
let attachments = util/* default */.
|
|
883
|
-
let lock = util/* default */.
|
|
892
|
+
events = util/* default */.A.orderBy(events, 'created', 'desc').filter(ev => ev.type === 'message_sent');
|
|
893
|
+
let attachments = util/* default */.A.get(events[0], 'data.message.attachments', []);
|
|
894
|
+
let lock = util/* default */.A.find(attachments, att => util/* default */.A.get(att, 'lock_input'));
|
|
884
895
|
if (lock) return true;
|
|
885
896
|
var last_agent_sent;
|
|
886
897
|
for (let ev of events) {
|
|
887
|
-
if (util/* default */.
|
|
898
|
+
if (util/* default */.A.get(ev, 'by.type') === 'user') continue;
|
|
888
899
|
last_agent_sent = ev;
|
|
889
900
|
break;
|
|
890
901
|
}
|
|
891
|
-
attachments = util/* default */.
|
|
892
|
-
let pendingForms = util/* default */.
|
|
902
|
+
attachments = util/* default */.A.get(last_agent_sent, 'data.message.attachments', []);
|
|
903
|
+
let pendingForms = util/* default */.A.filter(attachments, att => {
|
|
893
904
|
if (!att) return false;
|
|
894
905
|
if (att.type !== 'form' && att.type !== 'ask_info_form') return false;
|
|
895
906
|
var form = att.form;
|
|
896
907
|
if (!form) return false;
|
|
897
|
-
var state = util/* default */.
|
|
908
|
+
var state = util/* default */.A.parseJSON(form.state) || {};
|
|
898
909
|
if (!state.require_finished && att.type !== 'ask_info_form') return false;
|
|
899
910
|
if (isSummited(att.form)) return false;
|
|
900
911
|
return true;
|
|
901
912
|
});
|
|
902
|
-
return util/* default */.
|
|
913
|
+
return util/* default */.A.size(pendingForms) > 0;
|
|
903
914
|
}
|
|
904
915
|
renderEmojiPopup() {
|
|
905
916
|
if (!this.state.openEmoji) return null;
|
|
@@ -1003,10 +1014,10 @@ class MessageInput extends common/* Com */.up {
|
|
|
1003
1014
|
focus() {
|
|
1004
1015
|
if (this.props.disabled) return;
|
|
1005
1016
|
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
1006
|
-
util/* default */.
|
|
1017
|
+
util/* default */.A.setTimeout(() => {
|
|
1007
1018
|
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
1008
1019
|
});
|
|
1009
|
-
util/* default */.
|
|
1020
|
+
util/* default */.A.setTimeout(() => {
|
|
1010
1021
|
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
1011
1022
|
}, 100);
|
|
1012
1023
|
}
|
|
@@ -1056,9 +1067,9 @@ class MessageInput extends common/* Com */.up {
|
|
|
1056
1067
|
$input.value = '';
|
|
1057
1068
|
}
|
|
1058
1069
|
_sendFile(files) {
|
|
1059
|
-
if (util/* default */.
|
|
1070
|
+
if (util/* default */.A.size(files) === 0) return;
|
|
1060
1071
|
if (this.props.disabled) return;
|
|
1061
|
-
let attachments = util/* default */.
|
|
1072
|
+
let attachments = util/* default */.A.map(files, file => {
|
|
1062
1073
|
return {
|
|
1063
1074
|
type: 'file',
|
|
1064
1075
|
mimetype: file.type,
|
|
@@ -1072,7 +1083,7 @@ class MessageInput extends common/* Com */.up {
|
|
|
1072
1083
|
});
|
|
1073
1084
|
}
|
|
1074
1085
|
async submitMessage(msg) {
|
|
1075
|
-
msg = msg || util/* default */.
|
|
1086
|
+
msg = msg || util/* default */.A.trim(this.refMessageInput.current.value) || '';
|
|
1076
1087
|
if (!msg) return;
|
|
1077
1088
|
if (this.props.disabled) return;
|
|
1078
1089
|
this.refMessageInput.current.value = '';
|
|
@@ -1091,7 +1102,7 @@ class MessageInput extends common/* Com */.up {
|
|
|
1091
1102
|
}
|
|
1092
1103
|
pasteImage(event) {
|
|
1093
1104
|
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) return;
|
|
1094
|
-
let now = new util/* default */.
|
|
1105
|
+
let now = new util/* default */.A.Date();
|
|
1095
1106
|
let year = now.getFullYear();
|
|
1096
1107
|
let month = now.getMonth() + 1;
|
|
1097
1108
|
let date = now.getDate();
|
|
@@ -1113,8 +1124,8 @@ class MessageInput extends common/* Com */.up {
|
|
|
1113
1124
|
}
|
|
1114
1125
|
}
|
|
1115
1126
|
function isSummited(form) {
|
|
1116
|
-
let fields = util/* default */.
|
|
1117
|
-
return util/* default */.
|
|
1127
|
+
let fields = util/* default */.A.get(form, 'fields') || [];
|
|
1128
|
+
return util/* default */.A.find(fields, field => !!field.answered);
|
|
1118
1129
|
}
|
|
1119
1130
|
;// CONCATENATED MODULE: ./src/chatbox/ImageAttachments.js
|
|
1120
1131
|
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; }
|
|
@@ -1123,10 +1134,10 @@ function ImageAttachments_toPrimitive(t, r) { if ("object" != typeof t || !t) re
|
|
|
1123
1134
|
|
|
1124
1135
|
|
|
1125
1136
|
|
|
1126
|
-
class ImageAttachment extends common/* Com */.
|
|
1137
|
+
class ImageAttachment extends common/* Com */.Mw {
|
|
1127
1138
|
constructor(props) {
|
|
1128
1139
|
super(props);
|
|
1129
|
-
ImageAttachments_defineProperty(this, "containerRef", (0,preact_module/* createRef */.
|
|
1140
|
+
ImageAttachments_defineProperty(this, "containerRef", (0,preact_module/* createRef */._3)());
|
|
1130
1141
|
this.setState({
|
|
1131
1142
|
ready: false,
|
|
1132
1143
|
errorIndecies: []
|
|
@@ -1181,7 +1192,7 @@ class ImageAttachment extends common/* Com */.up {
|
|
|
1181
1192
|
if (!this.state.ready) {
|
|
1182
1193
|
return;
|
|
1183
1194
|
}
|
|
1184
|
-
let byType = util/* default */.
|
|
1195
|
+
let byType = util/* default */.A.get(this.props.ev, 'by.type');
|
|
1185
1196
|
if (!image.width || !image.height) {
|
|
1186
1197
|
return (0,preact_module.h)("div", {
|
|
1187
1198
|
class: `image-attachment image-attachment--${byType}`
|
|
@@ -1202,7 +1213,7 @@ class ImageAttachment extends common/* Com */.up {
|
|
|
1202
1213
|
let url = this.props.store.replaceFileUrl(image.thumbnail_url || image.url);
|
|
1203
1214
|
let trueUrl = this.props.store.replaceFileUrl(image.url);
|
|
1204
1215
|
if (this.state.errorIndecies.includes(index)) {
|
|
1205
|
-
url = __webpack_require__(
|
|
1216
|
+
url = __webpack_require__(2876);
|
|
1206
1217
|
trueUrl = url;
|
|
1207
1218
|
}
|
|
1208
1219
|
return (0,preact_module.h)("div", {
|
|
@@ -1225,12 +1236,12 @@ class ImageAttachment extends common/* Com */.up {
|
|
|
1225
1236
|
})));
|
|
1226
1237
|
}
|
|
1227
1238
|
render() {
|
|
1228
|
-
var attachments = util/* default */.
|
|
1239
|
+
var attachments = util/* default */.A.get(this.props.ev, 'data.message.attachments', []);
|
|
1229
1240
|
var images = [];
|
|
1230
|
-
let byType = util/* default */.
|
|
1231
|
-
util/* default */.
|
|
1241
|
+
let byType = util/* default */.A.get(this.props.ev, 'by.type');
|
|
1242
|
+
util/* default */.A.each(attachments, (att, i) => {
|
|
1232
1243
|
if (!att) return;
|
|
1233
|
-
if (!util/* default */.
|
|
1244
|
+
if (!util/* default */.A.includes(att.mimetype, 'image')) return;
|
|
1234
1245
|
if (!att.url) return;
|
|
1235
1246
|
var uri = att.url;
|
|
1236
1247
|
if (!uri.startsWith('https://') && !uri.startsWith('http://') && !uri.startsWith('content://') && !uri.startsWith('data:')) {
|
|
@@ -1239,7 +1250,7 @@ class ImageAttachment extends common/* Com */.up {
|
|
|
1239
1250
|
images.push(att);
|
|
1240
1251
|
});
|
|
1241
1252
|
if (images.length === 0) return null;
|
|
1242
|
-
let $images = util/* default */.
|
|
1253
|
+
let $images = util/* default */.A.map(images, (image, index) => this.renderImage(image, index));
|
|
1243
1254
|
if (byType === 'agent') {
|
|
1244
1255
|
return (0,preact_module.h)("div", {
|
|
1245
1256
|
class: "message-agent",
|
|
@@ -1257,20 +1268,20 @@ class ImageAttachment extends common/* Com */.up {
|
|
|
1257
1268
|
|
|
1258
1269
|
|
|
1259
1270
|
|
|
1260
|
-
class AudioAttachments extends common/* Com */.
|
|
1271
|
+
class AudioAttachments extends common/* Com */.Mw {
|
|
1261
1272
|
constructor(props) {
|
|
1262
1273
|
super(props);
|
|
1263
1274
|
}
|
|
1264
1275
|
render() {
|
|
1265
|
-
let byType = util/* default */.
|
|
1266
|
-
var attachments = util/* default */.
|
|
1276
|
+
let byType = util/* default */.A.get(this.props.ev, 'by.type');
|
|
1277
|
+
var attachments = util/* default */.A.get(this.props.ev, 'data.message.attachments', []);
|
|
1267
1278
|
var audios = [];
|
|
1268
|
-
util/* default */.
|
|
1279
|
+
util/* default */.A.each(attachments, (att, i) => {
|
|
1269
1280
|
if (!att) return;
|
|
1270
|
-
if (util/* default */.
|
|
1281
|
+
if (util/* default */.A.includes(att.mimetype, 'audio')) audios.push(att);
|
|
1271
1282
|
});
|
|
1272
1283
|
if (audios.length === 0) return null;
|
|
1273
|
-
var $audios = util/* default */.
|
|
1284
|
+
var $audios = util/* default */.A.map(audios, (audio, index) => {
|
|
1274
1285
|
return (0,preact_module.h)("div", {
|
|
1275
1286
|
key: index,
|
|
1276
1287
|
class: `audio-attachment audio-attachment--${byType}`
|
|
@@ -1291,20 +1302,20 @@ class AudioAttachments extends common/* Com */.up {
|
|
|
1291
1302
|
|
|
1292
1303
|
|
|
1293
1304
|
|
|
1294
|
-
class FileAttachments extends common/* Com */.
|
|
1305
|
+
class FileAttachments extends common/* Com */.Mw {
|
|
1295
1306
|
render() {
|
|
1296
|
-
var byType = util/* default */.
|
|
1297
|
-
var attachments = util/* default */.
|
|
1307
|
+
var byType = util/* default */.A.get(this.props.ev, 'by.type', 'agent');
|
|
1308
|
+
var attachments = util/* default */.A.get(this.props.ev, 'data.message.attachments', []);
|
|
1298
1309
|
var files = [];
|
|
1299
|
-
util/* default */.
|
|
1310
|
+
util/* default */.A.each(attachments, att => {
|
|
1300
1311
|
if (!att) return;
|
|
1301
1312
|
if (!att.url && !att._file) return;
|
|
1302
|
-
if (!util/* default */.
|
|
1313
|
+
if (!util/* default */.A.includes(att.mimetype, 'video') && !util/* default */.A.includes(att.mimetype, 'audio') && !util/* default */.A.includes(att.mimetype, 'image') && att.type !== 'button' && att.type !== 'quick_replies' && att.type !== 'form' && att.type !== 'form_submit') {
|
|
1303
1314
|
files.push(att);
|
|
1304
1315
|
}
|
|
1305
1316
|
});
|
|
1306
1317
|
if (files.length === 0) return null;
|
|
1307
|
-
var $files = util/* default */.
|
|
1318
|
+
var $files = util/* default */.A.map(files, (file, index) => {
|
|
1308
1319
|
return (0,preact_module.h)("div", {
|
|
1309
1320
|
key: index,
|
|
1310
1321
|
class: `file-attachment file-attachment--${byType}`
|
|
@@ -1327,13 +1338,13 @@ class FileAttachments extends common/* Com */.up {
|
|
|
1327
1338
|
|
|
1328
1339
|
|
|
1329
1340
|
|
|
1330
|
-
class Buttons extends common/* Com */.
|
|
1341
|
+
class Buttons extends common/* Com */.Mw {
|
|
1331
1342
|
constructor(props) {
|
|
1332
1343
|
super(props);
|
|
1333
1344
|
}
|
|
1334
1345
|
render() {
|
|
1335
|
-
if (util/* default */.
|
|
1336
|
-
var $buttons = util/* default */.
|
|
1346
|
+
if (util/* default */.A.size(this.props.buttons) === 0) return null;
|
|
1347
|
+
var $buttons = util/* default */.A.map(this.props.buttons, (button, index) => {
|
|
1337
1348
|
if (button.type === 'call_button') {
|
|
1338
1349
|
return (0,preact_module.h)("a", {
|
|
1339
1350
|
class: "url-button-attachment",
|
|
@@ -1372,18 +1383,18 @@ class Buttons extends common/* Com */.up {
|
|
|
1372
1383
|
|
|
1373
1384
|
|
|
1374
1385
|
|
|
1375
|
-
class ButtonAttachments extends common/* Com */.
|
|
1386
|
+
class ButtonAttachments extends common/* Com */.Mw {
|
|
1376
1387
|
constructor(props) {
|
|
1377
1388
|
super(props);
|
|
1378
1389
|
}
|
|
1379
1390
|
render() {
|
|
1380
|
-
let byType = util/* default */.
|
|
1391
|
+
let byType = util/* default */.A.get(this.props.ev, 'by.type');
|
|
1381
1392
|
if (byType === 'user') return null;
|
|
1382
1393
|
let buttons = [];
|
|
1383
|
-
let attachments = util/* default */.
|
|
1384
|
-
util/* default */.
|
|
1385
|
-
if (!att || util/* default */.
|
|
1386
|
-
util/* default */.
|
|
1394
|
+
let attachments = util/* default */.A.get(this.props.ev, 'data.message.attachments', []);
|
|
1395
|
+
util/* default */.A.each(attachments, (att, i) => {
|
|
1396
|
+
if (!att || util/* default */.A.get(att, 'type') !== 'button') return;
|
|
1397
|
+
util/* default */.A.each(util/* default */.A.get(att, 'buttons') || [], btn => buttons.push(btn));
|
|
1387
1398
|
});
|
|
1388
1399
|
return (0,preact_module.h)(Buttons, {
|
|
1389
1400
|
store: this.props.store,
|
|
@@ -1396,26 +1407,26 @@ class ButtonAttachments extends common/* Com */.up {
|
|
|
1396
1407
|
|
|
1397
1408
|
|
|
1398
1409
|
|
|
1399
|
-
class QuickReplies extends common/* Com */.
|
|
1410
|
+
class QuickReplies extends common/* Com */.Mw {
|
|
1400
1411
|
constructor(props) {
|
|
1401
1412
|
super(props);
|
|
1402
1413
|
}
|
|
1403
1414
|
render() {
|
|
1404
|
-
if (util/* default */.
|
|
1415
|
+
if (util/* default */.A.get(this.props.ev, 'by.type') === 'user') return null;
|
|
1405
1416
|
let quickreplies = [];
|
|
1406
|
-
util/* default */.
|
|
1417
|
+
util/* default */.A.map(util/* default */.A.get(this.props.ev, 'data.message.attachments', []), att => {
|
|
1407
1418
|
if (!att) return;
|
|
1408
1419
|
if (att.type === 'quick_replies') {
|
|
1409
|
-
quickreplies = util/* default */.
|
|
1420
|
+
quickreplies = util/* default */.A.get(att, 'quick_replies', []);
|
|
1410
1421
|
}
|
|
1411
1422
|
});
|
|
1412
|
-
quickreplies = util/* default */.
|
|
1423
|
+
quickreplies = util/* default */.A.filter(quickreplies, r => r.title);
|
|
1413
1424
|
if (quickreplies.length === 0) return null;
|
|
1414
|
-
let cid = util/* default */.
|
|
1425
|
+
let cid = util/* default */.A.convoOfEv(this.props.ev);
|
|
1415
1426
|
let convo = this.props.store.matchConvo(cid);
|
|
1416
|
-
if (util/* default */.
|
|
1417
|
-
let events = util/* default */.
|
|
1418
|
-
events = util/* default */.
|
|
1427
|
+
if (util/* default */.A.get(convo, 'state') === 'ended') return null;
|
|
1428
|
+
let events = util/* default */.A.map(this.props.store.listEvents(cid));
|
|
1429
|
+
events = util/* default */.A.orderBy(events, 'created', 'asc').filter(ev => ev.type === 'message_sent');
|
|
1419
1430
|
let evindex = 0;
|
|
1420
1431
|
for (var i = 0; i < events.length; i++) {
|
|
1421
1432
|
if (events[i].id === this.props.ev.id) {
|
|
@@ -1424,9 +1435,9 @@ class QuickReplies extends common/* Com */.up {
|
|
|
1424
1435
|
}
|
|
1425
1436
|
}
|
|
1426
1437
|
for (var i = evindex + 1; i < events.length; i++) {
|
|
1427
|
-
if (util/* default */.
|
|
1438
|
+
if (util/* default */.A.get(events[i], 'by.type') === 'user') return null;
|
|
1428
1439
|
}
|
|
1429
|
-
let $replies = util/* default */.
|
|
1440
|
+
let $replies = util/* default */.A.map(quickreplies, r => (0,preact_module.h)("div", {
|
|
1430
1441
|
class: "message_quick_reply",
|
|
1431
1442
|
onClick: e => this.props.onSelect(r)
|
|
1432
1443
|
}, r.title));
|
|
@@ -1439,7 +1450,7 @@ class QuickReplies extends common/* Com */.up {
|
|
|
1439
1450
|
|
|
1440
1451
|
|
|
1441
1452
|
|
|
1442
|
-
class ListField extends common/* Com */.
|
|
1453
|
+
class ListField extends common/* Com */.Mw {
|
|
1443
1454
|
constructor(props) {
|
|
1444
1455
|
super(props);
|
|
1445
1456
|
this.setState({
|
|
@@ -1448,18 +1459,18 @@ class ListField extends common/* Com */.up {
|
|
|
1448
1459
|
});
|
|
1449
1460
|
}
|
|
1450
1461
|
render() {
|
|
1451
|
-
let fields = util/* default */.
|
|
1462
|
+
let fields = util/* default */.A.filter(this.props.items, item => {
|
|
1452
1463
|
let search = this.state.search.toLowerCase();
|
|
1453
1464
|
let name = item || '';
|
|
1454
1465
|
return name.toLowerCase().indexOf(search) > -1;
|
|
1455
1466
|
});
|
|
1456
|
-
let $fields = util/* default */.
|
|
1467
|
+
let $fields = util/* default */.A.map(fields, field => {
|
|
1457
1468
|
return (0,preact_module.h)("li", {
|
|
1458
1469
|
class: "custom-select--item-options",
|
|
1459
1470
|
onClick: () => this.add(field)
|
|
1460
1471
|
}, field);
|
|
1461
1472
|
});
|
|
1462
|
-
let $selected = util/* default */.
|
|
1473
|
+
let $selected = util/* default */.A.map(this.props.selected, (item, i) => {
|
|
1463
1474
|
return (0,preact_module.h)("div", {
|
|
1464
1475
|
class: "custom-select--selected-item",
|
|
1465
1476
|
onClick: e => this.remove(e, i)
|
|
@@ -1492,7 +1503,7 @@ class ListField extends common/* Com */.up {
|
|
|
1492
1503
|
}
|
|
1493
1504
|
return (0,preact_module.h)("div", {
|
|
1494
1505
|
class: "form-control custom-select"
|
|
1495
|
-
}, (0,preact_module.h)(common/* Clickaway */.
|
|
1506
|
+
}, (0,preact_module.h)(common/* Clickaway */.tW, {
|
|
1496
1507
|
onClickaway: e => this.clickaway()
|
|
1497
1508
|
}, (0,preact_module.h)("div", {
|
|
1498
1509
|
class: "custom-select--wrap-selected",
|
|
@@ -1535,21 +1546,21 @@ class ListField extends common/* Com */.up {
|
|
|
1535
1546
|
|
|
1536
1547
|
|
|
1537
1548
|
|
|
1538
|
-
class FormAttachment extends common/* Com */.
|
|
1549
|
+
class FormAttachment extends common/* Com */.Mw {
|
|
1539
1550
|
constructor(props) {
|
|
1540
1551
|
super(props);
|
|
1541
1552
|
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
1542
1553
|
let user = this.props.store.matchUser();
|
|
1543
|
-
let fields = util/* default */.
|
|
1544
|
-
let formData = util/* default */.
|
|
1554
|
+
let fields = util/* default */.A.get(this.props.form, 'fields') || [];
|
|
1555
|
+
let formData = util/* default */.A.map(fields, field => {
|
|
1545
1556
|
let is_required = field.is_required || false;
|
|
1546
|
-
var state = util/* default */.
|
|
1557
|
+
var state = util/* default */.A.parseJSON(field.state) || {};
|
|
1547
1558
|
if (!is_required) is_required = state.require || false;
|
|
1548
|
-
var userattr = util/* default */.
|
|
1559
|
+
var userattr = util/* default */.A.getUserAttr(user, field.name, state.type || 'text');
|
|
1549
1560
|
return {
|
|
1550
1561
|
name: field.name,
|
|
1551
1562
|
items: field.items,
|
|
1552
|
-
value: util/* default */.
|
|
1563
|
+
value: util/* default */.A.parseJSON(field.answer) || util/* default */.A.parseJSON(field.default_answer) || userattr,
|
|
1553
1564
|
is_required,
|
|
1554
1565
|
label: field.title,
|
|
1555
1566
|
type: field.input_type
|
|
@@ -1560,13 +1571,13 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1560
1571
|
});
|
|
1561
1572
|
}
|
|
1562
1573
|
isSummited() {
|
|
1563
|
-
let found = util/* default */.
|
|
1574
|
+
let found = util/* default */.A.find(this.state.formData, field => !!field.answered);
|
|
1564
1575
|
if (found) return true;
|
|
1565
|
-
let convo = this.props.store.matchConvo(util/* default */.
|
|
1576
|
+
let convo = this.props.store.matchConvo(util/* default */.A.convoOfEv(this.props.ev));
|
|
1566
1577
|
return convo.state === 'ended';
|
|
1567
1578
|
}
|
|
1568
1579
|
render() {
|
|
1569
|
-
if (util/* default */.
|
|
1580
|
+
if (util/* default */.A.size(this.state.formData) === 0) return null;
|
|
1570
1581
|
let $fields = this.renderFields();
|
|
1571
1582
|
let $submitbutton = null;
|
|
1572
1583
|
if (!this.isSummited()) {
|
|
@@ -1585,11 +1596,11 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1585
1596
|
}
|
|
1586
1597
|
focus() {
|
|
1587
1598
|
if (this.props.store.isPreview) return;
|
|
1588
|
-
if (util/* default */.
|
|
1599
|
+
if (util/* default */.A.size(this.state.formData) === 0) return;
|
|
1589
1600
|
let $field;
|
|
1590
1601
|
if (this.isFormFilled()) {
|
|
1591
1602
|
var keys = Object.keys(this.state.formData);
|
|
1592
|
-
var lastkey = keys[util/* default */.
|
|
1603
|
+
var lastkey = keys[util/* default */.A.size(keys) - 1];
|
|
1593
1604
|
var lastfield = this.state.formData[lastkey];
|
|
1594
1605
|
$field = this['field.' + encode(lastfield.name)];
|
|
1595
1606
|
} else {
|
|
@@ -1600,20 +1611,20 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1600
1611
|
if ($field) $field.focus();
|
|
1601
1612
|
}
|
|
1602
1613
|
firstUnfilledField() {
|
|
1603
|
-
return util/* default */.
|
|
1614
|
+
return util/* default */.A.find(this.state.formData, field => field.value == null || field.value === '');
|
|
1604
1615
|
}
|
|
1605
1616
|
isFormFilled() {
|
|
1606
|
-
return !util/* default */.
|
|
1617
|
+
return !util/* default */.A.find(this.state.formData, field => field.value == null || field.value === '');
|
|
1607
1618
|
}
|
|
1608
1619
|
onInputChange(index, val) {
|
|
1609
|
-
let formData = util/* default */.
|
|
1620
|
+
let formData = util/* default */.A.cloneDeep(this.state.formData);
|
|
1610
1621
|
formData[index].value = val;
|
|
1611
1622
|
this.setState({
|
|
1612
1623
|
formData
|
|
1613
1624
|
});
|
|
1614
1625
|
}
|
|
1615
1626
|
onListAddItem(index, val) {
|
|
1616
|
-
let formData = util/* default */.
|
|
1627
|
+
let formData = util/* default */.A.cloneDeep(this.state.formData);
|
|
1617
1628
|
let field = formData[index];
|
|
1618
1629
|
field.value = field.value || [];
|
|
1619
1630
|
field.value.push(val);
|
|
@@ -1622,7 +1633,7 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1622
1633
|
});
|
|
1623
1634
|
}
|
|
1624
1635
|
onListRemoveItem(index, vindex) {
|
|
1625
|
-
let formData = util/* default */.
|
|
1636
|
+
let formData = util/* default */.A.cloneDeep(this.state.formData);
|
|
1626
1637
|
let field = formData[index];
|
|
1627
1638
|
field.value = field.value || [];
|
|
1628
1639
|
field.value.splice(vindex, 1);
|
|
@@ -1631,9 +1642,9 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1631
1642
|
});
|
|
1632
1643
|
}
|
|
1633
1644
|
renderFields() {
|
|
1634
|
-
if (util/* default */.
|
|
1645
|
+
if (util/* default */.A.size(this.state.formData) === 0) return null;
|
|
1635
1646
|
let $fields = null;
|
|
1636
|
-
$fields = util/* default */.
|
|
1647
|
+
$fields = util/* default */.A.map(this.state.formData, (field, index) => {
|
|
1637
1648
|
let $field = null;
|
|
1638
1649
|
var errclass = field.error ? 'input--error' : '';
|
|
1639
1650
|
if (field.type === 'text') {
|
|
@@ -1709,7 +1720,7 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1709
1720
|
}, (0,preact_module.h)("div", null)));
|
|
1710
1721
|
} else if (field.type === 'list') {
|
|
1711
1722
|
let selected = field.value || [];
|
|
1712
|
-
let items = util/* default */.
|
|
1723
|
+
let items = util/* default */.A.filter(util/* default */.A.get(field, 'items', []), item => !selected.includes(item));
|
|
1713
1724
|
$field = (0,preact_module.h)(ListField, {
|
|
1714
1725
|
selected: selected,
|
|
1715
1726
|
items: items,
|
|
@@ -1747,15 +1758,15 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1747
1758
|
}
|
|
1748
1759
|
async submit() {
|
|
1749
1760
|
var hasError = false;
|
|
1750
|
-
util/* default */.
|
|
1751
|
-
if (field.is_required && (field.value === undefined || field.value === '' || util/* default */.
|
|
1761
|
+
util/* default */.A.map(this.state.formData, field => {
|
|
1762
|
+
if (field.is_required && (field.value === undefined || field.value === '' || util/* default */.A.size(field.value) === 0 && Array.isArray(field.value))) {
|
|
1752
1763
|
field.error = this.props.t('error_empty');
|
|
1753
1764
|
hasError = true;
|
|
1754
1765
|
} else {
|
|
1755
1766
|
field.error = '';
|
|
1756
1767
|
}
|
|
1757
1768
|
if (field.name === 'emails' && field.value) {
|
|
1758
|
-
if (!util/* default */.
|
|
1769
|
+
if (!util/* default */.A.isEmail(field.value)) {
|
|
1759
1770
|
field.error = this.props.t('error_email_invalid');
|
|
1760
1771
|
hasError = true;
|
|
1761
1772
|
}
|
|
@@ -1764,32 +1775,32 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1764
1775
|
this.forceUpdate();
|
|
1765
1776
|
if (hasError) return;
|
|
1766
1777
|
let user = {};
|
|
1767
|
-
let formData = util/* default */.
|
|
1768
|
-
util/* default */.
|
|
1778
|
+
let formData = util/* default */.A.cloneDeep(this.state.formData);
|
|
1779
|
+
util/* default */.A.map(formData, field => {
|
|
1769
1780
|
var attr = {
|
|
1770
1781
|
key: field.name
|
|
1771
1782
|
};
|
|
1772
|
-
field.answered = new util/* default */.
|
|
1783
|
+
field.answered = new util/* default */.A.Date().getTime();
|
|
1773
1784
|
if (field.type === 'number') {
|
|
1774
1785
|
attr.number = parseInt(field.value);
|
|
1775
|
-
field.answer = util/* default */.
|
|
1786
|
+
field.answer = util/* default */.A.stringify(attr.number);
|
|
1776
1787
|
}
|
|
1777
1788
|
if (field.type === 'datetime') {
|
|
1778
|
-
attr.datetime = new util/* default */.
|
|
1779
|
-
field.answer = util/* default */.
|
|
1789
|
+
attr.datetime = new util/* default */.A.Date(field.value).toISOString();
|
|
1790
|
+
field.answer = util/* default */.A.stringify(attr.datetime);
|
|
1780
1791
|
}
|
|
1781
1792
|
if (field.type === 'list') {
|
|
1782
1793
|
attr.list = field.value;
|
|
1783
|
-
field.answer = util/* default */.
|
|
1794
|
+
field.answer = util/* default */.A.stringify(attr.list);
|
|
1784
1795
|
}
|
|
1785
1796
|
if (field.type === 'text' || field.type === 'boolean') {
|
|
1786
1797
|
attr[field.type] = field.value;
|
|
1787
|
-
field.answer = util/* default */.
|
|
1798
|
+
field.answer = util/* default */.A.stringify(field.value);
|
|
1788
1799
|
}
|
|
1789
|
-
util/* default */.
|
|
1800
|
+
util/* default */.A.setUserAttr(user, attr);
|
|
1790
1801
|
});
|
|
1791
|
-
util/* default */.
|
|
1792
|
-
let ffield = util/* default */.
|
|
1802
|
+
util/* default */.A.map(formData, field => {
|
|
1803
|
+
let ffield = util/* default */.A.find(this.props.form.fields, ffield => ffield.name === field.name);
|
|
1793
1804
|
if (!ffield) return;
|
|
1794
1805
|
ffield.answered = field.answered;
|
|
1795
1806
|
});
|
|
@@ -1802,12 +1813,12 @@ class FormAttachment extends common/* Com */.up {
|
|
|
1802
1813
|
type: 'form_submit',
|
|
1803
1814
|
form_submit: {
|
|
1804
1815
|
state: '{"user_id":"' + this.props.store.matchUser().id + '"}',
|
|
1805
|
-
form_message_id: util/* default */.
|
|
1816
|
+
form_message_id: util/* default */.A.get(this.props.ev, 'id'),
|
|
1806
1817
|
fields: formData
|
|
1807
1818
|
}
|
|
1808
1819
|
}]
|
|
1809
1820
|
};
|
|
1810
|
-
let cid = util/* default */.
|
|
1821
|
+
let cid = util/* default */.A.convoOfEv(this.props.ev);
|
|
1811
1822
|
this.props.store.sendConvoEvent(cid, 'message_sent', {
|
|
1812
1823
|
message
|
|
1813
1824
|
});
|
|
@@ -1822,22 +1833,22 @@ function encode(key) {
|
|
|
1822
1833
|
|
|
1823
1834
|
|
|
1824
1835
|
|
|
1825
|
-
class FormAttachments extends common/* Com */.
|
|
1836
|
+
class FormAttachments extends common/* Com */.Mw {
|
|
1826
1837
|
constructor(props) {
|
|
1827
1838
|
super(props);
|
|
1828
1839
|
}
|
|
1829
1840
|
render() {
|
|
1830
|
-
let byType = util/* default */.
|
|
1841
|
+
let byType = util/* default */.A.get(this.props.ev, 'by.type');
|
|
1831
1842
|
if (byType === 'user') return;
|
|
1832
1843
|
let forms = [];
|
|
1833
|
-
let attachments = util/* default */.
|
|
1834
|
-
util/* default */.
|
|
1844
|
+
let attachments = util/* default */.A.get(this.props.ev, 'data.message.attachments') || [];
|
|
1845
|
+
util/* default */.A.each(attachments, att => {
|
|
1835
1846
|
if (!att) return;
|
|
1836
1847
|
if (att.type !== 'form' && att.type !== 'ask_info_form') return;
|
|
1837
1848
|
att.form._type = att.type;
|
|
1838
1849
|
forms.push(att.form);
|
|
1839
1850
|
});
|
|
1840
|
-
let $forms = util/* default */.
|
|
1851
|
+
let $forms = util/* default */.A.map(forms, (form, formIndex) => {
|
|
1841
1852
|
return (0,preact_module.h)(FormAttachment, {
|
|
1842
1853
|
store: this.props.store,
|
|
1843
1854
|
onSubmit: this.props.onSubmit,
|
|
@@ -1864,21 +1875,21 @@ class FormAttachments extends common/* Com */.up {
|
|
|
1864
1875
|
|
|
1865
1876
|
|
|
1866
1877
|
|
|
1867
|
-
class FormSubmitAttachments extends common/* Com */.
|
|
1878
|
+
class FormSubmitAttachments extends common/* Com */.Mw {
|
|
1868
1879
|
constructor(props) {
|
|
1869
1880
|
super(props);
|
|
1870
1881
|
}
|
|
1871
1882
|
render() {
|
|
1872
1883
|
return null;
|
|
1873
1884
|
let submits = [];
|
|
1874
|
-
let attachments = util/* default */.
|
|
1875
|
-
util/* default */.
|
|
1885
|
+
let attachments = util/* default */.A.get(this.props.ev, 'data.message.attachments') || [];
|
|
1886
|
+
util/* default */.A.each(attachments, att => {
|
|
1876
1887
|
if (!att) return;
|
|
1877
1888
|
if (att.type !== 'form_submit') return;
|
|
1878
1889
|
if (!att.form_submit) return;
|
|
1879
1890
|
submits.push(att.form_submit);
|
|
1880
1891
|
});
|
|
1881
|
-
let $submits = util/* default */.
|
|
1892
|
+
let $submits = util/* default */.A.map(submits, (submit, index) => (0,preact_module.h)("div", {
|
|
1882
1893
|
class: "info-message"
|
|
1883
1894
|
}, (0,preact_module.h)("span", null, this.props.tt('prechat_form_thanks'))));
|
|
1884
1895
|
return (0,preact_module.h)("div", null, $submits);
|
|
@@ -1929,13 +1940,13 @@ function getFirstTouch(ev) {
|
|
|
1929
1940
|
|
|
1930
1941
|
|
|
1931
1942
|
|
|
1932
|
-
class GenericTemplateAttachments extends common/* Com */.
|
|
1943
|
+
class GenericTemplateAttachments extends common/* Com */.Mw {
|
|
1933
1944
|
constructor(props) {
|
|
1934
1945
|
super(props);
|
|
1935
1946
|
this.state = {
|
|
1936
1947
|
focusing: 0
|
|
1937
1948
|
};
|
|
1938
|
-
this.galleryRef = (0,preact_module/* createRef */.
|
|
1949
|
+
this.galleryRef = (0,preact_module/* createRef */._3)();
|
|
1939
1950
|
}
|
|
1940
1951
|
componentDidMount() {
|
|
1941
1952
|
this.bindDrag();
|
|
@@ -1950,13 +1961,13 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1950
1961
|
});
|
|
1951
1962
|
}
|
|
1952
1963
|
render() {
|
|
1953
|
-
let byType = util/* default */.
|
|
1964
|
+
let byType = util/* default */.A.get(this.props.ev, 'by.type');
|
|
1954
1965
|
if (byType === 'user') return null;
|
|
1955
|
-
let attachments = util/* default */.
|
|
1956
|
-
let generics = util/* default */.
|
|
1966
|
+
let attachments = util/* default */.A.get(this.props.ev, 'data.message.attachments', []);
|
|
1967
|
+
let generics = util/* default */.A.filter(attachments, att => util/* default */.A.get(att, 'type') === 'generic');
|
|
1957
1968
|
if (generics.length === 0) return null;
|
|
1958
|
-
var $generics = util/* default */.
|
|
1959
|
-
var $eles = util/* default */.
|
|
1969
|
+
var $generics = util/* default */.A.map(generics, (gen, index) => {
|
|
1970
|
+
var $eles = util/* default */.A.map(gen.elements, ele => {
|
|
1960
1971
|
let title = this.props.t.i18n(ele.i18n_title) || ele.title;
|
|
1961
1972
|
let subtitle = this.props.t.i18n(ele.i18n_subtitle) || ele.subtitle;
|
|
1962
1973
|
let $title = title ? (0,preact_module.h)("div", {
|
|
@@ -1967,7 +1978,7 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1967
1978
|
}, subtitle) : null;
|
|
1968
1979
|
let imgsrc = this.props.store.replaceFileUrl(ele.image_url);
|
|
1969
1980
|
if (!ele.image_url) {
|
|
1970
|
-
imgsrc = __webpack_require__(
|
|
1981
|
+
imgsrc = __webpack_require__(2876);
|
|
1971
1982
|
}
|
|
1972
1983
|
return (0,preact_module.h)("div", {
|
|
1973
1984
|
class: "generic-attachment--element swiper-slide"
|
|
@@ -1983,7 +1994,7 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1983
1994
|
t: this.props.t
|
|
1984
1995
|
}));
|
|
1985
1996
|
});
|
|
1986
|
-
let elements = util/* default */.
|
|
1997
|
+
let elements = util/* default */.A.get(attachments, '0.elements', []);
|
|
1987
1998
|
let leftNavigatorCls = 'generic-attachment-navigator generic-attachment-navigator--left';
|
|
1988
1999
|
let rightNavigatorCls = 'generic-attachment-navigator generic-attachment-navigator--right';
|
|
1989
2000
|
if (this.state.focusing === 0) leftNavigatorCls += ' generic-attachment-navigator--disabled';
|
|
@@ -1993,7 +2004,7 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1993
2004
|
}, (0,preact_module.h)("div", {
|
|
1994
2005
|
class: "generic-attachment",
|
|
1995
2006
|
ref: this.galleryRef
|
|
1996
|
-
}, $eles), !this.props.store.isMobile() && (0,preact_module.h)(preact_module/* Fragment */.
|
|
2007
|
+
}, $eles), !this.props.store.isMobile() && (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
|
|
1997
2008
|
class: leftNavigatorCls,
|
|
1998
2009
|
onClick: _ => this.focus(this.state.focusing - 1)
|
|
1999
2010
|
}, (0,preact_module.h)("span", {
|
|
@@ -2010,38 +2021,38 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
2010
2021
|
bindDrag() {
|
|
2011
2022
|
if (!this.props.store.isMobile()) return;
|
|
2012
2023
|
let eles = document.getElementsByClassName('generic-attachment');
|
|
2013
|
-
util/* default */.
|
|
2024
|
+
util/* default */.A.map(eles, ele => bind(ele, () => {}));
|
|
2014
2025
|
}
|
|
2015
2026
|
}
|
|
2016
2027
|
;// CONCATENATED MODULE: ./src/chatbox/ProductAttachments.js
|
|
2017
2028
|
|
|
2018
2029
|
|
|
2019
2030
|
|
|
2020
|
-
class ProductAttachments extends common/* Com */.
|
|
2031
|
+
class ProductAttachments extends common/* Com */.Mw {
|
|
2021
2032
|
render() {
|
|
2022
|
-
let byType = util/* default */.
|
|
2033
|
+
let byType = util/* default */.A.get(this.props.ev, 'by.type');
|
|
2023
2034
|
if (byType === 'user') return null;
|
|
2024
|
-
let attachments = util/* default */.
|
|
2025
|
-
let products = util/* default */.
|
|
2035
|
+
let attachments = util/* default */.A.get(this.props.ev, 'data.message.attachments', []);
|
|
2036
|
+
let products = util/* default */.A.filter(attachments, att => util/* default */.A.get(att, 'type') === 'product' || util/* default */.A.get(att, 'type') === 'product_preview');
|
|
2026
2037
|
products = products.filter(product => product.product && product.product.name);
|
|
2027
2038
|
if (products.length === 0) return null;
|
|
2028
2039
|
let acc = this.props.store.matchAccount();
|
|
2029
|
-
let $products = util/* default */.
|
|
2040
|
+
let $products = util/* default */.A.map(products, (att, index) => {
|
|
2030
2041
|
let product = att.product;
|
|
2031
2042
|
let $detailbtns = [];
|
|
2032
2043
|
let url = product.url || product.mobile_url;
|
|
2033
2044
|
if (this.props.store.isMobile()) url = product.mobile_url || product.url;
|
|
2034
|
-
if (url && util/* default */.
|
|
2045
|
+
if (url && util/* default */.A.size(product.buttons) == 0) $detailbtns.push((0,preact_module.h)("a", {
|
|
2035
2046
|
class: "product_attachment__btn",
|
|
2036
2047
|
href: url,
|
|
2037
2048
|
target: "_blank"
|
|
2038
2049
|
}, this.props.t('detail'), (0,preact_module.h)("img", {
|
|
2039
|
-
src: __webpack_require__(
|
|
2050
|
+
src: __webpack_require__(3266),
|
|
2040
2051
|
class: "product_attachment__btn_external_link"
|
|
2041
2052
|
})));
|
|
2042
2053
|
console.log('P', product);
|
|
2043
|
-
if (util/* default */.
|
|
2044
|
-
$detailbtns = $detailbtns.concat(util/* default */.
|
|
2054
|
+
if (util/* default */.A.size(product.buttons) > 0) {
|
|
2055
|
+
$detailbtns = $detailbtns.concat(util/* default */.A.map(product.buttons, (button, index) => {
|
|
2045
2056
|
if (button.type === 'call_button') {
|
|
2046
2057
|
return (0,preact_module.h)("a", {
|
|
2047
2058
|
class: "product_attachment__btn",
|
|
@@ -2058,7 +2069,7 @@ class ProductAttachments extends common/* Com */.up {
|
|
|
2058
2069
|
key: index,
|
|
2059
2070
|
title: button.title
|
|
2060
2071
|
}, this.props.t.i18n(button.i18n_title) || button.title || this.props.t('detail'), ' ', (0,preact_module.h)("img", {
|
|
2061
|
-
src: __webpack_require__(
|
|
2072
|
+
src: __webpack_require__(3266),
|
|
2062
2073
|
class: "product_attachment__btn_external_link"
|
|
2063
2074
|
}));
|
|
2064
2075
|
}
|
|
@@ -2081,16 +2092,16 @@ class ProductAttachments extends common/* Com */.up {
|
|
|
2081
2092
|
if (desc) $subtitle = (0,preact_module.h)("div", {
|
|
2082
2093
|
class: "product_attachment__subtitle"
|
|
2083
2094
|
}, desc);
|
|
2084
|
-
let currency = product.currency || util/* default */.
|
|
2095
|
+
let currency = product.currency || util/* default */.A.get(acc, 'currency', 'VND');
|
|
2085
2096
|
let $price = null;
|
|
2086
2097
|
if (product.price) {
|
|
2087
2098
|
$price = (0,preact_module.h)("div", {
|
|
2088
2099
|
class: "product_attachment__price"
|
|
2089
|
-
}, util/* default */.
|
|
2100
|
+
}, util/* default */.A.formatCurrency(product.price, currency));
|
|
2090
2101
|
}
|
|
2091
2102
|
let imgsrc = this.props.store.replaceFileUrl(product.image);
|
|
2092
2103
|
if (!product.image) {
|
|
2093
|
-
imgsrc = __webpack_require__(
|
|
2104
|
+
imgsrc = __webpack_require__(2876);
|
|
2094
2105
|
}
|
|
2095
2106
|
return (0,preact_module.h)("div", {
|
|
2096
2107
|
class: 'product_attachment product_attachment__' + byType
|
|
@@ -2111,16 +2122,16 @@ class ProductAttachments extends common/* Com */.up {
|
|
|
2111
2122
|
|
|
2112
2123
|
|
|
2113
2124
|
|
|
2114
|
-
class OrderAttachments_ProductAttachments extends common/* Com */.
|
|
2125
|
+
class OrderAttachments_ProductAttachments extends common/* Com */.Mw {
|
|
2115
2126
|
render() {
|
|
2116
|
-
let byType = util/* default */.
|
|
2127
|
+
let byType = util/* default */.A.get(this.props.ev, 'by.type');
|
|
2117
2128
|
if (byType === 'user') return null;
|
|
2118
2129
|
let acc = this.props.store.matchAccount();
|
|
2119
|
-
var attachments = util/* default */.
|
|
2120
|
-
let orders = util/* default */.
|
|
2130
|
+
var attachments = util/* default */.A.get(this.props.ev, 'data.message.attachments', []);
|
|
2131
|
+
let orders = util/* default */.A.filter(attachments, att => att.type === 'order' && att.order).map(att => att.order);
|
|
2121
2132
|
if (orders.length === 0) return null;
|
|
2122
|
-
let $orders = util/* default */.
|
|
2123
|
-
util/* default */.
|
|
2133
|
+
let $orders = util/* default */.A.map(orders, (order, index) => {
|
|
2134
|
+
util/* default */.A.calcOrderTotal(order);
|
|
2124
2135
|
let $note = null;
|
|
2125
2136
|
if (order.note) {
|
|
2126
2137
|
$note = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
@@ -2131,17 +2142,17 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2131
2142
|
}, order.note));
|
|
2132
2143
|
}
|
|
2133
2144
|
let $products = null;
|
|
2134
|
-
if (util/* default */.
|
|
2145
|
+
if (util/* default */.A.size(order.items) > 0) {
|
|
2135
2146
|
$products = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
2136
2147
|
class: "order_attachment__label"
|
|
2137
|
-
}, this.props.t('product')), util/* default */.
|
|
2148
|
+
}, this.props.t('product')), util/* default */.A.map(order.items, item => {
|
|
2138
2149
|
let product = item.product || {};
|
|
2139
2150
|
return (0,preact_module.h)("div", {
|
|
2140
2151
|
class: "order_attachment__product"
|
|
2141
2152
|
}, (0,preact_module.h)("img", {
|
|
2142
2153
|
class: "order_attachment__product_img",
|
|
2143
|
-
alt: '' + util/* default */.
|
|
2144
|
-
src: util/* default */.
|
|
2154
|
+
alt: '' + util/* default */.A.get(product, 'id'),
|
|
2155
|
+
src: util/* default */.A.get(product, 'image', __webpack_require__(2876))
|
|
2145
2156
|
}), (0,preact_module.h)("div", {
|
|
2146
2157
|
style: "overflow: hidden !important;"
|
|
2147
2158
|
}, (0,preact_module.h)("div", {
|
|
@@ -2149,9 +2160,9 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2149
2160
|
title: this.props.t.i18n(product.i18n_name) || product.name
|
|
2150
2161
|
}, this.props.t.i18n(product.i18n_name) || product.name), (0,preact_module.h)("div", {
|
|
2151
2162
|
class: "order_attachment__product_desc"
|
|
2152
|
-
}, util/* default */.
|
|
2163
|
+
}, util/* default */.A.getProductPropName(product, ' / ')), (0,preact_module.h)("div", {
|
|
2153
2164
|
class: "order_attachment__product_desc"
|
|
2154
|
-
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default */.
|
|
2165
|
+
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default */.A.formatCurrency(product.price))));
|
|
2155
2166
|
}));
|
|
2156
2167
|
}
|
|
2157
2168
|
let $total = (0,preact_module.h)("div", {
|
|
@@ -2160,19 +2171,19 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2160
2171
|
class: "d-flex align-items-center justify-content-between"
|
|
2161
2172
|
}, (0,preact_module.h)("div", null, this.props.t('total')), ' ', (0,preact_module.h)("div", null, (0,preact_module.h)("b", {
|
|
2162
2173
|
class: "order_attachment__total"
|
|
2163
|
-
}, util/* default */.
|
|
2164
|
-
let phoneattr = util/* default */.
|
|
2174
|
+
}, util/* default */.A.formatCurrency(order.total)))));
|
|
2175
|
+
let phoneattr = util/* default */.A.find(util/* default */.A.get(order, 'user.attributes', []), attr => attr.key === 'phones') || {
|
|
2165
2176
|
key: 'phones',
|
|
2166
2177
|
text: ''
|
|
2167
2178
|
};
|
|
2168
|
-
let phone = util/* default */.
|
|
2169
|
-
phone = phone || util/* default */.
|
|
2179
|
+
let phone = util/* default */.A.get(order, 'shipping.address.phone', '').trim();
|
|
2180
|
+
phone = phone || util/* default */.A.trim(phoneattr.text);
|
|
2170
2181
|
if (phone) phone = this.props.t('phn') + ': ' + phone;
|
|
2171
2182
|
let $shipto = null;
|
|
2172
|
-
if (util/* default */.
|
|
2183
|
+
if (util/* default */.A.displayOrderShippingAddress(order) || phone) {
|
|
2173
2184
|
$shipto = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
2174
2185
|
class: "order_attachment__label"
|
|
2175
|
-
}, this.props.t('ship_to')), (0,preact_module.h)("div", null, util/* default */.
|
|
2186
|
+
}, this.props.t('ship_to')), (0,preact_module.h)("div", null, util/* default */.A.displayOrderShippingAddress(order)), (0,preact_module.h)("div", {
|
|
2176
2187
|
class: "order_attachment__text_truncate"
|
|
2177
2188
|
}, phone));
|
|
2178
2189
|
}
|
|
@@ -2184,11 +2195,11 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2184
2195
|
class: "d-flex align-items-center justify-content-between"
|
|
2185
2196
|
}, (0,preact_module.h)("div", {
|
|
2186
2197
|
class: "order_attachment__label no_margin"
|
|
2187
|
-
}, this.props.t('subtotal_before_tax')), ' ', (0,preact_module.h)("div", null, util/* default */.
|
|
2198
|
+
}, this.props.t('subtotal_before_tax')), ' ', (0,preact_module.h)("div", null, util/* default */.A.formatCurrency(order._order_value))), (0,preact_module.h)("div", {
|
|
2188
2199
|
class: "d-flex align-items-center justify-content-between"
|
|
2189
2200
|
}, (0,preact_module.h)("div", {
|
|
2190
2201
|
class: "order_attachment__label no_margin"
|
|
2191
|
-
}, this.props.t('discount_before_tax')), ' ', (0,preact_module.h)("div", null, "-", util/* default */.
|
|
2202
|
+
}, this.props.t('discount_before_tax')), ' ', (0,preact_module.h)("div", null, "-", util/* default */.A.formatCurrency(order._discount_before_tax))));
|
|
2192
2203
|
}
|
|
2193
2204
|
let $subtotal = (0,preact_module.h)("div", {
|
|
2194
2205
|
class: "d-flex align-items-center justify-content-between"
|
|
@@ -2196,12 +2207,12 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2196
2207
|
class: "order_attachment__label no_margin"
|
|
2197
2208
|
}, this.props.t('subtotal')), ' ', (0,preact_module.h)("div", {
|
|
2198
2209
|
style: ""
|
|
2199
|
-
}, util/* default */.
|
|
2210
|
+
}, util/* default */.A.formatCurrency(order.subtotal)));
|
|
2200
2211
|
let $tax = null;
|
|
2201
2212
|
if (order.total_tax) {
|
|
2202
2213
|
let taxname = '';
|
|
2203
|
-
if (util/* default */.
|
|
2204
|
-
let tax = util/* default */.
|
|
2214
|
+
if (util/* default */.A.size(order._taxM) === 1) {
|
|
2215
|
+
let tax = util/* default */.A.get(order._taxM, '0.tax', {});
|
|
2205
2216
|
if (tax.name && tax.percentage) taxname = `(${tax.name} ${Math.round(tax.percentage || 0) / 100}%)`;
|
|
2206
2217
|
}
|
|
2207
2218
|
$tax = (0,preact_module.h)("div", {
|
|
@@ -2210,7 +2221,7 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2210
2221
|
class: "order_attachment__label no_margin"
|
|
2211
2222
|
}, this.props.t('tax'), " ", taxname), (0,preact_module.h)("div", {
|
|
2212
2223
|
style: ""
|
|
2213
|
-
}, util/* default */.
|
|
2224
|
+
}, util/* default */.A.formatCurrency(order.total_tax)));
|
|
2214
2225
|
}
|
|
2215
2226
|
let $discount = null;
|
|
2216
2227
|
if (order.discount_type === 'percentage' && order.discount_percentage) {
|
|
@@ -2220,7 +2231,7 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2220
2231
|
class: "order_attachment__label no_margin"
|
|
2221
2232
|
}, this.props.t('discount_after_tax'), " (", Math.round(order.discount_percentage / 100), "%)"), ' ', (0,preact_module.h)("div", {
|
|
2222
2233
|
style: ""
|
|
2223
|
-
}, "-", util/* default */.
|
|
2234
|
+
}, "-", util/* default */.A.formatCurrency(order._computed_discount)));
|
|
2224
2235
|
}
|
|
2225
2236
|
if (order.discount_type === 'amount' && order.discount_amount) {
|
|
2226
2237
|
$discount = (0,preact_module.h)("div", {
|
|
@@ -2229,17 +2240,17 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2229
2240
|
class: "order_attachment__label no_margin"
|
|
2230
2241
|
}, this.props.t('discount_after_tax')), ' ', (0,preact_module.h)("div", {
|
|
2231
2242
|
class: "no-shrink"
|
|
2232
|
-
}, "-", util/* default */.
|
|
2243
|
+
}, "-", util/* default */.A.formatCurrency(order._computed_discount)));
|
|
2233
2244
|
}
|
|
2234
2245
|
let $shipping = null;
|
|
2235
|
-
if (util/* default */.
|
|
2246
|
+
if (util/* default */.A.get(order, 'shipping.nominal_fee')) {
|
|
2236
2247
|
$shipping = (0,preact_module.h)("div", {
|
|
2237
2248
|
class: "d-flex align-items-center justify-content-between"
|
|
2238
2249
|
}, (0,preact_module.h)("div", {
|
|
2239
2250
|
class: "order_attachment__label no_margin"
|
|
2240
2251
|
}, this.props.t('shipping_fee')), ' ', (0,preact_module.h)("div", {
|
|
2241
2252
|
style: ""
|
|
2242
|
-
}, util/* default */.
|
|
2253
|
+
}, util/* default */.A.formatCurrency(util/* default */.A.get(order, 'shipping.nominal_fee', 0))));
|
|
2243
2254
|
}
|
|
2244
2255
|
let $adjustment = null;
|
|
2245
2256
|
if (order.adjustment) {
|
|
@@ -2249,7 +2260,7 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2249
2260
|
class: "order_attachment__label no_margin"
|
|
2250
2261
|
}, order.adjustment_description), ' ', (0,preact_module.h)("div", {
|
|
2251
2262
|
class: "no-shrink"
|
|
2252
|
-
}, util/* default */.
|
|
2263
|
+
}, util/* default */.A.formatCurrency(order.adjustment)));
|
|
2253
2264
|
}
|
|
2254
2265
|
$subtotal = (0,preact_module.h)("div", {
|
|
2255
2266
|
class: "order_attachment__footer"
|
|
@@ -2263,7 +2274,7 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2263
2274
|
class: "order_attachment__header"
|
|
2264
2275
|
}, this.props.t('order'), (0,preact_module.h)("span", {
|
|
2265
2276
|
class: "order_attachment__text_muted order_attachment__text_sm"
|
|
2266
|
-
}, util/* default */.
|
|
2277
|
+
}, util/* default */.A.getOrderDisplayName(order))), $products, $shipto, $note, $beforeTax, $subtotal, $total);
|
|
2267
2278
|
});
|
|
2268
2279
|
return $orders;
|
|
2269
2280
|
}
|
|
@@ -2272,20 +2283,20 @@ class OrderAttachments_ProductAttachments extends common/* Com */.up {
|
|
|
2272
2283
|
|
|
2273
2284
|
|
|
2274
2285
|
|
|
2275
|
-
class VideoAttachments extends common/* Com */.
|
|
2286
|
+
class VideoAttachments extends common/* Com */.Mw {
|
|
2276
2287
|
constructor(props) {
|
|
2277
2288
|
super(props);
|
|
2278
2289
|
}
|
|
2279
2290
|
render() {
|
|
2280
|
-
let byType = util/* default */.
|
|
2281
|
-
var attachments = util/* default */.
|
|
2291
|
+
let byType = util/* default */.A.get(this.props.ev, 'by.type');
|
|
2292
|
+
var attachments = util/* default */.A.get(this.props.ev, 'data.message.attachments', []);
|
|
2282
2293
|
var videos = [];
|
|
2283
|
-
util/* default */.
|
|
2294
|
+
util/* default */.A.each(attachments, (att, i) => {
|
|
2284
2295
|
if (!att) return;
|
|
2285
|
-
if (util/* default */.
|
|
2296
|
+
if (util/* default */.A.includes(att.mimetype, 'video')) videos.push(att);
|
|
2286
2297
|
});
|
|
2287
2298
|
if (videos.length === 0) return null;
|
|
2288
|
-
var $videos = util/* default */.
|
|
2299
|
+
var $videos = util/* default */.A.map(videos, (video, index) => {
|
|
2289
2300
|
return (0,preact_module.h)("div", {
|
|
2290
2301
|
class: `video-attachment video-attachment--${byType}`
|
|
2291
2302
|
}, (0,preact_module.h)("video", {
|
|
@@ -2308,18 +2319,18 @@ class VideoAttachments extends common/* Com */.up {
|
|
|
2308
2319
|
|
|
2309
2320
|
|
|
2310
2321
|
|
|
2311
|
-
class TextMessage extends common/* Com */.
|
|
2322
|
+
class TextMessage extends common/* Com */.Mw {
|
|
2312
2323
|
render() {
|
|
2313
|
-
var format = util/* default */.
|
|
2324
|
+
var format = util/* default */.A.get(this.props.ev, 'data.message.format', 'plaintext');
|
|
2314
2325
|
if (format === 'delta') return this.renderDelta();
|
|
2315
2326
|
return this.renderPlainText();
|
|
2316
2327
|
}
|
|
2317
2328
|
renderPlainText() {
|
|
2318
|
-
var text = util/* default */.
|
|
2319
|
-
text = util/* default */.
|
|
2320
|
-
if (util/* default */.
|
|
2321
|
-
let byType = util/* default */.
|
|
2322
|
-
var tags = util/* default */.
|
|
2329
|
+
var text = util/* default */.A.get(this.props.ev, 'data.message.text');
|
|
2330
|
+
text = util/* default */.A.trim(text);
|
|
2331
|
+
if (util/* default */.A.size(text) === 0) return null;
|
|
2332
|
+
let byType = util/* default */.A.get(this.props.ev, 'by.type');
|
|
2333
|
+
var tags = util/* default */.A.extractText(text).map(tag => {
|
|
2323
2334
|
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
2324
2335
|
emojiCode: tag.text,
|
|
2325
2336
|
byType: byType
|
|
@@ -2343,7 +2354,7 @@ class TextMessage extends common/* Com */.up {
|
|
|
2343
2354
|
}, tag.text);
|
|
2344
2355
|
return tag.text;
|
|
2345
2356
|
});
|
|
2346
|
-
if (util/* default */.
|
|
2357
|
+
if (util/* default */.A.size(tags) === 0) return null;
|
|
2347
2358
|
if (byType === 'agent') {
|
|
2348
2359
|
return (0,preact_module.h)("div", {
|
|
2349
2360
|
class: "message-agent message-text--agent"
|
|
@@ -2354,16 +2365,16 @@ class TextMessage extends common/* Com */.up {
|
|
|
2354
2365
|
}, tags);
|
|
2355
2366
|
}
|
|
2356
2367
|
renderDelta() {
|
|
2357
|
-
let deltas = util/* default */.
|
|
2358
|
-
let quilldeltas = util/* default */.
|
|
2368
|
+
let deltas = util/* default */.A.get(this.props.ev, 'data.message.quill_delta') || util/* default */.A.get(this.props.ev, 'data.message.text');
|
|
2369
|
+
let quilldeltas = util/* default */.A.parseJSON(deltas) || {};
|
|
2359
2370
|
quilldeltas = trimQuillDelta(quilldeltas);
|
|
2360
|
-
if (!quilldeltas || util/* default */.
|
|
2361
|
-
let $deltas = util/* default */.
|
|
2371
|
+
if (!quilldeltas || util/* default */.A.size(quilldeltas.ops) === 0) return null;
|
|
2372
|
+
let $deltas = util/* default */.A.map(quilldeltas.ops, delta => {
|
|
2362
2373
|
let html = '';
|
|
2363
2374
|
let insert = delta.insert;
|
|
2364
2375
|
let attributes = delta.attributes;
|
|
2365
2376
|
if (insert.dynamicField) {
|
|
2366
|
-
return util/* default */.
|
|
2377
|
+
return util/* default */.A.get(insert, 'dynamicField.text', '');
|
|
2367
2378
|
}
|
|
2368
2379
|
if (insert.mention) {
|
|
2369
2380
|
if (insert.mention.id == '*' || insert.mention.id == 'all') {
|
|
@@ -2372,7 +2383,7 @@ class TextMessage extends common/* Com */.up {
|
|
|
2372
2383
|
}, "@", this.$t('all'));
|
|
2373
2384
|
}
|
|
2374
2385
|
let ag = store.matchAgent(insert.mention.id);
|
|
2375
|
-
let name = util/* default */.
|
|
2386
|
+
let name = util/* default */.A.getAgentDisplayName(ag, insert.mention.fullname);
|
|
2376
2387
|
return (0,preact_module.h)("span", {
|
|
2377
2388
|
class: "mention",
|
|
2378
2389
|
"data-agent-id": ag.id,
|
|
@@ -2383,7 +2394,7 @@ class TextMessage extends common/* Com */.up {
|
|
|
2383
2394
|
emojiCode: `:${insert.emoji}:`
|
|
2384
2395
|
});
|
|
2385
2396
|
if (typeof insert === 'string') {
|
|
2386
|
-
let $tags = util/* default */.
|
|
2397
|
+
let $tags = util/* default */.A.extractText(insert).map((tag, i) => {
|
|
2387
2398
|
if (tag.type === 'link') {
|
|
2388
2399
|
return (0,preact_module.h)("a", {
|
|
2389
2400
|
href: absLink(tag.text),
|
|
@@ -2407,9 +2418,9 @@ class TextMessage extends common/* Com */.up {
|
|
|
2407
2418
|
}
|
|
2408
2419
|
return null;
|
|
2409
2420
|
});
|
|
2410
|
-
let byType = util/* default */.
|
|
2421
|
+
let byType = util/* default */.A.get(this.ev, 'by.type');
|
|
2411
2422
|
if (byType !== 'user') byType = 'agent';
|
|
2412
|
-
if (util/* default */.
|
|
2423
|
+
if (util/* default */.A.size($deltas) === 0) return null;
|
|
2413
2424
|
if (byType === 'agent') {
|
|
2414
2425
|
return (0,preact_module.h)("div", {
|
|
2415
2426
|
class: "message-agent message-text--agent"
|
|
@@ -2467,11 +2478,11 @@ function absLink(url) {
|
|
|
2467
2478
|
}
|
|
2468
2479
|
;// CONCATENATED MODULE: ./src/chatbox/time.js
|
|
2469
2480
|
|
|
2470
|
-
var g_pub = new util/* default */.
|
|
2471
|
-
util/* default */.
|
|
2481
|
+
var g_pub = new util/* default */.A.Pubsub();
|
|
2482
|
+
util/* default */.A.setInterval(() => g_pub.publish('time'), 20 * 1000);
|
|
2472
2483
|
|
|
2473
2484
|
|
|
2474
|
-
class Time extends common/* Com */.
|
|
2485
|
+
class Time extends common/* Com */.Mw {
|
|
2475
2486
|
constructor(props) {
|
|
2476
2487
|
super(props);
|
|
2477
2488
|
this.setState({
|
|
@@ -2483,10 +2494,10 @@ class Time extends common/* Com */.up {
|
|
|
2483
2494
|
var t = '';
|
|
2484
2495
|
if (this.props.ago) {
|
|
2485
2496
|
if (this.props.short) {
|
|
2486
|
-
if (Math.abs(this.props.time - new util/* default */.
|
|
2487
|
-
let tim = new util/* default */.
|
|
2497
|
+
if (Math.abs(this.props.time - new util/* default */.A.Date().getTime()) > 86400000 * 10) {
|
|
2498
|
+
let tim = new util/* default */.A.Date(this.props.time);
|
|
2488
2499
|
let tzyear = tim.getFullYear();
|
|
2489
|
-
let locale = util/* default */.
|
|
2500
|
+
let locale = util/* default */.A.get(navigator, 'languages.0', 'en-US');
|
|
2490
2501
|
let tzmonthname = tim.toLocaleDateString(locale, {
|
|
2491
2502
|
month: 'short'
|
|
2492
2503
|
});
|
|
@@ -2494,8 +2505,8 @@ class Time extends common/* Com */.up {
|
|
|
2494
2505
|
t = tzdate + ' ' + tzmonthname + ' ' + tzyear;
|
|
2495
2506
|
}
|
|
2496
2507
|
}
|
|
2497
|
-
if (!t && this.props.time > 0) t = ago(this.props.time, new util/* default */.
|
|
2498
|
-
} else t = util/* default */.
|
|
2508
|
+
if (!t && this.props.time > 0) t = ago(this.props.time, new util/* default */.A.Date().getTime());
|
|
2509
|
+
} else t = util/* default */.A.shortTime(this.props.time, this.props.tzoffset);
|
|
2499
2510
|
if (this.props.uppercase) t = t.toUpperCase();
|
|
2500
2511
|
if (t === this.state.t) return;
|
|
2501
2512
|
this.setState({
|
|
@@ -2594,7 +2605,7 @@ function getRateLang(rating) {
|
|
|
2594
2605
|
|
|
2595
2606
|
|
|
2596
2607
|
|
|
2597
|
-
class InfoMessage extends common/* Com */.
|
|
2608
|
+
class InfoMessage extends common/* Com */.Mw {
|
|
2598
2609
|
render() {
|
|
2599
2610
|
let ev = this.props.ev.ev;
|
|
2600
2611
|
var $time = null;
|
|
@@ -2606,7 +2617,7 @@ class InfoMessage extends common/* Com */.up {
|
|
|
2606
2617
|
}));
|
|
2607
2618
|
}
|
|
2608
2619
|
if (ev.type === 'conversation_rated') {
|
|
2609
|
-
var rating = util/* default */.
|
|
2620
|
+
var rating = util/* default */.A.get(ev, 'data.conversation.ratings.0', {
|
|
2610
2621
|
no_rating: true,
|
|
2611
2622
|
rating: 0
|
|
2612
2623
|
});
|
|
@@ -2617,7 +2628,7 @@ class InfoMessage extends common/* Com */.up {
|
|
|
2617
2628
|
class: "info-message"
|
|
2618
2629
|
}, this.props.t('rated_as') + ' ' + this.props.t(getRateLang(rating.rating)).toLowerCase()));
|
|
2619
2630
|
}
|
|
2620
|
-
if (ev.type === 'conversation_state_updated' && util/* default */.
|
|
2631
|
+
if (ev.type === 'conversation_state_updated' && util/* default */.A.get(ev, 'data.conversation.state') === 'ended') {
|
|
2621
2632
|
return (0,preact_module.h)("div", {
|
|
2622
2633
|
class: "convo-event"
|
|
2623
2634
|
}, $time, (0,preact_module.h)("div", {
|
|
@@ -2645,13 +2656,13 @@ class InfoMessage extends common/* Com */.up {
|
|
|
2645
2656
|
|
|
2646
2657
|
|
|
2647
2658
|
|
|
2648
|
-
class Event extends common/* Com */.
|
|
2659
|
+
class Event extends common/* Com */.Mw {
|
|
2649
2660
|
constructor(props) {
|
|
2650
2661
|
super(props);
|
|
2651
|
-
this.refForm = (0,preact_module/* createRef */.
|
|
2662
|
+
this.refForm = (0,preact_module/* createRef */._3)();
|
|
2652
2663
|
}
|
|
2653
2664
|
render() {
|
|
2654
|
-
var ev = util/* default */.
|
|
2665
|
+
var ev = util/* default */.A.get(this.props.event, 'ev', {});
|
|
2655
2666
|
switch (ev.type) {
|
|
2656
2667
|
case 'conversation_joined':
|
|
2657
2668
|
break;
|
|
@@ -2660,7 +2671,7 @@ class Event extends common/* Com */.up {
|
|
|
2660
2671
|
case 'conversation_state_updated':
|
|
2661
2672
|
case 'conversation_rating_requested':
|
|
2662
2673
|
case 'conversation_rated':
|
|
2663
|
-
if (!util/* default */.
|
|
2674
|
+
if (!util/* default */.A.startsWith(ev.id, 'ev')) return null;
|
|
2664
2675
|
return (0,preact_module.h)(InfoMessage, {
|
|
2665
2676
|
t: this.props.t,
|
|
2666
2677
|
store: this.props.store,
|
|
@@ -2673,7 +2684,7 @@ class Event extends common/* Com */.up {
|
|
|
2673
2684
|
this.refForm.current && this.refForm.current.focus();
|
|
2674
2685
|
}
|
|
2675
2686
|
chooseQuickReply(reply) {
|
|
2676
|
-
let ev = util/* default */.
|
|
2687
|
+
let ev = util/* default */.A.get(this.props.event, 'ev', {});
|
|
2677
2688
|
let message = {
|
|
2678
2689
|
text: reply.title,
|
|
2679
2690
|
format: 'plaintext'
|
|
@@ -2690,7 +2701,7 @@ class Event extends common/* Com */.up {
|
|
|
2690
2701
|
this.props.onSend(message);
|
|
2691
2702
|
}
|
|
2692
2703
|
choosePostbackBtn(button) {
|
|
2693
|
-
let ev = util/* default */.
|
|
2704
|
+
let ev = util/* default */.A.get(this.props.event, 'ev', {});
|
|
2694
2705
|
let message = {
|
|
2695
2706
|
text: button.title,
|
|
2696
2707
|
format: 'plaintext'
|
|
@@ -2707,13 +2718,13 @@ class Event extends common/* Com */.up {
|
|
|
2707
2718
|
this.props.onSend(message);
|
|
2708
2719
|
}
|
|
2709
2720
|
renderAgentAvatar(ev) {
|
|
2710
|
-
let bytype = util/* default */.
|
|
2711
|
-
let byid = util/* default */.
|
|
2721
|
+
let bytype = util/* default */.A.get(ev, 'by.type');
|
|
2722
|
+
let byid = util/* default */.A.get(ev, 'by.display_id', util/* default */.A.get(ev, 'by.id'));
|
|
2712
2723
|
if (bytype === 'user') return null;
|
|
2713
2724
|
var senderName = this.getSenderName(ev);
|
|
2714
2725
|
let acc = this.props.store.matchAccount();
|
|
2715
|
-
var uri = acc.logo_url || __webpack_require__(
|
|
2716
|
-
if (util/* default */.
|
|
2726
|
+
var uri = acc.logo_url || __webpack_require__(3582);
|
|
2727
|
+
if (util/* default */.A.get(this.props, 'chatbox.hide_agent_profile')) {
|
|
2717
2728
|
return (0,preact_module.h)("div", {
|
|
2718
2729
|
class: "message-sender"
|
|
2719
2730
|
}, (0,preact_module.h)("img", {
|
|
@@ -2726,7 +2737,7 @@ class Event extends common/* Com */.up {
|
|
|
2726
2737
|
}
|
|
2727
2738
|
let agentM = this.props.store.matchAgent('*');
|
|
2728
2739
|
if (byid !== 'system' && bytype !== 'dummy' && bytype !== 'workflow') {
|
|
2729
|
-
uri = util/* default */.
|
|
2740
|
+
uri = util/* default */.A.get(agentM[byid], 'avatar_url') || acc.logo_url || __webpack_require__(2538);
|
|
2730
2741
|
}
|
|
2731
2742
|
return (0,preact_module.h)("div", {
|
|
2732
2743
|
class: "message-sender"
|
|
@@ -2748,8 +2759,8 @@ class Event extends common/* Com */.up {
|
|
|
2748
2759
|
time: ev.created
|
|
2749
2760
|
}));
|
|
2750
2761
|
}
|
|
2751
|
-
let t = new util/* default */.
|
|
2752
|
-
if (util/* default */.
|
|
2762
|
+
let t = new util/* default */.A.Date(ev.created).toLocaleString();
|
|
2763
|
+
if (util/* default */.A.get(ev, 'by.type') !== 'user') {
|
|
2753
2764
|
let $sender = null;
|
|
2754
2765
|
if (this.props.event.mode === 'lead') $sender = this.renderAgentAvatar(ev);
|
|
2755
2766
|
return (0,preact_module.h)("div", {
|
|
@@ -2805,15 +2816,15 @@ class Event extends common/* Com */.up {
|
|
|
2805
2816
|
onSelect: e => this.chooseQuickReply(e)
|
|
2806
2817
|
}));
|
|
2807
2818
|
}
|
|
2808
|
-
if (util/* default */.
|
|
2809
|
-
util/* default */.
|
|
2819
|
+
if (util/* default */.A.getMsgField(ev, 'idempotency') === ev.id && this.props.store.now() - ev.created < 900) {
|
|
2820
|
+
util/* default */.A.setTimeout(() => this.setState({
|
|
2810
2821
|
refresh: this.state.refresh
|
|
2811
2822
|
}), 1000);
|
|
2812
2823
|
}
|
|
2813
2824
|
let $dot = (0,preact_module.h)("div", {
|
|
2814
2825
|
class: "sending_dot"
|
|
2815
2826
|
});
|
|
2816
|
-
if (this.props.store.now() - ev.created < 900 || util/* default */.
|
|
2827
|
+
if (this.props.store.now() - ev.created < 900 || util/* default */.A.getMsgField(ev, 'idempotency') !== ev.id) {
|
|
2817
2828
|
$dot = (0,preact_module.h)("div", {
|
|
2818
2829
|
class: "sending_dot sending_dot__hide"
|
|
2819
2830
|
});
|
|
@@ -2877,7 +2888,7 @@ class Event extends common/* Com */.up {
|
|
|
2877
2888
|
})), $error);
|
|
2878
2889
|
}
|
|
2879
2890
|
renderUpdateConvo(ev) {
|
|
2880
|
-
var state = util/* default */.
|
|
2891
|
+
var state = util/* default */.A.get(ev, 'data.conversation.state');
|
|
2881
2892
|
if (state === 'active') return null;
|
|
2882
2893
|
if (state === 'pending') return null;
|
|
2883
2894
|
return (0,preact_module.h)("div", {
|
|
@@ -2887,27 +2898,27 @@ class Event extends common/* Com */.up {
|
|
|
2887
2898
|
}));
|
|
2888
2899
|
}
|
|
2889
2900
|
resendMessage() {
|
|
2890
|
-
let cid = util/* default */.
|
|
2891
|
-
const message = util/* default */.
|
|
2901
|
+
let cid = util/* default */.A.convoOfEv(this.props.event.ev);
|
|
2902
|
+
const message = util/* default */.A.get(this.props.event, 'ev.data.message');
|
|
2892
2903
|
this.props.store.sendConvoEvent(cid, 'message_sent', {
|
|
2893
2904
|
message
|
|
2894
2905
|
});
|
|
2895
2906
|
}
|
|
2896
2907
|
getSenderName(ev) {
|
|
2897
|
-
let bytype = util/* default */.
|
|
2898
|
-
let byid = util/* default */.
|
|
2899
|
-
if (bytype === 'user') return util/* default */.
|
|
2908
|
+
let bytype = util/* default */.A.get(ev, 'by.type');
|
|
2909
|
+
let byid = util/* default */.A.get(ev, 'by.display_id', util/* default */.A.get(ev, 'by.id'));
|
|
2910
|
+
if (bytype === 'user') return util/* default */.A.getUserDisplayName(this.props.store.matchUser());
|
|
2900
2911
|
let acc = this.props.store.matchAccount();
|
|
2901
|
-
if (bytype === 'agent') return util/* default */.
|
|
2912
|
+
if (bytype === 'agent') return util/* default */.A.getAgentDisplayName(acc, this.props.store.matchAgent(byid));
|
|
2902
2913
|
if (byid === 'system' || bytype === 'dummy' || bytype === 'workflow') return acc.name || 'system';
|
|
2903
2914
|
return '';
|
|
2904
2915
|
}
|
|
2905
2916
|
}
|
|
2906
2917
|
;// CONCATENATED MODULE: ./src/chatbox/spinner.js
|
|
2907
|
-
const loadingimg = __webpack_require__(
|
|
2918
|
+
const loadingimg = __webpack_require__(6973);
|
|
2908
2919
|
|
|
2909
2920
|
|
|
2910
|
-
class Spinner extends common/* Com */.
|
|
2921
|
+
class Spinner extends common/* Com */.Mw {
|
|
2911
2922
|
render() {
|
|
2912
2923
|
let mode = (this.props.mode + '').toLowerCase();
|
|
2913
2924
|
let mainColor = mode === 'dark' ? '#000000dd' : mode === 'blue' ? 'rgba(52, 152, 220, .8)' : mode;
|
|
@@ -2933,19 +2944,19 @@ class Spinner extends common/* Com */.up {
|
|
|
2933
2944
|
;// CONCATENATED MODULE: ./src/chatbox/Events.js
|
|
2934
2945
|
|
|
2935
2946
|
|
|
2936
|
-
const convoemptyimg = __webpack_require__(
|
|
2947
|
+
const convoemptyimg = __webpack_require__(1370);
|
|
2937
2948
|
|
|
2938
2949
|
|
|
2939
2950
|
|
|
2940
2951
|
|
|
2941
|
-
class Events extends common/* Com */.
|
|
2952
|
+
class Events extends common/* Com */.Mw {
|
|
2942
2953
|
constructor(props) {
|
|
2943
2954
|
super(props);
|
|
2944
2955
|
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
2945
2956
|
this.props.store.onConvoEvent(this, ev => this.onEvent(ev));
|
|
2946
2957
|
this.loadConvo();
|
|
2947
2958
|
this.refBody = null;
|
|
2948
|
-
this.checkAndSeen = util/* default */.
|
|
2959
|
+
this.checkAndSeen = util/* default */.A.throttle(() => {
|
|
2949
2960
|
if (this.props.isShow && this.isBottom() && this.props.store.browserVisibility === 'visible' && document.hasFocus()) {
|
|
2950
2961
|
this.props.store.seenConvo(this.props.cid);
|
|
2951
2962
|
}
|
|
@@ -2957,8 +2968,8 @@ class Events extends common/* Com */.up {
|
|
|
2957
2968
|
}
|
|
2958
2969
|
render() {
|
|
2959
2970
|
if (this.state.error) return this.renderError();
|
|
2960
|
-
let events = util/* default */.
|
|
2961
|
-
if (!this.state.loading && util/* default */.
|
|
2971
|
+
let events = util/* default */.A.map(this.props.store.listEvents(this.props.cid));
|
|
2972
|
+
if (!this.state.loading && util/* default */.A.size(events) === 0) {
|
|
2962
2973
|
return (0,preact_module.h)("div", {
|
|
2963
2974
|
ref: ref => this.refBody = ref,
|
|
2964
2975
|
class: "widget-body--events-container"
|
|
@@ -2972,13 +2983,13 @@ class Events extends common/* Com */.up {
|
|
|
2972
2983
|
store: this.props.store
|
|
2973
2984
|
}));
|
|
2974
2985
|
}
|
|
2975
|
-
events = util/* default */.
|
|
2986
|
+
events = util/* default */.A.orderBy(events, 'created', 'asc');
|
|
2976
2987
|
let convo = this.props.store.matchConvo(this.props.cid);
|
|
2977
|
-
events = util/* default */.
|
|
2988
|
+
events = util/* default */.A.map(events, ev => ({
|
|
2978
2989
|
ev: ev
|
|
2979
2990
|
}));
|
|
2980
2991
|
processEvents(convo, events);
|
|
2981
|
-
let $events = util/* default */.
|
|
2992
|
+
let $events = util/* default */.A.map(events, ev => (0,preact_module.h)(Event, {
|
|
2982
2993
|
chatbox: this.props.chatbox,
|
|
2983
2994
|
onLink: this.props.onLink,
|
|
2984
2995
|
store: this.props.store,
|
|
@@ -2994,13 +3005,13 @@ class Events extends common/* Com */.up {
|
|
|
2994
3005
|
if (this.state.loading || this.props.creating) {
|
|
2995
3006
|
$loading = (0,preact_module.h)(Spinner, {
|
|
2996
3007
|
static: true,
|
|
2997
|
-
mode: util/* default */.
|
|
3008
|
+
mode: util/* default */.A.get(this.props.chatbox, 'primary_color', 'dark'),
|
|
2998
3009
|
size: "120",
|
|
2999
3010
|
center: true
|
|
3000
3011
|
});
|
|
3001
3012
|
style = 'opacity: 0 !important';
|
|
3002
3013
|
}
|
|
3003
|
-
return (0,preact_module.h)(preact_module/* Fragment */.
|
|
3014
|
+
return (0,preact_module.h)(preact_module/* Fragment */.FK, null, $loading, (0,preact_module.h)("div", {
|
|
3004
3015
|
style: style,
|
|
3005
3016
|
ref: ref => this.refBody = ref,
|
|
3006
3017
|
class: "widget-body--events-container",
|
|
@@ -3033,23 +3044,23 @@ class Events extends common/* Com */.up {
|
|
|
3033
3044
|
}
|
|
3034
3045
|
focus() {
|
|
3035
3046
|
let events = this.props.store.listEvents(this.props.cid);
|
|
3036
|
-
events = util/* default */.
|
|
3047
|
+
events = util/* default */.A.orderBy(util/* default */.A.map(events), 'created', 'desc');
|
|
3037
3048
|
var last_agent_sent;
|
|
3038
3049
|
for (let ev of events) {
|
|
3039
|
-
if (util/* default */.
|
|
3040
|
-
if (util/* default */.
|
|
3050
|
+
if (util/* default */.A.get(ev, 'type') !== 'message_sent') continue;
|
|
3051
|
+
if (util/* default */.A.get(ev, 'by.type') === 'user') continue;
|
|
3041
3052
|
last_agent_sent = ev;
|
|
3042
3053
|
break;
|
|
3043
3054
|
}
|
|
3044
|
-
if (util/* default */.
|
|
3045
|
-
let attachments = util/* default */.
|
|
3055
|
+
if (util/* default */.A.get(last_agent_sent, 'by.type') === 'user') last_agent_sent = null;
|
|
3056
|
+
let attachments = util/* default */.A.get(last_agent_sent, 'data.message.attachments', []);
|
|
3046
3057
|
let convo = this.props.store.matchConvo(this.props.cid);
|
|
3047
|
-
let pendingForms = util/* default */.
|
|
3058
|
+
let pendingForms = util/* default */.A.filter(attachments, att => {
|
|
3048
3059
|
if (!att) return false;
|
|
3049
3060
|
if (att.type !== 'form' && att.type !== 'ask_info_form') return false;
|
|
3050
3061
|
var form = att.form;
|
|
3051
3062
|
if (!form) return false;
|
|
3052
|
-
var state = util/* default */.
|
|
3063
|
+
var state = util/* default */.A.parseJSON(form.state) || {};
|
|
3053
3064
|
if (!state.require_finished && att.type !== 'ask_info_form') return false;
|
|
3054
3065
|
if (Events_isSummited(att.form)) return false;
|
|
3055
3066
|
if (convo.state === 'ended') return false;
|
|
@@ -3057,10 +3068,10 @@ class Events extends common/* Com */.up {
|
|
|
3057
3068
|
});
|
|
3058
3069
|
}
|
|
3059
3070
|
onEvent(newev) {
|
|
3060
|
-
if (util/* default */.
|
|
3071
|
+
if (util/* default */.A.convoOfEv(newev) !== this.props.cid) return;
|
|
3061
3072
|
let isBottom = this.isBottom();
|
|
3062
3073
|
var byme = false;
|
|
3063
|
-
if (util/* default */.
|
|
3074
|
+
if (util/* default */.A.get(newev, 'type') === 'message_sent' && newev.id === util/* default */.A.getMsgField(newev, 'idempotency')) byme = true;
|
|
3064
3075
|
if (byme || isBottom) this.scrollToBottom();
|
|
3065
3076
|
}
|
|
3066
3077
|
async loadConvo() {
|
|
@@ -3070,7 +3081,7 @@ class Events extends common/* Com */.up {
|
|
|
3070
3081
|
loading: true
|
|
3071
3082
|
});
|
|
3072
3083
|
let events = this.props.store.listEvents(this.props.cid);
|
|
3073
|
-
if (util/* default */.
|
|
3084
|
+
if (util/* default */.A.size(events) === 0) {
|
|
3074
3085
|
let cid = this.props.cid;
|
|
3075
3086
|
let {
|
|
3076
3087
|
error
|
|
@@ -3094,7 +3105,7 @@ class Events extends common/* Com */.up {
|
|
|
3094
3105
|
error: false
|
|
3095
3106
|
});
|
|
3096
3107
|
this.scrollToBottom();
|
|
3097
|
-
util/* default */.
|
|
3108
|
+
util/* default */.A.setTimeout(() => this.setState({
|
|
3098
3109
|
loading: false
|
|
3099
3110
|
}), 50);
|
|
3100
3111
|
}
|
|
@@ -3104,11 +3115,11 @@ class Events extends common/* Com */.up {
|
|
|
3104
3115
|
return $container.scrollHeight < $container.scrollTop + $container.offsetHeight + 50;
|
|
3105
3116
|
}
|
|
3106
3117
|
scrollToBottom() {
|
|
3107
|
-
util/* default */.
|
|
3118
|
+
util/* default */.A.setTimeout(() => {
|
|
3108
3119
|
const $div = this.refBody;
|
|
3109
3120
|
if ($div) $div.scrollTop = $div.scrollHeight;
|
|
3110
3121
|
});
|
|
3111
|
-
util/* default */.
|
|
3122
|
+
util/* default */.A.setTimeout(() => {
|
|
3112
3123
|
const $div = this.refBody;
|
|
3113
3124
|
if ($div) $div.scrollTop = $div.scrollHeight;
|
|
3114
3125
|
}, 200);
|
|
@@ -3126,13 +3137,13 @@ function processEvents(convo, events) {
|
|
|
3126
3137
|
let curEvent = events[i];
|
|
3127
3138
|
let lastEvent = events[i - 1];
|
|
3128
3139
|
if (visibleEvent(curEvent.ev)) {
|
|
3129
|
-
let elapsedSec = util/* default */.
|
|
3140
|
+
let elapsedSec = util/* default */.A.unixSec(curEvent.ev.created) - util/* default */.A.unixSec(lastEvent.ev.created);
|
|
3130
3141
|
if (elapsedSec > 120) curEvent.show_time = true;
|
|
3131
3142
|
}
|
|
3132
3143
|
}
|
|
3133
3144
|
for (var i = 0; i < events.length; i++) {
|
|
3134
3145
|
let curEvent = events[i];
|
|
3135
|
-
if (util/* default */.
|
|
3146
|
+
if (util/* default */.A.get(curEvent, 'ev.type') === 'message_sent') {
|
|
3136
3147
|
curEvent.show_time = true;
|
|
3137
3148
|
break;
|
|
3138
3149
|
}
|
|
@@ -3142,7 +3153,7 @@ function processEvents(convo, events) {
|
|
|
3142
3153
|
let prevEvent = events[i - 1];
|
|
3143
3154
|
if (curEvent.ev.type === 'message_sent') {
|
|
3144
3155
|
curEvent.mode = 'lead';
|
|
3145
|
-
if (util/* default */.
|
|
3156
|
+
if (util/* default */.A.get(prevEvent, 'ev.type') === 'message_sent' && util/* default */.A.get(prevEvent, 'ev.by.id') === util/* default */.A.get(curEvent, 'ev.by.id')) {
|
|
3146
3157
|
curEvent.mode = 'follow';
|
|
3147
3158
|
}
|
|
3148
3159
|
continue;
|
|
@@ -3150,18 +3161,18 @@ function processEvents(convo, events) {
|
|
|
3150
3161
|
}
|
|
3151
3162
|
}
|
|
3152
3163
|
function visibleEvent(ev) {
|
|
3153
|
-
let type = util/* default */.
|
|
3164
|
+
let type = util/* default */.A.get(ev, 'type');
|
|
3154
3165
|
return type === 'message_sent' || type === 'conversation_state_updated';
|
|
3155
3166
|
}
|
|
3156
3167
|
function Events_isSummited(form) {
|
|
3157
|
-
let fields = util/* default */.
|
|
3158
|
-
return util/* default */.
|
|
3168
|
+
let fields = util/* default */.A.get(form, 'fields') || [];
|
|
3169
|
+
return util/* default */.A.find(fields, field => !!field.answered);
|
|
3159
3170
|
}
|
|
3160
3171
|
;// CONCATENATED MODULE: ./src/chatbox/Typing.js
|
|
3161
3172
|
|
|
3162
3173
|
|
|
3163
3174
|
|
|
3164
|
-
class Typing extends common/* Com */.
|
|
3175
|
+
class Typing extends common/* Com */.Mw {
|
|
3165
3176
|
constructor(props) {
|
|
3166
3177
|
super(props);
|
|
3167
3178
|
}
|
|
@@ -3171,29 +3182,29 @@ class Typing extends common/* Com */.up {
|
|
|
3171
3182
|
ev: {}
|
|
3172
3183
|
});
|
|
3173
3184
|
this.props.store.onConvoEvent(this, ev => {
|
|
3174
|
-
if (util/* default */.
|
|
3185
|
+
if (util/* default */.A.convoOfEv(ev) !== this.props.cid) return;
|
|
3175
3186
|
let user = this.props.store.matchUser();
|
|
3176
|
-
if (util/* default */.
|
|
3177
|
-
let oldby = util/* default */.
|
|
3178
|
-
if (oldby && util/* default */.
|
|
3179
|
-
if (util/* default */.
|
|
3180
|
-
if (this.timer) util/* default */.
|
|
3187
|
+
if (util/* default */.A.get(ev, 'by.id') === user.id) return;
|
|
3188
|
+
let oldby = util/* default */.A.get(this.state.ev, 'by.id');
|
|
3189
|
+
if (oldby && util/* default */.A.get(ev, 'by.id') !== oldby) return;
|
|
3190
|
+
if (util/* default */.A.get(ev, 'type') === 'message_sent') {
|
|
3191
|
+
if (this.timer) util/* default */.A.clearTimeout(this.timer);
|
|
3181
3192
|
this.timer = null;
|
|
3182
3193
|
this.setState({
|
|
3183
3194
|
isShow: false
|
|
3184
3195
|
});
|
|
3185
3196
|
return;
|
|
3186
3197
|
}
|
|
3187
|
-
if (util/* default */.
|
|
3188
|
-
let ag = this.props.store.matchAgent(util/* default */.
|
|
3198
|
+
if (util/* default */.A.get(ev, 'type') !== 'conversation_typing') return;
|
|
3199
|
+
let ag = this.props.store.matchAgent(util/* default */.A.get(ev, 'by.id')) || {};
|
|
3189
3200
|
if (ag.type == 'agent') return;
|
|
3190
3201
|
this.setState({
|
|
3191
3202
|
ev: ev,
|
|
3192
3203
|
isShow: true
|
|
3193
3204
|
});
|
|
3194
|
-
if (this.timer) util/* default */.
|
|
3195
|
-
this.timer = util/* default */.
|
|
3196
|
-
if (util/* default */.
|
|
3205
|
+
if (this.timer) util/* default */.A.clearTimeout(this.timer);
|
|
3206
|
+
this.timer = util/* default */.A.setTimeout(() => {
|
|
3207
|
+
if (util/* default */.A.convoOfEv(ev) !== this.props.cid) return;
|
|
3197
3208
|
this.timer = null;
|
|
3198
3209
|
this.setState({
|
|
3199
3210
|
isShow: false
|
|
@@ -3204,8 +3215,8 @@ class Typing extends common/* Com */.up {
|
|
|
3204
3215
|
render() {
|
|
3205
3216
|
let account = this.props.store.matchAccount();
|
|
3206
3217
|
var cls = this.state.isShow ? '' : 'typing--hidden';
|
|
3207
|
-
let byid = util/* default */.
|
|
3208
|
-
let agentName = util/* default */.
|
|
3218
|
+
let byid = util/* default */.A.get(this.state.ev, 'by.display_id', util/* default */.A.get(this.state.ev, 'by.id'));
|
|
3219
|
+
let agentName = util/* default */.A.getAgentDisplayName(account, this.props.store.matchAgent(byid));
|
|
3209
3220
|
return (0,preact_module.h)("div", {
|
|
3210
3221
|
class: `typing ${cls}`
|
|
3211
3222
|
}, agentName, " ", this.props.t('typing'));
|
|
@@ -3224,7 +3235,7 @@ class Typing extends common/* Com */.up {
|
|
|
3224
3235
|
this.stop();
|
|
3225
3236
|
var t0;
|
|
3226
3237
|
var run = t => {
|
|
3227
|
-
if (!t) t = new util/* default */.
|
|
3238
|
+
if (!t) t = new util/* default */.A.Date().getTime();
|
|
3228
3239
|
var deltaT = t - t0;
|
|
3229
3240
|
var [newy, done] = this.calcY(v, y0, deltaT);
|
|
3230
3241
|
cb(newy);
|
|
@@ -3232,7 +3243,7 @@ class Typing extends common/* Com */.up {
|
|
|
3232
3243
|
this.animationframe = window.requestAnimationFrame(run);
|
|
3233
3244
|
};
|
|
3234
3245
|
this.animationframe = window.requestAnimationFrame(t => {
|
|
3235
|
-
t0 = t || new util/* default */.
|
|
3246
|
+
t0 = t || new util/* default */.A.Date().getTime();
|
|
3236
3247
|
run(t0);
|
|
3237
3248
|
});
|
|
3238
3249
|
}
|
|
@@ -3276,7 +3287,7 @@ const POPUP_HARD_MAX_HEIGHT = 500;
|
|
|
3276
3287
|
const POPUP_MIN_HEIGHT = 0;
|
|
3277
3288
|
|
|
3278
3289
|
|
|
3279
|
-
class Rating extends common/* Com */.
|
|
3290
|
+
class Rating extends common/* Com */.Mw {
|
|
3280
3291
|
constructor(props) {
|
|
3281
3292
|
super(props);
|
|
3282
3293
|
Rating_defineProperty(this, "state", {
|
|
@@ -3285,16 +3296,16 @@ class Rating extends common/* Com */.up {
|
|
|
3285
3296
|
overlayOpacity: 0.3,
|
|
3286
3297
|
comment: ''
|
|
3287
3298
|
});
|
|
3288
|
-
this.refComment = (0,preact_module/* createRef */.
|
|
3289
|
-
this.refRating = (0,preact_module/* createRef */.
|
|
3290
|
-
this.refHandle = (0,preact_module/* createRef */.
|
|
3299
|
+
this.refComment = (0,preact_module/* createRef */._3)();
|
|
3300
|
+
this.refRating = (0,preact_module/* createRef */._3)();
|
|
3301
|
+
this.refHandle = (0,preact_module/* createRef */._3)();
|
|
3291
3302
|
}
|
|
3292
3303
|
componentDidMount() {
|
|
3293
3304
|
this.props.store.onUpdate(this, () => {
|
|
3294
3305
|
if (this.shoudDisplay()) this.open();
|
|
3295
3306
|
});
|
|
3296
3307
|
this.props.store.onConvoEvent(this, ev => {
|
|
3297
|
-
var cid = util/* default */.
|
|
3308
|
+
var cid = util/* default */.A.convoOfEv(ev);
|
|
3298
3309
|
if (cid !== this.props.cid) return;
|
|
3299
3310
|
if (this.shoudDisplay()) this.open();
|
|
3300
3311
|
});
|
|
@@ -3373,7 +3384,7 @@ class Rating extends common/* Com */.up {
|
|
|
3373
3384
|
onClick: e => this.onRatingPoor(e)
|
|
3374
3385
|
}, (0,preact_module.h)("img", {
|
|
3375
3386
|
alt: "poor",
|
|
3376
|
-
src: __webpack_require__(
|
|
3387
|
+
src: __webpack_require__(9801)
|
|
3377
3388
|
}), (0,preact_module.h)("p", {
|
|
3378
3389
|
class: "rating-face--text"
|
|
3379
3390
|
}, this.props.t('poor'))), (0,preact_module.h)("div", {
|
|
@@ -3381,7 +3392,7 @@ class Rating extends common/* Com */.up {
|
|
|
3381
3392
|
onClick: e => this.onRatingAverage(e)
|
|
3382
3393
|
}, (0,preact_module.h)("img", {
|
|
3383
3394
|
alt: "average",
|
|
3384
|
-
src: __webpack_require__(
|
|
3395
|
+
src: __webpack_require__(7134)
|
|
3385
3396
|
}), (0,preact_module.h)("p", {
|
|
3386
3397
|
class: "rating-face--text"
|
|
3387
3398
|
}, this.props.t('average'))), (0,preact_module.h)("div", {
|
|
@@ -3389,7 +3400,7 @@ class Rating extends common/* Com */.up {
|
|
|
3389
3400
|
onClick: e => this.onRatingGreat(e)
|
|
3390
3401
|
}, (0,preact_module.h)("img", {
|
|
3391
3402
|
alt: "great",
|
|
3392
|
-
src: __webpack_require__(
|
|
3403
|
+
src: __webpack_require__(940)
|
|
3393
3404
|
}), (0,preact_module.h)("p", {
|
|
3394
3405
|
class: "rating-face--text"
|
|
3395
3406
|
}, this.props.t('great')))), (0,preact_module.h)("div", {
|
|
@@ -3403,12 +3414,12 @@ class Rating extends common/* Com */.up {
|
|
|
3403
3414
|
var rated;
|
|
3404
3415
|
var ended;
|
|
3405
3416
|
let user = this.props.store.matchUser();
|
|
3406
|
-
util/* default */.
|
|
3407
|
-
if (util/* default */.
|
|
3417
|
+
util/* default */.A.map(this.props.store.listEvents(this.props.cid), ev => {
|
|
3418
|
+
if (util/* default */.A.get(ev, 'type') === 'conversation_state_updated' && util/* default */.A.get(ev, 'data.conversation.state') === 'ended') {
|
|
3408
3419
|
ended = ev;
|
|
3409
3420
|
}
|
|
3410
|
-
if (util/* default */.
|
|
3411
|
-
if (util/* default */.
|
|
3421
|
+
if (util/* default */.A.get(ev, 'type') === 'conversation_rating_requested') requested = ev;
|
|
3422
|
+
if (util/* default */.A.get(ev, 'type') === 'conversation_rated' && util/* default */.A.get(ev, 'by.id') === user.id) rated = ev;
|
|
3412
3423
|
});
|
|
3413
3424
|
if (rated) return false;
|
|
3414
3425
|
let accountSetting = this.props.plugin.chatbox;
|
|
@@ -3449,7 +3460,7 @@ class Rating extends common/* Com */.up {
|
|
|
3449
3460
|
hide: false
|
|
3450
3461
|
});
|
|
3451
3462
|
if (!this.refRating.current) return;
|
|
3452
|
-
util/* default */.
|
|
3463
|
+
util/* default */.A.setTimeout(() => {
|
|
3453
3464
|
if (this.refComment.current) this.refComment.current.focus();
|
|
3454
3465
|
}, 400);
|
|
3455
3466
|
this.refComment.current.value = '';
|
|
@@ -3538,15 +3549,15 @@ function DropdownSelect_toPrimitive(t, r) { if ("object" != typeof t || !t) retu
|
|
|
3538
3549
|
|
|
3539
3550
|
|
|
3540
3551
|
|
|
3541
|
-
class DropdownSelect extends common/* Com */.
|
|
3552
|
+
class DropdownSelect extends common/* Com */.Mw {
|
|
3542
3553
|
constructor(props) {
|
|
3543
3554
|
super(props);
|
|
3544
3555
|
DropdownSelect_defineProperty(this, "state", {
|
|
3545
3556
|
show: false,
|
|
3546
3557
|
searchValue: ''
|
|
3547
3558
|
});
|
|
3548
|
-
DropdownSelect_defineProperty(this, "filterRef", (0,preact_module/* createRef */.
|
|
3549
|
-
DropdownSelect_defineProperty(this, "overlayRef", (0,preact_module/* createRef */.
|
|
3559
|
+
DropdownSelect_defineProperty(this, "filterRef", (0,preact_module/* createRef */._3)());
|
|
3560
|
+
DropdownSelect_defineProperty(this, "overlayRef", (0,preact_module/* createRef */._3)());
|
|
3550
3561
|
DropdownSelect_defineProperty(this, "onTouchMove", e => {
|
|
3551
3562
|
if (e.target === this.overlayRef.current) {
|
|
3552
3563
|
e.preventDefault();
|
|
@@ -3571,15 +3582,15 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3571
3582
|
});
|
|
3572
3583
|
DropdownSelect_defineProperty(this, "hasSearch", () => {
|
|
3573
3584
|
if (this.props.has_search) return true;
|
|
3574
|
-
return util/* default */.
|
|
3585
|
+
return util/* default */.A.size(this.props.items) >= 10;
|
|
3575
3586
|
});
|
|
3576
3587
|
DropdownSelect_defineProperty(this, "getFilteredOptions", () => {
|
|
3577
3588
|
let items = this.props.items;
|
|
3578
3589
|
if (this.state.searchValue && this.hasSearch()) {
|
|
3579
|
-
items = util/* default */.
|
|
3580
|
-
let optionName = util/* default */.
|
|
3581
|
-
let optionDesc = util/* default */.
|
|
3582
|
-
let searchValue = util/* default */.
|
|
3590
|
+
items = util/* default */.A.filter(items, item => {
|
|
3591
|
+
let optionName = util/* default */.A.unicodeToAscii(item.name).toLowerCase().replace(/ /g, '');
|
|
3592
|
+
let optionDesc = util/* default */.A.unicodeToAscii(item.desc).toLowerCase().replace(/ /g, '');
|
|
3593
|
+
let searchValue = util/* default */.A.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g, '');
|
|
3583
3594
|
return optionName.indexOf(searchValue) != -1 || optionDesc.indexOf(searchValue) != -1;
|
|
3584
3595
|
});
|
|
3585
3596
|
}
|
|
@@ -3618,7 +3629,7 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3618
3629
|
class: "dropdown_select_filter__empty"
|
|
3619
3630
|
}, (0,preact_module.h)("img", {
|
|
3620
3631
|
class: "dropdown_select_filter__empty_img",
|
|
3621
|
-
src: __webpack_require__(
|
|
3632
|
+
src: __webpack_require__(3142)
|
|
3622
3633
|
}), (0,preact_module.h)("div", {
|
|
3623
3634
|
class: "muted",
|
|
3624
3635
|
style: "text-align: center !important;"
|
|
@@ -3638,7 +3649,7 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3638
3649
|
focusFilter() {
|
|
3639
3650
|
if (!this.filterRef.current) return;
|
|
3640
3651
|
this.filterRef.current.focus();
|
|
3641
|
-
util/* default */.
|
|
3652
|
+
util/* default */.A.setTimeout(() => {
|
|
3642
3653
|
if (!this.filterRef.current) return;
|
|
3643
3654
|
this.filterRef.current.focus();
|
|
3644
3655
|
}, 100);
|
|
@@ -3646,7 +3657,7 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3646
3657
|
renderDropdown() {
|
|
3647
3658
|
if (!this.state.show) return null;
|
|
3648
3659
|
let items = this.getFilteredOptions();
|
|
3649
|
-
let $items = util/* default */.
|
|
3660
|
+
let $items = util/* default */.A.map(items, item => {
|
|
3650
3661
|
return (0,preact_module.h)("div", {
|
|
3651
3662
|
class: "dropdown_select__item",
|
|
3652
3663
|
onClick: _ => this.onSelect(item)
|
|
@@ -3656,12 +3667,12 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3656
3667
|
if (this.hasSearch()) {
|
|
3657
3668
|
let $img = (0,preact_module.h)("img", {
|
|
3658
3669
|
class: "dropdown_select_filter__icon",
|
|
3659
|
-
src: __webpack_require__(
|
|
3670
|
+
src: __webpack_require__(5452)
|
|
3660
3671
|
});
|
|
3661
3672
|
if (this.props.loading) {
|
|
3662
3673
|
$img = (0,preact_module.h)("img", {
|
|
3663
3674
|
class: "dropdown_select_filter__icon",
|
|
3664
|
-
src: __webpack_require__(
|
|
3675
|
+
src: __webpack_require__(185)
|
|
3665
3676
|
});
|
|
3666
3677
|
}
|
|
3667
3678
|
$filter = (0,preact_module.h)("div", {
|
|
@@ -3707,17 +3718,17 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3707
3718
|
class: "muted text-truncate",
|
|
3708
3719
|
style: "flex: 1 !important;"
|
|
3709
3720
|
}, "Ch\u1ECDn m\u1ED9t ph\u1EA7n t\u1EED");
|
|
3710
|
-
if (util/* default */.
|
|
3721
|
+
if (util/* default */.A.get(this.props, 'selected.name')) $name = (0,preact_module.h)("div", {
|
|
3711
3722
|
class: "text-truncate",
|
|
3712
3723
|
style: "flex: 1 !important;"
|
|
3713
|
-
}, util/* default */.
|
|
3724
|
+
}, util/* default */.A.get(this.props, 'selected.name'));
|
|
3714
3725
|
let style = 'position: relative !important;';
|
|
3715
3726
|
if (this.props.full) {
|
|
3716
3727
|
style = '';
|
|
3717
3728
|
}
|
|
3718
3729
|
return (0,preact_module.h)("div", {
|
|
3719
3730
|
style: style
|
|
3720
|
-
}, (0,preact_module.h)(common/* Clickaway */.
|
|
3731
|
+
}, (0,preact_module.h)(common/* Clickaway */.tW, {
|
|
3721
3732
|
onClickaway: this.hideDropdown
|
|
3722
3733
|
}, (0,preact_module.h)("div", {
|
|
3723
3734
|
type: "text",
|
|
@@ -3725,7 +3736,7 @@ class DropdownSelect extends common/* Com */.up {
|
|
|
3725
3736
|
onClick: this.toogleDropdown
|
|
3726
3737
|
}, $name, "\xA0", (0,preact_module.h)("img", {
|
|
3727
3738
|
class: "dropdown_select__caret",
|
|
3728
|
-
src: __webpack_require__(
|
|
3739
|
+
src: __webpack_require__(7741)
|
|
3729
3740
|
})), this.renderDropdown()));
|
|
3730
3741
|
}
|
|
3731
3742
|
}
|
|
@@ -3737,7 +3748,7 @@ function address_picker_toPrimitive(t, r) { if ("object" != typeof t || !t) retu
|
|
|
3737
3748
|
|
|
3738
3749
|
|
|
3739
3750
|
|
|
3740
|
-
class AddressPicker extends common/* Com */.
|
|
3751
|
+
class AddressPicker extends common/* Com */.Mw {
|
|
3741
3752
|
constructor(props) {
|
|
3742
3753
|
super(props);
|
|
3743
3754
|
address_picker_defineProperty(this, "state", {
|
|
@@ -3745,8 +3756,8 @@ class AddressPicker extends common/* Com */.up {
|
|
|
3745
3756
|
searchValue: '',
|
|
3746
3757
|
addresses: []
|
|
3747
3758
|
});
|
|
3748
|
-
address_picker_defineProperty(this, "filterRef", (0,preact_module/* createRef */.
|
|
3749
|
-
address_picker_defineProperty(this, "overlayRef", (0,preact_module/* createRef */.
|
|
3759
|
+
address_picker_defineProperty(this, "filterRef", (0,preact_module/* createRef */._3)());
|
|
3760
|
+
address_picker_defineProperty(this, "overlayRef", (0,preact_module/* createRef */._3)());
|
|
3750
3761
|
address_picker_defineProperty(this, "onTouchMove", e => {
|
|
3751
3762
|
if (e.target === this.overlayRef.current) {
|
|
3752
3763
|
e.preventDefault();
|
|
@@ -3770,13 +3781,13 @@ class AddressPicker extends common/* Com */.up {
|
|
|
3770
3781
|
}
|
|
3771
3782
|
if (e.key == 'Enter') {}
|
|
3772
3783
|
});
|
|
3773
|
-
address_picker_defineProperty(this, "doSearch", util/* default */.
|
|
3784
|
+
address_picker_defineProperty(this, "doSearch", util/* default */.A.throttle(async () => {
|
|
3774
3785
|
let requestId = Date.now();
|
|
3775
3786
|
this.requestId = requestId;
|
|
3776
3787
|
let res = await this.props.store.suggest_addresses(this.state.searchValue);
|
|
3777
3788
|
if (this.requestId !== requestId) return;
|
|
3778
3789
|
this.setState({
|
|
3779
|
-
addresses: util/* default */.
|
|
3790
|
+
addresses: util/* default */.A.get(res, 'body.addresses', [])
|
|
3780
3791
|
});
|
|
3781
3792
|
}, 100));
|
|
3782
3793
|
address_picker_defineProperty(this, "onChangeSearchValue", e => {
|
|
@@ -3813,7 +3824,7 @@ class AddressPicker extends common/* Com */.up {
|
|
|
3813
3824
|
class: "dropdown_select_filter__empty"
|
|
3814
3825
|
}, (0,preact_module.h)("img", {
|
|
3815
3826
|
class: "dropdown_select_filter__empty_img",
|
|
3816
|
-
src: __webpack_require__(
|
|
3827
|
+
src: __webpack_require__(3142)
|
|
3817
3828
|
}), (0,preact_module.h)("div", {
|
|
3818
3829
|
class: "muted",
|
|
3819
3830
|
style: "text-align: center !important;"
|
|
@@ -3833,14 +3844,14 @@ class AddressPicker extends common/* Com */.up {
|
|
|
3833
3844
|
focusFilter() {
|
|
3834
3845
|
if (!this.filterRef.current) return;
|
|
3835
3846
|
this.filterRef.current.focus();
|
|
3836
|
-
util/* default */.
|
|
3847
|
+
util/* default */.A.setTimeout(() => {
|
|
3837
3848
|
if (!this.filterRef.current) return;
|
|
3838
3849
|
this.filterRef.current.focus();
|
|
3839
3850
|
}, 100);
|
|
3840
3851
|
}
|
|
3841
3852
|
renderDropdown() {
|
|
3842
3853
|
if (!this.state.show) return null;
|
|
3843
|
-
let $items = util/* default */.
|
|
3854
|
+
let $items = util/* default */.A.map(this.state.addresses, (addr, i) => {
|
|
3844
3855
|
let label = [((addr.address || '') + ' ' + normalize(addr.street)).trim()].join(', ');
|
|
3845
3856
|
let desc = [normalize(addr.ward), normalize(addr.district), normalize(addr.province)].join(', ');
|
|
3846
3857
|
return (0,preact_module.h)("div", {
|
|
@@ -3854,12 +3865,12 @@ class AddressPicker extends common/* Com */.up {
|
|
|
3854
3865
|
let $filter = null;
|
|
3855
3866
|
let $img = (0,preact_module.h)("img", {
|
|
3856
3867
|
class: "dropdown_select_filter__icon",
|
|
3857
|
-
src: __webpack_require__(
|
|
3868
|
+
src: __webpack_require__(5452)
|
|
3858
3869
|
});
|
|
3859
3870
|
if (this.props.loading) {
|
|
3860
3871
|
$img = (0,preact_module.h)("img", {
|
|
3861
3872
|
class: "dropdown_select_filter__icon",
|
|
3862
|
-
src: __webpack_require__(
|
|
3873
|
+
src: __webpack_require__(185)
|
|
3863
3874
|
});
|
|
3864
3875
|
}
|
|
3865
3876
|
$filter = (0,preact_module.h)("div", {
|
|
@@ -3910,7 +3921,7 @@ class AddressPicker extends common/* Com */.up {
|
|
|
3910
3921
|
}
|
|
3911
3922
|
return (0,preact_module.h)("div", {
|
|
3912
3923
|
style: style
|
|
3913
|
-
}, (0,preact_module.h)(common/* Clickaway */.
|
|
3924
|
+
}, (0,preact_module.h)(common/* Clickaway */.tW, {
|
|
3914
3925
|
onClickaway: this.hideDropdown
|
|
3915
3926
|
}, (0,preact_module.h)("div", {
|
|
3916
3927
|
type: "text",
|
|
@@ -3937,37 +3948,37 @@ function normalize(s) {
|
|
|
3937
3948
|
}
|
|
3938
3949
|
;// CONCATENATED MODULE: ./src/order/icon.js
|
|
3939
3950
|
|
|
3940
|
-
let promiseMainCSS = (() => __webpack_require__.e(/* import() */
|
|
3951
|
+
let promiseMainCSS = (() => __webpack_require__.e(/* import() */ 278).then(__webpack_require__.bind(__webpack_require__, 9278)))();
|
|
3941
3952
|
var $link = document.createElement('link');
|
|
3942
3953
|
$link.href = 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap';
|
|
3943
3954
|
$link.rel = 'stylesheet';
|
|
3944
3955
|
document.head.append($link);
|
|
3945
|
-
util/* default */.
|
|
3956
|
+
util/* default */.A.preloadWebfonts(['Roboto'], [400, 500]);
|
|
3946
3957
|
|
|
3947
|
-
let icon_defaultAvatar = __webpack_require__(
|
|
3958
|
+
let icon_defaultAvatar = __webpack_require__(2538);
|
|
3948
3959
|
|
|
3949
3960
|
|
|
3950
3961
|
|
|
3951
|
-
class Icon extends common/* Com */.
|
|
3962
|
+
class Icon extends common/* Com */.Mw {
|
|
3952
3963
|
render() {
|
|
3953
3964
|
if (this.props.name == 'package') {
|
|
3954
3965
|
if (this.props.active) return (0,preact_module.h)("img", {
|
|
3955
3966
|
style: "width: 18px !important;",
|
|
3956
|
-
src: __webpack_require__(
|
|
3967
|
+
src: __webpack_require__(8512)
|
|
3957
3968
|
});
|
|
3958
3969
|
return (0,preact_module.h)("img", {
|
|
3959
3970
|
style: "width: 18px !important;",
|
|
3960
|
-
src: __webpack_require__(
|
|
3971
|
+
src: __webpack_require__(6857)
|
|
3961
3972
|
});
|
|
3962
3973
|
}
|
|
3963
3974
|
if (this.props.name === 'shop') {
|
|
3964
3975
|
if (this.props.active) return (0,preact_module.h)("img", {
|
|
3965
3976
|
style: "width: 18px !important;",
|
|
3966
|
-
src: __webpack_require__(
|
|
3977
|
+
src: __webpack_require__(5244)
|
|
3967
3978
|
});
|
|
3968
3979
|
return (0,preact_module.h)("img", {
|
|
3969
3980
|
style: "width: 18px !important;",
|
|
3970
|
-
src: __webpack_require__(
|
|
3981
|
+
src: __webpack_require__(2523)
|
|
3971
3982
|
});
|
|
3972
3983
|
}
|
|
3973
3984
|
}
|
|
@@ -3984,9 +3995,9 @@ function order_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var
|
|
|
3984
3995
|
|
|
3985
3996
|
|
|
3986
3997
|
|
|
3987
|
-
var checkedimg = __webpack_require__(
|
|
3988
|
-
var ximg = __webpack_require__(
|
|
3989
|
-
class order_Order extends common/* Com */.
|
|
3998
|
+
var checkedimg = __webpack_require__(5860);
|
|
3999
|
+
var ximg = __webpack_require__(3080);
|
|
4000
|
+
class order_Order extends common/* Com */.Mw {
|
|
3990
4001
|
constructor(props) {
|
|
3991
4002
|
super(props);
|
|
3992
4003
|
order_defineProperty(this, "state", {
|
|
@@ -4049,7 +4060,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4049
4060
|
loadDistrict: false
|
|
4050
4061
|
});
|
|
4051
4062
|
if (!out.error) this.setState({
|
|
4052
|
-
districts: util/* default */.
|
|
4063
|
+
districts: util/* default */.A.get(out, 'body.addresses')
|
|
4053
4064
|
});
|
|
4054
4065
|
});
|
|
4055
4066
|
order_defineProperty(this, "onSelectDistrict", async item => {
|
|
@@ -4068,7 +4079,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4068
4079
|
loadWard: false
|
|
4069
4080
|
});
|
|
4070
4081
|
if (!out.error) this.setState({
|
|
4071
|
-
wards: util/* default */.
|
|
4082
|
+
wards: util/* default */.A.get(out, 'body.addresses')
|
|
4072
4083
|
});
|
|
4073
4084
|
});
|
|
4074
4085
|
order_defineProperty(this, "onSelectWard", item => this.setState({
|
|
@@ -4089,7 +4100,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4089
4100
|
order_defineProperty(this, "onSelectAddress", addr => {
|
|
4090
4101
|
if (!addr) return;
|
|
4091
4102
|
this.setState({
|
|
4092
|
-
address: [util/* default */.
|
|
4103
|
+
address: [util/* default */.A.trim(addr.address), util/* default */.A.trim(addr.street)].join(' ').trim(),
|
|
4093
4104
|
street: addr.street,
|
|
4094
4105
|
err: {},
|
|
4095
4106
|
g_err: ''
|
|
@@ -4136,36 +4147,36 @@ class order_Order extends common/* Com */.up {
|
|
|
4136
4147
|
});
|
|
4137
4148
|
}
|
|
4138
4149
|
if (this.state.shipping === 'shop') {
|
|
4139
|
-
if (!util/* default */.
|
|
4150
|
+
if (!util/* default */.A.isPhone(this.state.phone)) {
|
|
4140
4151
|
err.phone = true;
|
|
4141
4152
|
}
|
|
4142
|
-
if (!util/* default */.
|
|
4153
|
+
if (!util/* default */.A.trim(this.state.fullname)) {
|
|
4143
4154
|
err.name = true;
|
|
4144
4155
|
}
|
|
4145
|
-
if (!util/* default */.
|
|
4156
|
+
if (!util/* default */.A.trim(this.state.email)) {
|
|
4146
4157
|
err.email = true;
|
|
4147
4158
|
}
|
|
4148
4159
|
} else if (this.state.shipping_address == 'new') {
|
|
4149
|
-
if (!util/* default */.
|
|
4160
|
+
if (!util/* default */.A.isPhone(this.state.phone)) {
|
|
4150
4161
|
err.phone = true;
|
|
4151
4162
|
}
|
|
4152
|
-
if (!util/* default */.
|
|
4163
|
+
if (!util/* default */.A.trim(this.state.fullname)) {
|
|
4153
4164
|
err.name = true;
|
|
4154
4165
|
}
|
|
4155
|
-
if (!util/* default */.
|
|
4166
|
+
if (!util/* default */.A.trim(this.state.address)) {
|
|
4156
4167
|
err.address = true;
|
|
4157
4168
|
}
|
|
4158
|
-
if (util/* default */.
|
|
4169
|
+
if (util/* default */.A.size(this.state.selectedWard) == 0) {
|
|
4159
4170
|
err.ward = true;
|
|
4160
4171
|
}
|
|
4161
|
-
if (util/* default */.
|
|
4172
|
+
if (util/* default */.A.size(this.state.selectedDistrict) == 0) {
|
|
4162
4173
|
err.district = true;
|
|
4163
4174
|
}
|
|
4164
|
-
if (util/* default */.
|
|
4175
|
+
if (util/* default */.A.size(this.state.selectedProvince) == 0) {
|
|
4165
4176
|
err.province = true;
|
|
4166
4177
|
}
|
|
4167
4178
|
}
|
|
4168
|
-
if (util/* default */.
|
|
4179
|
+
if (util/* default */.A.size(err) > 0) {
|
|
4169
4180
|
this.setState({
|
|
4170
4181
|
err,
|
|
4171
4182
|
g_err: this.props.t('input_shipping_info_err')
|
|
@@ -4173,15 +4184,15 @@ class order_Order extends common/* Com */.up {
|
|
|
4173
4184
|
return;
|
|
4174
4185
|
}
|
|
4175
4186
|
let user = this.props.store.matchUser();
|
|
4176
|
-
let ufullname = util/* default */.
|
|
4177
|
-
let uemail = util/* default */.
|
|
4178
|
-
let uphone = util/* default */.
|
|
4179
|
-
let order = util/* default */.
|
|
4187
|
+
let ufullname = util/* default */.A.getUserAttr(user, 'fullname', 'text');
|
|
4188
|
+
let uemail = util/* default */.A.getUserAttr(user, 'emails', 'text');
|
|
4189
|
+
let uphone = util/* default */.A.getUserAttr(user, 'phones', 'text');
|
|
4190
|
+
let order = util/* default */.A.cloneDeep(this.state.order);
|
|
4180
4191
|
if (this.state.shipping === 'shop') {
|
|
4181
|
-
util/* default */.
|
|
4182
|
-
util/* default */.
|
|
4183
|
-
util/* default */.
|
|
4184
|
-
util/* default */.
|
|
4192
|
+
util/* default */.A.set(order, 'shipping.pickup_at_shop', true);
|
|
4193
|
+
util/* default */.A.set(order, 'shipping.address.phone', this.state.phone);
|
|
4194
|
+
util/* default */.A.set(order, 'shipping.address.fullname', this.state.fullname);
|
|
4195
|
+
util/* default */.A.set(order, 'shipping.address.email', this.state.email);
|
|
4185
4196
|
} else {
|
|
4186
4197
|
if (this.state.shipping_address == 'new') {
|
|
4187
4198
|
let out = await this.props.store.createShippingAddress({
|
|
@@ -4201,37 +4212,37 @@ class order_Order extends common/* Com */.up {
|
|
|
4201
4212
|
if (out.error) return this.setState({
|
|
4202
4213
|
g_err: this.props.t('update_failed')
|
|
4203
4214
|
});
|
|
4204
|
-
util/* default */.
|
|
4215
|
+
util/* default */.A.set(order, 'shipping.address', out.body);
|
|
4205
4216
|
} else {
|
|
4206
4217
|
let addresses = this.props.store.matchShippingAddresses();
|
|
4207
|
-
let sa = util/* default */.
|
|
4218
|
+
let sa = util/* default */.A.find(addresses, addr => addr.id === this.state.shipping_address);
|
|
4208
4219
|
if (!sa) {
|
|
4209
4220
|
return this.setState({
|
|
4210
4221
|
err,
|
|
4211
4222
|
g_err: this.props.t('input_shipping_info_err')
|
|
4212
4223
|
});
|
|
4213
4224
|
}
|
|
4214
|
-
util/* default */.
|
|
4225
|
+
util/* default */.A.set(order, 'shipping.address', sa);
|
|
4215
4226
|
}
|
|
4216
4227
|
}
|
|
4217
4228
|
let changeduser = false;
|
|
4218
4229
|
if (!ufullname && this.state.fullname) {
|
|
4219
4230
|
changeduser = true;
|
|
4220
|
-
util/* default */.
|
|
4231
|
+
util/* default */.A.setUserAttr(user, {
|
|
4221
4232
|
key: 'fullname',
|
|
4222
4233
|
text: this.state.fullname
|
|
4223
4234
|
});
|
|
4224
4235
|
}
|
|
4225
4236
|
if (!uemail && this.state.email) {
|
|
4226
4237
|
changeduser = true;
|
|
4227
|
-
util/* default */.
|
|
4238
|
+
util/* default */.A.setUserAttr(user, {
|
|
4228
4239
|
key: 'emails',
|
|
4229
4240
|
text: this.state.email
|
|
4230
4241
|
});
|
|
4231
4242
|
}
|
|
4232
4243
|
if (!uphone && this.state.phone) {
|
|
4233
4244
|
changeduser = true;
|
|
4234
|
-
util/* default */.
|
|
4245
|
+
util/* default */.A.setUserAttr(user, {
|
|
4235
4246
|
key: 'phones',
|
|
4236
4247
|
text: this.state.phone
|
|
4237
4248
|
});
|
|
@@ -4258,7 +4269,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4258
4269
|
order_defineProperty(this, "onCancel", () => {
|
|
4259
4270
|
if (this.props.onResponse) this.props.onResponse('rejected');
|
|
4260
4271
|
if (this.props.cid && !this.state.order.user_confirmation) {
|
|
4261
|
-
let order = util/* default */.
|
|
4272
|
+
let order = util/* default */.A.cloneDeep(this.state.order);
|
|
4262
4273
|
order.user_confirmation = 'rejected';
|
|
4263
4274
|
this.props.store.updateOrder(order);
|
|
4264
4275
|
}
|
|
@@ -4285,10 +4296,10 @@ class order_Order extends common/* Com */.up {
|
|
|
4285
4296
|
});
|
|
4286
4297
|
}
|
|
4287
4298
|
let user = this.props.store.matchUser();
|
|
4288
|
-
let attributes = util/* default */.
|
|
4289
|
-
let fullname = util/* default */.
|
|
4290
|
-
let email = util/* default */.
|
|
4291
|
-
let phone = util/* default */.
|
|
4299
|
+
let attributes = util/* default */.A.get(this.props.store.matchUser(), 'attributes', []);
|
|
4300
|
+
let fullname = util/* default */.A.get(util/* default */.A.find(attributes, att => att.key === 'fullname'), 'text');
|
|
4301
|
+
let email = util/* default */.A.get(util/* default */.A.find(attributes, att => att.key === 'emails'), 'text');
|
|
4302
|
+
let phone = util/* default */.A.get(util/* default */.A.find(attributes, att => att.key === 'phones'), 'text');
|
|
4292
4303
|
this.setState({
|
|
4293
4304
|
fullname,
|
|
4294
4305
|
email,
|
|
@@ -4300,7 +4311,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4300
4311
|
loadProvince: false
|
|
4301
4312
|
});
|
|
4302
4313
|
if (!out.error) this.setState({
|
|
4303
|
-
provinces: util/* default */.
|
|
4314
|
+
provinces: util/* default */.A.get(out, 'body.addresses')
|
|
4304
4315
|
});
|
|
4305
4316
|
}
|
|
4306
4317
|
isMobile() {
|
|
@@ -4330,7 +4341,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4330
4341
|
}
|
|
4331
4342
|
if (editmode) {
|
|
4332
4343
|
let pms = this.props.store.matchPaymentMethods();
|
|
4333
|
-
let $pms = util/* default */.
|
|
4344
|
+
let $pms = util/* default */.A.map(pms, pm => {
|
|
4334
4345
|
let $name = pm.description;
|
|
4335
4346
|
if (pm.method == 'bank_transfer') {
|
|
4336
4347
|
$name = pm.description + ' ' + pm.bank_name + ' ' + pm.bank_branch;
|
|
@@ -4372,7 +4383,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4372
4383
|
});
|
|
4373
4384
|
let seccls = 'card_section';
|
|
4374
4385
|
if (this.isMobile()) seccls = 'order_section';
|
|
4375
|
-
return (0,preact_module.h)(preact_module/* Fragment */.
|
|
4386
|
+
return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
|
|
4376
4387
|
class: "order_section__line"
|
|
4377
4388
|
}), (0,preact_module.h)("div", {
|
|
4378
4389
|
class: seccls
|
|
@@ -4399,7 +4410,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4399
4410
|
}, "S\u1ED1 t\xE0i kho\u1EA3n: ", pm.bank_number));
|
|
4400
4411
|
}
|
|
4401
4412
|
if (!$body) return null;
|
|
4402
|
-
return (0,preact_module.h)(preact_module/* Fragment */.
|
|
4413
|
+
return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
|
|
4403
4414
|
class: "order_label"
|
|
4404
4415
|
}, this.props.t('payment')), $body);
|
|
4405
4416
|
}
|
|
@@ -4411,15 +4422,15 @@ class order_Order extends common/* Com */.up {
|
|
|
4411
4422
|
let user = this.props.store.matchUser();
|
|
4412
4423
|
if (editmode) {
|
|
4413
4424
|
let addresses = this.props.store.matchShippingAddresses();
|
|
4414
|
-
let provinces = util/* default */.
|
|
4425
|
+
let provinces = util/* default */.A.map(this.state.provinces, province => ({
|
|
4415
4426
|
id: province.id,
|
|
4416
4427
|
name: province.province
|
|
4417
4428
|
}));
|
|
4418
|
-
let districts = util/* default */.
|
|
4429
|
+
let districts = util/* default */.A.map(this.state.districts, district => ({
|
|
4419
4430
|
id: district.id,
|
|
4420
4431
|
name: district.district
|
|
4421
4432
|
}));
|
|
4422
|
-
let wards = util/* default */.
|
|
4433
|
+
let wards = util/* default */.A.map(this.state.wards, ward => ({
|
|
4423
4434
|
id: ward.id,
|
|
4424
4435
|
name: ward.ward
|
|
4425
4436
|
}));
|
|
@@ -4428,11 +4439,11 @@ class order_Order extends common/* Com */.up {
|
|
|
4428
4439
|
let ship_icon_active = false;
|
|
4429
4440
|
if (this.state.shipping === 'ship') {
|
|
4430
4441
|
ship_icon_active = true;
|
|
4431
|
-
let $preaddrs = util/* default */.
|
|
4442
|
+
let $preaddrs = util/* default */.A.map(addresses, addr => {
|
|
4432
4443
|
let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
|
|
4433
4444
|
let $phone = null;
|
|
4434
4445
|
if (addr.phone) {
|
|
4435
|
-
$phone = (0,preact_module.h)(preact_module/* Fragment */.
|
|
4446
|
+
$phone = (0,preact_module.h)(preact_module/* Fragment */.FK, null, "\xA0\xB7\xA0", this.props.t('phn'), " ", addr.phone);
|
|
4436
4447
|
}
|
|
4437
4448
|
return (0,preact_module.h)("div", {
|
|
4438
4449
|
style: "margin-bottom: 15px !important"
|
|
@@ -4560,7 +4571,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4560
4571
|
style: "flex: 1 !important; margin-left: 7px !important;"
|
|
4561
4572
|
})));
|
|
4562
4573
|
cls += ' ship_card__active';
|
|
4563
|
-
if (util/* default */.
|
|
4574
|
+
if (util/* default */.A.size(addresses) == 0) {
|
|
4564
4575
|
$body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
4565
4576
|
class: 'mt-3 mb-2 '
|
|
4566
4577
|
}, this.props.t('input_shipping_info')), $new);
|
|
@@ -4612,7 +4623,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4612
4623
|
}
|
|
4613
4624
|
let seccls = 'card_section';
|
|
4614
4625
|
if (this.isMobile()) seccls = 'order_section';
|
|
4615
|
-
return (0,preact_module.h)(preact_module/* Fragment */.
|
|
4626
|
+
return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
|
|
4616
4627
|
class: "order_section__line"
|
|
4617
4628
|
}), (0,preact_module.h)("div", {
|
|
4618
4629
|
class: seccls
|
|
@@ -4638,13 +4649,13 @@ class order_Order extends common/* Com */.up {
|
|
|
4638
4649
|
class: "ml-2"
|
|
4639
4650
|
}, "Giao h\xE0ng cho t\xF4i"))), $body));
|
|
4640
4651
|
}
|
|
4641
|
-
let addr = util/* default */.
|
|
4652
|
+
let addr = util/* default */.A.get(order, 'shipping.address') || {};
|
|
4642
4653
|
let fulladdr = [addr.address, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
|
|
4643
4654
|
let $phone = null;
|
|
4644
4655
|
if (addr.phone) $phone = (0,preact_module.h)("div", {
|
|
4645
4656
|
class: "mt-1 muted"
|
|
4646
4657
|
}, this.props.t('phn'), ":\xA0", addr.phone);
|
|
4647
|
-
if (util/* default */.
|
|
4658
|
+
if (util/* default */.A.get(order, 'shipping.pickup_at_shop')) {
|
|
4648
4659
|
fulladdr = 'Nhận hàng tại cửa hàng';
|
|
4649
4660
|
}
|
|
4650
4661
|
let $addr = fulladdr ? (0,preact_module.h)("div", null, fulladdr) : (0,preact_module.h)("i", {
|
|
@@ -4663,28 +4674,28 @@ class order_Order extends common/* Com */.up {
|
|
|
4663
4674
|
if (order.deposit > 0) {
|
|
4664
4675
|
$deposit = (0,preact_module.h)("span", {
|
|
4665
4676
|
class: "muted"
|
|
4666
|
-
}, "(c\u1ECDc ", util/* default */.
|
|
4677
|
+
}, "(c\u1ECDc ", util/* default */.A.formatCurrency(order.deposit), ")");
|
|
4667
4678
|
}
|
|
4668
4679
|
let $discount = null;
|
|
4669
4680
|
if (order.total_discount > 0) {
|
|
4670
4681
|
$discount = (0,preact_module.h)("div", {
|
|
4671
4682
|
class: "order_summary_line"
|
|
4672
|
-
}, (0,preact_module.h)("div", null, "Gi\u1EA3m gi\xE1"), (0,preact_module.h)("div", null, util/* default */.
|
|
4683
|
+
}, (0,preact_module.h)("div", null, "Gi\u1EA3m gi\xE1"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency(order.total_discount)));
|
|
4673
4684
|
}
|
|
4674
4685
|
let $pay = null;
|
|
4675
4686
|
if ($deposit || order.payment_made) {
|
|
4676
|
-
$pay = (0,preact_module.h)(preact_module/* Fragment */.
|
|
4687
|
+
$pay = (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
|
|
4677
4688
|
class: "order_summary_line"
|
|
4678
|
-
}, (0,preact_module.h)("div", null, "B\u1EA1n \u0111\xE3 tr\u1EA3"), (0,preact_module.h)("div", null, $deposit, " ", util/* default */.
|
|
4689
|
+
}, (0,preact_module.h)("div", null, "B\u1EA1n \u0111\xE3 tr\u1EA3"), (0,preact_module.h)("div", null, $deposit, " ", util/* default */.A.formatCurrency(order.payment_made))), (0,preact_module.h)("div", {
|
|
4679
4690
|
class: "order_summary_line"
|
|
4680
|
-
}, (0,preact_module.h)("div", null, "B\u1EA1n ch\u01B0a tr\u1EA3"), (0,preact_module.h)("div", null, util/* default */.
|
|
4691
|
+
}, (0,preact_module.h)("div", null, "B\u1EA1n ch\u01B0a tr\u1EA3"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency((order.total || 0) - (order.payment_made || 0)))));
|
|
4681
4692
|
}
|
|
4682
4693
|
let $tax = (0,preact_module.h)("div", {
|
|
4683
4694
|
class: "order_summary_line"
|
|
4684
|
-
}, (0,preact_module.h)("div", null, "Ti\u1EC1n thu\u1EBF"), (0,preact_module.h)("div", null, util/* default */.
|
|
4695
|
+
}, (0,preact_module.h)("div", null, "Ti\u1EC1n thu\u1EBF"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency(order.total_tax)));
|
|
4685
4696
|
let $ship = (0,preact_module.h)("div", {
|
|
4686
4697
|
class: "order_summary_line"
|
|
4687
|
-
}, (0,preact_module.h)("div", null, "Ph\xED v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", null, util/* default */.
|
|
4698
|
+
}, (0,preact_module.h)("div", null, "Ph\xED v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", null, util/* default */.A.get(order, 'shipping.fee', 0), " d"));
|
|
4688
4699
|
let editmode = false;
|
|
4689
4700
|
if (!order.status || order.status == 'open') {
|
|
4690
4701
|
editmode = !order.user_confirmation;
|
|
@@ -4697,12 +4708,12 @@ class order_Order extends common/* Com */.up {
|
|
|
4697
4708
|
class: "muted"
|
|
4698
4709
|
}, (0,preact_module.h)("img", {
|
|
4699
4710
|
class: "order_ship_icon",
|
|
4700
|
-
src: __webpack_require__(
|
|
4711
|
+
src: __webpack_require__(7324)
|
|
4701
4712
|
}), "\xA0 Ch\u01B0a bao g\u1ED3m thu\u1EBF v\xE0 ph\xED v\u1EADn chuy\u1EC3n");
|
|
4702
4713
|
}
|
|
4703
4714
|
let seccls = '';
|
|
4704
4715
|
if (this.isMobile()) seccls = 'order_section';
|
|
4705
|
-
return (0,preact_module.h)(preact_module/* Fragment */.
|
|
4716
|
+
return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
|
|
4706
4717
|
class: "order_section__line"
|
|
4707
4718
|
}), (0,preact_module.h)("div", {
|
|
4708
4719
|
class: seccls
|
|
@@ -4710,12 +4721,12 @@ class order_Order extends common/* Com */.up {
|
|
|
4710
4721
|
class: "order_label"
|
|
4711
4722
|
}, "T\xF3m t\u1EAFt"), (0,preact_module.h)("div", {
|
|
4712
4723
|
class: "order_summary_line"
|
|
4713
|
-
}, (0,preact_module.h)("div", null, "T\u1ED5ng ti\u1EC1n h\xE0ng"), (0,preact_module.h)("div", null, util/* default */.
|
|
4724
|
+
}, (0,preact_module.h)("div", null, "T\u1ED5ng ti\u1EC1n h\xE0ng"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency(order.subtotal))), $tax, $discount, $ship, $note, (0,preact_module.h)("div", {
|
|
4714
4725
|
class: "order_summary_line",
|
|
4715
4726
|
style: "margin-top: 10px !important; padding-top: 15px !important; border-top: 1px solid #eee !important"
|
|
4716
4727
|
}, (0,preact_module.h)("div", null, "B\u1EA1n ph\u1EA3i tr\u1EA3"), (0,preact_module.h)("div", {
|
|
4717
4728
|
class: "order__total"
|
|
4718
|
-
}, util/* default */.
|
|
4729
|
+
}, util/* default */.A.formatCurrency(order.total))), $pay));
|
|
4719
4730
|
}
|
|
4720
4731
|
renderStatusBadge(order) {
|
|
4721
4732
|
let status = order.status || 'open';
|
|
@@ -4726,9 +4737,9 @@ class order_Order extends common/* Com */.up {
|
|
|
4726
4737
|
}
|
|
4727
4738
|
renderShippingInfo(order) {
|
|
4728
4739
|
if (order.status != 'open' || order.user_confirmation) {}
|
|
4729
|
-
let shipping_provider = util/* default */.
|
|
4740
|
+
let shipping_provider = util/* default */.A.get(order, 'shipping.shipping_provider');
|
|
4730
4741
|
if (!shipping_provider) return null;
|
|
4731
|
-
let shipping_code = util/* default */.
|
|
4742
|
+
let shipping_code = util/* default */.A.get(order, 'shipping.shipping_code');
|
|
4732
4743
|
let $tracking_code = null;
|
|
4733
4744
|
if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
|
|
4734
4745
|
class: "muted",
|
|
@@ -4739,7 +4750,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4739
4750
|
href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
|
|
4740
4751
|
}, shipping_code, "\xA0", (0,preact_module.h)("img", {
|
|
4741
4752
|
class: "order_tracking_link_icon",
|
|
4742
|
-
src: __webpack_require__(
|
|
4753
|
+
src: __webpack_require__(3266)
|
|
4743
4754
|
})));
|
|
4744
4755
|
if (shipping_provider == 'ghtk') {
|
|
4745
4756
|
return (0,preact_module.h)("div", {
|
|
@@ -4756,9 +4767,9 @@ class order_Order extends common/* Com */.up {
|
|
|
4756
4767
|
return null;
|
|
4757
4768
|
}
|
|
4758
4769
|
renderDesktopShippingInfo(order) {
|
|
4759
|
-
let shipping_provider = util/* default */.
|
|
4770
|
+
let shipping_provider = util/* default */.A.get(order, 'shipping.shipping_provider');
|
|
4760
4771
|
if (!shipping_provider) return null;
|
|
4761
|
-
let shipping_code = util/* default */.
|
|
4772
|
+
let shipping_code = util/* default */.A.get(order, 'shipping.shipping_code');
|
|
4762
4773
|
let $tracking_code = null;
|
|
4763
4774
|
if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
|
|
4764
4775
|
class: "muted",
|
|
@@ -4769,10 +4780,10 @@ class order_Order extends common/* Com */.up {
|
|
|
4769
4780
|
href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
|
|
4770
4781
|
}, shipping_code, "\xA0", (0,preact_module.h)("img", {
|
|
4771
4782
|
class: "order_tracking_link_icon",
|
|
4772
|
-
src: __webpack_require__(
|
|
4783
|
+
src: __webpack_require__(3266)
|
|
4773
4784
|
})));
|
|
4774
4785
|
if (shipping_provider == 'ghtk') {
|
|
4775
|
-
return (0,preact_module.h)(preact_module/* Fragment */.
|
|
4786
|
+
return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
|
|
4776
4787
|
class: "order_label"
|
|
4777
4788
|
}, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", {
|
|
4778
4789
|
class: "d-flex align-items-center"
|
|
@@ -4785,7 +4796,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4785
4796
|
}
|
|
4786
4797
|
renderProducts(order) {
|
|
4787
4798
|
let $products = null;
|
|
4788
|
-
$products = util/* default */.
|
|
4799
|
+
$products = util/* default */.A.map(order.items, item => {
|
|
4789
4800
|
if (!item || !item.product) return null;
|
|
4790
4801
|
let product = item.product;
|
|
4791
4802
|
return (0,preact_module.h)("div", {
|
|
@@ -4793,7 +4804,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4793
4804
|
}, (0,preact_module.h)("img", {
|
|
4794
4805
|
class: "order_attachment__product_img",
|
|
4795
4806
|
alt: '' + product.id,
|
|
4796
|
-
src: util/* default */.
|
|
4807
|
+
src: util/* default */.A.get(product, 'images.0') || __webpack_require__(2876)
|
|
4797
4808
|
}), (0,preact_module.h)("div", {
|
|
4798
4809
|
style: "overflow: hidden !important;"
|
|
4799
4810
|
}, (0,preact_module.h)("div", {
|
|
@@ -4802,7 +4813,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4802
4813
|
class: "order_attachment__product_desc"
|
|
4803
4814
|
}, product.description || product.long_description), (0,preact_module.h)("div", {
|
|
4804
4815
|
class: "order_attachment__product_desc"
|
|
4805
|
-
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default */.
|
|
4816
|
+
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default */.A.formatCurrency(product.price))));
|
|
4806
4817
|
});
|
|
4807
4818
|
if (!this.isMobile()) return (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
4808
4819
|
class: "order_label"
|
|
@@ -4820,7 +4831,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4820
4831
|
editmode = !order.user_confirmation;
|
|
4821
4832
|
}
|
|
4822
4833
|
if (editmode) {
|
|
4823
|
-
$products = util/* default */.
|
|
4834
|
+
$products = util/* default */.A.map(order.items, item => {
|
|
4824
4835
|
if (!item || !item.product) return null;
|
|
4825
4836
|
let product = item.product;
|
|
4826
4837
|
return (0,preact_module.h)("div", {
|
|
@@ -4828,7 +4839,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4828
4839
|
}, (0,preact_module.h)("img", {
|
|
4829
4840
|
class: "order_attachment__product_img",
|
|
4830
4841
|
alt: '' + product.id,
|
|
4831
|
-
src: util/* default */.
|
|
4842
|
+
src: util/* default */.A.get(product, 'images.0') || __webpack_require__(2876)
|
|
4832
4843
|
}), (0,preact_module.h)("div", {
|
|
4833
4844
|
style: "overflow: hidden !important; flex: 1 !important"
|
|
4834
4845
|
}, (0,preact_module.h)("div", {
|
|
@@ -4837,7 +4848,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4837
4848
|
class: "order_attachment__product_desc"
|
|
4838
4849
|
}, product.description || product.long_description), (0,preact_module.h)("div", {
|
|
4839
4850
|
class: "order_attachment__product_desc"
|
|
4840
|
-
}, util/* default */.
|
|
4851
|
+
}, util/* default */.A.formatCurrency(product.price))), (0,preact_module.h)("input", {
|
|
4841
4852
|
class: "form-control",
|
|
4842
4853
|
style: "text-align: center !important; font-weight: 400 !important; width: 50px !important",
|
|
4843
4854
|
value: item.quantity,
|
|
@@ -4845,10 +4856,10 @@ class order_Order extends common/* Com */.up {
|
|
|
4845
4856
|
type: "text"
|
|
4846
4857
|
}), (0,preact_module.h)("div", {
|
|
4847
4858
|
style: "width: 80px !important; text-align: right !important; "
|
|
4848
|
-
}, (0,preact_module.h)("b", null, util/* default */.
|
|
4859
|
+
}, (0,preact_module.h)("b", null, util/* default */.A.formatCurrency(item.quantity * product.price))));
|
|
4849
4860
|
});
|
|
4850
4861
|
} else {
|
|
4851
|
-
$products = util/* default */.
|
|
4862
|
+
$products = util/* default */.A.map(order.items, item => {
|
|
4852
4863
|
if (!item || !item.product) return null;
|
|
4853
4864
|
let product = item.product;
|
|
4854
4865
|
return (0,preact_module.h)("div", {
|
|
@@ -4856,7 +4867,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4856
4867
|
}, (0,preact_module.h)("img", {
|
|
4857
4868
|
class: "order_attachment__product_img",
|
|
4858
4869
|
alt: '' + product.id,
|
|
4859
|
-
src: util/* default */.
|
|
4870
|
+
src: util/* default */.A.get(product, 'images.0') || __webpack_require__(2876)
|
|
4860
4871
|
}), (0,preact_module.h)("div", {
|
|
4861
4872
|
style: "overflow: hidden !important; flex: 1 !important"
|
|
4862
4873
|
}, (0,preact_module.h)("div", {
|
|
@@ -4865,11 +4876,11 @@ class order_Order extends common/* Com */.up {
|
|
|
4865
4876
|
class: "order_attachment__product_desc"
|
|
4866
4877
|
}, product.description || product.long_description), (0,preact_module.h)("div", {
|
|
4867
4878
|
class: "order_attachment__product_desc"
|
|
4868
|
-
}, util/* default */.
|
|
4879
|
+
}, util/* default */.A.formatCurrency(product.price))), (0,preact_module.h)("div", {
|
|
4869
4880
|
style: "text-align: center !important; font-weight: 400 !important; width: 50px !important"
|
|
4870
4881
|
}, item.quantity), (0,preact_module.h)("div", {
|
|
4871
4882
|
style: "width: 80px !important; text-align: right !important; "
|
|
4872
|
-
}, (0,preact_module.h)("b", null, util/* default */.
|
|
4883
|
+
}, (0,preact_module.h)("b", null, util/* default */.A.formatCurrency(item.total))));
|
|
4873
4884
|
});
|
|
4874
4885
|
}
|
|
4875
4886
|
return (0,preact_module.h)("div", {
|
|
@@ -4977,7 +4988,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4977
4988
|
}
|
|
4978
4989
|
renderDesktop(order) {
|
|
4979
4990
|
let acc = this.props.store.matchAccount();
|
|
4980
|
-
var uri = acc.logo_url || __webpack_require__(
|
|
4991
|
+
var uri = acc.logo_url || __webpack_require__(3582);
|
|
4981
4992
|
return (0,preact_module.h)("div", {
|
|
4982
4993
|
class: "desktop order"
|
|
4983
4994
|
}, (0,preact_module.h)("div", {
|
|
@@ -5023,7 +5034,7 @@ class order_Order extends common/* Com */.up {
|
|
|
5023
5034
|
class: "order_error"
|
|
5024
5035
|
}, (0,preact_module.h)("img", {
|
|
5025
5036
|
class: "mt-3",
|
|
5026
|
-
src: __webpack_require__(
|
|
5037
|
+
src: __webpack_require__(6907)
|
|
5027
5038
|
}), (0,preact_module.h)("div", {
|
|
5028
5039
|
class: "mt-3"
|
|
5029
5040
|
}, this.props.t('order_load_error')));
|
|
@@ -5035,11 +5046,11 @@ class order_Order extends common/* Com */.up {
|
|
|
5035
5046
|
let ShippingProvider = {
|
|
5036
5047
|
ghtk: {
|
|
5037
5048
|
name: 'Giao hàng tiết kiệm',
|
|
5038
|
-
logo: __webpack_require__(
|
|
5049
|
+
logo: __webpack_require__(7362)
|
|
5039
5050
|
},
|
|
5040
5051
|
ghn: {
|
|
5041
5052
|
name: 'Giao hàng nhanh',
|
|
5042
|
-
logo: __webpack_require__(
|
|
5053
|
+
logo: __webpack_require__(1113)
|
|
5043
5054
|
}
|
|
5044
5055
|
};
|
|
5045
5056
|
;// CONCATENATED MODULE: ./src/chatbox/Order.js
|
|
@@ -5052,11 +5063,11 @@ function Order_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var
|
|
|
5052
5063
|
const Order_POPUP_MAX_HEIGHT = 400;
|
|
5053
5064
|
const Order_POPUP_HARD_MAX_HEIGHT = 500;
|
|
5054
5065
|
const Order_POPUP_MIN_HEIGHT = 0;
|
|
5055
|
-
let Order_defaultAvatar = __webpack_require__(
|
|
5066
|
+
let Order_defaultAvatar = __webpack_require__(2538);
|
|
5056
5067
|
|
|
5057
5068
|
|
|
5058
5069
|
|
|
5059
|
-
class Order extends common/* Com */.
|
|
5070
|
+
class Order extends common/* Com */.Mw {
|
|
5060
5071
|
constructor(props) {
|
|
5061
5072
|
super(props);
|
|
5062
5073
|
Order_defineProperty(this, "state", {
|
|
@@ -5087,7 +5098,7 @@ class Order extends common/* Com */.up {
|
|
|
5087
5098
|
});
|
|
5088
5099
|
});
|
|
5089
5100
|
Order_defineProperty(this, "close", async () => {
|
|
5090
|
-
await util/* default */.
|
|
5101
|
+
await util/* default */.A.sleep(100);
|
|
5091
5102
|
if (this.state.response === 'confirmed') {
|
|
5092
5103
|
this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
|
|
5093
5104
|
message: {
|
|
@@ -5143,8 +5154,8 @@ class Order extends common/* Com */.up {
|
|
|
5143
5154
|
});
|
|
5144
5155
|
this.props.onClose();
|
|
5145
5156
|
});
|
|
5146
|
-
this.refRating = (0,preact_module/* createRef */.
|
|
5147
|
-
this.refHandle = (0,preact_module/* createRef */.
|
|
5157
|
+
this.refRating = (0,preact_module/* createRef */._3)();
|
|
5158
|
+
this.refHandle = (0,preact_module/* createRef */._3)();
|
|
5148
5159
|
}
|
|
5149
5160
|
componentDidMount() {
|
|
5150
5161
|
this.mouseUp = e => this.onMouseUp(e);
|
|
@@ -5188,7 +5199,7 @@ class Order extends common/* Com */.up {
|
|
|
5188
5199
|
render() {
|
|
5189
5200
|
if (this._show != this.props.show) {
|
|
5190
5201
|
this._show = this.props.show;
|
|
5191
|
-
util/* default */.
|
|
5202
|
+
util/* default */.A.setTimeout(() => {
|
|
5192
5203
|
if (!this._show) this.close();else this.open();
|
|
5193
5204
|
});
|
|
5194
5205
|
}
|
|
@@ -5296,9 +5307,9 @@ function Widget_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; va
|
|
|
5296
5307
|
|
|
5297
5308
|
|
|
5298
5309
|
|
|
5299
|
-
var send = __webpack_require__(
|
|
5300
|
-
var Widget_checkedimg = __webpack_require__(
|
|
5301
|
-
var empty = __webpack_require__(
|
|
5310
|
+
var send = __webpack_require__(8506);
|
|
5311
|
+
var Widget_checkedimg = __webpack_require__(9150);
|
|
5312
|
+
var empty = __webpack_require__(9419);
|
|
5302
5313
|
|
|
5303
5314
|
|
|
5304
5315
|
|
|
@@ -5310,12 +5321,12 @@ const Widget_defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar
|
|
|
5310
5321
|
|
|
5311
5322
|
|
|
5312
5323
|
|
|
5313
|
-
class Widget extends common/* Com */.
|
|
5324
|
+
class Widget extends common/* Com */.Mw {
|
|
5314
5325
|
constructor(props) {
|
|
5315
5326
|
super(props);
|
|
5316
|
-
Widget_defineProperty(this, "msgInput", (0,preact_module/* createRef */.
|
|
5327
|
+
Widget_defineProperty(this, "msgInput", (0,preact_module/* createRef */._3)());
|
|
5317
5328
|
Widget_defineProperty(this, "sendMessage", async message => {
|
|
5318
|
-
let hasPostback = util/* default */.
|
|
5329
|
+
let hasPostback = util/* default */.A.find(message.attachments, att => att.type === 'postback');
|
|
5319
5330
|
if (this.isFormRequired() && hasPostback) {
|
|
5320
5331
|
this.onStartConvoClick();
|
|
5321
5332
|
this.fillQuickReplyToQuestion(message);
|
|
@@ -5394,7 +5405,7 @@ class Widget extends common/* Com */.up {
|
|
|
5394
5405
|
clickedJoin: false,
|
|
5395
5406
|
quickReplyMessage: {}
|
|
5396
5407
|
});
|
|
5397
|
-
util/* default */.
|
|
5408
|
+
util/* default */.A.setTimeout(() => {
|
|
5398
5409
|
this.events && this.events.focus();
|
|
5399
5410
|
if (!this.props.store.isMobile()) this.focusInput();
|
|
5400
5411
|
}, 100);
|
|
@@ -5405,10 +5416,10 @@ class Widget extends common/* Com */.up {
|
|
|
5405
5416
|
let form;
|
|
5406
5417
|
let accountSetting = this.props.plugin.chatbox || {};
|
|
5407
5418
|
let acc = this.props.store.matchAccount() || {};
|
|
5408
|
-
if (util/* default */.
|
|
5409
|
-
let offlineEnabled = util/* default */.
|
|
5419
|
+
if (util/* default */.A.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
5420
|
+
let offlineEnabled = util/* default */.A.get(accountSetting, 'offline_form.enabled');
|
|
5410
5421
|
if (this.isOffline(acc, accountSetting) && offlineEnabled) form = accountSetting.offline_form;
|
|
5411
|
-
if (!this.hasSentMessage(this.props.cid) && form && (util/* default */.
|
|
5422
|
+
if (!this.hasSentMessage(this.props.cid) && form && (util/* default */.A.size(form.groups) || form.group_required)) return true;
|
|
5412
5423
|
let formRequired = this.isFormRequired();
|
|
5413
5424
|
return formRequired && !this.props.cid || formRequired && this.props.cid && this.state.clickedJoin;
|
|
5414
5425
|
}
|
|
@@ -5418,8 +5429,8 @@ class Widget extends common/* Com */.up {
|
|
|
5418
5429
|
let accountSetting = this.props.plugin.chatbox || {};
|
|
5419
5430
|
let acc = this.props.store.matchAccount() || {};
|
|
5420
5431
|
let submitLabel = this.props.t('prechat_form_btn');
|
|
5421
|
-
if (util/* default */.
|
|
5422
|
-
let offlineEnabled = util/* default */.
|
|
5432
|
+
if (util/* default */.A.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
5433
|
+
let offlineEnabled = util/* default */.A.get(accountSetting, 'offline_form.enabled');
|
|
5423
5434
|
if (this.isOffline(acc, accountSetting) && offlineEnabled) {
|
|
5424
5435
|
form = accountSetting.offline_form;
|
|
5425
5436
|
submitLabel = this.props.t('offline_form_btn');
|
|
@@ -5436,10 +5447,10 @@ class Widget extends common/* Com */.up {
|
|
|
5436
5447
|
}
|
|
5437
5448
|
let $body = null;
|
|
5438
5449
|
if (this.props.view === 'list') $body = this.renderConvoList();else if (showform) $body = this.renderForm(form, submitLabel);else $body = this.renderChat();
|
|
5439
|
-
let position = util/* default */.
|
|
5440
|
-
if (this.props.store.isMobile()) position = util/* default */.
|
|
5450
|
+
let position = util/* default */.A.get(accountSetting, 'desktop_button.position') || 'right';
|
|
5451
|
+
if (this.props.store.isMobile()) position = util/* default */.A.get(accountSetting, 'mobile_button.position', position);
|
|
5441
5452
|
let cls = 'widget-container widget-container--' + position;
|
|
5442
|
-
if (!this.props.store.isMobile() && util/* default */.
|
|
5453
|
+
if (!this.props.store.isMobile() && util/* default */.A.get(accountSetting, 'window_mode') === 'full') cls += ' widget-container--full';
|
|
5443
5454
|
if (!this.props.isShow) cls += ' widget-container--hide';
|
|
5444
5455
|
return (0,preact_module.h)("div", {
|
|
5445
5456
|
class: cls
|
|
@@ -5457,42 +5468,42 @@ class Widget extends common/* Com */.up {
|
|
|
5457
5468
|
}
|
|
5458
5469
|
async submitPrechatForm(form) {
|
|
5459
5470
|
var hasError = false;
|
|
5460
|
-
util/* default */.
|
|
5461
|
-
if (field.is_required && (field.value === undefined || field.value === '' || util/* default */.
|
|
5471
|
+
util/* default */.A.map(this.state.formData, (field, key) => {
|
|
5472
|
+
if (field.is_required && (field.value === undefined || field.value === '' || util/* default */.A.size(field.value) === 0 && Array.isArray(field.value))) {
|
|
5462
5473
|
field.error = this.props.t('error_empty');
|
|
5463
5474
|
hasError = true;
|
|
5464
5475
|
} else field.error = '';
|
|
5465
|
-
if (key.substr(5) === 'emails' && !util/* default */.
|
|
5476
|
+
if (key.substr(5) === 'emails' && !util/* default */.A.isEmail(field.value) && field.is_required) {
|
|
5466
5477
|
field.error = this.props.t('error_email_invalid');
|
|
5467
5478
|
hasError = true;
|
|
5468
5479
|
}
|
|
5469
|
-
if (key.substr(5) === 'phones' && !util/* default */.
|
|
5480
|
+
if (key.substr(5) === 'phones' && !util/* default */.A.isPhone(field.value) && field.is_required) {
|
|
5470
5481
|
field.error = this.props.t('error_phone_invalid');
|
|
5471
5482
|
hasError = true;
|
|
5472
5483
|
}
|
|
5473
5484
|
});
|
|
5474
5485
|
if (hasError) return this.forceUpdate();
|
|
5475
|
-
let data = util/* default */.
|
|
5476
|
-
let user = util/* default */.
|
|
5486
|
+
let data = util/* default */.A.cloneDeep(this.state.formData);
|
|
5487
|
+
let user = util/* default */.A.cloneDeep(this.props.store.matchUser());
|
|
5477
5488
|
let is_lead = false;
|
|
5478
|
-
util/* default */.
|
|
5489
|
+
util/* default */.A.map(data, (field, key) => {
|
|
5479
5490
|
if (!key.startsWith('attr:')) return;
|
|
5480
5491
|
var attr = {
|
|
5481
5492
|
key: key.substr(5)
|
|
5482
5493
|
};
|
|
5483
5494
|
is_lead = is_lead || key == 'emails' || key == 'phones';
|
|
5484
5495
|
if (field.type === 'number') attr.number = parseInt(field.value);
|
|
5485
|
-
if (field.type === 'datetime') attr.datetime = new util/* default */.
|
|
5496
|
+
if (field.type === 'datetime') attr.datetime = new util/* default */.A.Date(field.value).toISOString();
|
|
5486
5497
|
if (field.type === 'list') attr.text = field.value;
|
|
5487
5498
|
if (field.type === 'text' || field.type === 'boolean') attr[field.type] = field.value;
|
|
5488
|
-
util/* default */.
|
|
5499
|
+
util/* default */.A.setUserAttr(user, attr);
|
|
5489
5500
|
});
|
|
5490
|
-
if (is_lead) util/* default */.
|
|
5501
|
+
if (is_lead) util/* default */.A.setUserAttr(user, {
|
|
5491
5502
|
key: 'lead_source',
|
|
5492
5503
|
text: 'widget'
|
|
5493
5504
|
});
|
|
5494
|
-
let firstmsg = util/* default */.
|
|
5495
|
-
let groupid = util/* default */.
|
|
5505
|
+
let firstmsg = util/* default */.A.get(data, 'question.value');
|
|
5506
|
+
let groupid = util/* default */.A.get(data, 'group.value', '');
|
|
5496
5507
|
if (this.props.cid) {
|
|
5497
5508
|
this.props.store.setUser(user);
|
|
5498
5509
|
this.setState({
|
|
@@ -5504,7 +5515,7 @@ class Widget extends common/* Com */.up {
|
|
|
5504
5515
|
format: 'plaintext',
|
|
5505
5516
|
fields: [{
|
|
5506
5517
|
key: 'to_agent_group',
|
|
5507
|
-
value: util/* default */.
|
|
5518
|
+
value: util/* default */.A.stringify(groupid)
|
|
5508
5519
|
}],
|
|
5509
5520
|
attachments: this.state.quickReplyMessage.attachments
|
|
5510
5521
|
}
|
|
@@ -5564,7 +5575,7 @@ class Widget extends common/* Com */.up {
|
|
|
5564
5575
|
formData['question'] = {
|
|
5565
5576
|
key: 'question',
|
|
5566
5577
|
is_required: true,
|
|
5567
|
-
label: this.props.t.i18n(util/* default */.
|
|
5578
|
+
label: this.props.t.i18n(util/* default */.A.get(form, `i18n_question_label`, {})) || form.question_label,
|
|
5568
5579
|
type: 'text',
|
|
5569
5580
|
value: this.state.quickReplyMessage.text
|
|
5570
5581
|
};
|
|
@@ -5575,8 +5586,8 @@ class Widget extends common/* Com */.up {
|
|
|
5575
5586
|
}
|
|
5576
5587
|
onBooleanChange(key, e) {
|
|
5577
5588
|
this.wasFormInputed = true;
|
|
5578
|
-
let formData = util/* default */.
|
|
5579
|
-
let field = util/* default */.
|
|
5589
|
+
let formData = util/* default */.A.cloneDeep(this.state.formData);
|
|
5590
|
+
let field = util/* default */.A.find(formData, (_, fkkey) => fkkey === key);
|
|
5580
5591
|
if (!field) return;
|
|
5581
5592
|
field.value = e.target.checked;
|
|
5582
5593
|
this.setState({
|
|
@@ -5585,8 +5596,8 @@ class Widget extends common/* Com */.up {
|
|
|
5585
5596
|
}
|
|
5586
5597
|
onInputChange(key, val) {
|
|
5587
5598
|
this.wasFormInputed = true;
|
|
5588
|
-
let formData = util/* default */.
|
|
5589
|
-
let field = util/* default */.
|
|
5599
|
+
let formData = util/* default */.A.cloneDeep(this.state.formData);
|
|
5600
|
+
let field = util/* default */.A.find(formData, (_, fkkey) => fkkey === key);
|
|
5590
5601
|
if (!field) return;
|
|
5591
5602
|
field.value = val;
|
|
5592
5603
|
this.setState({
|
|
@@ -5595,8 +5606,8 @@ class Widget extends common/* Com */.up {
|
|
|
5595
5606
|
}
|
|
5596
5607
|
onListAddItem(key, val) {
|
|
5597
5608
|
this.wasFormInputed = true;
|
|
5598
|
-
let formData = util/* default */.
|
|
5599
|
-
let field = util/* default */.
|
|
5609
|
+
let formData = util/* default */.A.cloneDeep(this.state.formData);
|
|
5610
|
+
let field = util/* default */.A.find(formData, (_, fkkey) => fkkey === key);
|
|
5600
5611
|
if (!field) return;
|
|
5601
5612
|
field.value = field.value || [];
|
|
5602
5613
|
field.value.push(val);
|
|
@@ -5606,8 +5617,8 @@ class Widget extends common/* Com */.up {
|
|
|
5606
5617
|
}
|
|
5607
5618
|
onListRemoveItem(key, index) {
|
|
5608
5619
|
this.wasFormInputed = true;
|
|
5609
|
-
let formData = util/* default */.
|
|
5610
|
-
let field = util/* default */.
|
|
5620
|
+
let formData = util/* default */.A.cloneDeep(this.state.formData);
|
|
5621
|
+
let field = util/* default */.A.find(formData, (_, fkkey) => fkkey === key);
|
|
5611
5622
|
if (!field) return;
|
|
5612
5623
|
field.value = field.value || [];
|
|
5613
5624
|
field.value.splice(index, 1);
|
|
@@ -5616,11 +5627,11 @@ class Widget extends common/* Com */.up {
|
|
|
5616
5627
|
});
|
|
5617
5628
|
}
|
|
5618
5629
|
renderCheckboxField(field) {
|
|
5619
|
-
let items = util/* default */.
|
|
5630
|
+
let items = util/* default */.A.get(field, 'def.items', []);
|
|
5620
5631
|
let values = [];
|
|
5621
5632
|
let value = field.value || '';
|
|
5622
5633
|
if (value) values = value.split(',');
|
|
5623
|
-
return (0,preact_module.h)("div", null, util/* default */.
|
|
5634
|
+
return (0,preact_module.h)("div", null, util/* default */.A.map(items, item => {
|
|
5624
5635
|
return (0,preact_module.h)("div", {
|
|
5625
5636
|
class: "checkbox"
|
|
5626
5637
|
}, (0,preact_module.h)("input", {
|
|
@@ -5638,14 +5649,14 @@ class Widget extends common/* Com */.up {
|
|
|
5638
5649
|
}
|
|
5639
5650
|
toggleCheckboxField(key, v) {
|
|
5640
5651
|
this.wasFormInputed = true;
|
|
5641
|
-
let formData = util/* default */.
|
|
5642
|
-
let field = util/* default */.
|
|
5652
|
+
let formData = util/* default */.A.cloneDeep(this.state.formData);
|
|
5653
|
+
let field = util/* default */.A.find(formData, (f, fkkey) => f.key === key);
|
|
5643
5654
|
if (!field) return;
|
|
5644
5655
|
let value = field.value || '';
|
|
5645
5656
|
let values = [];
|
|
5646
5657
|
if (value) values = value.split(',');
|
|
5647
5658
|
if (values.includes(v)) {
|
|
5648
|
-
values = util/* default */.
|
|
5659
|
+
values = util/* default */.A.filter(values, value => value !== v);
|
|
5649
5660
|
} else {
|
|
5650
5661
|
values.push(v);
|
|
5651
5662
|
}
|
|
@@ -5655,9 +5666,9 @@ class Widget extends common/* Com */.up {
|
|
|
5655
5666
|
});
|
|
5656
5667
|
}
|
|
5657
5668
|
renderRadioField(field) {
|
|
5658
|
-
let items = util/* default */.
|
|
5669
|
+
let items = util/* default */.A.get(field, 'def.items', []);
|
|
5659
5670
|
let value = field.value || '';
|
|
5660
|
-
return (0,preact_module.h)("div", null, util/* default */.
|
|
5671
|
+
return (0,preact_module.h)("div", null, util/* default */.A.map(items, item => {
|
|
5661
5672
|
return (0,preact_module.h)("div", {
|
|
5662
5673
|
class: "radio"
|
|
5663
5674
|
}, (0,preact_module.h)("input", {
|
|
@@ -5676,8 +5687,8 @@ class Widget extends common/* Com */.up {
|
|
|
5676
5687
|
}
|
|
5677
5688
|
toggleRadioField(key, v) {
|
|
5678
5689
|
this.wasFormInputed = true;
|
|
5679
|
-
let formData = util/* default */.
|
|
5680
|
-
let field = util/* default */.
|
|
5690
|
+
let formData = util/* default */.A.cloneDeep(this.state.formData);
|
|
5691
|
+
let field = util/* default */.A.find(formData, (f, fkkey) => f.key === key);
|
|
5681
5692
|
if (!field) return;
|
|
5682
5693
|
field.value = v;
|
|
5683
5694
|
this.setState({
|
|
@@ -5686,8 +5697,8 @@ class Widget extends common/* Com */.up {
|
|
|
5686
5697
|
}
|
|
5687
5698
|
selectDropdownField(key, v) {
|
|
5688
5699
|
this.wasFormInputed = true;
|
|
5689
|
-
let formData = util/* default */.
|
|
5690
|
-
let field = util/* default */.
|
|
5700
|
+
let formData = util/* default */.A.cloneDeep(this.state.formData);
|
|
5701
|
+
let field = util/* default */.A.find(formData, (f, fkkey) => f.key === key);
|
|
5691
5702
|
if (!field) return;
|
|
5692
5703
|
field.value = v;
|
|
5693
5704
|
this.setState({
|
|
@@ -5695,20 +5706,20 @@ class Widget extends common/* Com */.up {
|
|
|
5695
5706
|
});
|
|
5696
5707
|
}
|
|
5697
5708
|
renderDropdownField(field) {
|
|
5698
|
-
let items = util/* default */.
|
|
5709
|
+
let items = util/* default */.A.get(field, 'def.items', []);
|
|
5699
5710
|
return (0,preact_module.h)("select", {
|
|
5700
5711
|
class: "form-control",
|
|
5701
5712
|
value: field.value,
|
|
5702
5713
|
onChange: e => this.selectDropdownField(field.key, e.target.value)
|
|
5703
5714
|
}, (0,preact_module.h)("option", {
|
|
5704
5715
|
value: ""
|
|
5705
|
-
}, "-- ", this.props.t('no_select'), " --"), util/* default */.
|
|
5716
|
+
}, "-- ", this.props.t('no_select'), " --"), util/* default */.A.map(items, item => (0,preact_module.h)("option", {
|
|
5706
5717
|
value: item.value
|
|
5707
5718
|
}, this.props.t.i18n(item.i18n_label) || item.label || item.value)));
|
|
5708
5719
|
}
|
|
5709
5720
|
renderFields() {
|
|
5710
|
-
if (util/* default */.
|
|
5711
|
-
let $fields = util/* default */.
|
|
5721
|
+
if (util/* default */.A.size(this.state.formData) === 0) return null;
|
|
5722
|
+
let $fields = util/* default */.A.map(this.state.formData, (field, key) => {
|
|
5712
5723
|
if (this.state.quickReplyMessage.text && key === 'question') return null;
|
|
5713
5724
|
let $field = null;
|
|
5714
5725
|
var errclass = field.error ? 'input--error' : '';
|
|
@@ -5724,13 +5735,13 @@ class Widget extends common/* Com */.up {
|
|
|
5724
5735
|
row: "4",
|
|
5725
5736
|
class: "form-control"
|
|
5726
5737
|
});
|
|
5727
|
-
} else if (util/* default */.
|
|
5738
|
+
} else if (util/* default */.A.get(field, 'def.select') === 'checkbox') {
|
|
5728
5739
|
$field = this.renderCheckboxField(field);
|
|
5729
|
-
} else if (util/* default */.
|
|
5740
|
+
} else if (util/* default */.A.get(field, 'def.select') === 'radio') {
|
|
5730
5741
|
$field = this.renderRadioField(field);
|
|
5731
|
-
} else if (util/* default */.
|
|
5742
|
+
} else if (util/* default */.A.get(field, 'def.select') === 'dropdown') {
|
|
5732
5743
|
$field = this.renderDropdownField(field);
|
|
5733
|
-
} else if (util/* default */.
|
|
5744
|
+
} else if (util/* default */.A.get(field, 'def.multiple_line')) {
|
|
5734
5745
|
$field = (0,preact_module.h)("textarea", {
|
|
5735
5746
|
class: "form-control",
|
|
5736
5747
|
ref: ref => {
|
|
@@ -5777,7 +5788,7 @@ class Widget extends common/* Com */.up {
|
|
|
5777
5788
|
class: "checkbox--check"
|
|
5778
5789
|
}, (0,preact_module.h)("div", null)));
|
|
5779
5790
|
} else if (field.type === 'group') {
|
|
5780
|
-
$field = util/* default */.
|
|
5791
|
+
$field = util/* default */.A.map(field.list, item => (0,preact_module.h)("div", {
|
|
5781
5792
|
class: "radio"
|
|
5782
5793
|
}, (0,preact_module.h)("input", {
|
|
5783
5794
|
type: "radio",
|
|
@@ -5794,8 +5805,8 @@ class Widget extends common/* Com */.up {
|
|
|
5794
5805
|
}))));
|
|
5795
5806
|
} else if (field.type === 'list') {
|
|
5796
5807
|
let selected = this.state.formData[key].value || [];
|
|
5797
|
-
let items = util/* default */.
|
|
5798
|
-
return !util/* default */.
|
|
5808
|
+
let items = util/* default */.A.filter(util/* default */.A.get(field, 'list', []), item => {
|
|
5809
|
+
return !util/* default */.A.includes(selected, item);
|
|
5799
5810
|
});
|
|
5800
5811
|
$field = (0,preact_module.h)(ListField, {
|
|
5801
5812
|
selected: selected,
|
|
@@ -5843,8 +5854,8 @@ class Widget extends common/* Com */.up {
|
|
|
5843
5854
|
size: "16",
|
|
5844
5855
|
mode: "white"
|
|
5845
5856
|
}));
|
|
5846
|
-
let title = this.props.t.i18n(util/* default */.
|
|
5847
|
-
if (!title) title = util/* default */.
|
|
5857
|
+
let title = this.props.t.i18n(util/* default */.A.get(form, `i18n_title`, {}));
|
|
5858
|
+
if (!title) title = util/* default */.A.get(form, 'title', this.props.t('capture_lead_title'));
|
|
5848
5859
|
title = title.replace('↵', '');
|
|
5849
5860
|
return (0,preact_module.h)("div", {
|
|
5850
5861
|
class: "widget-body"
|
|
@@ -5875,15 +5886,15 @@ class Widget extends common/* Com */.up {
|
|
|
5875
5886
|
}
|
|
5876
5887
|
renderConvoList() {
|
|
5877
5888
|
let convoM = this.props.store.matchConvo('*');
|
|
5878
|
-
var convos = util/* default */.
|
|
5879
|
-
convos = util/* default */.
|
|
5880
|
-
convos = util/* default */.
|
|
5881
|
-
var $convos = util/* default */.
|
|
5882
|
-
let ags = util/* default */.
|
|
5889
|
+
var convos = util/* default */.A.map(convoM, convo => this.props.store.matchConvo(convo.id));
|
|
5890
|
+
convos = util/* default */.A.filter(convos, convo => !!convo);
|
|
5891
|
+
convos = util/* default */.A.orderByF(convos, convo => util/* default */.A.get(convo, 'last_message_sent.created', convo.actived), 'desc');
|
|
5892
|
+
var $convos = util/* default */.A.map(convos, convo => {
|
|
5893
|
+
let ags = util/* default */.A.filter(convo.members, m => {
|
|
5883
5894
|
return (m.type === 'agent' || m.type === 'bot') && m.membership === 'active';
|
|
5884
5895
|
});
|
|
5885
|
-
let agentids = util/* default */.
|
|
5886
|
-
agentids = agentids || util/* default */.
|
|
5896
|
+
let agentids = util/* default */.A.map(ags, m => m.id);
|
|
5897
|
+
agentids = agentids || util/* default */.A.agentsOfConvo(convo)[0];
|
|
5887
5898
|
return (0,preact_module.h)("div", {
|
|
5888
5899
|
class: "convo-list--item",
|
|
5889
5900
|
onClick: () => this.goToConvo(convo.id),
|
|
@@ -5900,7 +5911,7 @@ class Widget extends common/* Com */.up {
|
|
|
5900
5911
|
let $body = (0,preact_module.h)("div", {
|
|
5901
5912
|
class: "convo-list--list"
|
|
5902
5913
|
}, $convos);
|
|
5903
|
-
if (util/* default */.
|
|
5914
|
+
if (util/* default */.A.size(convos) === 0) {
|
|
5904
5915
|
$body = (0,preact_module.h)("div", {
|
|
5905
5916
|
class: "convo-list--list"
|
|
5906
5917
|
}, (0,preact_module.h)("div", {
|
|
@@ -5936,19 +5947,19 @@ class Widget extends common/* Com */.up {
|
|
|
5936
5947
|
if (this.props.store.isPreview) return;
|
|
5937
5948
|
var $input = this.msgInput.current;
|
|
5938
5949
|
if (!$input) return;
|
|
5939
|
-
util/* default */.
|
|
5940
|
-
util/* default */.
|
|
5950
|
+
util/* default */.A.setTimeout(() => $input && $input.blur());
|
|
5951
|
+
util/* default */.A.setTimeout(() => $input && $input.blur(), 300);
|
|
5941
5952
|
}
|
|
5942
5953
|
focusInput() {
|
|
5943
5954
|
if (this.props.store.isPreview) return;
|
|
5944
5955
|
if (this.shouldShowForm()) {
|
|
5945
5956
|
let firstemptykey = '';
|
|
5946
|
-
util/* default */.
|
|
5957
|
+
util/* default */.A.map(this.state.formData, (field, key) => {
|
|
5947
5958
|
if (field.type !== 'text') return;
|
|
5948
5959
|
if (firstemptykey) return;
|
|
5949
5960
|
if (!field.value) firstemptykey = key;
|
|
5950
5961
|
});
|
|
5951
|
-
util/* default */.
|
|
5962
|
+
util/* default */.A.setTimeout(() => {
|
|
5952
5963
|
var $input = this['form_' + Widget_encode(firstemptykey)];
|
|
5953
5964
|
if (!$input) return;
|
|
5954
5965
|
$input.focus();
|
|
@@ -5957,8 +5968,8 @@ class Widget extends common/* Com */.up {
|
|
|
5957
5968
|
}
|
|
5958
5969
|
var $input = this.msgInput.current;
|
|
5959
5970
|
if (!$input) return;
|
|
5960
|
-
util/* default */.
|
|
5961
|
-
util/* default */.
|
|
5971
|
+
util/* default */.A.setTimeout(() => $input.focus());
|
|
5972
|
+
util/* default */.A.setTimeout(() => $input.focus(), 300);
|
|
5962
5973
|
}
|
|
5963
5974
|
onRate(rating) {
|
|
5964
5975
|
if (!this.props.cid) return;
|
|
@@ -5972,7 +5983,7 @@ class Widget extends common/* Com */.up {
|
|
|
5972
5983
|
fillQuickReplyToQuestion(message) {
|
|
5973
5984
|
let formData = this.state.formData;
|
|
5974
5985
|
if (formData) {
|
|
5975
|
-
util/* default */.
|
|
5986
|
+
util/* default */.A.set(formData, 'question.value', message.text);
|
|
5976
5987
|
}
|
|
5977
5988
|
this.setState({
|
|
5978
5989
|
formData,
|
|
@@ -6065,8 +6076,8 @@ class Widget extends common/* Com */.up {
|
|
|
6065
6076
|
let form;
|
|
6066
6077
|
let accountSetting = this.props.plugin.chatbox || {};
|
|
6067
6078
|
let acc = this.props.store.matchAccount() || {};
|
|
6068
|
-
if (util/* default */.
|
|
6069
|
-
let offlineEnabled = util/* default */.
|
|
6079
|
+
if (util/* default */.A.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
6080
|
+
let offlineEnabled = util/* default */.A.get(accountSetting, 'offline_form.enabled');
|
|
6070
6081
|
if (this.isOffline(acc, accountSetting) && offlineEnabled) form = accountSetting.offline_form;
|
|
6071
6082
|
if (!form) return false;
|
|
6072
6083
|
let formData = this.fillForm(form);
|
|
@@ -6074,34 +6085,34 @@ class Widget extends common/* Com */.up {
|
|
|
6074
6085
|
if (convo.state === 'ended') return true;
|
|
6075
6086
|
if (convo.state && convo.state !== 'pending') delete formData.group;
|
|
6076
6087
|
let isAllFiledEmpty = true;
|
|
6077
|
-
util/* default */.
|
|
6088
|
+
util/* default */.A.each(formData, field => {
|
|
6078
6089
|
if (field.value) isAllFiledEmpty = false;
|
|
6079
6090
|
});
|
|
6080
6091
|
if (isAllFiledEmpty && !this.userHasSent(this.props.cid)) return true;
|
|
6081
|
-
return !!util/* default */.
|
|
6092
|
+
return !!util/* default */.A.find(formData, field => field.is_required && (field.value == null || field.value === ''));
|
|
6082
6093
|
}
|
|
6083
6094
|
renderConvoSummary(convo) {
|
|
6084
6095
|
let accountSetting = this.props.plugin.chatbox || {};
|
|
6085
6096
|
let agentM = this.props.store.matchAgent('*');
|
|
6086
|
-
let ags = util/* default */.
|
|
6097
|
+
let ags = util/* default */.A.filter(convo.members, m => {
|
|
6087
6098
|
return (m.type === 'agent' || m.type === 'bot') && m.membership === 'active';
|
|
6088
6099
|
});
|
|
6089
|
-
let agentids = util/* default */.
|
|
6090
|
-
agentids = agentids || util/* default */.
|
|
6091
|
-
let agents = util/* default */.
|
|
6100
|
+
let agentids = util/* default */.A.map(ags, m => m.id);
|
|
6101
|
+
agentids = agentids || util/* default */.A.agentsOfConvo(convo)[0];
|
|
6102
|
+
let agents = util/* default */.A.map(agentids, id => agentM[id] || {
|
|
6092
6103
|
avatar_url: Widget_defaultAvatar,
|
|
6093
6104
|
fullname: 'Offline Agent'
|
|
6094
6105
|
});
|
|
6095
|
-
var name = util/* default */.
|
|
6106
|
+
var name = util/* default */.A.each(agents, ag => ag.fullname).join(', ');
|
|
6096
6107
|
if (accountSetting.hide_agent_profile || !name) name = this.props.store.matchAccount().name;
|
|
6097
6108
|
if (!name) name = this.props.t('agent');
|
|
6098
6109
|
var $you = null;
|
|
6099
6110
|
if (convo.lastSenderType === 'user') {
|
|
6100
6111
|
$you = (0,preact_module.h)("span", null, this.props.t('you'), ":");
|
|
6101
6112
|
}
|
|
6102
|
-
let seen = util/* default */.
|
|
6113
|
+
let seen = util/* default */.A.isConvoSeen(convo, this.props.store.matchUser().id);
|
|
6103
6114
|
var lastmsg = this.renderMessagePreview(convo.last_message_sent);
|
|
6104
|
-
var time = util/* default */.
|
|
6115
|
+
var time = util/* default */.A.getMs(util/* default */.A.get(convo, 'last_message_sent.created')) || util/* default */.A.getMs(convo.created);
|
|
6105
6116
|
let $unread = seen ? null : (0,preact_module.h)("div", {
|
|
6106
6117
|
class: "convo-list--item-unread"
|
|
6107
6118
|
});
|
|
@@ -6134,23 +6145,23 @@ class Widget extends common/* Com */.up {
|
|
|
6134
6145
|
}
|
|
6135
6146
|
agentsOfConvo(convo) {
|
|
6136
6147
|
let agentM = this.props.store.matchAgent('*');
|
|
6137
|
-
var agentids = util/* default */.
|
|
6138
|
-
return util/* default */.
|
|
6148
|
+
var agentids = util/* default */.A.agentsOfConvo(convo, true);
|
|
6149
|
+
return util/* default */.A.map(agentids, id => agentM[id] || {
|
|
6139
6150
|
avatar_url: Widget_defaultAvatar,
|
|
6140
6151
|
fullname: 'Offline Agent'
|
|
6141
6152
|
});
|
|
6142
6153
|
}
|
|
6143
6154
|
renderMessagePreview(ev) {
|
|
6144
6155
|
let defmsg = this.props.t('sent_you_a_message');
|
|
6145
|
-
let message = util/* default */.
|
|
6146
|
-
var format = util/* default */.
|
|
6156
|
+
let message = util/* default */.A.get(ev, 'data.message.text');
|
|
6157
|
+
var format = util/* default */.A.get(ev, 'data.message.format');
|
|
6147
6158
|
if (format !== 'plaintext') message = defmsg;
|
|
6148
|
-
if (!message && util/* default */.
|
|
6159
|
+
if (!message && util/* default */.A.size(util/* default */.A.get(ev, 'data.message.attachments')) > 0) message = defmsg;
|
|
6149
6160
|
if (!message) return null;
|
|
6150
|
-
let byType = util/* default */.
|
|
6161
|
+
let byType = util/* default */.A.get(ev, 'by.type');
|
|
6151
6162
|
return (0,preact_module.h)("div", {
|
|
6152
6163
|
class: "convo-list--convo-last-mes"
|
|
6153
|
-
}, util/* default */.
|
|
6164
|
+
}, util/* default */.A.map(util/* default */.A.extractText(message), tag => {
|
|
6154
6165
|
if (tag.type === 'emoji') return (0,preact_module.h)(Emoji, {
|
|
6155
6166
|
emojiCode: tag.text,
|
|
6156
6167
|
byType: byType
|
|
@@ -6162,19 +6173,19 @@ class Widget extends common/* Com */.up {
|
|
|
6162
6173
|
var convo = this.props.store.matchConvo(cid) || {};
|
|
6163
6174
|
let user = this.props.store.matchUser();
|
|
6164
6175
|
if (this.userSent[cid]) return true;
|
|
6165
|
-
let joined = util/* default */.
|
|
6176
|
+
let joined = util/* default */.A.find(convo.members, mem => mem.id === user.id && (mem.membership === 'active' || mem.last_sent > 0));
|
|
6166
6177
|
return joined;
|
|
6167
6178
|
}
|
|
6168
6179
|
hasSentMessage(cid) {
|
|
6169
6180
|
let convo = this.props.store.matchConvo(cid) || {};
|
|
6170
|
-
let joined = util/* default */.
|
|
6181
|
+
let joined = util/* default */.A.find(convo.members, mem => {
|
|
6171
6182
|
if (mem.type === 'bot') return true;
|
|
6172
6183
|
return mem.last_sent;
|
|
6173
6184
|
});
|
|
6174
6185
|
return joined;
|
|
6175
6186
|
}
|
|
6176
6187
|
isOffline(acc, accSetting) {
|
|
6177
|
-
let enableWhen = util/* default */.
|
|
6188
|
+
let enableWhen = util/* default */.A.get(accSetting, 'offline_form.enable_when');
|
|
6178
6189
|
let isonline = true;
|
|
6179
6190
|
if (enableWhen === 'all_agents_offline') isonline = acc.is_online;
|
|
6180
6191
|
if (enableWhen === 'out_of_bussiness_hour') isonline = acc.is_in_business_hour;
|
|
@@ -6184,8 +6195,8 @@ class Widget extends common/* Com */.up {
|
|
|
6184
6195
|
let form;
|
|
6185
6196
|
let accountSetting = this.props.plugin.chatbox || {};
|
|
6186
6197
|
let acc = this.props.store.matchAccount() || {};
|
|
6187
|
-
if (util/* default */.
|
|
6188
|
-
let offlineEnabled = util/* default */.
|
|
6198
|
+
if (util/* default */.A.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
6199
|
+
let offlineEnabled = util/* default */.A.get(accountSetting, 'offline_form.enabled');
|
|
6189
6200
|
if (this.isOffline(acc, accountSetting) && offlineEnabled) {
|
|
6190
6201
|
form = accountSetting.offline_form;
|
|
6191
6202
|
}
|
|
@@ -6195,23 +6206,23 @@ class Widget extends common/* Com */.up {
|
|
|
6195
6206
|
if (this.props.view === 'prechat_form') {
|
|
6196
6207
|
form = accountSetting.prechat_form;
|
|
6197
6208
|
}
|
|
6198
|
-
if (util/* default */.
|
|
6209
|
+
if (util/* default */.A.size(form) === 0) return [];
|
|
6199
6210
|
var data = {};
|
|
6200
|
-
util/* default */.
|
|
6211
|
+
util/* default */.A.each(form.fields, f => {
|
|
6201
6212
|
var newf = Object.assign({}, f);
|
|
6202
6213
|
if (f.type === 'list') {
|
|
6203
6214
|
newf.list = f.list;
|
|
6204
6215
|
}
|
|
6205
|
-
newf.label = this.props.t.i18n(util/* default */.
|
|
6216
|
+
newf.label = this.props.t.i18n(util/* default */.A.get(f, `i18n_label`, {})) || f.label;
|
|
6206
6217
|
data['attr:' + f.key] = newf;
|
|
6207
6218
|
});
|
|
6208
|
-
if (form.group_required && util/* default */.
|
|
6219
|
+
if (form.group_required && util/* default */.A.size(form.groups) > 0) {
|
|
6209
6220
|
data['group'] = {
|
|
6210
6221
|
key: 'group',
|
|
6211
6222
|
is_required: !!form.group_required,
|
|
6212
|
-
label: this.props.t.i18n(util/* default */.
|
|
6223
|
+
label: this.props.t.i18n(util/* default */.A.get(form, `i18n_group_label`, {})) || form.group_label,
|
|
6213
6224
|
type: 'group',
|
|
6214
|
-
list: util/* default */.
|
|
6225
|
+
list: util/* default */.A.map(form.groups, group => ({
|
|
6215
6226
|
value: group.id,
|
|
6216
6227
|
label: group.name
|
|
6217
6228
|
}))
|
|
@@ -6220,7 +6231,7 @@ class Widget extends common/* Com */.up {
|
|
|
6220
6231
|
data['question'] = {
|
|
6221
6232
|
key: 'question',
|
|
6222
6233
|
is_required: true,
|
|
6223
|
-
label: this.props.t.i18n(util/* default */.
|
|
6234
|
+
label: this.props.t.i18n(util/* default */.A.get(form, `i18n_question_label`, {})) || form.question_label,
|
|
6224
6235
|
type: 'text'
|
|
6225
6236
|
};
|
|
6226
6237
|
if (this.isFormChanged(this.state.formData, data)) {
|
|
@@ -6234,44 +6245,44 @@ class Widget extends common/* Com */.up {
|
|
|
6234
6245
|
let newKeys = Object.keys(newForm);
|
|
6235
6246
|
if (oldKeys.length !== newKeys.length) return true;
|
|
6236
6247
|
for (let i = 0; i < oldKeys.length; i++) {
|
|
6237
|
-
if (util/* default */.
|
|
6238
|
-
if (util/* default */.
|
|
6239
|
-
if (util/* default */.
|
|
6248
|
+
if (util/* default */.A.get(oldForm, `${oldKeys[i]}.label`) !== util/* default */.A.get(newForm, `${newKeys[i]}.label`)) return true;
|
|
6249
|
+
if (util/* default */.A.get(oldForm, `${oldKeys[i]}.is_required`) !== util/* default */.A.get(newForm, `${newKeys[i]}.is_required`)) return true;
|
|
6250
|
+
if (util/* default */.A.stringify(util/* default */.A.get(oldForm, `${oldKeys[i]}.list`)) !== util/* default */.A.stringify(util/* default */.A.get(newForm, `${newKeys[i]}.list`))) {
|
|
6240
6251
|
return true;
|
|
6241
6252
|
}
|
|
6242
6253
|
}
|
|
6243
6254
|
return false;
|
|
6244
6255
|
}
|
|
6245
6256
|
fillForm(form) {
|
|
6246
|
-
if (util/* default */.
|
|
6257
|
+
if (util/* default */.A.size(form) === 0) return [];
|
|
6247
6258
|
var data = {};
|
|
6248
6259
|
let user = this.props.store.matchUser();
|
|
6249
|
-
util/* default */.
|
|
6260
|
+
util/* default */.A.each(form.fields, f => {
|
|
6250
6261
|
var newf = Object.assign({}, f);
|
|
6251
|
-
newf.value = util/* default */.
|
|
6262
|
+
newf.value = util/* default */.A.getUserAttr(user, f.key, f.type);
|
|
6252
6263
|
if (newf.key == 'emails' && !newf.value) {
|
|
6253
|
-
newf.value = util/* default */.
|
|
6264
|
+
newf.value = util/* default */.A.getUserAttr(user, 'related_email', 'text');
|
|
6254
6265
|
}
|
|
6255
6266
|
if (newf.key == 'phones' && !newf.value) {
|
|
6256
|
-
newf.value = util/* default */.
|
|
6267
|
+
newf.value = util/* default */.A.getUserAttr(user, 'related_phone', 'text');
|
|
6257
6268
|
}
|
|
6258
6269
|
if (f.type === 'boolean' && !newf.value) newf.value = false;
|
|
6259
6270
|
if (f.type === 'datetime' && newf.value) {
|
|
6260
|
-
newf.value = new util/* default */.
|
|
6271
|
+
newf.value = new util/* default */.A.Date(data.value).toLocaleDateString('en-CA');
|
|
6261
6272
|
}
|
|
6262
6273
|
if (f.type === 'list') {
|
|
6263
6274
|
newf.list = f.list;
|
|
6264
6275
|
}
|
|
6265
|
-
newf.label = this.props.t.i18n(util/* default */.
|
|
6276
|
+
newf.label = this.props.t.i18n(util/* default */.A.get(f, `i18n_label`, {})) || f.label;
|
|
6266
6277
|
data['attr:' + f.key] = newf;
|
|
6267
6278
|
});
|
|
6268
|
-
if (form.group_required && util/* default */.
|
|
6279
|
+
if (form.group_required && util/* default */.A.size(form.groups) > 0) {
|
|
6269
6280
|
data['group'] = {
|
|
6270
6281
|
key: 'group',
|
|
6271
6282
|
is_required: !!form.group_required,
|
|
6272
|
-
label: this.props.t.i18n(util/* default */.
|
|
6283
|
+
label: this.props.t.i18n(util/* default */.A.get(form, `i18n_group_label`, {})) || form.group_label,
|
|
6273
6284
|
type: 'group',
|
|
6274
|
-
list: util/* default */.
|
|
6285
|
+
list: util/* default */.A.map(form.groups, group => ({
|
|
6275
6286
|
value: group.id,
|
|
6276
6287
|
label: group.name
|
|
6277
6288
|
}))
|
|
@@ -6280,7 +6291,7 @@ class Widget extends common/* Com */.up {
|
|
|
6280
6291
|
return data;
|
|
6281
6292
|
}
|
|
6282
6293
|
}
|
|
6283
|
-
class FormMounter extends common/* Com */.
|
|
6294
|
+
class FormMounter extends common/* Com */.Mw {
|
|
6284
6295
|
componentDidMount() {
|
|
6285
6296
|
this.props.onMount(this.props.form);
|
|
6286
6297
|
}
|
|
@@ -6294,23 +6305,23 @@ function Widget_encode(key) {
|
|
|
6294
6305
|
|
|
6295
6306
|
|
|
6296
6307
|
|
|
6297
|
-
let main_promiseMainCSS = (() => __webpack_require__.e(/* import() */
|
|
6298
|
-
class Main extends common/* Com */.
|
|
6308
|
+
let main_promiseMainCSS = (() => __webpack_require__.e(/* import() */ 278).then(__webpack_require__.bind(__webpack_require__, 9278)))();
|
|
6309
|
+
class Main extends common/* Com */.Mw {
|
|
6299
6310
|
constructor(props) {
|
|
6300
6311
|
super(props);
|
|
6301
|
-
this.refButton = (0,preact_module/* createRef */.
|
|
6302
|
-
this.refWidget = (0,preact_module/* createRef */.
|
|
6312
|
+
this.refButton = (0,preact_module/* createRef */._3)();
|
|
6313
|
+
this.refWidget = (0,preact_module/* createRef */._3)();
|
|
6303
6314
|
}
|
|
6304
6315
|
async refreshCSS() {
|
|
6305
6316
|
let plugins = this.props.store.matchPlugin();
|
|
6306
|
-
let found = util/* default */.
|
|
6317
|
+
let found = util/* default */.A.find(plugins, plugin => plugin.id === this.props.plugin.id);
|
|
6307
6318
|
if (!found) return;
|
|
6308
6319
|
let css = (await main_promiseMainCSS).default.default.toString();
|
|
6309
|
-
var outcss = util/* default */.
|
|
6310
|
-
util/* default */.
|
|
6320
|
+
var outcss = util/* default */.A.replaceCssVariable(css, found.chatbox);
|
|
6321
|
+
util/* default */.A.setCss(this.props.plugin.id, this.$cssStyleDiv, outcss);
|
|
6311
6322
|
}
|
|
6312
6323
|
componentWillUnmount() {
|
|
6313
|
-
util/* default */.
|
|
6324
|
+
util/* default */.A.setCss(this.props.plugin.id, this.$cssStyleDiv, '');
|
|
6314
6325
|
}
|
|
6315
6326
|
async componentDidMount() {
|
|
6316
6327
|
this.$cssStyleDiv = document.getElementById('subiz-style-for-' + this.props.plugin.id);
|
|
@@ -6346,7 +6357,7 @@ class Main extends common/* Com */.up {
|
|
|
6346
6357
|
}
|
|
6347
6358
|
render() {
|
|
6348
6359
|
if (!this.state.cssready) return null;
|
|
6349
|
-
if (util/* default */.
|
|
6360
|
+
if (util/* default */.A.isUserBanned(this.props.store.matchUser())) return null;
|
|
6350
6361
|
if (!this.props.t) return null;
|
|
6351
6362
|
return (0,preact_module.h)("div", {
|
|
6352
6363
|
class: this.props.store.isMobile() ? 'mobile' : 'desktop'
|
|
@@ -6380,10 +6391,10 @@ class Main extends common/* Com */.up {
|
|
|
6380
6391
|
if ($widget.wasFormInputed) return;
|
|
6381
6392
|
if (ev.type !== 'message_sent') return;
|
|
6382
6393
|
if (!this.state.isShowWidget) return;
|
|
6383
|
-
let byType = util/* default */.
|
|
6384
|
-
let byid = util/* default */.
|
|
6394
|
+
let byType = util/* default */.A.get(ev, 'by.type');
|
|
6395
|
+
let byid = util/* default */.A.get(ev, 'by.id') || '';
|
|
6385
6396
|
if (!byid.startsWith('bb') || byType !== 'agent') return;
|
|
6386
|
-
let cid = util/* default */.
|
|
6397
|
+
let cid = util/* default */.A.get(ev, 'data.message.conversation_id');
|
|
6387
6398
|
if (!cid) return;
|
|
6388
6399
|
this.showWidget({
|
|
6389
6400
|
cid,
|
|
@@ -6395,7 +6406,7 @@ class Main extends common/* Com */.up {
|
|
|
6395
6406
|
if (this.props.plugin._no_auto_expand) return;
|
|
6396
6407
|
if (this.props.store.matchHasManuallyClosed()) return;
|
|
6397
6408
|
let convoM = this.props.store.matchConvo('*');
|
|
6398
|
-
let redconvo = util/* default */.
|
|
6409
|
+
let redconvo = util/* default */.A.find(convoM, convo => !util/* default */.A.isConvoSeen(convo, this.props.store.matchUser().id));
|
|
6399
6410
|
if (!redconvo || !redconvo.id) return;
|
|
6400
6411
|
if (!this.state.isShowWidget) this.showWidget({
|
|
6401
6412
|
view: 'chat',
|
|
@@ -6413,14 +6424,14 @@ class Main extends common/* Com */.up {
|
|
|
6413
6424
|
this.refButton.current && this.refButton.current.ClearPreview();
|
|
6414
6425
|
if (!p.view) {
|
|
6415
6426
|
let lastview = this.props.store.matchLastview() || {};
|
|
6416
|
-
p.view = util/* default */.
|
|
6417
|
-
p.cid = util/* default */.
|
|
6427
|
+
p.view = util/* default */.A.get(lastview, 'view');
|
|
6428
|
+
p.cid = util/* default */.A.get(lastview, 'opts.cid');
|
|
6418
6429
|
}
|
|
6419
6430
|
p = p || {};
|
|
6420
6431
|
if (!p.view && !p.cid) {
|
|
6421
6432
|
let convoM = this.props.store.matchConvo('*');
|
|
6422
|
-
let redconvo = util/* default */.
|
|
6423
|
-
p.cid = util/* default */.
|
|
6433
|
+
let redconvo = util/* default */.A.find(convoM, convo => !util/* default */.A.isConvoSeen(convo, this.props.store.matchUser().id));
|
|
6434
|
+
p.cid = util/* default */.A.get(redconvo, 'id', util/* default */.A.get(convoM, '0.id'));
|
|
6424
6435
|
p.view = 'chat';
|
|
6425
6436
|
}
|
|
6426
6437
|
if (this.props.store.isMobile()) modifyViewport();
|
|
@@ -6475,196 +6486,196 @@ function modifyViewport() {
|
|
|
6475
6486
|
|
|
6476
6487
|
/***/ }),
|
|
6477
6488
|
|
|
6478
|
-
/***/
|
|
6489
|
+
/***/ 1108:
|
|
6479
6490
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6480
6491
|
|
|
6481
6492
|
module.exports = __webpack_require__.p + "assets/img/bubble_default.7d5e4ab.svg";
|
|
6482
6493
|
|
|
6483
6494
|
/***/ }),
|
|
6484
6495
|
|
|
6485
|
-
/***/
|
|
6496
|
+
/***/ 7741:
|
|
6486
6497
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6487
6498
|
|
|
6488
6499
|
module.exports = __webpack_require__.p + "assets/img/caret.998eb8f.svg";
|
|
6489
6500
|
|
|
6490
6501
|
/***/ }),
|
|
6491
6502
|
|
|
6492
|
-
/***/
|
|
6503
|
+
/***/ 1370:
|
|
6493
6504
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6494
6505
|
|
|
6495
6506
|
module.exports = __webpack_require__.p + "assets/img/convos_empty.2353007.svg";
|
|
6496
6507
|
|
|
6497
6508
|
/***/ }),
|
|
6498
6509
|
|
|
6499
|
-
/***/
|
|
6510
|
+
/***/ 2876:
|
|
6500
6511
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6501
6512
|
|
|
6502
6513
|
module.exports = __webpack_require__.p + "assets/img/default.06e6ee0.jpg";
|
|
6503
6514
|
|
|
6504
6515
|
/***/ }),
|
|
6505
6516
|
|
|
6506
|
-
/***/
|
|
6517
|
+
/***/ 2538:
|
|
6507
6518
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6508
6519
|
|
|
6509
6520
|
module.exports = __webpack_require__.p + "assets/img/default_avatar.5b74dc1.png";
|
|
6510
6521
|
|
|
6511
6522
|
/***/ }),
|
|
6512
6523
|
|
|
6513
|
-
/***/
|
|
6524
|
+
/***/ 9150:
|
|
6514
6525
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6515
6526
|
|
|
6516
6527
|
module.exports = __webpack_require__.p + "assets/img/done_gray.d7e8203.svg";
|
|
6517
6528
|
|
|
6518
6529
|
/***/ }),
|
|
6519
6530
|
|
|
6520
|
-
/***/
|
|
6531
|
+
/***/ 5860:
|
|
6521
6532
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6522
6533
|
|
|
6523
6534
|
module.exports = __webpack_require__.p + "assets/img/done_green.b817fd4.svg";
|
|
6524
6535
|
|
|
6525
6536
|
/***/ }),
|
|
6526
6537
|
|
|
6527
|
-
/***/
|
|
6538
|
+
/***/ 9419:
|
|
6528
6539
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6529
6540
|
|
|
6530
6541
|
module.exports = __webpack_require__.p + "assets/img/empty.29bed2d.svg";
|
|
6531
6542
|
|
|
6532
6543
|
/***/ }),
|
|
6533
6544
|
|
|
6534
|
-
/***/
|
|
6545
|
+
/***/ 6907:
|
|
6535
6546
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6536
6547
|
|
|
6537
6548
|
module.exports = __webpack_require__.p + "assets/img/empty_1.0b98af0.svg";
|
|
6538
6549
|
|
|
6539
6550
|
/***/ }),
|
|
6540
6551
|
|
|
6541
|
-
/***/
|
|
6552
|
+
/***/ 3266:
|
|
6542
6553
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6543
6554
|
|
|
6544
6555
|
module.exports = __webpack_require__.p + "assets/img/external-link.90577cc.svg";
|
|
6545
6556
|
|
|
6546
6557
|
/***/ }),
|
|
6547
6558
|
|
|
6548
|
-
/***/
|
|
6559
|
+
/***/ 1113:
|
|
6549
6560
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6550
6561
|
|
|
6551
6562
|
module.exports = __webpack_require__.p + "assets/img/ghn.070f8e3.svg";
|
|
6552
6563
|
|
|
6553
6564
|
/***/ }),
|
|
6554
6565
|
|
|
6555
|
-
/***/
|
|
6566
|
+
/***/ 7362:
|
|
6556
6567
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6557
6568
|
|
|
6558
6569
|
module.exports = __webpack_require__.p + "assets/img/ghtk.326eac1.svg";
|
|
6559
6570
|
|
|
6560
6571
|
/***/ }),
|
|
6561
6572
|
|
|
6562
|
-
/***/
|
|
6573
|
+
/***/ 3582:
|
|
6563
6574
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6564
6575
|
|
|
6565
6576
|
module.exports = __webpack_require__.p + "assets/img/image_default.be0698b.png";
|
|
6566
6577
|
|
|
6567
6578
|
/***/ }),
|
|
6568
6579
|
|
|
6569
|
-
/***/
|
|
6580
|
+
/***/ 7324:
|
|
6570
6581
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6571
6582
|
|
|
6572
6583
|
module.exports = __webpack_require__.p + "assets/img/info.ebce7ea.svg";
|
|
6573
6584
|
|
|
6574
6585
|
/***/ }),
|
|
6575
6586
|
|
|
6576
|
-
/***/
|
|
6587
|
+
/***/ 185:
|
|
6577
6588
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6578
6589
|
|
|
6579
6590
|
module.exports = __webpack_require__.p + "assets/img/loader.37000a7.svg";
|
|
6580
6591
|
|
|
6581
6592
|
/***/ }),
|
|
6582
6593
|
|
|
6583
|
-
/***/
|
|
6594
|
+
/***/ 6973:
|
|
6584
6595
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6585
6596
|
|
|
6586
6597
|
module.exports = __webpack_require__.p + "assets/img/loading_static.a27f0ac.svg";
|
|
6587
6598
|
|
|
6588
6599
|
/***/ }),
|
|
6589
6600
|
|
|
6590
|
-
/***/
|
|
6601
|
+
/***/ 3142:
|
|
6591
6602
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6592
6603
|
|
|
6593
6604
|
module.exports = __webpack_require__.p + "assets/img/not_found_search.2ddb8d1.png";
|
|
6594
6605
|
|
|
6595
6606
|
/***/ }),
|
|
6596
6607
|
|
|
6597
|
-
/***/
|
|
6608
|
+
/***/ 8512:
|
|
6598
6609
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6599
6610
|
|
|
6600
6611
|
module.exports = __webpack_require__.p + "assets/img/package.8d37d0f.svg";
|
|
6601
6612
|
|
|
6602
6613
|
/***/ }),
|
|
6603
6614
|
|
|
6604
|
-
/***/
|
|
6615
|
+
/***/ 6857:
|
|
6605
6616
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6606
6617
|
|
|
6607
6618
|
module.exports = __webpack_require__.p + "assets/img/package_fade.763c001.svg";
|
|
6608
6619
|
|
|
6609
6620
|
/***/ }),
|
|
6610
6621
|
|
|
6611
|
-
/***/
|
|
6622
|
+
/***/ 7134:
|
|
6612
6623
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6613
6624
|
|
|
6614
6625
|
module.exports = __webpack_require__.p + "assets/img/rating--average.1ea492c.svg";
|
|
6615
6626
|
|
|
6616
6627
|
/***/ }),
|
|
6617
6628
|
|
|
6618
|
-
/***/
|
|
6629
|
+
/***/ 940:
|
|
6619
6630
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6620
6631
|
|
|
6621
6632
|
module.exports = __webpack_require__.p + "assets/img/rating--great.e3d712e.svg";
|
|
6622
6633
|
|
|
6623
6634
|
/***/ }),
|
|
6624
6635
|
|
|
6625
|
-
/***/
|
|
6636
|
+
/***/ 9801:
|
|
6626
6637
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6627
6638
|
|
|
6628
6639
|
module.exports = __webpack_require__.p + "assets/img/rating--poor.2938a25.svg";
|
|
6629
6640
|
|
|
6630
6641
|
/***/ }),
|
|
6631
6642
|
|
|
6632
|
-
/***/
|
|
6643
|
+
/***/ 5452:
|
|
6633
6644
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6634
6645
|
|
|
6635
6646
|
module.exports = __webpack_require__.p + "assets/img/search.f9705ff.svg";
|
|
6636
6647
|
|
|
6637
6648
|
/***/ }),
|
|
6638
6649
|
|
|
6639
|
-
/***/
|
|
6650
|
+
/***/ 8506:
|
|
6640
6651
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6641
6652
|
|
|
6642
6653
|
module.exports = __webpack_require__.p + "assets/img/send.6db52a9.svg";
|
|
6643
6654
|
|
|
6644
6655
|
/***/ }),
|
|
6645
6656
|
|
|
6646
|
-
/***/
|
|
6657
|
+
/***/ 5244:
|
|
6647
6658
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6648
6659
|
|
|
6649
6660
|
module.exports = __webpack_require__.p + "assets/img/shop.f7dc7d8.svg";
|
|
6650
6661
|
|
|
6651
6662
|
/***/ }),
|
|
6652
6663
|
|
|
6653
|
-
/***/
|
|
6664
|
+
/***/ 2523:
|
|
6654
6665
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6655
6666
|
|
|
6656
6667
|
module.exports = __webpack_require__.p + "assets/img/shop_faded.df7845a.svg";
|
|
6657
6668
|
|
|
6658
6669
|
/***/ }),
|
|
6659
6670
|
|
|
6660
|
-
/***/
|
|
6671
|
+
/***/ 9529:
|
|
6661
6672
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6662
6673
|
|
|
6663
6674
|
module.exports = __webpack_require__.p + "assets/img/subiz-mono.877e9f5.svg";
|
|
6664
6675
|
|
|
6665
6676
|
/***/ }),
|
|
6666
6677
|
|
|
6667
|
-
/***/
|
|
6678
|
+
/***/ 3080:
|
|
6668
6679
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
6669
6680
|
|
|
6670
6681
|
module.exports = __webpack_require__.p + "assets/img/x.26fdfa3.svg";
|