beem-component 2.0.13 → 2.0.14
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.
|
@@ -19,7 +19,7 @@ var _colors = require("../../colors");
|
|
|
19
19
|
var _FeedPostComments = require("./FeedPostComments");
|
|
20
20
|
var _excluded = ["state", "file", "src", "fileName", "onDownload", "link"],
|
|
21
21
|
_excluded2 = ["state", "src", "fileName"],
|
|
22
|
-
_excluded3 = ["children", "state", "displayTime", "status", "session", "src", "file", "fileName", "sessionDetails", "sessionTimeline", "feedPostComments", "agentName", "metadata", "type"];
|
|
22
|
+
_excluded3 = ["children", "state", "displayTime", "status", "session", "src", "file", "fileName", "sessionDetails", "sessionTimeline", "feedPostComments", "agentName", "metadata", "isInteractive", "type"];
|
|
23
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
24
|
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); }
|
|
25
25
|
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; }
|
|
@@ -50,8 +50,9 @@ var MessageDetails = _styledComponents.default.div.withConfig({
|
|
|
50
50
|
var Messages = _styledComponents.default.div.withConfig({
|
|
51
51
|
displayName: "chatBody__Messages"
|
|
52
52
|
})(["display:flex;flex-direction:", ";align-items:", ";padding:1rem 0.5rem;background:", ";color:", ";border-radius:", ";border-left:", ";border:", ";word-break:break-word;margin:0rem;"], function (_ref2) {
|
|
53
|
-
var type = _ref2.type
|
|
54
|
-
|
|
53
|
+
var type = _ref2.type,
|
|
54
|
+
isInteractive = _ref2.isInteractive;
|
|
55
|
+
if (type === 'interactive' || isInteractive) {
|
|
55
56
|
return 'column';
|
|
56
57
|
}
|
|
57
58
|
return 'row';
|
|
@@ -306,7 +307,7 @@ var RepliedTextWrapper = _styledComponents.default.div.withConfig({
|
|
|
306
307
|
});
|
|
307
308
|
exports.RepliedTextWrapper = RepliedTextWrapper;
|
|
308
309
|
BmChat.Details = function (_ref23) {
|
|
309
|
-
var _children$content, _children$content2, _children$content3, _children$content4, _children$content5, _children$options, _children$globalButto;
|
|
310
|
+
var _metadata$content, _metadata$content2, _metadata$content3, _metadata$content4, _metadata$content5, _metadata$options, _metadata$globalButto, _children$content, _children$content2, _children$content3, _children$content4, _children$content5, _children$options, _children$globalButto;
|
|
310
311
|
var children = _ref23.children,
|
|
311
312
|
state = _ref23.state,
|
|
312
313
|
displayTime = _ref23.displayTime,
|
|
@@ -320,6 +321,7 @@ BmChat.Details = function (_ref23) {
|
|
|
320
321
|
feedPostComments = _ref23.feedPostComments,
|
|
321
322
|
agentName = _ref23.agentName,
|
|
322
323
|
metadata = _ref23.metadata,
|
|
324
|
+
isInteractive = _ref23.isInteractive,
|
|
323
325
|
type = _ref23.type,
|
|
324
326
|
rest = _objectWithoutProperties(_ref23, _excluded3);
|
|
325
327
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Details, _extends({
|
|
@@ -336,14 +338,36 @@ BmChat.Details = function (_ref23) {
|
|
|
336
338
|
fileName: fileName
|
|
337
339
|
}, rest)), children && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, metadata ? /*#__PURE__*/_react.default.createElement(RepliedTextWrapper, {
|
|
338
340
|
state: state
|
|
339
|
-
}, /*#__PURE__*/_react.default.createElement(Messages, {
|
|
341
|
+
}, metadata.type === 'quick_reply' ? /*#__PURE__*/_react.default.createElement(Messages, {
|
|
342
|
+
isInteractive: isInteractive,
|
|
343
|
+
type: type,
|
|
344
|
+
state: state,
|
|
345
|
+
isImg: true
|
|
346
|
+
}, (metadata === null || metadata === void 0 ? void 0 : (_metadata$content = metadata.content) === null || _metadata$content === void 0 ? void 0 : _metadata$content.url) && /*#__PURE__*/_react.default.createElement(BmImageChat, _extends({
|
|
347
|
+
state: state,
|
|
348
|
+
src: metadata === null || metadata === void 0 ? void 0 : (_metadata$content2 = metadata.content) === null || _metadata$content2 === void 0 ? void 0 : _metadata$content2.url
|
|
349
|
+
}, rest)), /*#__PURE__*/_react.default.createElement("strong", null, metadata === null || metadata === void 0 ? void 0 : (_metadata$content3 = metadata.content) === null || _metadata$content3 === void 0 ? void 0 : _metadata$content3.header), /*#__PURE__*/_react.default.createElement("p", null, metadata === null || metadata === void 0 ? void 0 : (_metadata$content4 = metadata.content) === null || _metadata$content4 === void 0 ? void 0 : _metadata$content4.text), /*#__PURE__*/_react.default.createElement("small", null, metadata === null || metadata === void 0 ? void 0 : (_metadata$content5 = metadata.content) === null || _metadata$content5 === void 0 ? void 0 : _metadata$content5.caption), metadata === null || metadata === void 0 ? void 0 : (_metadata$options = metadata.options) === null || _metadata$options === void 0 ? void 0 : _metadata$options.map(function (button) {
|
|
350
|
+
return (
|
|
351
|
+
/*#__PURE__*/
|
|
352
|
+
// eslint-disable-next-line react/jsx-key
|
|
353
|
+
_react.default.createElement(IntButton, {
|
|
354
|
+
state: state
|
|
355
|
+
}, button === null || button === void 0 ? void 0 : button.title)
|
|
356
|
+
);
|
|
357
|
+
})) : metadata.type === 'quick_reply' ? /*#__PURE__*/_react.default.createElement(Messages, {
|
|
358
|
+
isInteractive: isInteractive,
|
|
359
|
+
type: type,
|
|
360
|
+
state: state
|
|
361
|
+
}, /*#__PURE__*/_react.default.createElement("strong", null, metadata === null || metadata === void 0 ? void 0 : metadata.title), /*#__PURE__*/_react.default.createElement("p", null, metadata === null || metadata === void 0 ? void 0 : metadata.body), /*#__PURE__*/_react.default.createElement(IntButton, {
|
|
362
|
+
state: state
|
|
363
|
+
}, /*#__PURE__*/_react.default.createElement(_List.default, null), metadata === null || metadata === void 0 ? void 0 : (_metadata$globalButto = metadata.globalButtons[0]) === null || _metadata$globalButto === void 0 ? void 0 : _metadata$globalButto.title)) : /*#__PURE__*/_react.default.createElement(Messages, {
|
|
340
364
|
metadata: metadata,
|
|
341
365
|
state: state
|
|
342
366
|
}, metadata), children) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, type && type === 'interactive' ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children.type === 'quick_reply' ? /*#__PURE__*/_react.default.createElement(Messages, {
|
|
343
367
|
type: type,
|
|
344
368
|
state: state,
|
|
345
369
|
isImg: true
|
|
346
|
-
}, (children === null || children === void 0 ? void 0 : (_children$content = children.content) === null || _children$content === void 0 ? void 0 : _children$content.
|
|
370
|
+
}, (children === null || children === void 0 ? void 0 : (_children$content = children.content) === null || _children$content === void 0 ? void 0 : _children$content.url) && /*#__PURE__*/_react.default.createElement(BmImageChat, _extends({
|
|
347
371
|
state: state,
|
|
348
372
|
src: children === null || children === void 0 ? void 0 : (_children$content2 = children.content) === null || _children$content2 === void 0 ? void 0 : _children$content2.url
|
|
349
373
|
}, rest)), /*#__PURE__*/_react.default.createElement("strong", null, children === null || children === void 0 ? void 0 : (_children$content3 = children.content) === null || _children$content3 === void 0 ? void 0 : _children$content3.header), /*#__PURE__*/_react.default.createElement("p", null, children === null || children === void 0 ? void 0 : (_children$content4 = children.content) === null || _children$content4 === void 0 ? void 0 : _children$content4.text), /*#__PURE__*/_react.default.createElement("small", null, children === null || children === void 0 ? void 0 : (_children$content5 = children.content) === null || _children$content5 === void 0 ? void 0 : _children$content5.caption), children === null || children === void 0 ? void 0 : (_children$options = children.options) === null || _children$options === void 0 ? void 0 : _children$options.map(function (button) {
|
package/package.json
CHANGED
package/src/App.js
CHANGED
|
@@ -39,6 +39,30 @@ const Chat = () => {
|
|
|
39
39
|
statusCode: 3,
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
|
+
const x = {
|
|
43
|
+
id: 64816,
|
|
44
|
+
message: 'Give Feedback',
|
|
45
|
+
time: '2025-02-13T11:19:42.000Z',
|
|
46
|
+
direction: 'inbound',
|
|
47
|
+
message_type: 'text',
|
|
48
|
+
messageId: null,
|
|
49
|
+
is_live_agent: 1,
|
|
50
|
+
is_deleted: 0,
|
|
51
|
+
is_comment: 0,
|
|
52
|
+
channel: 'whatsapp',
|
|
53
|
+
sent_to_vendor: 1,
|
|
54
|
+
replyMessageId: '035a7484-ee02-4829-8cb5-33c4623f1c8a',
|
|
55
|
+
agent_name: null,
|
|
56
|
+
df_agent_name: null,
|
|
57
|
+
resolve_time: null,
|
|
58
|
+
metadata: {
|
|
59
|
+
id: '035a7484-ee02-4829-8cb5-33c4623f1c8a',
|
|
60
|
+
prev_message:
|
|
61
|
+
'{"dotgoV2":{"type":"quick_reply","content":{"type":"text","url":"https://i.imgur.com/BZylAb1.jpeg","text":"We value your opinion! Would you be willing to take a short survey to help us improve?","caption":""},"options":[{"type":"text","title":"Give Feedback","postbackText":"bm-feedback|0|22a6d22a-1085-4c03-aa5b-364e68f1519c"},{"type":"text","title":"No Thank you","postbackText":"dev-defined-postback2"}]}}',
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const ms = JSON.parse(x.metadata.prev_message);
|
|
42
66
|
// const parsed = JSON.stringify(message.message);
|
|
43
67
|
// const dotGoV2Content = parsed?.dotgoV2;
|
|
44
68
|
const data = {
|
|
@@ -101,7 +125,7 @@ const Chat = () => {
|
|
|
101
125
|
const parsedMessage = JSON.parse(message.message);
|
|
102
126
|
const dotGoV2Content = parsedMessage?.dotgoV2;
|
|
103
127
|
console.log({ parsedMessage });
|
|
104
|
-
console.log(dotGoV2Content);
|
|
128
|
+
console.log({ dotGoV2Content });
|
|
105
129
|
return dotGoV2Content;
|
|
106
130
|
};
|
|
107
131
|
console.log(data);
|
|
@@ -451,6 +475,18 @@ const Chat = () => {
|
|
|
451
475
|
goes this wide mhhhhhh interesting
|
|
452
476
|
</p> */}
|
|
453
477
|
</BmChat.Details>
|
|
478
|
+
<BmChat.Details
|
|
479
|
+
state="inbound"
|
|
480
|
+
session="bot"
|
|
481
|
+
sessionTimeline={{ message: <p>12:00pm</p> }}
|
|
482
|
+
displayTime={<p>12:00pm</p>}
|
|
483
|
+
status="sent"
|
|
484
|
+
// type="interactive"
|
|
485
|
+
metadata={ms.dotgoV2}
|
|
486
|
+
isInteractive="true"
|
|
487
|
+
>
|
|
488
|
+
<p>{x.message}</p>
|
|
489
|
+
</BmChat.Details>
|
|
454
490
|
</BmChat>
|
|
455
491
|
</>
|
|
456
492
|
);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-nested-ternary */
|
|
1
2
|
/* eslint-disable react/display-name */
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { Done, DoneAll } from '@material-ui/icons';
|
|
@@ -72,8 +73,8 @@ const MessageDetails = styled.div`
|
|
|
72
73
|
|
|
73
74
|
const Messages = styled.div`
|
|
74
75
|
display: flex;
|
|
75
|
-
flex-direction: ${({ type }) => {
|
|
76
|
-
if (type === 'interactive') {
|
|
76
|
+
flex-direction: ${({ type, isInteractive }) => {
|
|
77
|
+
if (type === 'interactive' || isInteractive) {
|
|
77
78
|
return 'column';
|
|
78
79
|
}
|
|
79
80
|
return 'row';
|
|
@@ -376,6 +377,7 @@ BmChat.Details = ({
|
|
|
376
377
|
feedPostComments,
|
|
377
378
|
agentName,
|
|
378
379
|
metadata,
|
|
380
|
+
isInteractive,
|
|
379
381
|
type,
|
|
380
382
|
...rest
|
|
381
383
|
}) => {
|
|
@@ -403,9 +405,48 @@ BmChat.Details = ({
|
|
|
403
405
|
<>
|
|
404
406
|
{metadata ? (
|
|
405
407
|
<RepliedTextWrapper state={state}>
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
408
|
+
{metadata.type === 'quick_reply' ? (
|
|
409
|
+
<Messages
|
|
410
|
+
isInteractive={isInteractive}
|
|
411
|
+
type={type}
|
|
412
|
+
state={state}
|
|
413
|
+
isImg
|
|
414
|
+
>
|
|
415
|
+
{metadata?.content?.url && (
|
|
416
|
+
<BmImageChat
|
|
417
|
+
state={state}
|
|
418
|
+
src={metadata?.content?.url}
|
|
419
|
+
{...rest}
|
|
420
|
+
/>
|
|
421
|
+
)}
|
|
422
|
+
|
|
423
|
+
<strong>{metadata?.content?.header}</strong>
|
|
424
|
+
<p>{metadata?.content?.text}</p>
|
|
425
|
+
<small>{metadata?.content?.caption}</small>
|
|
426
|
+
{metadata?.options?.map((button) => (
|
|
427
|
+
// eslint-disable-next-line react/jsx-key
|
|
428
|
+
<IntButton state={state}>{button?.title}</IntButton>
|
|
429
|
+
))}
|
|
430
|
+
</Messages>
|
|
431
|
+
) : metadata.type === 'quick_reply' ? (
|
|
432
|
+
<Messages
|
|
433
|
+
isInteractive={isInteractive}
|
|
434
|
+
type={type}
|
|
435
|
+
state={state}
|
|
436
|
+
>
|
|
437
|
+
<strong>{metadata?.title}</strong>
|
|
438
|
+
<p>{metadata?.body}</p>
|
|
439
|
+
<IntButton state={state}>
|
|
440
|
+
<ListIcon />
|
|
441
|
+
{metadata?.globalButtons[0]?.title}
|
|
442
|
+
</IntButton>
|
|
443
|
+
</Messages>
|
|
444
|
+
) : (
|
|
445
|
+
<Messages metadata={metadata} state={state}>
|
|
446
|
+
{metadata}
|
|
447
|
+
</Messages>
|
|
448
|
+
)}
|
|
449
|
+
|
|
409
450
|
{children}
|
|
410
451
|
</RepliedTextWrapper>
|
|
411
452
|
) : (
|
|
@@ -414,7 +455,7 @@ BmChat.Details = ({
|
|
|
414
455
|
<>
|
|
415
456
|
{children.type === 'quick_reply' ? (
|
|
416
457
|
<Messages type={type} state={state} isImg>
|
|
417
|
-
{children?.content?.
|
|
458
|
+
{children?.content?.url && (
|
|
418
459
|
<BmImageChat
|
|
419
460
|
state={state}
|
|
420
461
|
src={children?.content?.url}
|