@subiz/widget-v4 4.0.75 → 4.0.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/less/message.less +11 -1
- package/compiled_src/chatbox/ButtonAttachments.js +2 -1
- package/compiled_src/chatbox/Buttons.js +3 -3
- package/compiled_src/chatbox/Event.js +6 -3
- package/compiled_src/chatbox/GenericTemplateAttachments.js +12 -6
- package/compiled_src/chatbox/ProductAttachments.js +4 -4
- package/compiled_src/lib.js +6 -0
- package/compiled_src/store/api.js +24 -18
- package/compiled_src/store/api_fake.js +0 -24
- package/compiled_src/store/store.js +21 -5
- package/dist/0b82fa7e5c3b07b40a44.png +1 -0
- package/dist/0f4af006e38ee8b93633.png +1 -0
- package/dist/132.js +6777 -0
- package/dist/178.js +573 -0
- package/dist/17f00e48d38.132.js +1 -0
- package/dist/17f00e48d38.178.js +1 -0
- package/dist/17f00e48d38.213.js +1 -0
- package/dist/17f00e48d38.335.js +1 -0
- package/dist/17f00e48d38.362.js +1 -0
- package/dist/17f00e48d38.441.js +1 -0
- package/dist/17f00e48d38.605.js +1 -0
- package/dist/17f00e48d38.678.js +1 -0
- package/dist/17f00e48d38.782.js +1 -0
- package/dist/17f00e48d38.app.js +1 -0
- package/dist/17f00e48d38.index.html +22 -0
- package/dist/17f00e48d38.library.html +22 -0
- package/dist/17f00e48d38.library.js +1 -0
- package/dist/17f00e48d38.preview.html +759 -0
- package/dist/17f00e48d38.preview.js +1 -0
- package/dist/17f00e48d38.screenshoot.js +1 -0
- package/dist/1ea1c6cd21d25176810c.png +1 -0
- package/dist/213.js +3188 -0
- package/dist/292d42404e1b03398f61.png +1 -0
- package/dist/312d376370831b7bea83.png +1 -0
- package/dist/313d1bfc1cf776d1aefe.png +1 -0
- package/dist/335.js +411 -0
- package/dist/362.js +157 -0
- package/dist/441.js +2732 -0
- package/dist/4aa58bb7a66bb44975aa.png +1 -0
- package/dist/56ce063bc6c81adb7322.png +1 -0
- package/dist/605.js +328 -0
- package/dist/678.js +157 -0
- package/dist/6a411166ef5cc79e0714.png +1 -0
- package/dist/6faf403782fefacc1649.png +1 -0
- package/dist/782.js +204 -0
- package/dist/79dca33c68fab79c067f.png +1 -0
- package/dist/82da1578fa84f9debaeb.png +1 -0
- package/dist/8b8e0f0824743974b282.png +1 -0
- package/dist/8d551390d81e39130a3c.png +1 -0
- package/dist/9fc61b9479877ebdb6c7.png +1 -0
- package/dist/HASH +1 -0
- package/dist/a165d31dcb3dc90f1057.png +1 -0
- package/dist/a98d4a5698812c4426b3.png +1 -0
- package/dist/assets/img/Facebook.64607ec.png +0 -0
- package/dist/assets/img/Zalo.6845707.png +0 -0
- package/dist/assets/img/award1a.1a58e10.png +0 -0
- package/dist/assets/img/award3a.3b74423.png +0 -0
- package/dist/assets/img/award4a.ed6ccd4.png +0 -0
- package/dist/assets/img/award5.39eb7ae.png +0 -0
- package/dist/assets/img/bubble_default.7d5e4ab.svg +20 -0
- package/dist/assets/img/caret.998eb8f.svg +1 -0
- package/dist/assets/img/convos_empty.2353007.svg +72 -0
- package/dist/assets/img/default.06e6ee0.jpg +0 -0
- package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
- package/dist/assets/img/done_gray.d7e8203.svg +4 -0
- package/dist/assets/img/done_green.b817fd4.svg +4 -0
- package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
- package/dist/assets/img/empty.29bed2d.svg +23 -0
- package/dist/assets/img/empty_1.0b98af0.svg +11 -0
- package/dist/assets/img/examplte_logo.f86535f.svg +1 -0
- package/dist/assets/img/external-link.90577cc.svg +1 -0
- package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
- package/dist/assets/img/ghn.070f8e3.svg +17 -0
- package/dist/assets/img/ghtk.326eac1.svg +18 -0
- package/dist/assets/img/image_default.be0698b.png +0 -0
- package/dist/assets/img/info.ebce7ea.svg +1 -0
- package/dist/assets/img/loader.37000a7.svg +1 -0
- package/dist/assets/img/loading_static.8f403ae.svg +10 -0
- package/dist/assets/img/main-service1.d536cc2.png +0 -0
- package/dist/assets/img/main-service2.9b99549.png +0 -0
- package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
- package/dist/assets/img/package.8d37d0f.svg +5 -0
- package/dist/assets/img/package_fade.763c001.svg +1 -0
- package/dist/assets/img/rating--average.1ea492c.svg +12 -0
- package/dist/assets/img/rating--great.e3d712e.svg +16 -0
- package/dist/assets/img/rating--poor.2938a25.svg +12 -0
- package/dist/assets/img/search.f9705ff.svg +1 -0
- package/dist/assets/img/send.6db52a9.svg +3 -0
- package/dist/assets/img/shop.f7dc7d8.svg +1 -0
- package/dist/assets/img/shop_faded.df7845a.svg +1 -0
- package/dist/assets/img/subiz-mono.877e9f5.svg +3 -0
- package/dist/assets/img/x.26fdfa3.svg +5 -0
- package/dist/c41606bf9d1b604e46d5.png +1 -0
- package/dist/ce1f7450ce6c1aacd330.png +1 -0
- package/dist/cf8c01e88f4770a6e3e5.png +1 -0
- package/dist/dfbcfeab1d5622a737e2.png +1 -0
- package/dist/e4893ed8c2f7b8329919.png +1 -0
- package/dist/ec2ab4eb4ef73d186186.png +1 -0
- package/dist/malicious-app.js +13 -0
- package/dist/screenshoot.html +7 -0
- package/dist/screenshoot.js +5919 -0
- package/index.html +6 -2
- package/package.json +10 -10
- package/src/chatbox/ButtonAttachments.js +1 -1
- package/src/chatbox/Buttons.js +3 -3
- package/src/chatbox/Event.js +3 -3
- package/src/chatbox/GenericTemplateAttachments.js +30 -24
- package/src/chatbox/ProductAttachments.js +4 -4
- package/src/lib.js +5 -0
- package/src/store/api.js +16 -10
- package/src/store/api_fake.js +0 -16
- package/src/store/store.js +38 -4
package/index.html
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
|
-
<meta name="description" content="Subiz preview"
|
|
4
|
+
<meta name="description" content="Subiz preview" />
|
|
5
5
|
<meta charset="utf-8" />
|
|
6
6
|
<title>Widget v4</title>
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
@@ -27,13 +27,17 @@
|
|
|
27
27
|
getUrlParameter('id') || getUrlParameter('acc_id') || getUrlParameter('account_id') || 'acpxkgumifuoofoosble'
|
|
28
28
|
// making a queue, so we can process data asynchronous
|
|
29
29
|
window._sbzaccid = accid
|
|
30
|
-
window.subiz = function() {
|
|
30
|
+
window.subiz = function () {
|
|
31
31
|
window.subiz.q.push(arguments)
|
|
32
32
|
}
|
|
33
33
|
window.subiz.q = []
|
|
34
34
|
// set account it in the very first call
|
|
35
35
|
window.subiz('setAccount', accid)
|
|
36
36
|
window.subiz('expandWidget')
|
|
37
|
+
|
|
38
|
+
if (accid == 'acpxkgumifuoofoosble') {
|
|
39
|
+
window.subiz('setViewingProduct', {id: '220170', sku: 'ipx', source_id: 'IPHONE10'})
|
|
40
|
+
}
|
|
37
41
|
</script>
|
|
38
42
|
</body>
|
|
39
43
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subiz/widget-v4",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.79",
|
|
4
4
|
"main": "./compiled_src/lib.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npx webpack serve --config webpack.dev.js",
|
|
@@ -14,28 +14,28 @@
|
|
|
14
14
|
"@subiz/storage": "0.0.8",
|
|
15
15
|
"@subiz/wsclient": "^3.1.7",
|
|
16
16
|
"cookie_js": "1.4.2",
|
|
17
|
-
"core-js": "^3.22.
|
|
17
|
+
"core-js": "^3.22.8",
|
|
18
18
|
"css-loader": "5.2.7",
|
|
19
19
|
"file-loader": "^6.2.0",
|
|
20
20
|
"less": "^4.1.2",
|
|
21
|
-
"less-loader": "^
|
|
22
|
-
"marked": "^4.0.
|
|
23
|
-
"preact": "^10.7.
|
|
21
|
+
"less-loader": "^11.0.0",
|
|
22
|
+
"marked": "^4.0.16",
|
|
23
|
+
"preact": "^10.7.3"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@babel/cli": "^7.17.10",
|
|
27
|
-
"@babel/core": "^7.
|
|
27
|
+
"@babel/core": "^7.18.2",
|
|
28
28
|
"@babel/plugin-proposal-class-properties": "^7.17.12",
|
|
29
29
|
"@babel/plugin-transform-react-jsx": "^7.17.12",
|
|
30
|
-
"@babel/preset-env": "^7.
|
|
30
|
+
"@babel/preset-env": "^7.18.2",
|
|
31
31
|
"babel-loader": "^8.2.5",
|
|
32
32
|
"babel-plugin-syntax-jsx": "^6.18.0",
|
|
33
33
|
"html-webpack-plugin": "^5.5.0",
|
|
34
34
|
"prettier": "^2.6.2",
|
|
35
|
-
"puppeteer": "^14.1
|
|
36
|
-
"webpack": "^5.
|
|
35
|
+
"puppeteer": "^14.2.1",
|
|
36
|
+
"webpack": "^5.73.0",
|
|
37
37
|
"webpack-bundle-analyzer": "^4.5.0",
|
|
38
38
|
"webpack-cli": "^4.9.2",
|
|
39
|
-
"webpack-dev-server": "^4.9.
|
|
39
|
+
"webpack-dev-server": "^4.9.1"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -21,6 +21,6 @@ export default class ButtonAttachments extends Com {
|
|
|
21
21
|
sb.each(sb.get(att, 'buttons') || [], btn => buttons.push(btn))
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
return <Buttons store={this.props.store} buttons={buttons} />
|
|
24
|
+
return <Buttons store={this.props.store} buttons={buttons} t={this.props.t}/>
|
|
25
25
|
}
|
|
26
26
|
}
|
package/src/chatbox/Buttons.js
CHANGED
|
@@ -13,7 +13,7 @@ export default class Buttons extends Com {
|
|
|
13
13
|
if (button.type === 'call_button') {
|
|
14
14
|
return (
|
|
15
15
|
<a class='url-button-attachment' href={'tel:' + button.phone_number} key={index} title={button.title}>
|
|
16
|
-
{button.title}
|
|
16
|
+
{this.props.t.i18n(button.i18n_title) || button.title}
|
|
17
17
|
</a>
|
|
18
18
|
)
|
|
19
19
|
}
|
|
@@ -21,7 +21,7 @@ export default class Buttons extends Com {
|
|
|
21
21
|
if (button.type === 'url_button') {
|
|
22
22
|
return (
|
|
23
23
|
<a class='url-button-attachment' href={button.url} target='_blank' key={index} title={button.title}>
|
|
24
|
-
{button.title || button.url}
|
|
24
|
+
{this.props.t.i18n(button.i18n_title) || button.title || button.url}
|
|
25
25
|
</a>
|
|
26
26
|
)
|
|
27
27
|
}
|
|
@@ -29,7 +29,7 @@ export default class Buttons extends Com {
|
|
|
29
29
|
if (button.type === 'postback_button') {
|
|
30
30
|
return (
|
|
31
31
|
<a class='url-button-attachment' href='javascript:;' onClick={(_) => this.props.onSelect(button)}>
|
|
32
|
-
{button.title}
|
|
32
|
+
{this.props.t.i18n(button.i18n_title) || button.title}
|
|
33
33
|
</a>
|
|
34
34
|
)
|
|
35
35
|
}
|
package/src/chatbox/Event.js
CHANGED
|
@@ -130,7 +130,7 @@ export default class Event extends Com {
|
|
|
130
130
|
<AudioAttachments store={this.props.store} ev={ev} />
|
|
131
131
|
<VideoAttachments store={this.props.store} ev={ev} />
|
|
132
132
|
<FileAttachments store={this.props.store} ev={ev} />
|
|
133
|
-
<ButtonAttachments store={this.props.store} ev={ev} />
|
|
133
|
+
<ButtonAttachments store={this.props.store} ev={ev} t={this.props.t}/>
|
|
134
134
|
<FormAttachments
|
|
135
135
|
store={this.props.store}
|
|
136
136
|
onSubmit={this.props.onFormSubmit}
|
|
@@ -139,7 +139,7 @@ export default class Event extends Com {
|
|
|
139
139
|
t={this.props.t}
|
|
140
140
|
/>
|
|
141
141
|
<FormSubmitAttachments store={this.props.store} ev={ev} t={this.props.t} />
|
|
142
|
-
<GenericTemplateAttachments store={this.props.store} ev={ev} onSelect={(e) => this.choosePostbackBtn(e)} />
|
|
142
|
+
<GenericTemplateAttachments store={this.props.store} ev={ev} onSelect={(e) => this.choosePostbackBtn(e)} t={this.props.t}/>
|
|
143
143
|
<ProductAttachments t={this.props.t} onPostback={(e) => this.choosePostbackBtn(e)} store={this.props.store} ev={ev} />
|
|
144
144
|
<OrderAttachments t={this.props.t} store={this.props.store} ev={ev} />
|
|
145
145
|
<QuickReplies store={this.props.store} ev={ev} onSelect={(e) => this.chooseQuickReply(e)} />
|
|
@@ -182,7 +182,7 @@ export default class Event extends Com {
|
|
|
182
182
|
<AudioAttachments store={this.props.store} ev={ev} />
|
|
183
183
|
<VideoAttachments store={this.props.store} ev={ev} />
|
|
184
184
|
<FileAttachments store={this.props.store} ev={ev} />
|
|
185
|
-
<ButtonAttachments store={this.props.store} ev={ev} />
|
|
185
|
+
<ButtonAttachments store={this.props.store} ev={ev} t={this.props.t}/>
|
|
186
186
|
<FormAttachments store={this.props.store} onSubmit={this.props.onFormSubmit} ref={this.refForm} ev={ev} />
|
|
187
187
|
<ProductAttachments t={this.props.t} store={this.props.store} ev={ev} />
|
|
188
188
|
<FormSubmitAttachments store={this.props.store} ev={ev} />
|
|
@@ -2,11 +2,11 @@ import Buttons from './Buttons.js'
|
|
|
2
2
|
import sb from '../util/index.js'
|
|
3
3
|
import Drag from './touchscroll'
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import {Com} from '../common.js'
|
|
6
|
+
import {h, createRef, Fragment} from 'preact'
|
|
7
7
|
|
|
8
8
|
export default class GenericTemplateAttachments extends Com {
|
|
9
|
-
constructor
|
|
9
|
+
constructor(props) {
|
|
10
10
|
super(props)
|
|
11
11
|
this.state = {
|
|
12
12
|
focusing: 0, // element index
|
|
@@ -15,39 +15,45 @@ export default class GenericTemplateAttachments extends Com {
|
|
|
15
15
|
this.galleryRef = createRef()
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
componentDidMount
|
|
18
|
+
componentDidMount() {
|
|
19
19
|
this.bindDrag()
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
focus
|
|
23
|
-
this.setState({
|
|
24
|
-
|
|
25
|
-
this.galleryRef.current.scrollLeft =
|
|
22
|
+
focus(eleindex) {
|
|
23
|
+
this.setState({focusing: eleindex})
|
|
24
|
+
this.galleryRef.current.scrollTo({left: 220 * eleindex, behavior: 'smooth'})
|
|
25
|
+
//this.galleryRef.current.scrollLeft = 220 * eleindex - 20
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
render
|
|
28
|
+
render() {
|
|
29
29
|
// dont support user sent button yet
|
|
30
30
|
let byType = sb.get(this.props.ev, 'by.type')
|
|
31
31
|
if (byType === 'user') return null
|
|
32
32
|
|
|
33
33
|
// filter out all generic
|
|
34
34
|
let attachments = sb.get(this.props.ev, 'data.message.attachments', [])
|
|
35
|
-
let generics = sb.filter(attachments, att => sb.get(att, 'type') === 'generic')
|
|
35
|
+
let generics = sb.filter(attachments, (att) => sb.get(att, 'type') === 'generic')
|
|
36
36
|
|
|
37
37
|
if (generics.length === 0) return null
|
|
38
38
|
var $generics = sb.map(generics, (gen, index) => {
|
|
39
|
-
var $eles = sb.map(gen.elements, ele => {
|
|
40
|
-
let
|
|
41
|
-
let
|
|
39
|
+
var $eles = sb.map(gen.elements, (ele) => {
|
|
40
|
+
let title = this.props.t.i18n(ele.i18n_title) || ele.title
|
|
41
|
+
let subtitle = this.props.t.i18n(ele.i18n_subtitle) || ele.subtitle
|
|
42
|
+
let $title = title ? <div class='generic-attachment--element-title'>{title}</div> : null
|
|
43
|
+
let $subtitle = subtitle ? <div class='generic-attachment--element-subtitle'>{subtitle}</div> : null
|
|
42
44
|
|
|
43
45
|
return (
|
|
44
|
-
<div class=
|
|
46
|
+
<div class='generic-attachment--element swiper-slide'>
|
|
45
47
|
<div>
|
|
46
|
-
<img
|
|
48
|
+
<img
|
|
49
|
+
alt='generic attachment element'
|
|
50
|
+
class='generic-attachment--element-img'
|
|
51
|
+
src={this.props.store.replaceFileUrl(ele.image_url)}
|
|
52
|
+
/>
|
|
47
53
|
</div>
|
|
48
54
|
{$title}
|
|
49
55
|
{$subtitle}
|
|
50
|
-
<Buttons buttons={ele.buttons} onSelect={button => this.props.onSelect(button)} />
|
|
56
|
+
<Buttons buttons={ele.buttons} onSelect={(button) => this.props.onSelect(button)} t={this.props.t} />
|
|
51
57
|
</div>
|
|
52
58
|
)
|
|
53
59
|
})
|
|
@@ -60,17 +66,17 @@ export default class GenericTemplateAttachments extends Com {
|
|
|
60
66
|
if (this.state.focusing === elements.length - 1) rightNavigatorCls += ' generic-attachment-navigator--disabled'
|
|
61
67
|
|
|
62
68
|
return (
|
|
63
|
-
<div class=
|
|
64
|
-
<div class=
|
|
69
|
+
<div class='generic-attachment-container'>
|
|
70
|
+
<div class='generic-attachment' ref={this.galleryRef}>
|
|
65
71
|
{$eles}
|
|
66
72
|
</div>
|
|
67
73
|
{!this.props.store.isMobile() && (
|
|
68
74
|
<Fragment>
|
|
69
|
-
<div class={leftNavigatorCls} onClick={_ => this.focus(this.state.focusing - 1)}>
|
|
70
|
-
<span class=
|
|
75
|
+
<div class={leftNavigatorCls} onClick={(_) => this.focus(this.state.focusing - 1)}>
|
|
76
|
+
<span class='generic-attachment-navigator-icon'>‹</span>
|
|
71
77
|
</div>
|
|
72
|
-
<div class={rightNavigatorCls} onClick={_ => this.focus(this.state.focusing + 1)}>
|
|
73
|
-
<span class=
|
|
78
|
+
<div class={rightNavigatorCls} onClick={(_) => this.focus(this.state.focusing + 1)}>
|
|
79
|
+
<span class='generic-attachment-navigator-icon'>›</span>
|
|
74
80
|
</div>
|
|
75
81
|
</Fragment>
|
|
76
82
|
)}
|
|
@@ -81,9 +87,9 @@ export default class GenericTemplateAttachments extends Com {
|
|
|
81
87
|
return $generics
|
|
82
88
|
}
|
|
83
89
|
|
|
84
|
-
bindDrag
|
|
90
|
+
bindDrag() {
|
|
85
91
|
if (!this.props.store.isMobile()) return
|
|
86
92
|
let eles = document.getElementsByClassName('generic-attachment')
|
|
87
|
-
sb.map(eles, ele => Drag(ele, () => {}))
|
|
93
|
+
sb.map(eles, (ele) => Drag(ele, () => {}))
|
|
88
94
|
}
|
|
89
95
|
}
|
|
@@ -33,7 +33,7 @@ export default class ProductAttachments extends Com {
|
|
|
33
33
|
</a>,
|
|
34
34
|
)
|
|
35
35
|
|
|
36
|
-
console.log(
|
|
36
|
+
console.log('P', product)
|
|
37
37
|
|
|
38
38
|
if (sb.size(product.buttons) > 0) {
|
|
39
39
|
$detailbtns = $detailbtns.concat(
|
|
@@ -41,7 +41,7 @@ export default class ProductAttachments extends Com {
|
|
|
41
41
|
if (button.type === 'call_button') {
|
|
42
42
|
return (
|
|
43
43
|
<a class='product_attachment__btn' href={'tel:' + button.phone_number} key={index} title={button.title}>
|
|
44
|
-
{button.title}
|
|
44
|
+
{this.props.t.i18n(button.i18n_title) || button.title}
|
|
45
45
|
</a>
|
|
46
46
|
)
|
|
47
47
|
}
|
|
@@ -49,7 +49,7 @@ export default class ProductAttachments extends Com {
|
|
|
49
49
|
if (button.type === 'url_button') {
|
|
50
50
|
return (
|
|
51
51
|
<a class='product_attachment__btn' href={button.url} target='_blank' key={index} title={button.title}>
|
|
52
|
-
{button.title || this.props.t('detail')}{' '}
|
|
52
|
+
{this.props.t.i18n(button.i18n_title) || button.title || this.props.t('detail')}{' '}
|
|
53
53
|
<img
|
|
54
54
|
src={require('../../assets/img/external-link.svg')}
|
|
55
55
|
class='product_attachment__btn_external_link'
|
|
@@ -61,7 +61,7 @@ export default class ProductAttachments extends Com {
|
|
|
61
61
|
if (button.type === 'postback_button') {
|
|
62
62
|
return (
|
|
63
63
|
<a class='product_attachment__btn' href='javascript:;' onClick={(_) => this.props.onPostback(button)}>
|
|
64
|
-
{button.title}
|
|
64
|
+
{this.props.t.i18n(button.i18n_title) || button.title}
|
|
65
65
|
</a>
|
|
66
66
|
)
|
|
67
67
|
}
|
package/src/lib.js
CHANGED
|
@@ -128,6 +128,11 @@ class Widget {
|
|
|
128
128
|
|
|
129
129
|
getUser = () => sb.parseJSON(sb.stringify(this.store.matchUser()))
|
|
130
130
|
|
|
131
|
+
setViewingProduct = (p) => this.store.linkProduct(p)
|
|
132
|
+
getViewingProduct = () => this.store.getLinkedProduct()
|
|
133
|
+
|
|
134
|
+
track = () => this.store.track()
|
|
135
|
+
|
|
131
136
|
async setLocale(locale) {
|
|
132
137
|
await this.domGate.entry()
|
|
133
138
|
return this.pluginMgr.setCurrentChatboxLocale(locale)
|
package/src/store/api.js
CHANGED
|
@@ -47,10 +47,7 @@ export default class {
|
|
|
47
47
|
.get('/conversations')
|
|
48
48
|
|
|
49
49
|
listMessages = (cid, limit, start_id) =>
|
|
50
|
-
this.apireq
|
|
51
|
-
.addQuery('limit', limit)
|
|
52
|
-
.addQuery('start_id', start_id)
|
|
53
|
-
.get(`/conversations/${cid}/messages`)
|
|
50
|
+
this.apireq.addQuery('limit', limit).addQuery('start_id', start_id).get(`/conversations/${cid}/messages`)
|
|
54
51
|
|
|
55
52
|
ajax = ajax
|
|
56
53
|
|
|
@@ -73,19 +70,28 @@ export default class {
|
|
|
73
70
|
sendEvent = (data) => this.apireq.post(`/users/${this.uid}/events`, data)
|
|
74
71
|
sendTyping = (cid) => this.apireq.post(`/conversations/${cid}/typing`)
|
|
75
72
|
|
|
76
|
-
sendPresence(device, is_focused)
|
|
77
|
-
|
|
73
|
+
sendPresence = (device, is_focused, productid, source_id, sku) =>
|
|
74
|
+
this.sendEvent({
|
|
78
75
|
by: {id: this.uid, device: device},
|
|
79
76
|
type: 'presence_updated',
|
|
80
|
-
data: {
|
|
77
|
+
data: {
|
|
78
|
+
presence: {
|
|
79
|
+
viewing_product_sku: sku,
|
|
80
|
+
viewing_product_source_id: source_id,
|
|
81
|
+
viewing_product_id: productid,
|
|
82
|
+
pinged: sb.Date.now(),
|
|
83
|
+
is_focused,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
81
86
|
})
|
|
82
|
-
}
|
|
83
87
|
|
|
84
|
-
|
|
88
|
+
sendContentView(device, pageUrl, pageTitle, id, source_id, sku) {
|
|
89
|
+
if (!id) id = undefined // dont accept ''
|
|
90
|
+
if (!source_id) source_id = undefined // dont accept ''
|
|
85
91
|
return this.sendEvent({
|
|
86
92
|
by: {id: this.uid, device: device},
|
|
87
93
|
type: 'content_viewed',
|
|
88
|
-
data: {product: {url: pageUrl, name: pageTitle, title: pageTitle}},
|
|
94
|
+
data: {product: {id: id, source_id: source_id, url: pageUrl, name: pageTitle, title: pageTitle, sku: sku}},
|
|
89
95
|
})
|
|
90
96
|
}
|
|
91
97
|
|
package/src/store/api_fake.js
CHANGED
|
@@ -112,22 +112,6 @@ function makeFakeConvo(accid, convoid, userid, agentid) {
|
|
|
112
112
|
id: inteid,
|
|
113
113
|
},
|
|
114
114
|
actived: 1610453070259,
|
|
115
|
-
last_event: {
|
|
116
|
-
id: 'evqyiykaoizbwnkaecwphttwk',
|
|
117
|
-
account_id: accid,
|
|
118
|
-
created: 1616213311830,
|
|
119
|
-
type: 'message_sent',
|
|
120
|
-
by: {id: userid, client_id: 'clsubizapi', type: 'user'},
|
|
121
|
-
data: {
|
|
122
|
-
message: {
|
|
123
|
-
conversation_id: convoid,
|
|
124
|
-
text: 'ok cám ơn!',
|
|
125
|
-
format: 'plaintext',
|
|
126
|
-
integration_id: inteid,
|
|
127
|
-
pongs: [{member_id: userid, type: 'seen', created: 1616213312110}],
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
115
|
last_message_sent: {
|
|
132
116
|
id: 'evqyiykaoizbwnkaecwphttwk',
|
|
133
117
|
account_id: accid,
|
package/src/store/store.js
CHANGED
|
@@ -45,7 +45,11 @@ export default class Store {
|
|
|
45
45
|
|
|
46
46
|
window.addEventListener('blur', () => this.sendPresence())
|
|
47
47
|
window.addEventListener('focus', () => this.sendPresence())
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
// faster send rate when has focus
|
|
50
|
+
setInterval(() => this.browserVisibility === 'visible' && document.hasFocus() && this.sendPresence(), 20000) // dont bother delete this
|
|
51
|
+
// slower send rate send when no focus
|
|
52
|
+
setInterval(() => (this.browserVisibility !== 'visible' || document.hasFocus()) && this.sendPresence(), 60000) // dont bother delete this
|
|
49
53
|
|
|
50
54
|
onVisibilityChange((val) => {
|
|
51
55
|
this.browserVisibility = val
|
|
@@ -75,6 +79,24 @@ export default class Store {
|
|
|
75
79
|
inmem = false
|
|
76
80
|
cookie = cookie
|
|
77
81
|
|
|
82
|
+
// inmem
|
|
83
|
+
_currentViewingProduct = {}
|
|
84
|
+
linkProduct(p) {
|
|
85
|
+
if (!p) {
|
|
86
|
+
this._currentViewingProduct = {}
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (p.id) this._currentViewingProduct.id = (p.id + '').trim()
|
|
91
|
+
if (p.source_id) this._currentViewingProduct.source_id = (p.source_id + '').trim()
|
|
92
|
+
if (p.sku) this._currentViewingProduct.sku = (p.sku + '').trim()
|
|
93
|
+
// call link product
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
getLinkedProduct() {
|
|
97
|
+
return sb.cloneDeep(this._currentViewingProduct)
|
|
98
|
+
}
|
|
99
|
+
|
|
78
100
|
isInsync(key) {
|
|
79
101
|
return sb.Date.now() - (this.g_sync[key] || 0) < 300000
|
|
80
102
|
}
|
|
@@ -297,7 +319,13 @@ export default class Store {
|
|
|
297
319
|
await this.readyGate.entry()
|
|
298
320
|
if (!sb.get(this.kv.match('user'), 'id')) return // store not init
|
|
299
321
|
if (sb.isUserBanned(this.kv.match('user'))) return
|
|
300
|
-
return this.api.sendPresence(
|
|
322
|
+
return this.api.sendPresence(
|
|
323
|
+
this.device,
|
|
324
|
+
this.browserVisibility === 'visible' && document.hasFocus(),
|
|
325
|
+
this._currentViewingProduct.id,
|
|
326
|
+
this._currentViewingProduct.source_id,
|
|
327
|
+
this._currentViewingProduct.sku,
|
|
328
|
+
)
|
|
301
329
|
}, 1000)
|
|
302
330
|
|
|
303
331
|
now = () => sb.Date.now() + this.timeDiff // millisecond on server
|
|
@@ -573,7 +601,14 @@ export default class Store {
|
|
|
573
601
|
// send the content view, the first presence and record domain
|
|
574
602
|
async track() {
|
|
575
603
|
let user = this.kv.match('user') || {}
|
|
576
|
-
await this.api.
|
|
604
|
+
await this.api.sendContentView(
|
|
605
|
+
this.device,
|
|
606
|
+
location.href,
|
|
607
|
+
document.title,
|
|
608
|
+
this._currentViewingProduct.id,
|
|
609
|
+
this._currentViewingProduct.source_id,
|
|
610
|
+
this._currentViewingProduct.sku,
|
|
611
|
+
)
|
|
577
612
|
this.sendPresence()
|
|
578
613
|
}
|
|
579
614
|
|
|
@@ -692,7 +727,6 @@ export default class Store {
|
|
|
692
727
|
if (ev.type !== 'message_pong' && ev.type !== 'conversation_typing') {
|
|
693
728
|
this.chain.put(cid, ev.id, sb.getMs(ev.created), ev)
|
|
694
729
|
}
|
|
695
|
-
convo.last_event = ev
|
|
696
730
|
this._setConvo(convo)
|
|
697
731
|
this.pubsub.publish('account')
|
|
698
732
|
}
|