beem-component 2.1.29 → 2.1.31
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/Dockerfile +1 -1
- package/Jenkinsfile +20 -5
- package/dist/assets/voiceCallIcon.svg +5 -0
- package/dist/components/Alert/Alert.js +83 -0
- package/dist/components/Alert/Alert.stories.js +66 -0
- package/dist/components/BmCustomCardTitle/CustomCardTitle.js +181 -0
- package/dist/components/BmCustomCardTitle/CustomCardTitle.stories.js +92 -0
- package/dist/components/BmSelector/BmSelector.js +15 -2
- package/dist/components/BmSelector/BmSelector.stories.js +14 -1
- package/dist/components/BmTabv2/BmTabv2.js +51 -0
- package/dist/components/BmTabv2/BmTabv2.stories.js +73 -0
- package/dist/components/Card_v2/Card.js +38 -12
- package/dist/components/ChatComponents/ChatBody/chatBody.js +402 -104
- package/dist/components/DepartmentCard/DepartmentCard.js +99 -0
- package/dist/components/DepartmentCard/DepartmentCard.stories.js +53 -0
- package/dist/components/HorizontalCard/HorizontalCard.js +142 -0
- package/dist/components/HorizontalCard/HorizontalCard.stories.js +40 -0
- package/dist/components/InfoPanel/InfoPanel.js +54 -17
- package/dist/components/InfoPanel/InfoPanel.stories.js +56 -4
- package/dist/components/Modals/modal.js +26 -10
- package/dist/components/Modals/modals.stories.js +13 -6
- package/dist/components/ProfileIcon/ProfileIcon.js +5 -0
- package/dist/components/ResourceCard/ResourceCard.js +132 -0
- package/dist/components/ResourceCard/ResourceCard.stories.js +94 -0
- package/dist/components/globalStyles.js +1 -1
- package/dist/components/index.js +42 -0
- package/dist/components/text.js +11 -10
- package/dist/components/typography.js +3 -2
- package/package.json +2 -1
- package/public/index.html +1 -0
- package/src/App.js +804 -1412
- package/src/fonts/Inter-Black.woff2 +0 -0
- package/src/fonts/Inter-Bold.woff2 +0 -0
- package/src/fonts/Inter-ExtraBold.woff2 +0 -0
- package/src/fonts/Inter-ExtraLight.woff2 +0 -0
- package/src/fonts/Inter-Light.woff2 +0 -0
- package/src/fonts/Inter-Medium.woff2 +0 -0
- package/src/fonts/Inter-Regular.woff2 +0 -0
- package/src/fonts/Inter-SemiBold.woff2 +0 -0
- package/src/fonts/Inter-Thin.woff2 +0 -0
- package/src/fonts/Inter-VariableFont_opsz,wght.ttf +0 -0
- package/src/fonts/InterDisplay-Black.woff2 +0 -0
- package/src/fonts/InterDisplay-Bold.woff2 +0 -0
- package/src/fonts/InterDisplay-ExtraBold.woff2 +0 -0
- package/src/fonts/InterDisplay-ExtraLight.woff2 +0 -0
- package/src/fonts/InterDisplay-Light.woff2 +0 -0
- package/src/fonts/InterDisplay-Medium.woff2 +0 -0
- package/src/fonts/InterDisplay-SemiBold.woff2 +0 -0
- package/src/fonts/InterDisplay-Thin.woff2 +0 -0
- package/src/fonts.scss +4 -1
- package/src/lib/assets/voiceCallIcon.svg +5 -0
- package/src/lib/components/Alert/Alert.js +111 -0
- package/src/lib/components/Alert/Alert.stories.jsx +66 -0
- package/src/lib/components/BmCustomCardTitle/CustomCardTitle.js +162 -0
- package/src/lib/components/BmCustomCardTitle/CustomCardTitle.stories.jsx +92 -0
- package/src/lib/components/BmSelector/BmSelector.js +14 -1
- package/src/lib/components/BmSelector/BmSelector.stories.jsx +10 -0
- package/src/lib/components/BmTabv2/BmTabv2.js +109 -0
- package/src/lib/components/BmTabv2/BmTabv2.stories.jsx +51 -0
- package/src/lib/components/Card_v2/Card.js +46 -13
- package/src/lib/components/ChatComponents/ChatBody/chatBody.js +551 -57
- package/src/lib/components/DepartmentCard/DepartmentCard.js +130 -0
- package/src/lib/components/DepartmentCard/DepartmentCard.stories.jsx +38 -0
- package/src/lib/components/HorizontalCard/HorizontalCard.js +276 -0
- package/src/lib/components/HorizontalCard/HorizontalCard.stories.jsx +33 -0
- package/src/lib/components/InfoPanel/InfoPanel.js +35 -11
- package/src/lib/components/InfoPanel/InfoPanel.stories.jsx +42 -2
- package/src/lib/components/Modals/modal.js +17 -4
- package/src/lib/components/Modals/modals.stories.js +10 -6
- package/src/lib/components/ProfileIcon/ProfileIcon.js +4 -0
- package/src/lib/components/ResourceCard/ResourceCard.js +213 -0
- package/src/lib/components/ResourceCard/ResourceCard.stories.jsx +68 -0
- package/src/lib/components/globalStyles.js +2 -1
- package/src/lib/components/index.js +13 -0
- package/src/lib/components/text.js +17 -11
- package/src/lib/components/typography.js +1 -0
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
/* eslint-disable react/no-array-index-key */
|
|
1
2
|
/* eslint-disable no-nested-ternary */
|
|
2
3
|
/* eslint-disable react/display-name */
|
|
3
|
-
import React, { useState } from 'react';
|
|
4
|
+
import React, { useState, useEffect } from 'react';
|
|
4
5
|
import { Done, DoneAll } from '@material-ui/icons';
|
|
5
6
|
import FilePresentIcon from '@mui/icons-material/FilePresent';
|
|
7
|
+
import PhoneCallbackOutlinedIcon from '@mui/icons-material/PhoneCallbackOutlined';
|
|
8
|
+
import PhoneOutlinedIcon from '@mui/icons-material/PhoneOutlined';
|
|
9
|
+
|
|
10
|
+
import PhoneMissedIcon from '@mui/icons-material/PhoneMissed';
|
|
11
|
+
|
|
6
12
|
import DownloadIcon from '@mui/icons-material/Download';
|
|
7
13
|
import styled from 'styled-components';
|
|
8
14
|
import Avatar from 'react-avatar';
|
|
@@ -28,6 +34,63 @@ import { BmFeedPostComments } from './FeedPostComments';
|
|
|
28
34
|
|
|
29
35
|
pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;
|
|
30
36
|
|
|
37
|
+
const formatDuration = (totalSeconds) => {
|
|
38
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
39
|
+
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
40
|
+
const seconds = totalSeconds % 60;
|
|
41
|
+
|
|
42
|
+
if (hours > 0) {
|
|
43
|
+
return (
|
|
44
|
+
`${String(hours).padStart(2, '0')}:` +
|
|
45
|
+
`${String(minutes).padStart(2, '0')}:` +
|
|
46
|
+
`${String(seconds).padStart(2, '0')}`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
`${String(minutes).padStart(2, '0')}:` +
|
|
52
|
+
`${String(seconds).padStart(2, '0')}`
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const formatCallDuration = (totalSeconds) => {
|
|
57
|
+
// eslint-disable-next-line no-param-reassign
|
|
58
|
+
if (!totalSeconds || totalSeconds < 0) totalSeconds = 0;
|
|
59
|
+
|
|
60
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
61
|
+
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
62
|
+
const seconds = totalSeconds % 60;
|
|
63
|
+
|
|
64
|
+
let result = '';
|
|
65
|
+
if (hours > 0) result += `${hours} hr `;
|
|
66
|
+
result += `${minutes} min ${seconds} sec`;
|
|
67
|
+
|
|
68
|
+
return result.trim();
|
|
69
|
+
};
|
|
70
|
+
const useCallDuration = (running, callStartedAt) => {
|
|
71
|
+
const [seconds, setSeconds] = useState(0);
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!running || !callStartedAt) return;
|
|
75
|
+
|
|
76
|
+
const startTime = new Date(callStartedAt).getTime();
|
|
77
|
+
|
|
78
|
+
const updateSeconds = () => {
|
|
79
|
+
const now = Date.now();
|
|
80
|
+
const elapsed = Math.max(Math.floor((now - startTime) / 1000), 0);
|
|
81
|
+
setSeconds(elapsed);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
updateSeconds();
|
|
85
|
+
|
|
86
|
+
const intervalId = setInterval(updateSeconds, 1000);
|
|
87
|
+
|
|
88
|
+
return () => clearInterval(intervalId);
|
|
89
|
+
}, [running, callStartedAt]);
|
|
90
|
+
|
|
91
|
+
return formatDuration(seconds);
|
|
92
|
+
};
|
|
93
|
+
|
|
31
94
|
const BmChat = styled.div`
|
|
32
95
|
display: flex;
|
|
33
96
|
flex-direction: column;
|
|
@@ -61,7 +124,7 @@ const Details = styled.div`
|
|
|
61
124
|
}
|
|
62
125
|
overflow-wrap: break-word !important;
|
|
63
126
|
word-wrap: break-word !important;
|
|
64
|
-
margin: 0rem;
|
|
127
|
+
margin: 0rem;
|
|
65
128
|
|
|
66
129
|
flex-grow: 1;
|
|
67
130
|
${'' /* border: 1px solid red; */}
|
|
@@ -214,6 +277,60 @@ const CartContent = styled.div`
|
|
|
214
277
|
}};
|
|
215
278
|
`;
|
|
216
279
|
|
|
280
|
+
const CallContainer = styled.div`
|
|
281
|
+
display: flex;
|
|
282
|
+
flex-direction: row;
|
|
283
|
+
gap: 0.6rem;
|
|
284
|
+
align-items: center;
|
|
285
|
+
justify-content: center;
|
|
286
|
+
color: ${({ state }) => {
|
|
287
|
+
if (state) {
|
|
288
|
+
if (state === 'inbound') return `${BmPrimaryBlack}`;
|
|
289
|
+
if (state === 'outbound') return `${BmPrimaryWhite}`;
|
|
290
|
+
}
|
|
291
|
+
return `${BmPrimaryWhite}`;
|
|
292
|
+
}};
|
|
293
|
+
`;
|
|
294
|
+
const CallInfoContainer = styled.div`
|
|
295
|
+
display: flex;
|
|
296
|
+
padding-right: 1.5rem;
|
|
297
|
+
flex-direction: column;
|
|
298
|
+
gap: 0.3rem;
|
|
299
|
+
align-items: center;
|
|
300
|
+
justify-content: center;
|
|
301
|
+
color: ${({ state }) => {
|
|
302
|
+
if (state === 'inbound') return `${BmPrimaryBlack} !important`;
|
|
303
|
+
if (state === 'outbound') return `${BmPrimaryWhite} !important`;
|
|
304
|
+
return `${BmPrimaryWhite} !important`;
|
|
305
|
+
}};
|
|
306
|
+
& > :last-child {
|
|
307
|
+
color: ${({ state }) => (state === 'inbound' ? '#A6A29F' : '#cde3ddff')};
|
|
308
|
+
}
|
|
309
|
+
`;
|
|
310
|
+
const IconContainer = styled.div`
|
|
311
|
+
display: flex;
|
|
312
|
+
align-items: center;
|
|
313
|
+
justify-content: center;
|
|
314
|
+
width: max-content;
|
|
315
|
+
height: max-content;
|
|
316
|
+
padding: 0.8rem;
|
|
317
|
+
border: ${({ state }) => {
|
|
318
|
+
if (state) {
|
|
319
|
+
if (state === 'inbound') return `1px solid #F3F4F6`;
|
|
320
|
+
if (state === 'outbound') return `1px solid #5CC1C8`;
|
|
321
|
+
}
|
|
322
|
+
return `${BmPrimaryWhite}`;
|
|
323
|
+
}};
|
|
324
|
+
|
|
325
|
+
border-radius: 50%;
|
|
326
|
+
background-color: ${({ state }) => {
|
|
327
|
+
if (state) {
|
|
328
|
+
if (state === 'inbound') return `#F3F4F6`;
|
|
329
|
+
if (state === 'outbound') return `#5CC1C8`;
|
|
330
|
+
}
|
|
331
|
+
return `${BmPrimaryWhite}`;
|
|
332
|
+
}};
|
|
333
|
+
`;
|
|
217
334
|
const MessagesSubDetails = styled.div`
|
|
218
335
|
display: flex;
|
|
219
336
|
flex-direction: row;
|
|
@@ -433,30 +550,241 @@ const QuickReplyRender = ({
|
|
|
433
550
|
state,
|
|
434
551
|
rest,
|
|
435
552
|
isInteractive,
|
|
553
|
+
connector,
|
|
554
|
+
body,
|
|
555
|
+
action,
|
|
556
|
+
header,
|
|
557
|
+
footer,
|
|
436
558
|
}) => {
|
|
437
|
-
|
|
438
|
-
|
|
559
|
+
const MEDIA_TYPES = ['document', 'image', 'video'];
|
|
560
|
+
const renderers = {
|
|
561
|
+
dotgo_v3: () => (
|
|
562
|
+
<>
|
|
563
|
+
{header && (
|
|
564
|
+
<>
|
|
565
|
+
{MEDIA_TYPES.includes(header?.type) ? (
|
|
566
|
+
<BmImageChat
|
|
567
|
+
state={state}
|
|
568
|
+
src={header[header.type]?.link}
|
|
569
|
+
{...rest}
|
|
570
|
+
/>
|
|
571
|
+
) : (
|
|
572
|
+
<h5>{header[header.type]?.text}</h5>
|
|
573
|
+
)}
|
|
574
|
+
</>
|
|
575
|
+
)}
|
|
576
|
+
|
|
577
|
+
{body && (
|
|
578
|
+
<>
|
|
579
|
+
{body?.text?.split('\n').map((line, idx) => (
|
|
580
|
+
<p key={`body-line-${idx}`}>
|
|
581
|
+
{line}
|
|
582
|
+
<br />
|
|
583
|
+
</p>
|
|
584
|
+
))}
|
|
585
|
+
</>
|
|
586
|
+
)}
|
|
587
|
+
|
|
588
|
+
{footer && <small>{footer?.text}</small>}
|
|
589
|
+
|
|
590
|
+
{action?.buttons?.length > 0 &&
|
|
591
|
+
action.buttons.map((button, idx) => (
|
|
592
|
+
<IntButton state={state} key={`action-btn-${idx}`}>
|
|
593
|
+
{button[button.type]?.title}
|
|
594
|
+
</IntButton>
|
|
595
|
+
))}
|
|
596
|
+
</>
|
|
597
|
+
),
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
const FallbackRenderer = () => (
|
|
601
|
+
<>
|
|
439
602
|
{content?.url && (
|
|
440
|
-
<
|
|
603
|
+
<div>
|
|
604
|
+
<BmImageChat state={state} src={content?.url} {...rest} />
|
|
605
|
+
</div>
|
|
441
606
|
)}
|
|
442
607
|
|
|
443
|
-
<strong>{content
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
<
|
|
448
|
-
|
|
608
|
+
{content?.header && <strong>{content.header}</strong>}
|
|
609
|
+
|
|
610
|
+
{content?.text?.split('\n').map((line, idx) => (
|
|
611
|
+
<div>
|
|
612
|
+
<p key={`content-line-${idx}`}>
|
|
613
|
+
{line}
|
|
614
|
+
<br />
|
|
615
|
+
</p>
|
|
616
|
+
</div>
|
|
449
617
|
))}
|
|
450
|
-
|
|
451
|
-
{
|
|
452
|
-
|
|
453
|
-
|
|
618
|
+
|
|
619
|
+
{content?.caption && <small>{content.caption}</small>}
|
|
620
|
+
|
|
621
|
+
{options?.map((button, idx) => (
|
|
622
|
+
<IntButton state={state} key={`opt-btn-${idx}`}>
|
|
623
|
+
{button?.title}
|
|
624
|
+
</IntButton>
|
|
454
625
|
))}
|
|
626
|
+
</>
|
|
627
|
+
);
|
|
628
|
+
|
|
629
|
+
const ConnectorRenderer = renderers[connector] || FallbackRenderer;
|
|
630
|
+
return (
|
|
631
|
+
<Messages type={type} state={state} isInteractive={isInteractive} isImg>
|
|
632
|
+
<ConnectorRenderer />
|
|
633
|
+
</Messages>
|
|
634
|
+
);
|
|
635
|
+
};
|
|
636
|
+
const ImageRender = ({
|
|
637
|
+
type,
|
|
638
|
+
state,
|
|
639
|
+
rest,
|
|
640
|
+
isInteractive,
|
|
641
|
+
connector,
|
|
642
|
+
caption,
|
|
643
|
+
originalUrl,
|
|
644
|
+
}) => {
|
|
645
|
+
const renderers = {
|
|
646
|
+
dotgo_v3: () => (
|
|
647
|
+
<>
|
|
648
|
+
{originalUrl && (
|
|
649
|
+
<>
|
|
650
|
+
<BmImageChat state={state} src={originalUrl} {...rest} />
|
|
651
|
+
</>
|
|
652
|
+
)}
|
|
653
|
+
|
|
654
|
+
{caption && (
|
|
655
|
+
<>
|
|
656
|
+
{caption?.text?.split('\n').map((line, idx) => (
|
|
657
|
+
<p key={`body-line-${idx}`}>
|
|
658
|
+
{line}
|
|
659
|
+
<br />
|
|
660
|
+
</p>
|
|
661
|
+
))}
|
|
662
|
+
</>
|
|
663
|
+
)}
|
|
664
|
+
</>
|
|
665
|
+
),
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
const FallbackRenderer = () => (
|
|
669
|
+
<>
|
|
670
|
+
{originalUrl && (
|
|
671
|
+
<div>
|
|
672
|
+
<BmImageChat state={state} src={originalUrl} {...rest} />
|
|
673
|
+
</div>
|
|
674
|
+
)}
|
|
675
|
+
|
|
676
|
+
{caption && (
|
|
677
|
+
<>
|
|
678
|
+
{caption?.split('\n').map((line, idx) => (
|
|
679
|
+
<div>
|
|
680
|
+
<p key={`content-line-${idx}`}>
|
|
681
|
+
{line}
|
|
682
|
+
<br />
|
|
683
|
+
</p>
|
|
684
|
+
</div>
|
|
685
|
+
))}
|
|
686
|
+
</>
|
|
687
|
+
)}
|
|
688
|
+
</>
|
|
689
|
+
);
|
|
690
|
+
|
|
691
|
+
const ConnectorRenderer = renderers[connector] || FallbackRenderer;
|
|
692
|
+
return (
|
|
693
|
+
<Messages type={type} state={state} isInteractive={isInteractive} isImg>
|
|
694
|
+
<ConnectorRenderer />
|
|
695
|
+
</Messages>
|
|
696
|
+
);
|
|
697
|
+
};
|
|
698
|
+
const CallRender = ({
|
|
699
|
+
type,
|
|
700
|
+
state,
|
|
701
|
+
isInteractive,
|
|
702
|
+
connector,
|
|
703
|
+
message,
|
|
704
|
+
status,
|
|
705
|
+
call_started_at,
|
|
706
|
+
}) => {
|
|
707
|
+
const duration = useCallDuration(status === 'in_progress', call_started_at);
|
|
708
|
+
const renderers = {
|
|
709
|
+
yeastar: () => (
|
|
710
|
+
<>
|
|
711
|
+
{status === 'in_progress' && (
|
|
712
|
+
<CallContainer state={state}>
|
|
713
|
+
<IconContainer state={state}>
|
|
714
|
+
{state === 'inbound' ? (
|
|
715
|
+
<PhoneCallbackOutlinedIcon sx={{ color: '#4A5565' }} />
|
|
716
|
+
) : (
|
|
717
|
+
<PhoneOutlinedIcon />
|
|
718
|
+
)}
|
|
719
|
+
</IconContainer>
|
|
720
|
+
|
|
721
|
+
<CallInfoContainer state={state}>
|
|
722
|
+
<p>
|
|
723
|
+
<strong>Voice Call</strong>
|
|
724
|
+
</p>
|
|
725
|
+
|
|
726
|
+
<p>{duration}</p>
|
|
727
|
+
</CallInfoContainer>
|
|
728
|
+
</CallContainer>
|
|
729
|
+
)}
|
|
730
|
+
{status === 'answered' && (
|
|
731
|
+
<CallContainer state={state}>
|
|
732
|
+
<IconContainer state={state}>
|
|
733
|
+
{state === 'inbound' ? (
|
|
734
|
+
<PhoneCallbackOutlinedIcon sx={{ color: '#4A5565' }} />
|
|
735
|
+
) : (
|
|
736
|
+
<PhoneOutlinedIcon />
|
|
737
|
+
)}
|
|
738
|
+
</IconContainer>
|
|
739
|
+
|
|
740
|
+
<CallInfoContainer state={state}>
|
|
741
|
+
<h4>
|
|
742
|
+
<strong>Voice Call</strong>
|
|
743
|
+
</h4>
|
|
744
|
+
|
|
745
|
+
<p>{formatCallDuration(message.talk_duration)}</p>
|
|
746
|
+
</CallInfoContainer>
|
|
747
|
+
</CallContainer>
|
|
748
|
+
)}
|
|
749
|
+
{status === 'no answer' && (
|
|
750
|
+
<CallContainer state={state}>
|
|
751
|
+
<IconContainer state={state}>
|
|
752
|
+
<PhoneMissedIcon sx={{ color: '#e64d4dff' }} />
|
|
753
|
+
</IconContainer>
|
|
754
|
+
|
|
755
|
+
<CallInfoContainer state={state}>
|
|
756
|
+
<h4>
|
|
757
|
+
<strong>Voice Call</strong>
|
|
758
|
+
</h4>
|
|
759
|
+
|
|
760
|
+
<p>No answer</p>
|
|
761
|
+
</CallInfoContainer>
|
|
762
|
+
</CallContainer>
|
|
763
|
+
)}
|
|
764
|
+
</>
|
|
765
|
+
),
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
const FallbackRenderer = () => (
|
|
769
|
+
<>
|
|
770
|
+
<div>{status}</div>
|
|
771
|
+
</>
|
|
772
|
+
);
|
|
773
|
+
|
|
774
|
+
const ConnectorRenderer = renderers[connector] || FallbackRenderer;
|
|
775
|
+
return (
|
|
776
|
+
<Messages
|
|
777
|
+
type={type}
|
|
778
|
+
state={state}
|
|
779
|
+
isInteractive={isInteractive}
|
|
780
|
+
connector={connector}
|
|
781
|
+
isImg
|
|
782
|
+
>
|
|
783
|
+
<ConnectorRenderer />
|
|
455
784
|
</Messages>
|
|
456
785
|
);
|
|
457
786
|
};
|
|
458
787
|
const ProductDetailRender = ({ type, state, header, body, isInteractive }) => {
|
|
459
|
-
console.log(type, state, header, body);
|
|
460
788
|
return (
|
|
461
789
|
<>
|
|
462
790
|
<Messages type={type} state={state} isInteractive={isInteractive}>
|
|
@@ -477,43 +805,88 @@ const ListReplyRender = ({
|
|
|
477
805
|
isInteractive,
|
|
478
806
|
type,
|
|
479
807
|
state,
|
|
808
|
+
connector,
|
|
809
|
+
header,
|
|
810
|
+
action,
|
|
811
|
+
footer,
|
|
480
812
|
}) => {
|
|
813
|
+
const renderers = {
|
|
814
|
+
dotgo_v3: () => (
|
|
815
|
+
<>
|
|
816
|
+
{header && (
|
|
817
|
+
<>
|
|
818
|
+
<h6>{header[header.type]?.text}</h6>
|
|
819
|
+
</>
|
|
820
|
+
)}
|
|
821
|
+
|
|
822
|
+
{body && (
|
|
823
|
+
<>
|
|
824
|
+
{body?.text?.split('\n').map((line, idx) => (
|
|
825
|
+
<p key={`body-line-${idx}`}>
|
|
826
|
+
{line}
|
|
827
|
+
<br />
|
|
828
|
+
</p>
|
|
829
|
+
))}
|
|
830
|
+
</>
|
|
831
|
+
)}
|
|
832
|
+
|
|
833
|
+
{footer && <small>{footer?.text}</small>}
|
|
834
|
+
|
|
835
|
+
{action.button && (
|
|
836
|
+
<IntButton state={state}>
|
|
837
|
+
<ListIcon />
|
|
838
|
+
{action.button}
|
|
839
|
+
</IntButton>
|
|
840
|
+
)}
|
|
841
|
+
</>
|
|
842
|
+
),
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
const FallbackRenderer = () => (
|
|
846
|
+
<>
|
|
847
|
+
<strong>{title}</strong>
|
|
848
|
+
{body.split('\n').map((line) => (
|
|
849
|
+
<p>
|
|
850
|
+
{line}
|
|
851
|
+
<br />
|
|
852
|
+
</p>
|
|
853
|
+
))}
|
|
854
|
+
<IntButton state={state}>
|
|
855
|
+
<ListIcon />
|
|
856
|
+
{globalButtons[0]?.title}
|
|
857
|
+
</IntButton>
|
|
858
|
+
</>
|
|
859
|
+
);
|
|
860
|
+
|
|
861
|
+
const ConnectorRenderer = renderers[connector] || FallbackRenderer;
|
|
481
862
|
return (
|
|
482
863
|
<>
|
|
483
864
|
<Messages type={type} state={state} isInteractive={isInteractive}>
|
|
484
|
-
<
|
|
485
|
-
{body.split('\n').map((line) => (
|
|
486
|
-
<p>
|
|
487
|
-
{line}
|
|
488
|
-
<br />
|
|
489
|
-
</p>
|
|
490
|
-
))}
|
|
491
|
-
<IntButton state={state}>
|
|
492
|
-
<ListIcon />
|
|
493
|
-
{globalButtons[0]?.title}
|
|
494
|
-
</IntButton>
|
|
865
|
+
<ConnectorRenderer />
|
|
495
866
|
</Messages>
|
|
496
867
|
</>
|
|
497
868
|
);
|
|
498
869
|
};
|
|
499
870
|
|
|
500
|
-
const OrderRender = ({
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
871
|
+
const OrderRender = ({
|
|
872
|
+
amount,
|
|
873
|
+
type,
|
|
874
|
+
state,
|
|
875
|
+
items,
|
|
876
|
+
product_items,
|
|
877
|
+
connector,
|
|
878
|
+
isInteractive,
|
|
879
|
+
}) => {
|
|
880
|
+
const renderers = {
|
|
881
|
+
dotgo_v3: ({ displayItems, sumQuantities, setDisplayItems }) => (
|
|
882
|
+
<>
|
|
511
883
|
<OrderBody state={state}>
|
|
512
884
|
<CartContent state={state}>
|
|
513
885
|
<ShoppingCartOutlinedIcon fontSize="small" />
|
|
514
886
|
<h5>
|
|
515
887
|
<strong>
|
|
516
|
-
{sumQuantities()}
|
|
888
|
+
{sumQuantities(product_items)}{' '}
|
|
889
|
+
{sumQuantities(product_items) > 1 ? 'items' : 'item'}
|
|
517
890
|
</strong>
|
|
518
891
|
</h5>
|
|
519
892
|
</CartContent>
|
|
@@ -521,7 +894,7 @@ const OrderRender = ({ amount, type, state, items }) => {
|
|
|
521
894
|
|
|
522
895
|
{displayItems ? (
|
|
523
896
|
<OrderBody state={state}>
|
|
524
|
-
{
|
|
897
|
+
{product_items.map((data, index) => (
|
|
525
898
|
<>
|
|
526
899
|
<CartContent state={state}>
|
|
527
900
|
<p>{index + 1}. </p>
|
|
@@ -555,6 +928,84 @@ const OrderRender = ({ amount, type, state, items }) => {
|
|
|
555
928
|
>
|
|
556
929
|
<p>{displayItems ? 'HIDE' : 'SHOW'} CART ITEMS</p>
|
|
557
930
|
</IntButton>
|
|
931
|
+
</>
|
|
932
|
+
),
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
const FallbackRenderer = ({
|
|
936
|
+
sumQuantities,
|
|
937
|
+
displayItems,
|
|
938
|
+
setDisplayItems,
|
|
939
|
+
}) => (
|
|
940
|
+
<>
|
|
941
|
+
<OrderBody state={state}>
|
|
942
|
+
<CartContent state={state}>
|
|
943
|
+
<ShoppingCartOutlinedIcon fontSize="small" />
|
|
944
|
+
<h5>
|
|
945
|
+
<strong>
|
|
946
|
+
{sumQuantities(items)}{' '}
|
|
947
|
+
{sumQuantities(items) > 1 ? 'items' : 'item'}
|
|
948
|
+
</strong>
|
|
949
|
+
</h5>
|
|
950
|
+
</CartContent>
|
|
951
|
+
</OrderBody>
|
|
952
|
+
|
|
953
|
+
{displayItems ? (
|
|
954
|
+
<OrderBody state={state}>
|
|
955
|
+
{items.map((data, index) => (
|
|
956
|
+
<>
|
|
957
|
+
<CartContent state={state}>
|
|
958
|
+
<p>{index + 1}. </p>
|
|
959
|
+
<ProductImage src={data.imgURL} alt="product" />
|
|
960
|
+
|
|
961
|
+
<p>
|
|
962
|
+
{data.quantity} X {data.description} @ {data.currency}{' '}
|
|
963
|
+
{data.amount}
|
|
964
|
+
</p>
|
|
965
|
+
</CartContent>
|
|
966
|
+
<hr style={{ width: '100%' }} />
|
|
967
|
+
</>
|
|
968
|
+
))}
|
|
969
|
+
</OrderBody>
|
|
970
|
+
) : (
|
|
971
|
+
<></>
|
|
972
|
+
)}
|
|
973
|
+
<OrderBody state={state}>
|
|
974
|
+
<CartContent state={state}>
|
|
975
|
+
<p>
|
|
976
|
+
{' '}
|
|
977
|
+
Estimated Total: <strong>{amount}</strong>
|
|
978
|
+
</p>
|
|
979
|
+
</CartContent>
|
|
980
|
+
</OrderBody>
|
|
981
|
+
<IntButton
|
|
982
|
+
state={state}
|
|
983
|
+
onClick={() => {
|
|
984
|
+
setDisplayItems(!displayItems);
|
|
985
|
+
}}
|
|
986
|
+
>
|
|
987
|
+
<p>{displayItems ? 'HIDE' : 'SHOW'} CART ITEMS</p>
|
|
988
|
+
</IntButton>
|
|
989
|
+
</>
|
|
990
|
+
);
|
|
991
|
+
|
|
992
|
+
const ConnectorRenderer = renderers[connector] || FallbackRenderer;
|
|
993
|
+
const [displayItems, setDisplayItems] = useState(false);
|
|
994
|
+
|
|
995
|
+
const sumQuantities = (data) => {
|
|
996
|
+
return data?.reduce((total, item) => {
|
|
997
|
+
return total + parseInt(item.quantity, 10);
|
|
998
|
+
}, 0);
|
|
999
|
+
};
|
|
1000
|
+
return (
|
|
1001
|
+
<>
|
|
1002
|
+
<Messages type={type} state={state} isInteractive={isInteractive}>
|
|
1003
|
+
<ConnectorRenderer
|
|
1004
|
+
sumQuantities={sumQuantities}
|
|
1005
|
+
setDisplayItems={setDisplayItems}
|
|
1006
|
+
displayItems={displayItems}
|
|
1007
|
+
items={items}
|
|
1008
|
+
/>
|
|
558
1009
|
</Messages>
|
|
559
1010
|
</>
|
|
560
1011
|
);
|
|
@@ -573,6 +1024,7 @@ BmChat.Details = ({
|
|
|
573
1024
|
sessionTimeline,
|
|
574
1025
|
feedPostComments,
|
|
575
1026
|
agentName,
|
|
1027
|
+
|
|
576
1028
|
metadata,
|
|
577
1029
|
isInteractive,
|
|
578
1030
|
type,
|
|
@@ -603,33 +1055,50 @@ BmChat.Details = ({
|
|
|
603
1055
|
<>
|
|
604
1056
|
{metadata ? (
|
|
605
1057
|
<RepliedTextWrapper state={state}>
|
|
606
|
-
{metadata.type === 'quick_reply'
|
|
1058
|
+
{metadata.message.type === 'quick_reply' ||
|
|
1059
|
+
metadata.message.type === 'button' ? (
|
|
607
1060
|
<QuickReplyRender
|
|
608
1061
|
isInteractive
|
|
609
1062
|
rest={rest}
|
|
610
|
-
{...metadata}
|
|
1063
|
+
{...metadata.message}
|
|
611
1064
|
type={type}
|
|
612
1065
|
state={state}
|
|
1066
|
+
connector={metadata.connector}
|
|
613
1067
|
/>
|
|
614
|
-
) : metadata.type === 'list' ? (
|
|
1068
|
+
) : metadata.message.type === 'list' ? (
|
|
615
1069
|
<ListReplyRender
|
|
616
1070
|
isInteractive
|
|
617
|
-
{...metadata}
|
|
1071
|
+
{...metadata.message}
|
|
618
1072
|
type={type}
|
|
619
1073
|
state={state}
|
|
1074
|
+
connector={metadata.connector}
|
|
620
1075
|
/>
|
|
621
|
-
) : metadata.type === 'product_details' ? (
|
|
1076
|
+
) : metadata.message.type === 'product_details' ? (
|
|
622
1077
|
<ProductDetailRender
|
|
623
1078
|
isInteractive
|
|
624
|
-
{...metadata}
|
|
1079
|
+
{...metadata.message}
|
|
625
1080
|
type={type}
|
|
626
1081
|
state={state}
|
|
627
1082
|
/>
|
|
628
|
-
) : metadata.type === 'order' ? (
|
|
629
|
-
<OrderRender
|
|
1083
|
+
) : metadata.message.type === 'order' ? (
|
|
1084
|
+
<OrderRender
|
|
1085
|
+
isInteractive
|
|
1086
|
+
{...metadata.message}
|
|
1087
|
+
type={type}
|
|
1088
|
+
state={state}
|
|
1089
|
+
connector={metadata.connector}
|
|
1090
|
+
/>
|
|
1091
|
+
) : metadata.message.type === 'image' ? (
|
|
1092
|
+
<ImageRender
|
|
1093
|
+
isInteractive
|
|
1094
|
+
{...metadata.message}
|
|
1095
|
+
type={type}
|
|
1096
|
+
state={state}
|
|
1097
|
+
connector={metadata?.connector}
|
|
1098
|
+
/>
|
|
630
1099
|
) : (
|
|
631
1100
|
<Messages metadata={metadata} state={state}>
|
|
632
|
-
{metadata}
|
|
1101
|
+
{metadata.message.text}
|
|
633
1102
|
</Messages>
|
|
634
1103
|
)}
|
|
635
1104
|
|
|
@@ -639,30 +1108,54 @@ BmChat.Details = ({
|
|
|
639
1108
|
<>
|
|
640
1109
|
{type && (type === 'interactive' || type === 'order') ? (
|
|
641
1110
|
<>
|
|
642
|
-
{children
|
|
1111
|
+
{(children?.message?.type === 'quick_reply' ||
|
|
1112
|
+
children?.message?.type === 'button') && (
|
|
643
1113
|
<QuickReplyRender
|
|
644
1114
|
rest={rest}
|
|
645
|
-
{...children}
|
|
1115
|
+
{...children.message}
|
|
646
1116
|
type={type}
|
|
647
1117
|
state={state}
|
|
1118
|
+
connector={children?.connector}
|
|
648
1119
|
/>
|
|
649
1120
|
)}
|
|
650
|
-
{children.type === 'list' && (
|
|
1121
|
+
{children.message.type === 'list' && (
|
|
651
1122
|
<ListReplyRender
|
|
652
|
-
{...children}
|
|
1123
|
+
{...children.message}
|
|
653
1124
|
type={type}
|
|
654
1125
|
state={state}
|
|
1126
|
+
connector={children?.connector}
|
|
655
1127
|
/>
|
|
656
1128
|
)}
|
|
657
|
-
{children.type === 'product_details' && (
|
|
1129
|
+
{children.message.type === 'product_details' && (
|
|
658
1130
|
<ProductDetailRender
|
|
659
|
-
{...children}
|
|
1131
|
+
{...children.message}
|
|
660
1132
|
type={type}
|
|
661
1133
|
state={state}
|
|
662
1134
|
/>
|
|
663
1135
|
)}
|
|
664
|
-
{children.type === 'order' && (
|
|
665
|
-
<OrderRender
|
|
1136
|
+
{children.message.type === 'order' && (
|
|
1137
|
+
<OrderRender
|
|
1138
|
+
{...children.message}
|
|
1139
|
+
type={type}
|
|
1140
|
+
state={state}
|
|
1141
|
+
connector={children?.connector}
|
|
1142
|
+
/>
|
|
1143
|
+
)}
|
|
1144
|
+
{children.message.type === 'image' && (
|
|
1145
|
+
<ImageRender
|
|
1146
|
+
{...children.message}
|
|
1147
|
+
type={type}
|
|
1148
|
+
state={state}
|
|
1149
|
+
connector={children?.connector}
|
|
1150
|
+
/>
|
|
1151
|
+
)}
|
|
1152
|
+
{children.message.type === 'call' && (
|
|
1153
|
+
<CallRender
|
|
1154
|
+
{...children.message}
|
|
1155
|
+
type={type}
|
|
1156
|
+
state={state}
|
|
1157
|
+
connector={children?.connector}
|
|
1158
|
+
/>
|
|
666
1159
|
)}
|
|
667
1160
|
</>
|
|
668
1161
|
) : type === 'pdf' ? (
|
|
@@ -727,6 +1220,7 @@ BmChat.Details = ({
|
|
|
727
1220
|
{sessionTimeline && (
|
|
728
1221
|
<SessionTimeline message={sessionTimeline.message} {...rest} />
|
|
729
1222
|
)}
|
|
1223
|
+
|
|
730
1224
|
{sessionDetails && (
|
|
731
1225
|
<SessionDetails
|
|
732
1226
|
time={sessionDetails.time}
|