@subiz/widget-v4 4.1.82 → 4.1.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled_src/bot.js +1 -1
- package/compiled_src/call/call.js +2 -2
- package/compiled_src/chatbox/AgentsAvatar.js +1 -1
- package/compiled_src/chatbox/AudioAttachments.js +1 -1
- package/compiled_src/chatbox/ButtonAttachments.js +1 -1
- package/compiled_src/chatbox/Buttons.js +1 -1
- package/compiled_src/chatbox/ChatButton.js +8 -30
- package/compiled_src/chatbox/DropdownSelect.js +2 -2
- package/compiled_src/chatbox/Emoji.js +1 -1
- package/compiled_src/chatbox/Event.js +1 -1
- package/compiled_src/chatbox/Events.js +1 -1
- package/compiled_src/chatbox/FileAttachments.js +1 -1
- package/compiled_src/chatbox/FormAttachment.js +1 -1
- package/compiled_src/chatbox/FormAttachments.js +1 -1
- package/compiled_src/chatbox/FormSubmitAttachments.js +1 -1
- package/compiled_src/chatbox/GenericTemplateAttachments.js +1 -1
- package/compiled_src/chatbox/Header.js +1 -1
- package/compiled_src/chatbox/ImageAttachments.js +2 -2
- package/compiled_src/chatbox/InfoMessage.js +1 -1
- package/compiled_src/chatbox/ListField.js +1 -1
- package/compiled_src/chatbox/MessageInput.js +2 -2
- package/compiled_src/chatbox/Order.js +2 -2
- package/compiled_src/chatbox/OrderAttachments.js +1 -1
- package/compiled_src/chatbox/ProductAttachments.js +1 -1
- package/compiled_src/chatbox/QuickReplies.js +1 -1
- package/compiled_src/chatbox/Rating.js +2 -2
- package/compiled_src/chatbox/TextMessage.js +18 -97
- package/compiled_src/chatbox/Typing.js +1 -1
- package/compiled_src/chatbox/VideoAttachments.js +1 -1
- package/compiled_src/chatbox/Widget.js +2 -2
- package/compiled_src/chatbox/block.js +152 -0
- package/compiled_src/chatbox/main.js +1 -1
- package/compiled_src/chatbox/releaseAnimation.js +1 -1
- package/compiled_src/chatbox/time.js +1 -1
- package/compiled_src/common.js +1 -1
- package/compiled_src/contact/contact.js +2 -2
- package/compiled_src/lib.js +2 -2
- package/compiled_src/notif/notif.js +37 -37
- package/compiled_src/order/address_picker.js +2 -2
- package/compiled_src/order/icon.js +1 -1
- package/compiled_src/order/index.js +1 -1
- package/compiled_src/order/order.js +2 -2
- package/compiled_src/plugin.js +1 -1
- package/compiled_src/popup/countdown.js +2 -2
- package/compiled_src/popup/popup.js +2 -2
- package/compiled_src/popup/tick.core.commonjs.js +1 -1
- package/compiled_src/store/api.js +2 -2
- package/compiled_src/store/api_fake.js +2 -2
- package/compiled_src/store/store.js +2 -2
- package/compiled_src/util/common.js +174 -1
- package/compiled_src/util/index.js +0 -2
- package/dist/127.js +273 -0
- package/dist/132.js +2569 -6434
- package/dist/185.js +1885 -0
- package/dist/19077b40b00.127.js +1 -0
- package/dist/19077b40b00.132.js +1 -0
- package/dist/19077b40b00.185.js +1 -0
- package/dist/19077b40b00.27.js +1 -0
- package/dist/19077b40b00.278.js +1 -0
- package/dist/19077b40b00.459.js +1 -0
- package/dist/19077b40b00.490.js +1 -0
- package/dist/19077b40b00.74.js +1 -0
- package/dist/19077b40b00.997.js +1 -0
- package/dist/19077b40b00.app.js +1 -0
- package/dist/{18a02a9c54e.index.html → 19077b40b00.index.html} +4 -4
- package/dist/{18a02a9c54e.library.html → 19077b40b00.library.html} +4 -4
- package/dist/19077b40b00.library.js +1 -0
- package/dist/{18a02a9c54e.preview.html → 19077b40b00.preview.html} +1 -1
- package/dist/19077b40b00.preview.js +1 -0
- package/dist/19077b40b00.screenshoot.js +1 -0
- package/dist/19077b40b00.webview.js +1 -0
- package/dist/{782.js → 27.js} +7 -7
- package/dist/278.js +406 -0
- package/dist/{362.js → 459.js} +7 -7
- package/dist/{605.js → 490.js} +60 -61
- package/dist/{335.js → 74.js} +35 -35
- package/dist/{678.js → 997.js} +6 -6
- package/dist/HASH +1 -1
- package/dist/malicious-app.js +6 -4
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +5690 -1605
- package/package.json +1 -1
- package/src/chatbox/ChatButton.js +5 -36
- package/src/chatbox/Emoji.js +1 -1
- package/src/chatbox/TextMessage.js +18 -96
- package/src/chatbox/block.js +161 -0
- package/src/common.js +2 -10
- package/src/notif/notif.js +30 -43
- package/src/util/common.js +224 -0
- package/src/util/index.js +0 -3
- package/compiled_src/util/extractor.js +0 -136
- package/dist/178.js +0 -406
- package/dist/18a02a9c54e.132.js +0 -1
- package/dist/18a02a9c54e.178.js +0 -1
- package/dist/18a02a9c54e.213.js +0 -1
- package/dist/18a02a9c54e.335.js +0 -1
- package/dist/18a02a9c54e.362.js +0 -1
- package/dist/18a02a9c54e.441.js +0 -1
- package/dist/18a02a9c54e.605.js +0 -1
- package/dist/18a02a9c54e.678.js +0 -1
- package/dist/18a02a9c54e.782.js +0 -1
- package/dist/18a02a9c54e.app.js +0 -1
- package/dist/18a02a9c54e.library.js +0 -1
- package/dist/18a02a9c54e.preview.js +0 -1
- package/dist/18a02a9c54e.screenshoot.js +0 -1
- package/dist/18a02a9c54e.webview.js +0 -1
- package/dist/213.js +0 -2780
- package/dist/441.js +0 -2855
- package/src/util/extractor.js +0 -166
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.XMLHttpRequest = exports.Date = exports.DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = exports.DEFVAL = void 0;
|
|
7
7
|
exports.agentsOfConvo = agentsOfConvo;
|
|
8
|
+
exports.blockToText = blockToText;
|
|
8
9
|
exports.checkRunConditions = checkRunConditions;
|
|
9
10
|
exports.clearTimeout = exports.clearInterval = void 0;
|
|
10
11
|
exports.cloneDeep = cloneDeep;
|
|
@@ -14,6 +15,12 @@ exports.detectLang = detectLang;
|
|
|
14
15
|
exports.diffDay = diffDay;
|
|
15
16
|
exports.diffYear = diffYear;
|
|
16
17
|
exports.each = each;
|
|
18
|
+
exports.extract = extract;
|
|
19
|
+
exports.extractEmails = extractEmails;
|
|
20
|
+
exports.extractEmojis = extractEmojis;
|
|
21
|
+
exports.extractLinks = extractLinks;
|
|
22
|
+
exports.extractPhones = extractPhones;
|
|
23
|
+
exports.extractText = extractText;
|
|
17
24
|
exports.filter = filter;
|
|
18
25
|
exports.find = find;
|
|
19
26
|
exports.formatCurrency = formatCurrency;
|
|
@@ -39,6 +46,7 @@ exports.offsetToMin = offsetToMin;
|
|
|
39
46
|
exports.orderBy = orderBy;
|
|
40
47
|
exports.orderByF = orderByF;
|
|
41
48
|
exports.parseJSON = parseJSON;
|
|
49
|
+
exports.pipeExtracts = pipeExtracts;
|
|
42
50
|
exports.preloadImg = preloadImg;
|
|
43
51
|
exports.preloadWebfonts = preloadWebfonts;
|
|
44
52
|
exports.randomString = randomString;
|
|
@@ -64,6 +72,127 @@ exports.unicodeToAscii = unicodeToAscii;
|
|
|
64
72
|
exports.unixSec = unixSec;
|
|
65
73
|
exports.usersOfConvo = usersOfConvo;
|
|
66
74
|
var op = require('./op.js');
|
|
75
|
+
function extractEmojis(text) {
|
|
76
|
+
var out = [];
|
|
77
|
+
for (var i = 0; i < text.length; i++) {
|
|
78
|
+
for (var e = 0; e < emojis.length; e++) {
|
|
79
|
+
if (text.indexOf(emojis[e], i) !== i) continue;
|
|
80
|
+
out.push({
|
|
81
|
+
index: i,
|
|
82
|
+
length: emojis[e].length
|
|
83
|
+
});
|
|
84
|
+
i += emojis[e].length - 1;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
function extractLinks(text) {
|
|
91
|
+
text = text || '';
|
|
92
|
+
var reg = /(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.,~#?&//=]*)/gim;
|
|
93
|
+
var out = [];
|
|
94
|
+
var match;
|
|
95
|
+
while (match = reg.exec(text)) {
|
|
96
|
+
out.push({
|
|
97
|
+
index: match.index,
|
|
98
|
+
length: reg.lastIndex - match.index
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
function extractEmails(text) {
|
|
104
|
+
text = text || '';
|
|
105
|
+
var reg = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/gim;
|
|
106
|
+
var out = [];
|
|
107
|
+
var match;
|
|
108
|
+
while (match = reg.exec(text)) {
|
|
109
|
+
out.push({
|
|
110
|
+
index: match.index,
|
|
111
|
+
length: reg.lastIndex - match.index
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
function extractPhones(msg) {
|
|
117
|
+
msg = msg || '';
|
|
118
|
+
var fgmsg = '';
|
|
119
|
+
var realchmap = {};
|
|
120
|
+
for (var i = 0; i < msg.length; i++) {
|
|
121
|
+
var ch = msg.charAt(i);
|
|
122
|
+
if (ch !== '.' && ch !== '-' && ch !== ' ') {
|
|
123
|
+
fgmsg += ch;
|
|
124
|
+
realchmap[fgmsg.length - 1] = i;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
var prevCh = i > 0 ? msg.charAt(i - 1) : '-';
|
|
128
|
+
var nextCh = i < msg.length - 1 ? msg.charAt(i + 1) : '-';
|
|
129
|
+
if ('0123456789'.indexOf(prevCh) !== -1 && '0123456789'.indexOf(nextCh) !== -1) continue;
|
|
130
|
+
fgmsg += ch;
|
|
131
|
+
realchmap[fgmsg.length - 1] = i;
|
|
132
|
+
}
|
|
133
|
+
var reg = /([0-9]{8,13})/gim;
|
|
134
|
+
var out = [];
|
|
135
|
+
var match;
|
|
136
|
+
while (match = reg.exec(fgmsg)) {
|
|
137
|
+
out.push({
|
|
138
|
+
index: realchmap[match.index],
|
|
139
|
+
length: realchmap[reg.lastIndex - 1] - realchmap[match.index] + 1
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
function extract(text, extractor, type) {
|
|
145
|
+
if (!text) return [];
|
|
146
|
+
var out = [];
|
|
147
|
+
var lastindex = 0;
|
|
148
|
+
var tags = extractor(text);
|
|
149
|
+
if (size(tags) === 0) return [{
|
|
150
|
+
type: 'text',
|
|
151
|
+
text
|
|
152
|
+
}];
|
|
153
|
+
each(tags, tag => {
|
|
154
|
+
out.push({
|
|
155
|
+
type: 'text',
|
|
156
|
+
text: text.substr(lastindex, tag.index - lastindex)
|
|
157
|
+
});
|
|
158
|
+
out.push({
|
|
159
|
+
type,
|
|
160
|
+
text: text.substr(tag.index, tag.length)
|
|
161
|
+
});
|
|
162
|
+
lastindex = tag.index + tag.length;
|
|
163
|
+
});
|
|
164
|
+
var lastTag = last(tags);
|
|
165
|
+
out.push({
|
|
166
|
+
type: 'text',
|
|
167
|
+
text: text.substr(lastTag.index + lastTag.length, text.length - lastTag.index + lastTag.length)
|
|
168
|
+
});
|
|
169
|
+
return filter(out, o => o.text !== '');
|
|
170
|
+
}
|
|
171
|
+
function pipeExtracts(text, extractors) {
|
|
172
|
+
var out = [];
|
|
173
|
+
if (size(extractors) === 0) return [{
|
|
174
|
+
type: 'text',
|
|
175
|
+
text
|
|
176
|
+
}];
|
|
177
|
+
var ext = extractors.shift();
|
|
178
|
+
var tags = extract(text, ext, ext.type);
|
|
179
|
+
each(tags, t => {
|
|
180
|
+
if (t.type !== 'text') return out.push(t);
|
|
181
|
+
out = out.concat(pipeExtracts(t.text, extractors.slice()));
|
|
182
|
+
});
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
function extractText(text) {
|
|
186
|
+
var link = extractLinks;
|
|
187
|
+
link.type = 'link';
|
|
188
|
+
var email = extractEmails;
|
|
189
|
+
email.type = 'email';
|
|
190
|
+
var phone = extractPhones;
|
|
191
|
+
phone.type = 'phone';
|
|
192
|
+
var emoji = extractEmojis;
|
|
193
|
+
emoji.type = 'emoji';
|
|
194
|
+
return pipeExtracts(text, [email, link, phone, emoji]);
|
|
195
|
+
}
|
|
67
196
|
function parseJSON(str) {
|
|
68
197
|
try {
|
|
69
198
|
return parse(str);
|
|
@@ -974,4 +1103,48 @@ const ALL_CURRENCIES = [{
|
|
|
974
1103
|
}, {
|
|
975
1104
|
code: 'VND',
|
|
976
1105
|
symbol: '₫'
|
|
977
|
-
}];
|
|
1106
|
+
}];
|
|
1107
|
+
function blockToText(block) {
|
|
1108
|
+
return _blockToText(block).trim();
|
|
1109
|
+
}
|
|
1110
|
+
function _blockToText(block) {
|
|
1111
|
+
if (!block || !block.type) return '';
|
|
1112
|
+
let out = '';
|
|
1113
|
+
if (block.type == 'bullet_list' || block.type == 'ordered_list') {
|
|
1114
|
+
map(block.content, item => {
|
|
1115
|
+
preifx = '\n* ';
|
|
1116
|
+
if (block.type == 'ordered_list') {
|
|
1117
|
+
prefix = i + '\n. ';
|
|
1118
|
+
}
|
|
1119
|
+
out += prefix + blockToText(item).trim();
|
|
1120
|
+
});
|
|
1121
|
+
return out;
|
|
1122
|
+
}
|
|
1123
|
+
if (block.type == 'heading' || block.type == 'paragraph') {
|
|
1124
|
+
out += '\n';
|
|
1125
|
+
}
|
|
1126
|
+
if (block.type == '' || block.type == 'text' || block.type == 'link' || block.type == 'mention-agent' || block.type == 'dynamic-field') {
|
|
1127
|
+
return out + block.text;
|
|
1128
|
+
}
|
|
1129
|
+
if (block.type == 'horizontal_rule') return out + '\n---\n';
|
|
1130
|
+
if (block.type == 'emoji') {
|
|
1131
|
+
let code;
|
|
1132
|
+
if (size(block.attrs) > 0) code = block.attrs['code'];
|
|
1133
|
+
if (code == '') code = block.text;
|
|
1134
|
+
if (code != '') {
|
|
1135
|
+
let emoji = find(LEXICAL_EMOJI_LIST, emoji => emoji.code === code);
|
|
1136
|
+
out + op.get(emoji, 'text', code);
|
|
1137
|
+
}
|
|
1138
|
+
return out;
|
|
1139
|
+
}
|
|
1140
|
+
map(block.content, block => {
|
|
1141
|
+
out += blockToText(block);
|
|
1142
|
+
});
|
|
1143
|
+
return out;
|
|
1144
|
+
}
|
|
1145
|
+
let emojis = ['like', 'unlike', 'wink', 'tongue-out', 'tired', 'surprised', 'smiling', 'sleepy', 'sad', 'neutral', 'heart-eyes', 'grinning', 'crying', 'confused', 'angry', 'cry', 'heart_eyes', 'neutral_face', 'emoji--disappointed', 'smile', 'open_mouth', 'tired_face', 'stuck_out_tongue', 'moyai', 'thumbsdown', 'dislike', 'thumbsup', 'ok_hand', 'octopus', 'pig2', 'wave', 'mouse', 'mouse2', 'rat'];
|
|
1146
|
+
emojis = map(emojis, e => ':' + e + ':');
|
|
1147
|
+
function absLink(url) {
|
|
1148
|
+
if (!url.startsWith('http://') && !url.startsWith('https://') && !url.startsWith('//')) return 'http://' + url;
|
|
1149
|
+
return url;
|
|
1150
|
+
}
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var common = _interopRequireWildcard(require("./common.js"));
|
|
8
|
-
var extractor = _interopRequireWildcard(require("./extractor.js"));
|
|
9
8
|
var campaign = _interopRequireWildcard(require("./campaign.js"));
|
|
10
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -17,6 +16,5 @@ var op = require('./op.js');
|
|
|
17
16
|
sb.get = op.get;
|
|
18
17
|
sb.set = op.set;
|
|
19
18
|
sb.Pubsub = require('./pubsub.js').default;
|
|
20
|
-
sb = Object.assign(sb, extractor);
|
|
21
19
|
sb = Object.assign(sb, campaign);
|
|
22
20
|
var _default = exports.default = sb;
|
package/dist/127.js
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(self["webpackChunk_subiz_widget_v4"] = self["webpackChunk_subiz_widget_v4"] || []).push([[127],{
|
|
3
|
+
|
|
4
|
+
/***/ 6127:
|
|
5
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
6
|
+
|
|
7
|
+
__webpack_require__.r(__webpack_exports__);
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ "default": () => (/* binding */ ProductAttachments)
|
|
10
|
+
/* harmony export */ });
|
|
11
|
+
/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6801);
|
|
12
|
+
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2840);
|
|
13
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(172);
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ProductAttachments extends _common_js__WEBPACK_IMPORTED_MODULE_1__/* .Com */ .Mw {
|
|
18
|
+
render() {
|
|
19
|
+
let byType = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(this.props.ev, 'by.type');
|
|
20
|
+
if (byType === 'user') return null;
|
|
21
|
+
let acc = this.props.store.matchAccount();
|
|
22
|
+
var attachments = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(this.props.ev, 'data.message.attachments', []);
|
|
23
|
+
let orders = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.filter(attachments, att => att.type === 'order' && att.order).map(att => att.order);
|
|
24
|
+
if (orders.length === 0) return null;
|
|
25
|
+
let $orders = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.map(orders, (order, index) => {
|
|
26
|
+
calcOrderTotal(order);
|
|
27
|
+
let $note = null;
|
|
28
|
+
if (order.note) {
|
|
29
|
+
$note = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
30
|
+
class: "order_attachment__label"
|
|
31
|
+
}, this.props.t('note')), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
32
|
+
class: "order_attachment__note",
|
|
33
|
+
title: order.note
|
|
34
|
+
}, order.note));
|
|
35
|
+
}
|
|
36
|
+
let $products = null;
|
|
37
|
+
if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.size(order.items) > 0) {
|
|
38
|
+
$products = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
39
|
+
class: "order_attachment__label"
|
|
40
|
+
}, this.props.t('product')), _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.map(order.items, item => {
|
|
41
|
+
let product = item.product || {};
|
|
42
|
+
return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
43
|
+
class: "order_attachment__product"
|
|
44
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("img", {
|
|
45
|
+
class: "order_attachment__product_img",
|
|
46
|
+
alt: '' + _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(product, 'id'),
|
|
47
|
+
src: _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(product, 'image', __webpack_require__(2876))
|
|
48
|
+
}), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
49
|
+
style: "overflow: hidden !important;"
|
|
50
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
51
|
+
class: "order_attachment__product_name",
|
|
52
|
+
title: this.props.t.i18n(product.i18n_name) || product.name
|
|
53
|
+
}, this.props.t.i18n(product.i18n_name) || product.name), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
54
|
+
class: "order_attachment__product_desc"
|
|
55
|
+
}, getProductPropName(product, ' / ')), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
56
|
+
class: "order_attachment__product_desc"
|
|
57
|
+
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(product.price))));
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
let $total = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
61
|
+
class: "order_attachment__footer"
|
|
62
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
63
|
+
class: "d-flex align-items-center justify-content-between"
|
|
64
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, this.props.t('total')), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("b", {
|
|
65
|
+
class: "order_attachment__total"
|
|
66
|
+
}, _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order.total)))));
|
|
67
|
+
let phoneattr = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.find(_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(order, 'user.attributes', []), attr => attr.key === 'phones') || {
|
|
68
|
+
key: 'phones',
|
|
69
|
+
text: ''
|
|
70
|
+
};
|
|
71
|
+
let phone = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(order, 'shipping.address.phone', '').trim();
|
|
72
|
+
phone = phone || _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.trim(phoneattr.text);
|
|
73
|
+
if (phone) phone = this.props.t('phn') + ': ' + phone;
|
|
74
|
+
let $shipto = null;
|
|
75
|
+
if (displayOrderShippingAddress(order) || phone) {
|
|
76
|
+
$shipto = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
77
|
+
class: "order_attachment__label"
|
|
78
|
+
}, this.props.t('ship_to')), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, displayOrderShippingAddress(order)), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
79
|
+
class: "order_attachment__text_truncate"
|
|
80
|
+
}, phone));
|
|
81
|
+
}
|
|
82
|
+
let $beforeTax = null;
|
|
83
|
+
if (order._discount_before_tax) {
|
|
84
|
+
$beforeTax = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
85
|
+
class: "order_attachment__footer"
|
|
86
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
87
|
+
class: "d-flex align-items-center justify-content-between"
|
|
88
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
89
|
+
class: "order_attachment__label no_margin"
|
|
90
|
+
}, this.props.t('subtotal_before_tax')), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order._order_value))), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
91
|
+
class: "d-flex align-items-center justify-content-between"
|
|
92
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
93
|
+
class: "order_attachment__label no_margin"
|
|
94
|
+
}, this.props.t('discount_before_tax')), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", null, "-", _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order._discount_before_tax))));
|
|
95
|
+
}
|
|
96
|
+
let $subtotal = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
97
|
+
class: "d-flex align-items-center justify-content-between"
|
|
98
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
99
|
+
class: "order_attachment__label no_margin"
|
|
100
|
+
}, this.props.t('subtotal')), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
101
|
+
style: ""
|
|
102
|
+
}, _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order.subtotal)));
|
|
103
|
+
let $tax = null;
|
|
104
|
+
if (order.total_tax) {
|
|
105
|
+
let taxname = '';
|
|
106
|
+
if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.size(order._taxM) === 1) {
|
|
107
|
+
let tax = _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(order._taxM, '0.tax', {});
|
|
108
|
+
if (tax.name && tax.percentage) taxname = `(${tax.name} ${Math.round(tax.percentage || 0) / 100}%)`;
|
|
109
|
+
}
|
|
110
|
+
$tax = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
111
|
+
class: "d-flex align-items-center justify-content-between"
|
|
112
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
113
|
+
class: "order_attachment__label no_margin"
|
|
114
|
+
}, this.props.t('tax'), " ", taxname), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
115
|
+
style: ""
|
|
116
|
+
}, _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order.total_tax)));
|
|
117
|
+
}
|
|
118
|
+
let $discount = null;
|
|
119
|
+
if (order.discount_type === 'percentage' && order.discount_percentage) {
|
|
120
|
+
$discount = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
121
|
+
class: "d-flex align-items-center justify-content-between"
|
|
122
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
123
|
+
class: "order_attachment__label no_margin"
|
|
124
|
+
}, this.props.t('discount_after_tax'), " (", Math.round(order.discount_percentage / 100), "%)"), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
125
|
+
style: ""
|
|
126
|
+
}, "-", _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order._computed_discount)));
|
|
127
|
+
}
|
|
128
|
+
if (order.discount_type === 'amount' && order.discount_amount) {
|
|
129
|
+
$discount = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
130
|
+
class: "d-flex align-items-center justify-content-between"
|
|
131
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
132
|
+
class: "order_attachment__label no_margin"
|
|
133
|
+
}, this.props.t('discount_after_tax')), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
134
|
+
class: "no-shrink"
|
|
135
|
+
}, "-", _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order._computed_discount)));
|
|
136
|
+
}
|
|
137
|
+
let $shipping = null;
|
|
138
|
+
if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(order, 'shipping.nominal_fee')) {
|
|
139
|
+
$shipping = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
140
|
+
class: "d-flex align-items-center justify-content-between"
|
|
141
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
142
|
+
class: "order_attachment__label no_margin"
|
|
143
|
+
}, this.props.t('shipping_fee')), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
144
|
+
style: ""
|
|
145
|
+
}, _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(_util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.get(order, 'shipping.nominal_fee', 0))));
|
|
146
|
+
}
|
|
147
|
+
let $adjustment = null;
|
|
148
|
+
if (order.adjustment) {
|
|
149
|
+
$adjustment = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
150
|
+
class: "d-flex align-items-center justify-content-between"
|
|
151
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
152
|
+
class: "order_attachment__label no_margin"
|
|
153
|
+
}, order.adjustment_description), ' ', (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
154
|
+
class: "no-shrink"
|
|
155
|
+
}, _util_index_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formatCurrency(order.adjustment)));
|
|
156
|
+
}
|
|
157
|
+
$subtotal = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
158
|
+
class: "order_attachment__footer"
|
|
159
|
+
}, $subtotal, $tax, $shipping, $discount, $adjustment);
|
|
160
|
+
if (!$shipping && !$adjustment && !$discount && !$tax) {
|
|
161
|
+
$subtotal = null;
|
|
162
|
+
}
|
|
163
|
+
return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
164
|
+
class: `order_attachment order_attachment__${byType}`
|
|
165
|
+
}, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("div", {
|
|
166
|
+
class: "order_attachment__header"
|
|
167
|
+
}, this.props.t('order'), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)("span", {
|
|
168
|
+
class: "order_attachment__text_muted order_attachment__text_sm"
|
|
169
|
+
}, getOrderDisplayName(order))), $products, $shipto, $note, $beforeTax, $subtotal, $total);
|
|
170
|
+
});
|
|
171
|
+
return $orders;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function getProductPropName(product, seperator = ' - ') {
|
|
175
|
+
let options = op.get(product, 'options', []);
|
|
176
|
+
let props = op.get(product, 'props', []);
|
|
177
|
+
let multiPropsOptions = op.filter(options, option => op.size(option.values) > 1);
|
|
178
|
+
let names = [];
|
|
179
|
+
op.each(multiPropsOptions, option => {
|
|
180
|
+
let prop = op.find(props, prop => prop.key === option.key) || {};
|
|
181
|
+
if (prop.value) names.push(prop.value);
|
|
182
|
+
});
|
|
183
|
+
return names.join(seperator);
|
|
184
|
+
}
|
|
185
|
+
function getOrderDisplayName(order = {}) {
|
|
186
|
+
return order.number || order.id || '';
|
|
187
|
+
}
|
|
188
|
+
function displayOrderShippingAddress(order, isShorten) {
|
|
189
|
+
let addr = op.get(order, 'shipping.address', {});
|
|
190
|
+
let fulladdr = [addr.address, addr.ward, addr.district, addr.province].filter(a => a).join(', ').trim();
|
|
191
|
+
if (isShorten) fulladdr = shortenAddr(fulladdr);
|
|
192
|
+
return fulladdr;
|
|
193
|
+
}
|
|
194
|
+
function shortenAddr(str) {
|
|
195
|
+
str = str || '';
|
|
196
|
+
str = str.replace(/Hà Nội/gi, 'HN');
|
|
197
|
+
str = str.replace(/Hồ Chí Minh/gi, 'HCM');
|
|
198
|
+
str = str.replace(/Thành Phố/gi, 'TP');
|
|
199
|
+
return str;
|
|
200
|
+
}
|
|
201
|
+
function calcOrderTotal(order) {
|
|
202
|
+
let subtotal = 0;
|
|
203
|
+
let beforeTaxDiscount = 0;
|
|
204
|
+
let ordervalue = 0;
|
|
205
|
+
op.map(order.items, item => {
|
|
206
|
+
if (!item.product) return 0;
|
|
207
|
+
let price = op.get(item, 'product.price', 0) * (item.quantity || 0);
|
|
208
|
+
ordervalue += price;
|
|
209
|
+
if (item.discount_type == 'percentage') {
|
|
210
|
+
if (item.discount_percentage > 0) {
|
|
211
|
+
beforeTaxDiscount += price * item.discount_percentage / 10000;
|
|
212
|
+
price = price * (1 - (item.discount_percentage || 0) / 10000);
|
|
213
|
+
}
|
|
214
|
+
} else if (item.discount_type == 'amount') {
|
|
215
|
+
if (item.discount_amount > 0) {
|
|
216
|
+
beforeTaxDiscount += item.discount_amount;
|
|
217
|
+
price = price - (item.discount_amount || 0);
|
|
218
|
+
if (price <= 0) price = 0;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
item.total = price;
|
|
222
|
+
subtotal += price;
|
|
223
|
+
});
|
|
224
|
+
let taxM = {};
|
|
225
|
+
op.map(order.items, (item, i) => {
|
|
226
|
+
if (!item.product) return;
|
|
227
|
+
let tax = item.product.tax;
|
|
228
|
+
if (!tax) return;
|
|
229
|
+
if (!tax.id) return;
|
|
230
|
+
let taxprice = item.total * tax.percentage / 10000;
|
|
231
|
+
item.total_tax = taxprice;
|
|
232
|
+
taxM[i] = {
|
|
233
|
+
tax: tax,
|
|
234
|
+
taxprice: taxprice
|
|
235
|
+
};
|
|
236
|
+
});
|
|
237
|
+
let totaltax = 0;
|
|
238
|
+
op.map(taxM, t => totaltax += t.taxprice);
|
|
239
|
+
let computed_discount = 0;
|
|
240
|
+
if (order.discount_type == 'percentage' && order.discount_percentage > 0) {
|
|
241
|
+
computed_discount = (subtotal + totaltax) * order.discount_percentage / 10000;
|
|
242
|
+
} else if (order.discount_type == 'amount') {
|
|
243
|
+
computed_discount = order.discount_amount || 0;
|
|
244
|
+
}
|
|
245
|
+
let shippingfee = op.get(order, 'shipping.nominal_fee', 0);
|
|
246
|
+
if (shippingfee > 0) {
|
|
247
|
+
if (op.get(order, 'shipping.tax.id')) {
|
|
248
|
+
let tax = order.shipping.tax;
|
|
249
|
+
let taxprice = shippingfee * (tax.percentage / 10000);
|
|
250
|
+
taxM['ship'] = {
|
|
251
|
+
tax: tax,
|
|
252
|
+
taxprice: taxprice
|
|
253
|
+
};
|
|
254
|
+
order.shipping.total_tax = taxprice;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
totaltax = 0;
|
|
258
|
+
op.map(taxM, t => totaltax += t.taxprice);
|
|
259
|
+
let total = subtotal + totaltax - computed_discount + shippingfee;
|
|
260
|
+
total += order.adjustment || 0;
|
|
261
|
+
if (total < 0) total = 0;
|
|
262
|
+
order.subtotal = subtotal;
|
|
263
|
+
order._computed_discount = computed_discount;
|
|
264
|
+
order._taxM = taxM;
|
|
265
|
+
order.total = total;
|
|
266
|
+
order.total_tax = totaltax;
|
|
267
|
+
order._discount_before_tax = beforeTaxDiscount;
|
|
268
|
+
order._order_value = ordervalue;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/***/ })
|
|
272
|
+
|
|
273
|
+
}]);
|