@capillarytech/creatives-library 8.0.330-alpha.0 → 8.0.330

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 (122) hide show
  1. package/constants/unified.js +0 -18
  2. package/package.json +1 -1
  3. package/services/api.js +0 -17
  4. package/services/tests/api.test.js +0 -85
  5. package/utils/commonUtils.js +0 -28
  6. package/utils/tests/commonUtil.test.js +0 -169
  7. package/v2Components/CapTagList/index.js +0 -10
  8. package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +49 -70
  9. package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +2 -8
  10. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +21 -207
  11. package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -16
  12. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +10 -85
  13. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -30
  14. package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +11 -79
  15. package/v2Components/CommonTestAndPreview/SendTestMessage.js +53 -87
  16. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -20
  17. package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +4 -133
  18. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +34 -145
  19. package/v2Components/CommonTestAndPreview/actions.js +0 -10
  20. package/v2Components/CommonTestAndPreview/constants.js +1 -53
  21. package/v2Components/CommonTestAndPreview/index.js +168 -998
  22. package/v2Components/CommonTestAndPreview/messages.js +3 -147
  23. package/v2Components/CommonTestAndPreview/reducer.js +0 -10
  24. package/v2Components/CommonTestAndPreview/sagas.js +6 -15
  25. package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +286 -328
  26. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +65 -231
  27. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +5 -118
  28. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +0 -341
  29. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +24 -65
  30. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +1 -199
  31. package/v2Components/CommonTestAndPreview/tests/constants.test.js +1 -31
  32. package/v2Components/CommonTestAndPreview/tests/index.test.js +4 -168
  33. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -71
  34. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +2 -2
  35. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -17
  36. package/v2Components/FormBuilder/index.js +1 -7
  37. package/v2Components/TestAndPreviewSlidebox/index.js +1 -13
  38. package/v2Components/TestAndPreviewSlidebox/sagas.js +4 -11
  39. package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +1 -3
  40. package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -36
  41. package/v2Containers/CreativesContainer/SlideBoxFooter.js +1 -10
  42. package/v2Containers/CreativesContainer/SlideBoxHeader.js +4 -29
  43. package/v2Containers/CreativesContainer/constants.js +0 -9
  44. package/v2Containers/CreativesContainer/index.js +93 -292
  45. package/v2Containers/CreativesContainer/index.scss +1 -51
  46. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +34 -78
  47. package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +16 -79
  48. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +0 -8
  49. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +98 -357
  50. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +10 -20
  51. package/v2Containers/CreativesContainer/tests/index.test.js +9 -71
  52. package/v2Containers/Rcs/constants.js +3 -40
  53. package/v2Containers/Rcs/index.js +895 -1145
  54. package/v2Containers/Rcs/index.scss +6 -85
  55. package/v2Containers/Rcs/messages.js +2 -12
  56. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +2236 -41719
  57. package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +5 -0
  58. package/v2Containers/Rcs/tests/index.test.js +38 -41
  59. package/v2Containers/Rcs/tests/mockData.js +0 -38
  60. package/v2Containers/Rcs/tests/utils.test.js +1 -435
  61. package/v2Containers/Rcs/utils.js +10 -405
  62. package/v2Containers/Sms/Create/index.js +38 -100
  63. package/v2Containers/SmsTrai/Create/index.js +4 -9
  64. package/v2Containers/SmsTrai/Edit/constants.js +0 -2
  65. package/v2Containers/SmsTrai/Edit/index.js +128 -636
  66. package/v2Containers/SmsTrai/Edit/messages.js +4 -14
  67. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +2604 -4590
  68. package/v2Containers/SmsWrapper/index.js +8 -37
  69. package/v2Containers/TagList/index.js +0 -6
  70. package/v2Containers/Templates/_templates.scss +2 -63
  71. package/v2Containers/Templates/actions.js +0 -11
  72. package/v2Containers/Templates/constants.js +0 -2
  73. package/v2Containers/Templates/index.js +40 -90
  74. package/v2Containers/Templates/sagas.js +12 -57
  75. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1079 -1043
  76. package/v2Containers/Templates/tests/sagas.test.js +123 -193
  77. package/v2Containers/TemplatesV2/TemplatesV2.style.js +1 -72
  78. package/v2Containers/TemplatesV2/index.js +23 -86
  79. package/v2Containers/Whatsapp/index.js +20 -3
  80. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4872 -5790
  81. package/utils/templateVarUtils.js +0 -201
  82. package/utils/tests/templateVarUtils.test.js +0 -204
  83. package/v2Components/CommonTestAndPreview/AddTestCustomer.js +0 -42
  84. package/v2Components/CommonTestAndPreview/CustomerCreationModal.js +0 -155
  85. package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +0 -93
  86. package/v2Components/CommonTestAndPreview/previewApiUtils.js +0 -59
  87. package/v2Components/CommonTestAndPreview/tests/AddTestCustomer.test.js +0 -66
  88. package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +0 -648
  89. package/v2Components/CommonTestAndPreview/tests/CustomerCreationModal.test.js +0 -174
  90. package/v2Components/CommonTestAndPreview/tests/ExistingCustomerModal.test.js +0 -114
  91. package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +0 -67
  92. package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +0 -87
  93. package/v2Components/SmsFallback/constants.js +0 -73
  94. package/v2Components/SmsFallback/index.js +0 -955
  95. package/v2Components/SmsFallback/index.scss +0 -265
  96. package/v2Components/SmsFallback/messages.js +0 -78
  97. package/v2Components/SmsFallback/smsFallbackUtils.js +0 -118
  98. package/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +0 -50
  99. package/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +0 -147
  100. package/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +0 -304
  101. package/v2Components/SmsFallback/tests/smsFallbackUi.test.js +0 -197
  102. package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +0 -277
  103. package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +0 -422
  104. package/v2Components/SmsFallback/useLocalTemplateList.js +0 -92
  105. package/v2Components/VarSegmentMessageEditor/constants.js +0 -2
  106. package/v2Components/VarSegmentMessageEditor/index.js +0 -125
  107. package/v2Components/VarSegmentMessageEditor/index.scss +0 -46
  108. package/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +0 -43
  109. package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +0 -67
  110. package/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +0 -90
  111. package/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +0 -258
  112. package/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +0 -125
  113. package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +0 -225
  114. package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +0 -318
  115. package/v2Containers/Sms/smsFormDataHelpers.js +0 -67
  116. package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +0 -253
  117. package/v2Containers/SmsTrai/Edit/index.scss +0 -121
  118. package/v2Containers/Templates/TemplatesActionBar.js +0 -101
  119. package/v2Containers/Templates/tests/TemplatesActionBar.test.js +0 -120
  120. package/v2Containers/Templates/tests/smsTemplatesListApi.test.js +0 -180
  121. package/v2Containers/Templates/utils/smsTemplatesListApi.js +0 -79
  122. package/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +0 -131
@@ -1,93 +0,0 @@
1
- import CapModal from "@capillarytech/cap-ui-library/CapModal";
2
- import { FormattedMessage, injectIntl, intlShape } from "react-intl";
3
- import messages from "./messages";
4
- import React, { useState } from "react";
5
- import PropTypes from "prop-types";
6
- import { CapCard, CapRow, CapColumn } from "@capillarytech/cap-ui-library";
7
- import { CHANNELS } from "./constants";
8
- import CapButton from "@capillarytech/cap-ui-library/CapButton";
9
- import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
10
-
11
-
12
- const ExistingCustomerModal = ({ customerModal, onCloseCustomerModal, customerData, channel, onSave, intl }) => {
13
- const [isLoading, setIsLoading] = useState(false);
14
- return (
15
- <CapModal
16
- visible={customerModal[0]}
17
- onCancel={onCloseCustomerModal}
18
- centered={true}
19
- width={500}
20
- maskStyle={{ backgroundColor: 'rgba(244, 245, 247, 0.9)' }}
21
- footer={
22
- <CapRow justify="start">
23
- <CapButton
24
- type="primary"
25
- onClick={() => onSave({}, setIsLoading)}
26
- loading={isLoading}
27
- >
28
- <FormattedMessage {...messages.saveButton} />
29
- </CapButton>
30
- <CapButton
31
- type="secondary"
32
- onClick={onCloseCustomerModal}
33
- disabled={isLoading}
34
- >
35
- <FormattedMessage {...messages.cancelButton} />
36
- </CapButton>
37
- </CapRow>
38
- }
39
- title={intl.formatMessage(messages.customerCreationModalTitle)}
40
- wrapClassName="common-test-preview-modal-wrap existing-customer-modal-wrap"
41
- className="common-test-preview-modal"
42
- >
43
- <div className="existing-customer-modal">
44
- <CapRow className="existing-customer-modal-intro-row">
45
- <FormattedMessage {...messages.existingCustomerModalDescription} />
46
- </CapRow>
47
- <CapCard className="existing-customer-modal-card">
48
- <CapRow className="existing-customer-modal-card-row">
49
- <CapColumn className="existing-customer-modal-avatar">
50
- <CapIcon type="user-profile" className="existing-customer-modal-avatar-icon" />
51
- </CapColumn>
52
- <CapColumn className="existing-customer-modal-details">
53
- <CapRow className="existing-customer-modal-name">
54
- {customerData.name || "-"}
55
- </CapRow>
56
- <CapColumn className="existing-customer-modal-meta">
57
- {channel === CHANNELS.EMAIL && customerData.email && (
58
- <CapRow><span className="existing-customer-modal-meta-label"><FormattedMessage {...messages.customerEmail} />: </span> {customerData.email}</CapRow>
59
- )}
60
- {channel === CHANNELS.SMS && customerData.mobile && (
61
- <CapRow><span className="existing-customer-modal-meta-label"><FormattedMessage {...messages.customerMobile} />: </span>{customerData.mobile}</CapRow>
62
- )}
63
- <CapRow><span className="existing-customer-modal-meta-label"><FormattedMessage {...messages.customerID} />: </span>{customerData.customerId}</CapRow>
64
- </CapColumn>
65
- </CapColumn>
66
- </CapRow>
67
- </CapCard>
68
- </div>
69
- </CapModal>
70
- );
71
- };
72
-
73
- ExistingCustomerModal.propTypes = {
74
- customerModal: PropTypes.arrayOf(
75
- PropTypes.oneOfType([PropTypes.bool, PropTypes.string, PropTypes.number]),
76
- ).isRequired,
77
- onCloseCustomerModal: PropTypes.func.isRequired,
78
- customerData: PropTypes.shape({
79
- name: PropTypes.string,
80
- email: PropTypes.string,
81
- mobile: PropTypes.string,
82
- customerId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
83
- }),
84
- channel: PropTypes.oneOf(Object.values(CHANNELS)).isRequired,
85
- onSave: PropTypes.func.isRequired,
86
- intl: intlShape.isRequired,
87
- };
88
-
89
- ExistingCustomerModal.defaultProps = {
90
- customerData: {},
91
- };
92
-
93
- export default injectIntl(ExistingCustomerModal);
@@ -1,59 +0,0 @@
1
- /**
2
- * Helpers for Liquid `/preview` (updateEmailPreview) responses.
3
- * The API may nest the payload under `data` or return fields at the top level.
4
- * SMS responses often use `messageBody` instead of `resolvedBody`.
5
- */
6
-
7
- import { getFallbackResolvedContent } from '../../utils/templateVarUtils';
8
- import { RCS_SMS_FALLBACK_VAR_MAPPED_PROP } from './constants';
9
-
10
- export function normalizePreviewApiPayload(raw) {
11
- if (!raw || typeof raw !== 'object') return raw;
12
- const next = { ...raw };
13
- if (next.resolvedBody == null) {
14
- const alt = next.messageBody ?? next.previewMessage ?? next.previewText;
15
- if (alt != null) next.resolvedBody = alt;
16
- }
17
- return next;
18
- }
19
-
20
- /**
21
- * Returns a normalized preview object suitable for Redux `previewData`, or null on error / empty.
22
- */
23
- export function extractPreviewFromLiquidResponse(response) {
24
- if (!response || response.error) return null;
25
- if (response.errors && Array.isArray(response.errors) && response.errors.length > 0) return null;
26
-
27
- let body;
28
- if (response.data !== undefined && response.data !== null && typeof response.data === 'object') {
29
- body = normalizePreviewApiPayload(response.data);
30
- } else if (typeof response === 'object' && !Array.isArray(response)) {
31
- body = normalizePreviewApiPayload(response);
32
- } else {
33
- return null;
34
- }
35
-
36
- if (!body) return null;
37
- if (body.resolvedBody === undefined && body.messageBody === undefined) {
38
- return null;
39
- }
40
- return body;
41
- }
42
-
43
- /**
44
- * RCS SMS fallback: merge template (`templateContent` / `content`) with VarSegment
45
- * `rcsSmsFallbackVarMapped` before Liquid /preview, tag extraction, or createMessageMeta.
46
- * Raw template alone is stale when the user edits slot values.
47
- */
48
- export function getSmsFallbackTextForTagExtraction(smsFallbackContext) {
49
- const rawTemplateBody =
50
- smsFallbackContext?.templateContent ?? smsFallbackContext?.content ?? '';
51
- if (!rawTemplateBody) return '';
52
- const rcsSmsFallbackVarMapped = smsFallbackContext?.[RCS_SMS_FALLBACK_VAR_MAPPED_PROP];
53
- const hasRcsSmsFallbackVarMappedEntries =
54
- Object.keys(rcsSmsFallbackVarMapped ?? {}).length > 0;
55
- if (hasRcsSmsFallbackVarMappedEntries) {
56
- return getFallbackResolvedContent(rawTemplateBody, rcsSmsFallbackVarMapped ?? {});
57
- }
58
- return rawTemplateBody;
59
- }
@@ -1,66 +0,0 @@
1
- /**
2
- * Tests for AddTestCustomerButton Component
3
- *
4
- * The parent (index.js) only renders this button when channel is EMAIL/SMS and value is valid.
5
- * This component always renders the button when mounted; visibility is the parent's responsibility.
6
- */
7
-
8
- import React from 'react';
9
- import { render, screen, fireEvent } from '@testing-library/react';
10
- import { IntlProvider } from 'react-intl';
11
- import AddTestCustomerButton from '../AddTestCustomer';
12
-
13
- const mockMessages = {
14
- 'app.v2Components.TestAndPreviewSlidebox.addTestCustomerWithValue': 'Add {searchValue} as Test Customer',
15
- };
16
-
17
- const TestWrapper = ({ children }) => (
18
- <IntlProvider locale="en" messages={mockMessages}>
19
- {children}
20
- </IntlProvider>
21
- );
22
-
23
- describe('AddTestCustomerButton', () => {
24
- const defaultProps = {
25
- searchValue: 'user@example.com',
26
- handleAddTestCustomer: jest.fn(),
27
- };
28
-
29
- beforeEach(() => {
30
- jest.clearAllMocks();
31
- });
32
-
33
- it('should render button with searchValue in message', () => {
34
- render(
35
- <TestWrapper>
36
- <AddTestCustomerButton {...defaultProps} />
37
- </TestWrapper>
38
- );
39
- const button = screen.getByRole('button', { name: /add.*test customer/i });
40
- expect(button).toBeTruthy();
41
- });
42
-
43
- it('should show searchValue in button text', () => {
44
- render(
45
- <TestWrapper>
46
- <AddTestCustomerButton {...defaultProps} searchValue="user@example.com" />
47
- </TestWrapper>
48
- );
49
- expect(screen.getByRole('button', { name: /user@example.com/i })).toBeTruthy();
50
- });
51
-
52
- it('should call handleAddTestCustomer when button is clicked', () => {
53
- const handleAddTestCustomer = jest.fn();
54
- render(
55
- <TestWrapper>
56
- <AddTestCustomerButton
57
- searchValue="user@example.com"
58
- handleAddTestCustomer={handleAddTestCustomer}
59
- />
60
- </TestWrapper>
61
- );
62
- const button = screen.getByRole('button', { name: /add.*test customer/i });
63
- fireEvent.click(button);
64
- expect(handleAddTestCustomer).toHaveBeenCalledTimes(1);
65
- });
66
- });