beem-component 2.0.21 → 2.0.22
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.
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = exports.RepliedTextWrapper = exports.MessageState = exports.BmImageWrapper = exports.BmImageChat = exports.BmImage = void 0;
|
|
7
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
9
|
var _icons = require("@material-ui/icons");
|
|
9
10
|
var _FilePresent = _interopRequireDefault(require("@mui/icons-material/FilePresent"));
|
|
10
11
|
var _Download = _interopRequireDefault(require("@mui/icons-material/Download"));
|
|
@@ -24,6 +25,14 @@ var _excluded = ["state", "file", "src", "fileName", "onDownload", "extension",
|
|
|
24
25
|
_excluded2 = ["state", "src", "extensions", "fileName"],
|
|
25
26
|
_excluded3 = ["children", "state", "displayTime", "status", "session", "src", "file", "fileName", "sessionDetails", "sessionTimeline", "feedPostComments", "agentName", "metadata", "isInteractive", "type", "extension"];
|
|
26
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
30
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
31
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
32
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
33
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
34
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
35
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
27
36
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
28
37
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
29
38
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -149,6 +158,9 @@ var OrderBody = _styledComponents.default.button.withConfig({
|
|
|
149
158
|
}
|
|
150
159
|
return "".concat(_colors.BmPrimaryWhite);
|
|
151
160
|
});
|
|
161
|
+
var ProductImage = _styledComponents.default.img.withConfig({
|
|
162
|
+
displayName: "chatBody__ProductImage"
|
|
163
|
+
})(["width:50px;height:50px;border-radius:50%;padding:5px;"]);
|
|
152
164
|
var CartContent = _styledComponents.default.div.withConfig({
|
|
153
165
|
displayName: "chatBody__CartContent"
|
|
154
166
|
})(["margin-bottom:0.5rem;display:flex;flex-direction:row;align-items:center;justify-content:center;color:", ";"], function (_ref12) {
|
|
@@ -403,7 +415,12 @@ var OrderRender = function OrderRender(_ref29) {
|
|
|
403
415
|
var count = _ref29.count,
|
|
404
416
|
amount = _ref29.amount,
|
|
405
417
|
type = _ref29.type,
|
|
406
|
-
state = _ref29.state
|
|
418
|
+
state = _ref29.state,
|
|
419
|
+
items = _ref29.items;
|
|
420
|
+
var _useState = (0, _react.useState)(false),
|
|
421
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
422
|
+
displayItems = _useState2[0],
|
|
423
|
+
setDisplayItems = _useState2[1];
|
|
407
424
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Messages, {
|
|
408
425
|
type: type,
|
|
409
426
|
state: state
|
|
@@ -413,9 +430,29 @@ var OrderRender = function OrderRender(_ref29) {
|
|
|
413
430
|
state: state
|
|
414
431
|
}, /*#__PURE__*/_react.default.createElement(_ShoppingCartOutlined.default, {
|
|
415
432
|
fontSize: "small"
|
|
416
|
-
}), /*#__PURE__*/_react.default.createElement("h5", null, /*#__PURE__*/_react.default.createElement("strong", null, count, " items"))),
|
|
433
|
+
}), /*#__PURE__*/_react.default.createElement("h5", null, /*#__PURE__*/_react.default.createElement("strong", null, count, " items")))), displayItems ? /*#__PURE__*/_react.default.createElement(OrderBody, {
|
|
417
434
|
state: state
|
|
418
|
-
},
|
|
435
|
+
}, items.map(function (data, index) {
|
|
436
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(CartContent, {
|
|
437
|
+
state: state
|
|
438
|
+
}, /*#__PURE__*/_react.default.createElement("p", null, index + 1, ". "), /*#__PURE__*/_react.default.createElement(ProductImage, {
|
|
439
|
+
src: data.imgURL,
|
|
440
|
+
alt: "product"
|
|
441
|
+
}), /*#__PURE__*/_react.default.createElement("p", null, data.description, " @ ", data.currency, " ", data.amount)), /*#__PURE__*/_react.default.createElement("hr", {
|
|
442
|
+
style: {
|
|
443
|
+
width: '100%'
|
|
444
|
+
}
|
|
445
|
+
}));
|
|
446
|
+
})) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null), /*#__PURE__*/_react.default.createElement(OrderBody, {
|
|
447
|
+
state: state
|
|
448
|
+
}, /*#__PURE__*/_react.default.createElement(CartContent, {
|
|
449
|
+
state: state
|
|
450
|
+
}, /*#__PURE__*/_react.default.createElement("p", null, amount, " (Estimated Total)"))), /*#__PURE__*/_react.default.createElement(IntButton, {
|
|
451
|
+
state: state,
|
|
452
|
+
onClick: function onClick() {
|
|
453
|
+
setDisplayItems(!displayItems);
|
|
454
|
+
}
|
|
455
|
+
}, /*#__PURE__*/_react.default.createElement("p", null, displayItems ? 'HIDE' : 'SHOW', " CART ITEMS"))));
|
|
419
456
|
};
|
|
420
457
|
BmChat.Details = function (_ref30) {
|
|
421
458
|
var children = _ref30.children,
|
package/package.json
CHANGED
package/src/App.js
CHANGED
|
@@ -745,6 +745,134 @@ const Chat = () => {
|
|
|
745
745
|
// setCheckboxVisibility(updatedVisibility); // Update the state
|
|
746
746
|
// };
|
|
747
747
|
|
|
748
|
+
const renderOrderJsonMessage = () => {
|
|
749
|
+
const parsedMessage = {
|
|
750
|
+
dotgoV2: {
|
|
751
|
+
type: 'order',
|
|
752
|
+
catalog: {
|
|
753
|
+
id: '1828458897997668',
|
|
754
|
+
order: {
|
|
755
|
+
items: [
|
|
756
|
+
{
|
|
757
|
+
id: '147',
|
|
758
|
+
currency: 'USD',
|
|
759
|
+
amount: '960',
|
|
760
|
+
quantity: '1',
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
id: '144',
|
|
764
|
+
currency: 'USD',
|
|
765
|
+
amount: '505',
|
|
766
|
+
quantity: '1',
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
id: '145',
|
|
770
|
+
currency: 'USD',
|
|
771
|
+
amount: '505',
|
|
772
|
+
quantity: '1',
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
id: '148',
|
|
776
|
+
currency: 'USD',
|
|
777
|
+
amount: '505',
|
|
778
|
+
quantity: '1',
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
id: '149',
|
|
782
|
+
currency: 'USD',
|
|
783
|
+
amount: '505',
|
|
784
|
+
quantity: '1',
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
id: '146',
|
|
788
|
+
currency: 'USD',
|
|
789
|
+
amount: '960',
|
|
790
|
+
quantity: '1',
|
|
791
|
+
},
|
|
792
|
+
],
|
|
793
|
+
},
|
|
794
|
+
},
|
|
795
|
+
forwarded: false,
|
|
796
|
+
frequently_forwarded: false,
|
|
797
|
+
},
|
|
798
|
+
};
|
|
799
|
+
const dotGoV2Content = parsedMessage?.dotgoV2;
|
|
800
|
+
const items = dotGoV2Content?.catalog?.order?.items || [];
|
|
801
|
+
if (items.length === 0) {
|
|
802
|
+
return { amount: 0, type: 'order', count: 0 };
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
const totalValue = items.reduce((total, item) => {
|
|
806
|
+
return total + item.amount * item.quantity;
|
|
807
|
+
}, 0);
|
|
808
|
+
|
|
809
|
+
const currency = items[0]?.currency || '';
|
|
810
|
+
const count = items.length;
|
|
811
|
+
const formattedTotal = totalValue.toLocaleString('en-US');
|
|
812
|
+
|
|
813
|
+
return {
|
|
814
|
+
amount: `${currency} ${formattedTotal}`,
|
|
815
|
+
type: 'order',
|
|
816
|
+
count,
|
|
817
|
+
items: [
|
|
818
|
+
{
|
|
819
|
+
id: 147,
|
|
820
|
+
currency: 'USD',
|
|
821
|
+
amount: '960',
|
|
822
|
+
quantity: '1',
|
|
823
|
+
description: '18" Zuri Wig Straight Miss Van Platinum Blonde',
|
|
824
|
+
imgURL:
|
|
825
|
+
'https://bm-chatbot-images.s3.eu-west-1.amazonaws.com/Miss Van.jpg',
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
id: 144,
|
|
829
|
+
currency: 'USD',
|
|
830
|
+
amount: '505',
|
|
831
|
+
quantity: '1',
|
|
832
|
+
description: '10" Zuri Wig Straight Mirna Caramel Brown',
|
|
833
|
+
imgURL:
|
|
834
|
+
'https://bm-chatbot-images.s3.eu-west-1.amazonaws.com/Wig Mirna.jpg',
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
id: 145,
|
|
838
|
+
currency: 'USD',
|
|
839
|
+
amount: '505',
|
|
840
|
+
quantity: '1',
|
|
841
|
+
description: '20" Zuri Wig Straight Mirna Caramel Brown',
|
|
842
|
+
imgURL:
|
|
843
|
+
'https://bm-chatbot-images.s3.eu-west-1.amazonaws.com/Wig Mirna.jpg',
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
id: 148,
|
|
847
|
+
currency: 'USD',
|
|
848
|
+
amount: '505',
|
|
849
|
+
quantity: '1',
|
|
850
|
+
description: '10" Zuri Wig Straight Monroe Platinum Blonde',
|
|
851
|
+
imgURL:
|
|
852
|
+
'https://bm-chatbot-images.s3.eu-west-1.amazonaws.com/monroe-wig-14.jpg',
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
id: 149,
|
|
856
|
+
currency: 'USD',
|
|
857
|
+
amount: '505',
|
|
858
|
+
quantity: '1',
|
|
859
|
+
description: '14" Zuri Wig Straight Monroe Platinum Blonde',
|
|
860
|
+
imgURL:
|
|
861
|
+
'https://bm-chatbot-images.s3.eu-west-1.amazonaws.com/monroe-wig-14.jpg',
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
id: 146,
|
|
865
|
+
currency: 'USD',
|
|
866
|
+
amount: '960',
|
|
867
|
+
quantity: '1',
|
|
868
|
+
description: '14" Zuri Wig Straight Miss Van Platinum Blonde',
|
|
869
|
+
imgURL:
|
|
870
|
+
'https://bm-chatbot-images.s3.eu-west-1.amazonaws.com/Miss Van.jpg',
|
|
871
|
+
},
|
|
872
|
+
],
|
|
873
|
+
};
|
|
874
|
+
};
|
|
875
|
+
|
|
748
876
|
const renderJsonMessagex = () => {
|
|
749
877
|
const parsedMessage = JSON.parse(x.metadata.prev_message);
|
|
750
878
|
const dotGoV2Content = parsedMessage?.dotgoV2;
|
|
@@ -765,6 +893,18 @@ const Chat = () => {
|
|
|
765
893
|
<GlobalStyle />
|
|
766
894
|
|
|
767
895
|
<div>
|
|
896
|
+
<BmChat.Details
|
|
897
|
+
key={85279}
|
|
898
|
+
state="inbound"
|
|
899
|
+
session="bot"
|
|
900
|
+
displayTime={<p>12:00pm</p>}
|
|
901
|
+
status="sent"
|
|
902
|
+
type="interactive"
|
|
903
|
+
sessionTimeline={{ message: <p>12:00pm</p> }}
|
|
904
|
+
style={{ margin: '-0.6% 0 0 0' }}
|
|
905
|
+
>
|
|
906
|
+
{renderOrderJsonMessage()}
|
|
907
|
+
</BmChat.Details>
|
|
768
908
|
<BmChat.Details
|
|
769
909
|
state="outbound"
|
|
770
910
|
session="bot"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
2
|
/* eslint-disable react/display-name */
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
4
|
import { Done, DoneAll } from '@material-ui/icons';
|
|
5
5
|
import FilePresentIcon from '@mui/icons-material/FilePresent';
|
|
6
6
|
import DownloadIcon from '@mui/icons-material/Download';
|
|
@@ -192,6 +192,13 @@ const OrderBody = styled.button`
|
|
|
192
192
|
}};
|
|
193
193
|
}
|
|
194
194
|
`;
|
|
195
|
+
|
|
196
|
+
const ProductImage = styled.img`
|
|
197
|
+
width: 50px;
|
|
198
|
+
height: 50px;
|
|
199
|
+
border-radius: 50%;
|
|
200
|
+
padding: 5px;
|
|
201
|
+
`;
|
|
195
202
|
const CartContent = styled.div`
|
|
196
203
|
margin-bottom: 0.5rem;
|
|
197
204
|
display: flex;
|
|
@@ -480,7 +487,8 @@ const ListReplyRender = ({
|
|
|
480
487
|
);
|
|
481
488
|
};
|
|
482
489
|
|
|
483
|
-
const OrderRender = ({ count, amount, type, state }) => {
|
|
490
|
+
const OrderRender = ({ count, amount, type, state, items }) => {
|
|
491
|
+
const [displayItems, setDisplayItems] = useState(false);
|
|
484
492
|
return (
|
|
485
493
|
<>
|
|
486
494
|
<Messages type={type} state={state}>
|
|
@@ -491,10 +499,40 @@ const OrderRender = ({ count, amount, type, state }) => {
|
|
|
491
499
|
<strong>{count} items</strong>
|
|
492
500
|
</h5>
|
|
493
501
|
</CartContent>
|
|
494
|
-
<div>{amount} (estimated total)</div>
|
|
495
502
|
</OrderBody>
|
|
496
503
|
|
|
497
|
-
|
|
504
|
+
{displayItems ? (
|
|
505
|
+
<OrderBody state={state}>
|
|
506
|
+
{items.map((data, index) => (
|
|
507
|
+
<>
|
|
508
|
+
<CartContent state={state}>
|
|
509
|
+
<p>{index + 1}. </p>
|
|
510
|
+
<ProductImage src={data.imgURL} alt="product" />
|
|
511
|
+
|
|
512
|
+
<p>
|
|
513
|
+
{data.description} @ {data.currency} {data.amount}
|
|
514
|
+
</p>
|
|
515
|
+
</CartContent>
|
|
516
|
+
<hr style={{ width: '100%' }} />
|
|
517
|
+
</>
|
|
518
|
+
))}
|
|
519
|
+
</OrderBody>
|
|
520
|
+
) : (
|
|
521
|
+
<></>
|
|
522
|
+
)}
|
|
523
|
+
<OrderBody state={state}>
|
|
524
|
+
<CartContent state={state}>
|
|
525
|
+
<p>{amount} (Estimated Total)</p>
|
|
526
|
+
</CartContent>
|
|
527
|
+
</OrderBody>
|
|
528
|
+
<IntButton
|
|
529
|
+
state={state}
|
|
530
|
+
onClick={() => {
|
|
531
|
+
setDisplayItems(!displayItems);
|
|
532
|
+
}}
|
|
533
|
+
>
|
|
534
|
+
<p>{displayItems ? 'HIDE' : 'SHOW'} CART ITEMS</p>
|
|
535
|
+
</IntButton>
|
|
498
536
|
</Messages>
|
|
499
537
|
</>
|
|
500
538
|
);
|