@subiz/widget-v4 4.0.48 → 4.0.52
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/img/default.jpg +0 -0
- package/assets/img/external-link.svg +1 -0
- package/assets/less/message.less +210 -42
- package/compiled_src/chatbox/Event.js +22 -2
- package/compiled_src/chatbox/OrderAttachments.js +112 -0
- package/compiled_src/chatbox/ProductAttachments.js +79 -0
- package/compiled_src/chatbox/TextMessage.js +1 -1
- package/compiled_src/plugin.js +8 -2
- package/compiled_src/store/api.js +1 -0
- package/compiled_src/store/store.js +140 -0
- package/compiled_src/util/common.js +12 -1
- package/compiled_src/util/pubsub.js +6 -3
- package/dist/17d517e44e2.178.js +1 -0
- package/dist/17d517e44e2.213.js +1 -0
- package/dist/17d517e44e2.362.js +1 -0
- package/dist/17d517e44e2.441.js +1 -0
- package/dist/17d517e44e2.605.js +1 -0
- package/dist/17d517e44e2.619.js +1 -0
- package/dist/17d517e44e2.678.js +1 -0
- package/dist/17d517e44e2.74.js +1 -0
- package/dist/17d517e44e2.782.js +1 -0
- package/dist/17d517e44e2.app.js +1 -0
- package/dist/17d517e44e2.index.html +21 -0
- package/dist/17d517e44e2.library.html +21 -0
- package/dist/17d517e44e2.library.js +1 -0
- package/dist/17d517e44e2.preview.html +759 -0
- package/dist/17d517e44e2.preview.js +1 -0
- package/dist/HASH +1 -1
- 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/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/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/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/image_default.be0698b.png +0 -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/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/send.6db52a9.svg +3 -0
- package/dist/assets/img/subiz-mono.877e9f5.svg +3 -0
- package/package.json +18 -18
- package/src/chatbox/Event.js +72 -56
- package/src/chatbox/OrderAttachments.js +109 -0
- package/src/chatbox/ProductAttachments.js +70 -0
- package/src/chatbox/TextMessage.js +1 -1
- package/src/plugin.js +9 -4
- package/src/store/api.js +2 -5
- package/src/store/store.js +138 -8
- package/src/util/common.js +6 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M30 60C46.5685 60 60 46.5685 60 30C60 13.4315 46.5685 0 30 0C13.4315 0 0 13.4315 0 30C0 46.5685 13.4315 60 30 60Z" fill="#FCD063"/>
|
|
3
|
+
<path d="M49.249 7.00098C53.614 12.2116 56.2502 18.9204 56.2502 26.2497C56.2502 42.8173 42.8177 56.2498 26.2502 56.2498C18.9208 56.2498 12.2121 53.6135 7.00146 49.2485C12.5046 55.8185 20.7602 59.9998 30.0002 59.9998C46.5677 59.9998 60.0002 46.5673 60.0002 29.9997C60.0002 20.7597 55.819 12.5041 49.249 7.00098Z" fill="#F7B84E"/>
|
|
4
|
+
<path d="M40.2281 35.625H19.7719C19.2075 35.625 18.75 36.045 18.75 36.5625C18.75 42.2494 23.7956 46.875 30 46.875C36.2044 46.875 41.25 42.2494 41.25 36.5625C41.25 36.045 40.7925 35.625 40.2281 35.625Z" fill="#C98E3F"/>
|
|
5
|
+
<path d="M41.175 37.5C41.2087 37.1888 41.25 36.8813 41.25 36.5625C41.25 36.045 40.7925 35.625 40.2281 35.625H19.7719C19.2075 35.625 18.75 36.045 18.75 36.5625C18.75 36.8813 18.7912 37.1888 18.825 37.5H41.175Z" fill="#AB7934"/>
|
|
6
|
+
<path d="M18.75 30C20.8211 30 22.5 28.3211 22.5 26.25C22.5 24.1789 20.8211 22.5 18.75 22.5C16.6789 22.5 15 24.1789 15 26.25C15 28.3211 16.6789 30 18.75 30Z" fill="#C98E3F"/>
|
|
7
|
+
<path d="M18.75 24.375C20.4956 24.375 21.9488 25.5731 22.3669 27.1875C22.4456 26.8856 22.5 26.5763 22.5 26.25C22.5 24.18 20.82 22.5 18.75 22.5C16.68 22.5 15 24.18 15 26.25C15 26.5763 15.0544 26.8856 15.1331 27.1875C15.5513 25.5731 17.0044 24.375 18.75 24.375Z" fill="#AB7934"/>
|
|
8
|
+
<path d="M41.25 30C43.3211 30 45 28.3211 45 26.25C45 24.1789 43.3211 22.5 41.25 22.5C39.1789 22.5 37.5 24.1789 37.5 26.25C37.5 28.3211 39.1789 30 41.25 30Z" fill="#C98E3F"/>
|
|
9
|
+
<path d="M47.8125 35.625C49.3658 35.625 50.625 34.3658 50.625 32.8125C50.625 31.2592 49.3658 30 47.8125 30C46.2592 30 45 31.2592 45 32.8125C45 34.3658 46.2592 35.625 47.8125 35.625Z" fill="#F7B84E"/>
|
|
10
|
+
<path d="M12.1875 35.625C13.7408 35.625 15 34.3658 15 32.8125C15 31.2592 13.7408 30 12.1875 30C10.6342 30 9.375 31.2592 9.375 32.8125C9.375 34.3658 10.6342 35.625 12.1875 35.625Z" fill="#F7B84E"/>
|
|
11
|
+
<path d="M41.25 24.375C42.9956 24.375 44.4488 25.5731 44.8688 27.1875C44.9456 26.8856 45 26.5763 45 26.25C45 24.18 43.32 22.5 41.25 22.5C39.18 22.5 37.5 24.18 37.5 26.25C37.5 26.5763 37.5544 26.8856 37.6312 27.1875C38.0512 25.5731 39.5044 24.375 41.25 24.375Z" fill="#AB7934"/>
|
|
12
|
+
</svg>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M30 60C46.5685 60 60 46.5685 60 30C60 13.4315 46.5685 0 30 0C13.4315 0 0 13.4315 0 30C0 46.5685 13.4315 60 30 60Z" fill="#A7D544"/>
|
|
3
|
+
<path d="M49.2485 7.00098C53.6135 12.2116 56.2498 18.9204 56.2498 26.2497C56.2498 42.8173 42.8173 56.2498 26.2497 56.2498C18.9204 56.2498 12.2116 53.6135 7.00098 49.2485C12.5041 55.8185 20.7597 59.9998 29.9998 59.9998C46.5673 59.9998 59.9998 46.5673 59.9998 29.9997C59.9998 20.7597 55.8185 12.5041 49.2485 7.00098Z" fill="#88BB1A"/>
|
|
4
|
+
<path d="M47.0475 33.75H12.9544C12.0131 33.75 11.25 34.4494 11.25 35.3137C11.25 44.7919 19.6613 52.5 30 52.5C40.3387 52.5 48.75 44.7919 48.75 35.3137C48.75 34.4494 47.9887 33.75 47.0475 33.75Z" fill="#5BAA1D"/>
|
|
5
|
+
<path d="M48.6263 36.8737C48.6806 36.3581 48.75 35.8444 48.75 35.3137C48.75 34.4494 47.9887 33.75 47.0475 33.75H12.9544C12.0131 33.75 11.25 34.4494 11.25 35.3137C11.25 35.8444 11.3212 36.3581 11.3756 36.8737H48.6263Z" fill="#187E1B"/>
|
|
6
|
+
<path d="M49.6875 30C51.2408 30 52.5 28.7408 52.5 27.1875C52.5 25.6342 51.2408 24.375 49.6875 24.375C48.1342 24.375 46.875 25.6342 46.875 27.1875C46.875 28.7408 48.1342 30 49.6875 30Z" fill="#AFE881"/>
|
|
7
|
+
<path d="M10.3125 30C11.8658 30 13.125 28.7408 13.125 27.1875C13.125 25.6342 11.8658 24.375 10.3125 24.375C8.7592 24.375 7.5 25.6342 7.5 27.1875C7.5 28.7408 8.7592 30 10.3125 30Z" fill="#AFE881"/>
|
|
8
|
+
<path d="M45.1272 26.25C44.9322 26.25 44.7372 26.2012 44.5591 26.1037L41.2497 24.2887L37.9384 26.1037C37.5259 26.3306 37.0272 26.2912 36.6484 26.0062C36.2716 25.7194 36.0841 25.2337 36.1628 24.7556L36.7947 20.9175L34.1172 18.2006C33.7834 17.8594 33.6616 17.3512 33.8059 16.8862C33.9503 16.4231 34.3328 16.0856 34.7941 16.0162L38.4953 15.4556L40.1491 11.9625C40.3572 11.5256 40.7828 11.25 41.2497 11.25C41.7147 11.25 42.1403 11.5256 42.3466 11.9606L44.0022 15.4537L47.7035 16.0144C48.1628 16.0838 48.5453 16.4212 48.6897 16.8844C48.8341 17.3494 48.7141 17.8594 48.3766 18.1988L45.7028 20.9156L46.3347 24.7537C46.4135 25.2337 46.2222 25.7175 45.8491 26.0044C45.6353 26.1675 45.3803 26.25 45.1272 26.25Z" fill="#529F16"/>
|
|
9
|
+
<path d="M22.6273 26.25C22.4323 26.25 22.2373 26.2012 22.0591 26.1037L18.7498 24.2887L15.4385 26.1037C15.026 26.3306 14.5273 26.2912 14.1485 26.0062C13.7716 25.7194 13.5841 25.2337 13.6629 24.7556L14.2929 20.9175L11.6191 18.2006C11.2854 17.8594 11.1635 17.3494 11.3079 16.8844C11.4523 16.4212 11.8348 16.0838 12.2979 16.0144L15.9973 15.4537L17.651 11.9606C17.8573 11.5256 18.2829 11.25 18.7498 11.25C19.2148 11.25 19.6404 11.5256 19.8466 11.9606L21.5023 15.4537L25.2016 16.0144C25.6629 16.0838 26.0454 16.4212 26.1898 16.8844C26.3341 17.3494 26.2123 17.8594 25.8766 18.1988L23.2029 20.9156L23.8348 24.7537C23.9135 25.2337 23.7241 25.7175 23.3491 26.0044C23.1354 26.1675 22.8823 26.25 22.6273 26.25Z" fill="#529F16"/>
|
|
10
|
+
<path d="M14.2965 20.9155L13.6665 24.7537C13.6177 25.0518 13.7002 25.333 13.8371 25.5862L14.2965 22.7905V20.9155Z" fill="#187E1B"/>
|
|
11
|
+
<path d="M11.6491 18.2306C11.8291 18.0563 12.0466 17.9288 12.2979 17.8913L15.9973 17.3306L17.651 13.8375C17.8573 13.4006 18.2829 13.125 18.7498 13.125C19.2148 13.125 19.6404 13.4006 19.8466 13.8356L21.5023 17.3288L25.2016 17.8894C25.4529 17.9269 25.6685 18.0544 25.8466 18.2288L25.8766 18.1988C26.2123 17.8575 26.3341 17.3494 26.1898 16.8844C26.0454 16.4213 25.6629 16.0838 25.2016 16.0144L21.5023 15.4538L19.8466 11.9606C19.6404 11.5256 19.2148 11.25 18.7498 11.25C18.2829 11.25 17.8573 11.5256 17.651 11.9606L15.9973 15.4538L12.2979 16.0163C11.8348 16.0856 11.4523 16.4231 11.3079 16.8844C11.1635 17.3494 11.2854 17.8594 11.6191 18.1988L11.6491 18.2306Z" fill="#187E1B"/>
|
|
12
|
+
<path d="M23.2031 22.7905L23.6625 25.5843C23.8013 25.3312 23.8838 25.0518 23.835 24.7537L23.2031 20.9155V22.7905Z" fill="#187E1B"/>
|
|
13
|
+
<path d="M36.7964 20.9155L36.1645 24.7537C36.1158 25.0518 36.1983 25.333 36.3351 25.5862L36.7964 22.7905V20.9155Z" fill="#187E1B"/>
|
|
14
|
+
<path d="M34.1491 18.2306C34.3291 18.0563 34.5466 17.9269 34.7979 17.8894L38.4991 17.3288L40.1529 13.8356C40.3573 13.4006 40.7829 13.125 41.2498 13.125C41.7148 13.125 42.1404 13.4006 42.3466 13.8356L44.0023 17.3288L47.7035 17.8894C47.9529 17.9269 48.1685 18.0544 48.3485 18.2288L48.3785 18.1988C48.716 17.8575 48.836 17.3494 48.6916 16.8844C48.5473 16.4213 48.1648 16.0838 47.7054 16.0144L44.0041 15.4538L42.3485 11.9606C42.1404 11.5256 41.7148 11.25 41.2498 11.25C40.7829 11.25 40.3573 11.5256 40.151 11.9606L38.4973 15.4538L34.796 16.0144C34.3348 16.0838 33.9523 16.4213 33.8079 16.8844C33.6635 17.3494 33.7854 17.8594 34.1191 18.1988L34.1491 18.2306Z" fill="#187E1B"/>
|
|
15
|
+
<path d="M45.7031 22.7905L46.1625 25.5843C46.2994 25.3312 46.3838 25.0518 46.335 24.7537L45.7031 20.9155V22.7905Z" fill="#187E1B"/>
|
|
16
|
+
</svg>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M30 60C46.5685 60 60 46.5685 60 30C60 13.4315 46.5685 0 30 0C13.4315 0 0 13.4315 0 30C0 46.5685 13.4315 60 30 60Z" fill="#FC6363"/>
|
|
3
|
+
<path d="M49.249 7.00098C53.614 12.2116 56.2502 18.9204 56.2502 26.2497C56.2502 42.8173 42.8177 56.2498 26.2502 56.2498C18.9208 56.2498 12.2121 53.6135 7.00146 49.2485C12.5046 55.8185 20.7602 59.9998 30.0002 59.9998C46.5677 59.9998 60.0002 46.5673 60.0002 29.9997C60.0002 20.7597 55.819 12.5041 49.249 7.00098Z" fill="#E84242"/>
|
|
4
|
+
<path d="M38.1769 43.1254C37.6369 43.1254 37.0913 42.9942 36.5944 42.7186C33.0807 40.7742 26.9157 40.7742 23.4019 42.7186C21.9525 43.523 20.0644 43.0954 19.1888 41.7642C18.3132 40.4329 18.78 38.7023 20.2294 37.8979C25.7063 34.8661 34.2882 34.8661 39.765 37.8979C41.2144 38.7023 41.6813 40.4329 40.8057 41.7642C40.2319 42.6398 39.2175 43.1254 38.1769 43.1254Z" fill="#BD1F1F"/>
|
|
5
|
+
<path d="M18.75 31.875C20.8211 31.875 22.5 30.1961 22.5 28.125C22.5 26.0539 20.8211 24.375 18.75 24.375C16.6789 24.375 15 26.0539 15 28.125C15 30.1961 16.6789 31.875 18.75 31.875Z" fill="#BD1F1F"/>
|
|
6
|
+
<path d="M41.25 31.875C43.3211 31.875 45 30.1961 45 28.125C45 26.0539 43.3211 24.375 41.25 24.375C39.1789 24.375 37.5 26.0539 37.5 28.125C37.5 30.1961 39.1789 31.875 41.25 31.875Z" fill="#BD1F1F"/>
|
|
7
|
+
<path d="M20.2313 39.7749C25.7082 36.743 34.2901 36.743 39.7669 39.7749C40.4044 40.1293 40.8394 40.6655 41.0663 41.2655C41.5538 40.028 41.0401 38.6068 39.7669 37.8999C34.2901 34.868 25.7082 34.868 20.2313 37.8999C18.9563 38.6068 18.4444 40.028 18.9319 41.2655C19.1588 40.6655 19.5938 40.1293 20.2313 39.7749Z" fill="#982020"/>
|
|
8
|
+
<path d="M18.75 26.25C20.4956 26.25 21.9488 27.4481 22.3669 29.0625C22.4456 28.7606 22.5 28.4513 22.5 28.125C22.5 26.055 20.82 24.375 18.75 24.375C16.68 24.375 15 26.055 15 28.125C15 28.4513 15.0544 28.7606 15.1331 29.0625C15.5513 27.4481 17.0044 26.25 18.75 26.25Z" fill="#982020"/>
|
|
9
|
+
<path d="M41.25 26.25C42.9956 26.25 44.4488 27.4481 44.8688 29.0625C44.9456 28.7606 45 28.4513 45 28.125C45 26.055 43.32 24.375 41.25 24.375C39.18 24.375 37.5 26.055 37.5 28.125C37.5 28.4513 37.5544 28.7606 37.6312 29.0625C38.0512 27.4481 39.5044 26.25 41.25 26.25Z" fill="#982020"/>
|
|
10
|
+
<path d="M47.8125 37.5C49.3658 37.5 50.625 36.2408 50.625 34.6875C50.625 33.1342 49.3658 31.875 47.8125 31.875C46.2592 31.875 45 33.1342 45 34.6875C45 36.2408 46.2592 37.5 47.8125 37.5Z" fill="#FF9F9F"/>
|
|
11
|
+
<path d="M12.1875 37.5C13.7408 37.5 15 36.2408 15 34.6875C15 33.1342 13.7408 31.875 12.1875 31.875C10.6342 31.875 9.375 33.1342 9.375 34.6875C9.375 36.2408 10.6342 37.5 12.1875 37.5Z" fill="#FF9F9F"/>
|
|
12
|
+
</svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M24.9901 12.7278C24.9893 12.2942 24.7395 11.8965 24.3465 11.7119L9.2318 4.55228C8.82529 4.35897 8.34162 4.42739 8.00511 4.72571C7.66782 5.02482 7.54133 5.49497 7.68373 5.92375L9.50863 11.3953L17.5012 12.7278L9.50704 14.0603L7.68214 19.5318C7.54849 19.9375 7.65509 20.383 7.955 20.6829C7.9717 20.6996 7.98841 20.7147 8.00511 20.7298C8.34241 21.029 8.82529 21.0982 9.23339 20.9049L24.3481 13.7452C24.7395 13.5591 24.9901 13.1621 24.9901 12.7278Z" fill="white"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="21" height="15" viewBox="0 0 21 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M20.2176 15C18.4857 15 16.7537 15 15.0379 15C13.0955 15 11.1693 15 9.22689 15C8.35282 15 7.49492 14.8374 6.65322 14.6259C5.87626 14.4308 5.11549 14.1543 4.38709 13.7802C3.62632 13.3898 2.93029 12.9182 2.29901 12.3489C1.60298 11.7309 1.03645 11.0153 0.631786 10.2021C0.227119 9.38886 0.0166929 8.51059 0.000506273 7.58354C-0.0156804 6.29867 0.356612 5.14391 1.06882 4.103C1.73248 3.09463 2.62274 2.31395 3.6425 1.67964C4.67845 1.02908 5.81151 0.606207 6.99314 0.329716C7.6406 0.183339 8.28807 0.0857536 8.96791 0.0369611C9.37257 0.020697 9.77724 -0.0118315 10.1819 0.00443267C11.0236 0.0206968 11.8653 0.118282 12.6908 0.313452C13.6782 0.541151 14.6332 0.882698 15.5397 1.35436C16.2519 1.7447 16.9156 2.2001 17.5306 2.75308C18.2752 3.43617 18.8579 4.23312 19.2626 5.16018C19.4892 5.68063 19.6349 6.23361 19.7158 6.81912C19.8453 7.86003 19.6997 8.83588 19.3112 9.79547C19.0684 10.3972 18.7285 10.934 18.3238 11.4381C18.1943 11.6008 18.0648 11.7472 17.9353 11.8773C17.8706 11.9423 17.8544 11.9911 17.8867 12.0887C18.1457 12.9019 18.5504 13.6338 19.1817 14.2193C19.4245 14.447 19.6997 14.6585 20.0072 14.8048C20.0881 14.8374 20.1691 14.9024 20.25 14.9349C20.2338 14.9675 20.2338 14.9837 20.2176 15ZM12.8365 8.70576C13.2736 8.70576 13.7268 8.6895 14.1638 8.70576C14.3581 8.70576 14.3904 8.64071 14.3904 8.4618C14.3742 7.81124 14.3742 7.16067 14.3904 6.49384C14.3904 6.31493 14.3419 6.26614 14.1638 6.26614C13.2736 6.2824 12.3995 6.26614 11.5092 6.2824C11.2988 6.2824 11.2664 6.21735 11.2664 6.02218C11.2826 5.14391 11.2664 4.28191 11.2664 3.40364C11.2664 3.241 11.234 3.19221 11.056 3.19221C10.3761 3.20847 9.68012 3.20847 9.00028 3.19221C8.82223 3.19221 8.78986 3.25727 8.78986 3.40364C8.78986 4.28191 8.78986 5.16018 8.78986 6.03844C8.78986 6.21735 8.74129 6.26614 8.56324 6.26614C7.68916 6.24988 6.83127 6.26614 5.95719 6.24988C5.74677 6.24988 5.71439 6.31493 5.71439 6.5101C5.73058 7.16067 5.73058 7.79497 5.71439 8.44554C5.71439 8.62444 5.76295 8.6895 5.94101 8.6895C6.7989 8.67324 7.65679 8.6895 8.51468 8.67324C8.72511 8.67324 8.77367 8.73829 8.77367 8.93346C8.75748 9.81173 8.77367 10.6737 8.75748 11.552C8.75748 11.6984 8.78986 11.7472 8.95172 11.7472C9.63156 11.7309 10.3276 11.7309 11.0074 11.7472C11.1855 11.7472 11.2179 11.6821 11.2179 11.5195C11.2017 10.6412 11.2179 9.76294 11.2179 8.88467C11.2179 8.72203 11.2502 8.67324 11.4283 8.67324C11.9463 8.72203 12.3995 8.70576 12.8365 8.70576Z" fill="#ccc"/>
|
|
3
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subiz/widget-v4",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.52",
|
|
4
4
|
"main": "./compiled_src/lib.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npx webpack serve --config webpack.dev.js",
|
|
@@ -9,33 +9,33 @@
|
|
|
9
9
|
"lib": "rm -rf compiled_src && npx babel --out-dir=compiled_src src"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@babel/core": "^7.
|
|
12
|
+
"@babel/core": "^7.16.0",
|
|
13
13
|
"@googlemaps/js-api-loader": "^1.11.4",
|
|
14
|
-
"@subiz/ajax": "^3.0.
|
|
14
|
+
"@subiz/ajax": "^3.0.12",
|
|
15
15
|
"@subiz/flow": "^1.0.9",
|
|
16
16
|
"@subiz/storage": "0.0.8",
|
|
17
|
-
"@subiz/wsclient": "^3.1.
|
|
18
|
-
"babel-loader": "^8.2.
|
|
17
|
+
"@subiz/wsclient": "^3.1.7",
|
|
18
|
+
"babel-loader": "^8.2.3",
|
|
19
19
|
"cookie_js": "1.4.2",
|
|
20
|
-
"core-js": "^3.
|
|
20
|
+
"core-js": "^3.19.1",
|
|
21
21
|
"css-loader": "^5.2.6",
|
|
22
22
|
"file-loader": "^6.2.0",
|
|
23
23
|
"less": "^4.1.2",
|
|
24
|
-
"less-loader": "^10.0
|
|
25
|
-
"marked": "^
|
|
26
|
-
"preact": "^10.
|
|
24
|
+
"less-loader": "^10.2.0",
|
|
25
|
+
"marked": "^4.0.4",
|
|
26
|
+
"preact": "^10.6.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@babel/cli": "^7.
|
|
30
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
31
|
-
"@babel/plugin-transform-react-jsx": "^7.
|
|
32
|
-
"@babel/preset-env": "^7.
|
|
29
|
+
"@babel/cli": "^7.16.0",
|
|
30
|
+
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
31
|
+
"@babel/plugin-transform-react-jsx": "^7.16.0",
|
|
32
|
+
"@babel/preset-env": "^7.16.4",
|
|
33
33
|
"babel-plugin-syntax-jsx": "^6.18.0",
|
|
34
|
-
"html-webpack-plugin": "^5.
|
|
34
|
+
"html-webpack-plugin": "^5.5.0",
|
|
35
35
|
"prettier": "^2.4.1",
|
|
36
|
-
"webpack": "^5.
|
|
37
|
-
"webpack-bundle-analyzer": "^4.
|
|
38
|
-
"webpack-cli": "^4.9.
|
|
39
|
-
"webpack-dev-server": "^4.
|
|
36
|
+
"webpack": "^5.64.3",
|
|
37
|
+
"webpack-bundle-analyzer": "^4.5.0",
|
|
38
|
+
"webpack-cli": "^4.9.1",
|
|
39
|
+
"webpack-dev-server": "^4.5.0"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/chatbox/Event.js
CHANGED
|
@@ -6,6 +6,8 @@ import QuickReplies from './QuickReplies.js'
|
|
|
6
6
|
import FormAttachments from './FormAttachments.js'
|
|
7
7
|
import FormSubmitAttachments from './FormSubmitAttachments.js'
|
|
8
8
|
import GenericTemplateAttachments from './GenericTemplateAttachments.js'
|
|
9
|
+
import ProductAttachments from './ProductAttachments.js'
|
|
10
|
+
import OrderAttachments from './OrderAttachments.js'
|
|
9
11
|
//import FormSubmitAttachment from './formSubmitAttachment.js'
|
|
10
12
|
import VideoAttachments from './VideoAttachments.js'
|
|
11
13
|
import TextMessage from './TextMessage.js'
|
|
@@ -13,68 +15,72 @@ import InfoMessage from './InfoMessage.js' // message by system like convo join,
|
|
|
13
15
|
|
|
14
16
|
import sb from '../util/index.js'
|
|
15
17
|
import Time from './time.js'
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
+
import {Com} from '../common.js'
|
|
19
|
+
import {h, createRef} from 'preact'
|
|
18
20
|
|
|
19
21
|
// ['event'],
|
|
20
22
|
export default class Event extends Com {
|
|
21
|
-
constructor
|
|
23
|
+
constructor(props) {
|
|
22
24
|
super(props)
|
|
23
25
|
this.refForm = createRef()
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
render
|
|
28
|
+
render() {
|
|
27
29
|
var ev = sb.get(this.props.event, 'ev', {})
|
|
28
30
|
switch (ev.type) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
case 'conversation_joined':
|
|
32
|
+
// return this.renderMessageChatJoin()
|
|
33
|
+
break
|
|
34
|
+
case 'message_sent':
|
|
35
|
+
return this.renderMessageSent()
|
|
36
|
+
case 'conversation_state_updated':
|
|
37
|
+
case 'conversation_rating_requested':
|
|
38
|
+
case 'conversation_rated':
|
|
39
|
+
if (!sb.startsWith(ev.id, 'ev')) return null // don't show local msg (id == idempotency key)
|
|
40
|
+
return <InfoMessage t={this.props.t} store={this.props.store} ev={this.props.event} />
|
|
39
41
|
}
|
|
40
42
|
return null
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
focus
|
|
45
|
+
focus() {
|
|
44
46
|
this.refForm.current && this.refForm.current.focus()
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
chooseQuickReply
|
|
49
|
+
chooseQuickReply(reply) {
|
|
48
50
|
let ev = sb.get(this.props.event, 'ev', {})
|
|
49
|
-
let message = {
|
|
51
|
+
let message = {text: reply.title, format: 'plaintext'}
|
|
50
52
|
if (reply.payload) {
|
|
51
|
-
message.attachments = [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
message.attachments = [
|
|
54
|
+
{
|
|
55
|
+
type: 'postback',
|
|
56
|
+
postback: {
|
|
57
|
+
event_id: ev.id,
|
|
58
|
+
payload: reply.payload,
|
|
59
|
+
},
|
|
56
60
|
},
|
|
57
|
-
|
|
61
|
+
]
|
|
58
62
|
}
|
|
59
63
|
this.props.onSend(message)
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
choosePostbackBtn
|
|
66
|
+
choosePostbackBtn(button) {
|
|
63
67
|
let ev = sb.get(this.props.event, 'ev', {})
|
|
64
|
-
let message = {
|
|
68
|
+
let message = {text: button.title, format: 'plaintext'}
|
|
65
69
|
if (button.payload) {
|
|
66
|
-
message.attachments = [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
message.attachments = [
|
|
71
|
+
{
|
|
72
|
+
type: 'postback',
|
|
73
|
+
postback: {
|
|
74
|
+
event_id: ev.id,
|
|
75
|
+
payload: button.payload,
|
|
76
|
+
},
|
|
71
77
|
},
|
|
72
|
-
|
|
78
|
+
]
|
|
73
79
|
}
|
|
74
80
|
this.props.onSend(message)
|
|
75
81
|
}
|
|
76
82
|
|
|
77
|
-
renderAgentAvatar
|
|
83
|
+
renderAgentAvatar(ev) {
|
|
78
84
|
let bytype = sb.get(ev, 'by.type')
|
|
79
85
|
let byid = sb.get(ev, 'by.display_id', sb.get(ev, 'by.id'))
|
|
80
86
|
|
|
@@ -91,31 +97,32 @@ export default class Event extends Com {
|
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
return (
|
|
94
|
-
<div class=
|
|
95
|
-
<img alt=
|
|
96
|
-
<p class=
|
|
100
|
+
<div class='message-sender'>
|
|
101
|
+
<img alt='sender' class='message-sender-avatar' src={this.props.store.replaceFileUrl(uri)} />
|
|
102
|
+
<p class='message-sender-name'>{senderName}</p>
|
|
97
103
|
</div>
|
|
98
104
|
)
|
|
99
105
|
}
|
|
100
106
|
|
|
101
|
-
renderMessageSent
|
|
107
|
+
renderMessageSent() {
|
|
102
108
|
let ev = this.props.event.ev
|
|
103
109
|
|
|
104
110
|
var $time = null
|
|
105
111
|
if (this.props.event.show_time) {
|
|
106
112
|
$time = (
|
|
107
|
-
<div class=
|
|
113
|
+
<div class='convo-event-time'>
|
|
108
114
|
<Time time={ev.created} />
|
|
109
115
|
</div>
|
|
110
116
|
)
|
|
111
117
|
}
|
|
112
118
|
|
|
119
|
+
let t = new sb.Date(ev.created).toLocaleString()
|
|
113
120
|
// message of agent
|
|
114
121
|
if (sb.get(ev, 'by.type') !== 'user') {
|
|
115
122
|
let $sender = null
|
|
116
123
|
if (this.props.event.mode === 'lead') $sender = this.renderAgentAvatar(ev)
|
|
117
124
|
return (
|
|
118
|
-
<div class=
|
|
125
|
+
<div class='convo-event agent-message' title={t}>
|
|
119
126
|
{$time}
|
|
120
127
|
{$sender}
|
|
121
128
|
<TextMessage store={this.props.store} ev={ev} />
|
|
@@ -124,43 +131,51 @@ export default class Event extends Com {
|
|
|
124
131
|
<VideoAttachments store={this.props.store} ev={ev} />
|
|
125
132
|
<FileAttachments store={this.props.store} ev={ev} />
|
|
126
133
|
<ButtonAttachments store={this.props.store} ev={ev} />
|
|
127
|
-
<FormAttachments
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
<FormAttachments
|
|
135
|
+
store={this.props.store}
|
|
136
|
+
onSubmit={this.props.onFormSubmit}
|
|
137
|
+
ref={this.refForm}
|
|
138
|
+
ev={ev}
|
|
139
|
+
t={this.props.t}
|
|
140
|
+
/>
|
|
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)} />
|
|
143
|
+
<ProductAttachments t={this.props.t} store={this.props.store} ev={ev} />
|
|
144
|
+
<OrderAttachments t={this.props.t} store={this.props.store} ev={ev} />
|
|
145
|
+
<QuickReplies store={this.props.store} ev={ev} onSelect={(e) => this.chooseQuickReply(e)} />
|
|
131
146
|
</div>
|
|
132
147
|
)
|
|
133
148
|
}
|
|
134
149
|
|
|
135
150
|
if (sb.getMsgField(ev, 'idempotency') === ev.id && this.props.store.now() - ev.created < 900) {
|
|
136
|
-
setTimeout(() => this.setState({
|
|
151
|
+
setTimeout(() => this.setState({refresh: this.state.refresh}), 1000)
|
|
137
152
|
}
|
|
138
153
|
|
|
139
154
|
// only show sending while the message is send too long (>300ms) but haven't returned from
|
|
140
155
|
// the server
|
|
141
|
-
let $dot = <div class=
|
|
156
|
+
let $dot = <div class='sending_dot'></div>
|
|
142
157
|
if (this.props.store.now() - ev.created < 900 || sb.getMsgField(ev, 'idempotency') !== ev.id) {
|
|
143
|
-
$dot = <div class=
|
|
158
|
+
$dot = <div class='sending_dot sending_dot__hide'></div>
|
|
144
159
|
}
|
|
145
160
|
|
|
146
161
|
let $sender = null
|
|
147
|
-
if (this.props.event.mode === 'lead') $sender = <div class=
|
|
162
|
+
if (this.props.event.mode === 'lead') $sender = <div class='pt-3'></div>
|
|
148
163
|
|
|
149
164
|
let $error = null
|
|
150
165
|
if (ev._error && ev.type === 'message_sent') {
|
|
151
166
|
$error = (
|
|
152
|
-
<a class=
|
|
153
|
-
<div class=
|
|
154
|
-
<div class=
|
|
167
|
+
<a class='message_error' src='javascript:;' onClick={(e) => this.resendMessage()}>
|
|
168
|
+
<div class='message_error__text'>{this.props.t('error_send_message')}</div>
|
|
169
|
+
<div class='message_error__icon' />
|
|
155
170
|
</a>
|
|
156
171
|
)
|
|
157
172
|
}
|
|
158
173
|
|
|
159
174
|
return (
|
|
160
|
-
<div class=
|
|
175
|
+
<div class='convo-event user-message' title={t}>
|
|
161
176
|
{$time}
|
|
162
177
|
{$sender}
|
|
163
|
-
<div class=
|
|
178
|
+
<div class='message-user__container'>
|
|
164
179
|
{$dot}
|
|
165
180
|
<TextMessage store={this.props.store} ev={ev} refresh={this.state.refresh} />
|
|
166
181
|
<ImageAttachments store={this.props.store} ev={ev} />
|
|
@@ -169,6 +184,7 @@ export default class Event extends Com {
|
|
|
169
184
|
<FileAttachments store={this.props.store} ev={ev} />
|
|
170
185
|
<ButtonAttachments store={this.props.store} ev={ev} />
|
|
171
186
|
<FormAttachments store={this.props.store} onSubmit={this.props.onFormSubmit} ref={this.refForm} ev={ev} />
|
|
187
|
+
<ProductAttachments t={this.props.t} store={this.props.store} ev={ev} />
|
|
172
188
|
<FormSubmitAttachments store={this.props.store} ev={ev} />
|
|
173
189
|
</div>
|
|
174
190
|
{$error}
|
|
@@ -176,20 +192,20 @@ export default class Event extends Com {
|
|
|
176
192
|
)
|
|
177
193
|
}
|
|
178
194
|
|
|
179
|
-
renderUpdateConvo
|
|
195
|
+
renderUpdateConvo(ev) {
|
|
180
196
|
var state = sb.get(ev, 'data.conversation.state')
|
|
181
197
|
if (state === 'active') return null
|
|
182
198
|
if (state === 'pending') return null
|
|
183
|
-
return <div class=
|
|
199
|
+
return <div class='message-system'>{this.props.t('conversation_state_updated', {state})}</div>
|
|
184
200
|
}
|
|
185
201
|
|
|
186
|
-
resendMessage
|
|
202
|
+
resendMessage() {
|
|
187
203
|
let cid = sb.convoOfEv(this.props.event.ev)
|
|
188
204
|
const message = sb.get(this.props.event, 'ev.data.message')
|
|
189
|
-
this.props.store.sendConvoEvent(cid, 'message_sent', {
|
|
205
|
+
this.props.store.sendConvoEvent(cid, 'message_sent', {message})
|
|
190
206
|
}
|
|
191
207
|
|
|
192
|
-
getSenderName
|
|
208
|
+
getSenderName(ev) {
|
|
193
209
|
let bytype = sb.get(ev, 'by.type')
|
|
194
210
|
let byid = sb.get(ev, 'by.display_id', sb.get(ev, 'by.id'))
|
|
195
211
|
if (byid === 'system' || bytype === 'dummy') return 'system'
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import sb from '../util/index.js'
|
|
2
|
+
import {Com} from '../common.js'
|
|
3
|
+
import {h, createRef, Fragment} from 'preact'
|
|
4
|
+
|
|
5
|
+
export default class ProductAttachments extends Com {
|
|
6
|
+
render() {
|
|
7
|
+
let byType = sb.get(this.props.ev, 'by.type')
|
|
8
|
+
if (byType === 'user') return null
|
|
9
|
+
// filter out all generic
|
|
10
|
+
|
|
11
|
+
let acc = this.props.store.matchAccount()
|
|
12
|
+
var attachments = sb.get(this.props.ev, 'data.message.attachments', [])
|
|
13
|
+
let orders = sb.filter(attachments, (att) => att.type === 'order' && att.order).map((att) => att.order)
|
|
14
|
+
|
|
15
|
+
if (orders.length === 0) return null
|
|
16
|
+
|
|
17
|
+
let $orders = sb.map(orders, (order, index) => {
|
|
18
|
+
let $note = null
|
|
19
|
+
if (order.note) {
|
|
20
|
+
$note = (
|
|
21
|
+
<div>
|
|
22
|
+
<div class='order_attachment__label'>{this.props.t('note')}</div>
|
|
23
|
+
<div class='order_attachment__text_truncate'>{order.note}</div>
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let $products = null
|
|
29
|
+
if (sb.size(order.items) > 0) {
|
|
30
|
+
$products = (
|
|
31
|
+
<div>
|
|
32
|
+
<div class='order_attachment__label'>{this.props.t('product')}</div>
|
|
33
|
+
{sb.map(order.items, (item) => {
|
|
34
|
+
let product = item.product || {}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div class='order_attachment__product'>
|
|
38
|
+
<img
|
|
39
|
+
class='order_attachment__product_img'
|
|
40
|
+
src={(sb.get(product, 'images.0'), require('../../assets/img/default.jpg'))}
|
|
41
|
+
/>
|
|
42
|
+
<div style='overflow: hidden !important;'>
|
|
43
|
+
<div class='order_attachment__product_name'>{product.name}</div>
|
|
44
|
+
<div class='order_attachment__product_desc'>{product.description || product.long_description}</div>
|
|
45
|
+
<div class='order_attachment__product_desc'>
|
|
46
|
+
{this.props.t('qty')} {item.quantity} · {sb.formatCurrency(product.price)}
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
)
|
|
51
|
+
})}
|
|
52
|
+
</div>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let {total} = this.props.store.getOrderTotal(order)
|
|
57
|
+
|
|
58
|
+
let $total = (
|
|
59
|
+
<div class='order_attachment__footer'>
|
|
60
|
+
<div>{this.props.t('total')}</div>{' '}
|
|
61
|
+
<div>
|
|
62
|
+
<b>{sb.formatCurrency(total)}</b>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
let addr = sb.get(order, 'shipping.address', {})
|
|
68
|
+
let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter((a) => a).join(', ')
|
|
69
|
+
let address = fulladdr
|
|
70
|
+
|
|
71
|
+
let phoneattr = sb.find(sb.get(order, 'user.attributes', []), (attr) => attr.key === 'phones') || {
|
|
72
|
+
key: 'phones',
|
|
73
|
+
text: '',
|
|
74
|
+
}
|
|
75
|
+
let phone = sb.get(order, 'shipping.address.phone', '').trim()
|
|
76
|
+
phone = phone || sb.trim(phoneattr.text)
|
|
77
|
+
if (phone) phone = this.props.t('phn') + ': ' + phone
|
|
78
|
+
|
|
79
|
+
let $shipto = null
|
|
80
|
+
if (address || phone) {
|
|
81
|
+
$shipto = (
|
|
82
|
+
<div>
|
|
83
|
+
<div class='order_attachment__label'>{this.props.t('ship_to')}</div>
|
|
84
|
+
<div class='order_attachment__text_truncate'>{address}</div>
|
|
85
|
+
<div class='order_attachment__text_truncate'>{phone}</div>
|
|
86
|
+
</div>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div class={`order_attachment order_attachment__${byType}`}>
|
|
92
|
+
<div class='order_attachment__header'>
|
|
93
|
+
{this.props.t('order')}
|
|
94
|
+
<span class='order_attachment__text_muted order_attachment__text_sm'>#{order.id}</span>
|
|
95
|
+
</div>
|
|
96
|
+
{$products}
|
|
97
|
+
{$shipto}
|
|
98
|
+
<div>
|
|
99
|
+
<div class='order_attachment__label'>{this.props.t('payment')}</div>
|
|
100
|
+
<div>COD</div>
|
|
101
|
+
</div>
|
|
102
|
+
{$note}
|
|
103
|
+
{$total}
|
|
104
|
+
</div>
|
|
105
|
+
)
|
|
106
|
+
})
|
|
107
|
+
return $orders
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import sb from '../util/index.js'
|
|
2
|
+
import {Com} from '../common.js'
|
|
3
|
+
import {h, createRef, Fragment} from 'preact'
|
|
4
|
+
|
|
5
|
+
export default class ProductAttachments extends Com {
|
|
6
|
+
render() {
|
|
7
|
+
let byType = sb.get(this.props.ev, 'by.type')
|
|
8
|
+
if (byType === 'user') return null
|
|
9
|
+
// filter out all generic
|
|
10
|
+
let attachments = sb.get(this.props.ev, 'data.message.attachments', [])
|
|
11
|
+
let products = sb.filter(
|
|
12
|
+
attachments,
|
|
13
|
+
(att) => sb.get(att, 'type') === 'product' || sb.get(att, 'type') === 'product_preview',
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
products = products.filter((product) => product.product && product.product.name)
|
|
17
|
+
|
|
18
|
+
if (products.length === 0) return null
|
|
19
|
+
|
|
20
|
+
let acc = this.props.store.matchAccount()
|
|
21
|
+
|
|
22
|
+
let $products = sb.map(products, (att, index) => {
|
|
23
|
+
let product = att.product
|
|
24
|
+
|
|
25
|
+
let $detailbtn = null
|
|
26
|
+
let url = product.url || product.mobile_url
|
|
27
|
+
if (this.props.store.isMobile()) url = product.mobile_url || product.url
|
|
28
|
+
if (url)
|
|
29
|
+
$detailbtn = (
|
|
30
|
+
<a class='product_attachment__btn' href={url} target='_blank'>
|
|
31
|
+
{this.props.t('detail')}
|
|
32
|
+
<img src={require('../../assets/img/external-link.svg')} class='product_attachment__btn_external_link' />
|
|
33
|
+
</a>
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
let $title = (
|
|
37
|
+
<a href={url} class='product_attachment__title' target='_blank'>
|
|
38
|
+
{product.name}
|
|
39
|
+
</a>
|
|
40
|
+
)
|
|
41
|
+
let $subtitle = null
|
|
42
|
+
let desc = product.description || product.long_description
|
|
43
|
+
if (desc) $subtitle = <div class='product_attachment__subtitle'>{desc}</div>
|
|
44
|
+
|
|
45
|
+
let $price = null
|
|
46
|
+
if (product.price) {
|
|
47
|
+
$price = (
|
|
48
|
+
<div class='product_attachment__price'>
|
|
49
|
+
{product.currency || sb.get(acc, 'currency', '')} {sb.formatCurrency(product.price)}
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
return (
|
|
54
|
+
<div class={'product_attachment product_attachment__' + byType}>
|
|
55
|
+
<div>
|
|
56
|
+
<a href={this.props.store.replaceFileUrl(product.image)} target='_blank'>
|
|
57
|
+
<img class='product_attachment__img' src={this.props.store.replaceFileUrl(product.image)} />
|
|
58
|
+
</a>
|
|
59
|
+
</div>
|
|
60
|
+
{$title}
|
|
61
|
+
{$subtitle}
|
|
62
|
+
{$price}
|
|
63
|
+
<div class='product_attachment__btns'>{$detailbtn}</div>
|
|
64
|
+
</div>
|
|
65
|
+
)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
return $products
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -7,7 +7,7 @@ let marked = (obj, text) => {
|
|
|
7
7
|
|
|
8
8
|
const loadMarked = () => import(/*webpackChunkName: "marked" */ 'marked')
|
|
9
9
|
;(async () => {
|
|
10
|
-
let markedf = (await loadMarked()).
|
|
10
|
+
let markedf = (await loadMarked()).marked
|
|
11
11
|
marked = (obj, text) => markedf(text)
|
|
12
12
|
sb.map(mustrerender, obj => obj.forceUpdate())
|
|
13
13
|
mustrerender = []
|
package/src/plugin.js
CHANGED
|
@@ -29,7 +29,7 @@ function Plugin(plugin, store, $container, lib) {
|
|
|
29
29
|
|
|
30
30
|
this.getState = () => state
|
|
31
31
|
|
|
32
|
-
var run = async function() {
|
|
32
|
+
var run = async function () {
|
|
33
33
|
if (_destroy) return
|
|
34
34
|
if (state !== 'hold') return
|
|
35
35
|
|
|
@@ -370,10 +370,15 @@ function downloadLanguage(store, locale, force) {
|
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
const getLocale = (plugin, loc) => {
|
|
373
|
-
|
|
373
|
+
if (!loc) loc = ''
|
|
374
|
+
let found = sb.find(plugin.locales, (l) => l.toLowerCase().trim() === loc.toLowerCase().trim())
|
|
374
375
|
if (found) return loc
|
|
375
|
-
found = sb.find(plugin.locales, (l) => (l || '').toLowerCase().includes(loc.toLowerCase()))
|
|
376
|
-
if (found) return found
|
|
377
376
|
|
|
377
|
+
found = sb.find(plugin.locales, (l) => {
|
|
378
|
+
l = l.replace('-', '_').split('_')[0].trim().toLowerCase()
|
|
379
|
+
let compareloc = loc.replace('-', '_').split('_')[0].trim().toLowerCase()
|
|
380
|
+
return l == compareloc
|
|
381
|
+
})
|
|
382
|
+
if (found) return found
|
|
378
383
|
return plugin.locale || 'en-US'
|
|
379
384
|
}
|
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
|
|
|
@@ -85,7 +82,7 @@ export default class {
|
|
|
85
82
|
return this.sendEvent({
|
|
86
83
|
by: {id: this.uid, device: device},
|
|
87
84
|
type: 'content_viewed',
|
|
88
|
-
data: {product: {url: pageUrl, title: pageTitle}},
|
|
85
|
+
data: {product: {url: pageUrl, name: pageTitle, title: pageTitle}},
|
|
89
86
|
})
|
|
90
87
|
}
|
|
91
88
|
|