beem-component 2.1.29 → 2.1.30

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