@capillarytech/creatives-library 8.0.188 → 8.0.190

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 (29) hide show
  1. package/config/app.js +2 -1
  2. package/package.json +1 -1
  3. package/services/api.js +1 -0
  4. package/v2Components/CapActionButton/index.js +2 -1
  5. package/v2Containers/Cap/reducer.js +3 -0
  6. package/v2Containers/Cap/sagas.js +13 -0
  7. package/v2Containers/Cap/selectors.js +2 -1
  8. package/v2Containers/Cap/tests/saga-coverage.test.js +93 -0
  9. package/v2Containers/Cap/tests/saga.test.js +616 -53
  10. package/v2Containers/Cap/tests/selectors.test.js +440 -2
  11. package/v2Containers/CreativesContainer/SlideBoxContent.js +2 -0
  12. package/v2Containers/CreativesContainer/actions.js +9 -1
  13. package/v2Containers/CreativesContainer/constants.js +1 -0
  14. package/v2Containers/CreativesContainer/index.js +7 -0
  15. package/v2Containers/CreativesContainer/reducer.js +6 -0
  16. package/v2Containers/CreativesContainer/selectors.js +5 -0
  17. package/v2Containers/CreativesContainer/tests/reducer.test.js +72 -0
  18. package/v2Containers/CreativesContainer/tests/selectors.test.js +112 -0
  19. package/v2Containers/Rcs/constants.js +2 -1
  20. package/v2Containers/Rcs/index.js +278 -81
  21. package/v2Containers/Rcs/messages.js +12 -0
  22. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +606 -1790
  23. package/v2Containers/Rcs/tests/index.test.js +187 -0
  24. package/v2Containers/Templates/index.js +7 -4
  25. package/v2Containers/Templates/sagas.js +10 -3
  26. package/v2Containers/Templates/tests/reducer.test.js +101 -0
  27. package/v2Containers/Templates/tests/sagas.test.js +51 -2
  28. package/v2Containers/Whatsapp/constants.js +22 -1
  29. package/v2Containers/Whatsapp/index.js +20 -1
package/config/app.js CHANGED
@@ -20,7 +20,8 @@ const config = {
20
20
  accountConfig: (strs, accountId) => `${window.location.origin}/org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
21
21
  },
22
22
  development: {
23
- api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
23
+ // api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
24
+ api_endpoint: 'http://localhost:2022/arya/api/v1/creatives',
24
25
  campaigns_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/campaigns',
25
26
  campaigns_api_org_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/org/campaign',
26
27
  auth_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/auth',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.188",
4
+ "version": "8.0.190",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/services/api.js CHANGED
@@ -264,6 +264,7 @@ export const getUserData = () => {
264
264
 
265
265
  export const createTemplate = ({template}) => {
266
266
  const url = `${API_ENDPOINT}/templates/SMS`;
267
+ console.log("creating template",template);
267
268
  return request(url, getAPICallObject('POST', template));
268
269
  };
269
270
 
@@ -185,7 +185,7 @@ export const CapActionButton = (props) => {
185
185
  const phoneNumber = type !== RCS_BUTTON_TYPES.PHONE_NUMBER ? null : cta.phoneNumber;
186
186
  if (isFullMode && !isEditFlow && !isSaved) {
187
187
  renderArray.push(
188
- <div className="rcs-button-cta-create-container">
188
+ <div className="rcs-button-cta-create-container" key={`cta-edit-${index}`}>
189
189
  <CapRow className="rcs-button-cta-create margin-t-16">
190
190
  <CapColumn span={12}>
191
191
  {/* Type of action */}
@@ -351,6 +351,7 @@ export const CapActionButton = (props) => {
351
351
  const ctaIsReply = type === RCS_BUTTON_TYPES.QUICK_REPLY;
352
352
  renderArray.push(
353
353
  <CapRow
354
+ key={`cta-saved-${index}`}
354
355
  className="cap-rcs-saved-cta margin-t-12"
355
356
  align="middle"
356
357
  type="flex"
@@ -113,6 +113,8 @@ function capReducer(state = fromJS(initialState.cap), action) {
113
113
  // Process extended tags
114
114
  const extendedSubtags = getTagMapValue(action?.data?.metaEntities?.extended);
115
115
 
116
+ const loyaltySubTagsData = getTagMapValue(action?.data?.metaEntities?.loyaltyTags);
117
+
116
118
  const getExistingTagLookupMap = (state) => {
117
119
  if (!state || !state.get) return {};
118
120
  const tagLookupMap = state.getIn(['metaEntities', 'tagLookupMap']);
@@ -126,6 +128,7 @@ function capReducer(state = fromJS(initialState.cap), action) {
126
128
  ...standardTagMap,
127
129
  ...customSubtags,
128
130
  ...extendedSubtags,
131
+ ...loyaltySubTagsData,
129
132
  ...getExistingTagLookupMap(state),
130
133
  };
131
134
  const stateMeta = state.get("metaEntities");
@@ -2,6 +2,7 @@ import {
2
2
  take, call, put, cancelled, takeLatest, all,
3
3
  fork,
4
4
  cancel,
5
+ select,
5
6
  } from 'redux-saga/effects';
6
7
  // import { normalize } from 'normalizr';
7
8
  import * as Api from '../../services/api';
@@ -14,6 +15,7 @@ import {
14
15
  getLoyaltyTopbarMenuDataValue,
15
16
  LOYALTY,
16
17
  } from "../App/constants";
18
+ import { loyaltyTagProps } from "../CreativesContainer/selectors";
17
19
  // import {makeSelectOrgId} from './selectors';
18
20
 
19
21
  export function* authorize(user) {
@@ -125,6 +127,17 @@ export function* fetchUserInfo(option) {
125
127
 
126
128
  export function* fetchSchemaForEntity(queryParams) {
127
129
  try {
130
+ // Get stored loyalty tag props from Redux state
131
+ const loyaltyTagPropsData = yield select(loyaltyTagProps());
132
+
133
+ // Check if loyalty module is enabled and data exists
134
+ const isLoyaltyModuleEnabled = loyaltyTagPropsData?.isLoyaltyModule;
135
+
136
+ // If loyalty module is enabled and data exists, we can add specific logic here
137
+ if (isLoyaltyModuleEnabled && loyaltyTagPropsData) {
138
+ queryParams.queryParams.loyaltyTagsParams = loyaltyTagPropsData;
139
+ }
140
+
128
141
  const result = yield call(Api.fetchSchemaForEntity, queryParams);
129
142
 
130
143
  // const sidebar = result.response.sidebar;
@@ -31,7 +31,8 @@ const setInjectedTags = () => createSelector(
31
31
  const { tags } = metaEntities;
32
32
  const customTags = tags && (tags.custom || {});
33
33
  const extendedTags = tags && (tags.extended || {});
34
- return (injectedTags = _.merge({}, injectedTags, customTags, extendedTags));
34
+ const loyaltyTags = tags && (tags.loyaltyTags || {});
35
+ return (injectedTags = _.merge({}, injectedTags, customTags, extendedTags, loyaltyTags));
35
36
  }
36
37
  );
37
38
 
@@ -0,0 +1,93 @@
1
+ import { call } from 'redux-saga/effects';
2
+ import { fromJS } from 'immutable';
3
+ import { expectSaga } from 'redux-saga-test-plan';
4
+ import { fetchSchemaForEntity } from '../sagas';
5
+ import * as api from '../../../services/api';
6
+ import { GET_SCHEMA_FOR_ENTITY_SUCCESS } from '../constants';
7
+
8
+ describe('fetchSchemaForEntity Saga Coverage Test', () => {
9
+ it('should handle success when loyalty module is enabled', () => {
10
+ const loyaltyMock = { isLoyaltyModule: true };
11
+
12
+ const inputQueryParams = {
13
+ queryParams: {
14
+ type: 'someType',
15
+ },
16
+ };
17
+
18
+ const expectedParams = {
19
+ queryParams: {
20
+ type: 'someType',
21
+ loyaltyTagsParams: loyaltyMock,
22
+ },
23
+ };
24
+
25
+ const apiResponse = {
26
+ success: true,
27
+ response: fromJS({ metaEntities: ['x'] }),
28
+ status: { code: '200' },
29
+ };
30
+
31
+ const mockReduxState = fromJS({
32
+ creativesContainer: {
33
+ loyaltyTagProps: loyaltyMock,
34
+ containerLoader: false,
35
+ },
36
+ });
37
+
38
+ return expectSaga(fetchSchemaForEntity, inputQueryParams)
39
+ .withState(mockReduxState) // ✅ Provides correct state for selector chain
40
+ .provide([
41
+ [call(api.fetchSchemaForEntity, expectedParams), apiResponse]
42
+ ])
43
+ .put({
44
+ type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
45
+ data: apiResponse.response,
46
+ statusCode: '200',
47
+ entityType: 'someType',
48
+ })
49
+ .run();
50
+ });
51
+
52
+ it('should handle success when loyalty module is disabled', () => {
53
+ const loyaltyMock = { isLoyaltyModule: false };
54
+
55
+ const inputQueryParams = {
56
+ queryParams: {
57
+ type: 'someType',
58
+ },
59
+ };
60
+
61
+ const expectedParams = {
62
+ queryParams: {
63
+ type: 'someType',
64
+ },
65
+ };
66
+
67
+ const apiResponse = {
68
+ success: true,
69
+ response: fromJS({ metaEntities: ['x'] }),
70
+ status: { code: '200' },
71
+ };
72
+
73
+ const mockReduxState = fromJS({
74
+ creativesContainer: {
75
+ loyaltyTagProps: loyaltyMock,
76
+ containerLoader: false,
77
+ },
78
+ });
79
+
80
+ return expectSaga(fetchSchemaForEntity, inputQueryParams)
81
+ .withState(mockReduxState) // ✅ Provides correct state for selector chain
82
+ .provide([
83
+ [call(api.fetchSchemaForEntity, expectedParams), apiResponse]
84
+ ])
85
+ .put({
86
+ type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
87
+ data: apiResponse.response,
88
+ statusCode: '200',
89
+ entityType: 'someType',
90
+ })
91
+ .run();
92
+ });
93
+ });