@capillarytech/creatives-library 8.0.65 → 8.0.67

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.
@@ -180,12 +180,17 @@ function templatesReducer(state = initialState, action) {
180
180
  return state.set('fetchedOrgLevelCampaignSettings', false);
181
181
  case types.GET_SENDER_DETAILS_REQUEST:
182
182
  return state.set('senderDetails', { status: 'REQUEST' });
183
- case types.GET_SENDER_DETAILS_SUCCESS:
183
+ case types.GET_SENDER_DETAILS_SUCCESS: {
184
+ const { channel, domainProperties = {} } = action?.payload || {};
185
+ const isMultiAccountChannel = ['WHATSAPP', 'ZALO'].includes(channel);
186
+ const senderDetailsKey = isMultiAccountChannel ? 'domainProperties' : 'hostName';
187
+ // For Whatsapp and Zalo we need to store domainProperties instead of only hostName
184
188
  return state.set('senderDetails', {
185
189
  status: 'SUCCESS',
186
- hostName: action.payload,
190
+ [senderDetailsKey]: isMultiAccountChannel ? domainProperties : action?.payload,
187
191
  errors: [],
188
192
  });
193
+ }
189
194
  case types.GET_SENDER_DETAILS_FAILURE:
190
195
  return state.set('senderDetails', {
191
196
  status: 'FAILURE',
@@ -161,8 +161,13 @@ export function* getSenderDetails({
161
161
  if (!apiResponse?.errors?.length) {
162
162
  yield put({
163
163
  type: types.GET_SENDER_DETAILS_SUCCESS,
164
- payload: get(apiResponse, `entity.${channel}[0].domainProperties.hostName`, ''),
164
+ payload: ['WHATSAPP', 'ZALO'].includes(channel) ?
165
+ { channel,
166
+ domainProperties: get(apiResponse, `entity.${channel}`, '')
167
+ } :
168
+ get(apiResponse, `entity.${channel}[0].domainProperties.hostName`, ''),
165
169
  });
170
+
166
171
  } else {
167
172
  yield put({
168
173
  type: types.GET_SENDER_DETAILS_FAILURE,
@@ -10,11 +10,49 @@ exports[`Test Templates container Should render correct component for whatsapp c
10
10
  }
11
11
  }
12
12
  >
13
- <FormattedMessage
14
- defaultMessage="Whatsapp accounts are not setup for your brand"
15
- id="creatives.containersV2.Templates.noAccountsPresentWhatsapp"
16
- values={Object {}}
17
- />
13
+ <div
14
+ style={
15
+ Object {
16
+ "overflowX": "auto",
17
+ "paddingBottom": "1.142rem",
18
+ }
19
+ }
20
+ >
21
+ <CapHeader
22
+ className="select-account-header"
23
+ description="Choose the account to send content"
24
+ descriptionClass=""
25
+ inline={false}
26
+ size="regular"
27
+ title="Whatsapp account"
28
+ titleClass=""
29
+ />
30
+ <CapRadioCard
31
+ cardHeight="48px"
32
+ cardWidth="276px"
33
+ className="select-account"
34
+ defaultValue=""
35
+ onChange={[Function]}
36
+ panes={
37
+ Array [
38
+ Object {
39
+ "icon": <CapIconAvatar
40
+ backgroundProps={Object {}}
41
+ height="2rem"
42
+ labelProps={Object {}}
43
+ text="W"
44
+ width="auto"
45
+ />,
46
+ "key": "abc12",
47
+ "title": "WhatsappAccount",
48
+ "value": "WhatsappAccount",
49
+ },
50
+ ]
51
+ }
52
+ selected=""
53
+ size="small"
54
+ />
55
+ </div>
18
56
  </CapSkeleton>
19
57
  `;
20
58
 
@@ -190,6 +228,30 @@ exports[`Test Templates container Should render temlates when whatsapp templates
190
228
  templateInProgress={false}
191
229
  >
192
230
  <div>
231
+ <CapHeader
232
+ description={
233
+ <React.Fragment>
234
+ <CapHeading
235
+ type="h3"
236
+ >
237
+
238
+
239
+
240
+ </CapHeading>
241
+ </React.Fragment>
242
+ }
243
+ descriptionClass=""
244
+ inline={false}
245
+ size="regular"
246
+ title={
247
+ <CapHeading
248
+ type="h4"
249
+ >
250
+ Whatsapp account
251
+ </CapHeading>
252
+ }
253
+ titleClass=""
254
+ />
193
255
  <div
194
256
  className="action-container"
195
257
  >
@@ -423,6 +485,30 @@ exports[`Test Templates container Should render temlates when whatsapp templates
423
485
  templateInProgress={false}
424
486
  >
425
487
  <div>
488
+ <CapHeader
489
+ description={
490
+ <React.Fragment>
491
+ <CapHeading
492
+ type="h3"
493
+ >
494
+
495
+
496
+
497
+ </CapHeading>
498
+ </React.Fragment>
499
+ }
500
+ descriptionClass=""
501
+ inline={false}
502
+ size="regular"
503
+ title={
504
+ <CapHeading
505
+ type="h4"
506
+ >
507
+ Whatsapp account
508
+ </CapHeading>
509
+ }
510
+ titleClass=""
511
+ />
426
512
  <div
427
513
  className="action-container"
428
514
  >
@@ -474,24 +560,6 @@ exports[`Test Templates container Should render temlates when whatsapp templates
474
560
  />,
475
561
  "value": "rejected",
476
562
  },
477
- Object {
478
- "key": "pending",
479
- "label": <FormattedMessage
480
- defaultMessage="Pending"
481
- id="creatives.containersV2.Whatsapp.pending"
482
- values={Object {}}
483
- />,
484
- "value": "pending",
485
- },
486
- Object {
487
- "key": "paused",
488
- "label": <FormattedMessage
489
- defaultMessage="Paused"
490
- id="creatives.containersV2.Whatsapp.paused"
491
- values={Object {}}
492
- />,
493
- "value": "paused",
494
- },
495
563
  ]
496
564
  }
497
565
  dropdownMaxHeight="320px"
@@ -800,6 +868,30 @@ exports[`Test Templates container Test max templates exceeded 1`] = `
800
868
  templateInProgress={false}
801
869
  >
802
870
  <div>
871
+ <CapHeader
872
+ description={
873
+ <React.Fragment>
874
+ <CapHeading
875
+ type="h3"
876
+ >
877
+
878
+
879
+
880
+ </CapHeading>
881
+ </React.Fragment>
882
+ }
883
+ descriptionClass=""
884
+ inline={false}
885
+ size="regular"
886
+ title={
887
+ <CapHeading
888
+ type="h4"
889
+ >
890
+ Whatsapp account
891
+ </CapHeading>
892
+ }
893
+ titleClass=""
894
+ />
803
895
  <div
804
896
  className="action-container"
805
897
  >
@@ -851,24 +943,6 @@ exports[`Test Templates container Test max templates exceeded 1`] = `
851
943
  />,
852
944
  "value": "rejected",
853
945
  },
854
- Object {
855
- "key": "pending",
856
- "label": <FormattedMessage
857
- defaultMessage="Pending"
858
- id="creatives.containersV2.Whatsapp.pending"
859
- values={Object {}}
860
- />,
861
- "value": "pending",
862
- },
863
- Object {
864
- "key": "paused",
865
- "label": <FormattedMessage
866
- defaultMessage="Paused"
867
- id="creatives.containersV2.Whatsapp.paused"
868
- values={Object {}}
869
- />,
870
- "value": "paused",
871
- },
872
946
  ]
873
947
  }
874
948
  dropdownMaxHeight="320px"
@@ -1136,8 +1210,8 @@ Click {{unsubscribe}} to unsubscribe
1136
1210
  "base": Object {
1137
1211
  "content": Object {
1138
1212
  "whatsapp": Object {
1139
- "accessToken": "Bearer gDwEuRIm9icV6phixociSw==",
1140
- "accountId": "107499611940863",
1213
+ "accessToken": "Bearer abcd",
1214
+ "accountId": "12345",
1141
1215
  "buttonType": "CTA",
1142
1216
  "buttons": Array [
1143
1217
  Object {
@@ -1273,6 +1347,30 @@ exports[`Test Templates container Test max templates not exceeded 1`] = `
1273
1347
  templateInProgress={false}
1274
1348
  >
1275
1349
  <div>
1350
+ <CapHeader
1351
+ description={
1352
+ <React.Fragment>
1353
+ <CapHeading
1354
+ type="h3"
1355
+ >
1356
+
1357
+
1358
+
1359
+ </CapHeading>
1360
+ </React.Fragment>
1361
+ }
1362
+ descriptionClass=""
1363
+ inline={false}
1364
+ size="regular"
1365
+ title={
1366
+ <CapHeading
1367
+ type="h4"
1368
+ >
1369
+ Whatsapp account
1370
+ </CapHeading>
1371
+ }
1372
+ titleClass=""
1373
+ />
1276
1374
  <div
1277
1375
  className="action-container"
1278
1376
  >
@@ -1324,24 +1422,6 @@ exports[`Test Templates container Test max templates not exceeded 1`] = `
1324
1422
  />,
1325
1423
  "value": "rejected",
1326
1424
  },
1327
- Object {
1328
- "key": "pending",
1329
- "label": <FormattedMessage
1330
- defaultMessage="Pending"
1331
- id="creatives.containersV2.Whatsapp.pending"
1332
- values={Object {}}
1333
- />,
1334
- "value": "pending",
1335
- },
1336
- Object {
1337
- "key": "paused",
1338
- "label": <FormattedMessage
1339
- defaultMessage="Paused"
1340
- id="creatives.containersV2.Whatsapp.paused"
1341
- values={Object {}}
1342
- />,
1343
- "value": "paused",
1344
- },
1345
1425
  ]
1346
1426
  }
1347
1427
  dropdownMaxHeight="320px"
@@ -1591,8 +1671,8 @@ Click {{unsubscribe}} to unsubscribe
1591
1671
  "base": Object {
1592
1672
  "content": Object {
1593
1673
  "whatsapp": Object {
1594
- "accessToken": "Bearer gDwEuRIm9icV6phixociSw==",
1595
- "accountId": "107499611940863",
1674
+ "accessToken": "Bearer abcd",
1675
+ "accountId": "12345",
1596
1676
  "buttonType": "CTA",
1597
1677
  "buttons": Array [
1598
1678
  Object {
@@ -1728,6 +1808,30 @@ exports[`Test Templates container Test max templates warning 1`] = `
1728
1808
  templateInProgress={false}
1729
1809
  >
1730
1810
  <div>
1811
+ <CapHeader
1812
+ description={
1813
+ <React.Fragment>
1814
+ <CapHeading
1815
+ type="h3"
1816
+ >
1817
+
1818
+
1819
+
1820
+ </CapHeading>
1821
+ </React.Fragment>
1822
+ }
1823
+ descriptionClass=""
1824
+ inline={false}
1825
+ size="regular"
1826
+ title={
1827
+ <CapHeading
1828
+ type="h4"
1829
+ >
1830
+ Whatsapp account
1831
+ </CapHeading>
1832
+ }
1833
+ titleClass=""
1834
+ />
1731
1835
  <div
1732
1836
  className="action-container"
1733
1837
  >
@@ -1779,24 +1883,6 @@ exports[`Test Templates container Test max templates warning 1`] = `
1779
1883
  />,
1780
1884
  "value": "rejected",
1781
1885
  },
1782
- Object {
1783
- "key": "pending",
1784
- "label": <FormattedMessage
1785
- defaultMessage="Pending"
1786
- id="creatives.containersV2.Whatsapp.pending"
1787
- values={Object {}}
1788
- />,
1789
- "value": "pending",
1790
- },
1791
- Object {
1792
- "key": "paused",
1793
- "label": <FormattedMessage
1794
- defaultMessage="Paused"
1795
- id="creatives.containersV2.Whatsapp.paused"
1796
- values={Object {}}
1797
- />,
1798
- "value": "paused",
1799
- },
1800
1886
  ]
1801
1887
  }
1802
1888
  dropdownMaxHeight="320px"
@@ -2046,8 +2132,8 @@ Click {{unsubscribe}} to unsubscribe
2046
2132
  "base": Object {
2047
2133
  "content": Object {
2048
2134
  "whatsapp": Object {
2049
- "accessToken": "Bearer gDwEuRIm9icV6phixociSw==",
2050
- "accountId": "107499611940863",
2135
+ "accessToken": "Bearer abcd",
2136
+ "accountId": "12345",
2051
2137
  "buttonType": "CTA",
2052
2138
  "buttons": Array [
2053
2139
  Object {
@@ -2183,6 +2269,30 @@ exports[`Test Templates container Test removing all whatsapp filterss 1`] = `
2183
2269
  templateInProgress={false}
2184
2270
  >
2185
2271
  <div>
2272
+ <CapHeader
2273
+ description={
2274
+ <React.Fragment>
2275
+ <CapHeading
2276
+ type="h3"
2277
+ >
2278
+
2279
+
2280
+
2281
+ </CapHeading>
2282
+ </React.Fragment>
2283
+ }
2284
+ descriptionClass=""
2285
+ inline={false}
2286
+ size="regular"
2287
+ title={
2288
+ <CapHeading
2289
+ type="h4"
2290
+ >
2291
+ Whatsapp account
2292
+ </CapHeading>
2293
+ }
2294
+ titleClass=""
2295
+ />
2186
2296
  <div
2187
2297
  className="action-container"
2188
2298
  >
@@ -2442,6 +2552,30 @@ exports[`Test Templates container Test removing all whatsapp filterss 2`] = `
2442
2552
  templateInProgress={false}
2443
2553
  >
2444
2554
  <div>
2555
+ <CapHeader
2556
+ description={
2557
+ <React.Fragment>
2558
+ <CapHeading
2559
+ type="h3"
2560
+ >
2561
+
2562
+
2563
+
2564
+ </CapHeading>
2565
+ </React.Fragment>
2566
+ }
2567
+ descriptionClass=""
2568
+ inline={false}
2569
+ size="regular"
2570
+ title={
2571
+ <CapHeading
2572
+ type="h4"
2573
+ >
2574
+ Whatsapp account
2575
+ </CapHeading>
2576
+ }
2577
+ titleClass=""
2578
+ />
2445
2579
  <div
2446
2580
  className="action-container"
2447
2581
  >
@@ -2675,6 +2809,30 @@ exports[`Test Templates container Test removing single filter 1`] = `
2675
2809
  templateInProgress={false}
2676
2810
  >
2677
2811
  <div>
2812
+ <CapHeader
2813
+ description={
2814
+ <React.Fragment>
2815
+ <CapHeading
2816
+ type="h3"
2817
+ >
2818
+
2819
+
2820
+
2821
+ </CapHeading>
2822
+ </React.Fragment>
2823
+ }
2824
+ descriptionClass=""
2825
+ inline={false}
2826
+ size="regular"
2827
+ title={
2828
+ <CapHeading
2829
+ type="h4"
2830
+ >
2831
+ Whatsapp account
2832
+ </CapHeading>
2833
+ }
2834
+ titleClass=""
2835
+ />
2678
2836
  <div
2679
2837
  className="action-container"
2680
2838
  >
@@ -72,3 +72,34 @@ export const getAllTemplatesListFailure = {
72
72
  "message": "Resource Not Found",
73
73
  "error": {},
74
74
  };
75
+
76
+ export const senderDetailsWhatsapp = {
77
+ channel: "WHATSAPP",
78
+ domainProperties: {
79
+ connectionProperties: {
80
+ account_sid: "testSourceAccount",
81
+ wabaId: "testSourceAccount",
82
+ userid: "testSourceAccount",
83
+ sourceAccountIdentifier: "testSourceAccount",
84
+ },
85
+ hostname: "testWhatsappHost",
86
+ },
87
+ };
88
+
89
+ export const senderDetailsZalo = {
90
+ channel: "ZALO",
91
+ domainProperties: {
92
+ connectionProperties: {
93
+ oa_id: "testSourceAccount",
94
+ sourceAccountIdentifier: "testSourceAccount",
95
+ },
96
+ hostname: "testZaloHost",
97
+ },
98
+ };
99
+
100
+ export const senderDetailsSMS = {
101
+ channel: "SMS",
102
+ hostName: "TestSMSHost",
103
+ };
104
+
105
+ export const errorMessage = ["Error fetching sender details"];
@@ -48,3 +48,63 @@ describe("test reducer", () => {
48
48
  });
49
49
  });
50
50
  });
51
+
52
+
53
+ describe("test reducer - sender details", () => {
54
+ afterEach(() => {
55
+ jest.clearAllMocks();
56
+ });
57
+
58
+ it("should handle GET_SENDER_DETAILS_REQUEST", () => {
59
+ const action = { type: types.GET_SENDER_DETAILS_REQUEST };
60
+ expect(reducer(initialState, action).toJS()).toEqual({
61
+ ...initialState.toJS(),
62
+ senderDetails: { status: "REQUEST" },
63
+ });
64
+ });
65
+
66
+ it("should handle GET_SENDER_DETAILS_SUCCESS for WHATSAPP (multi-account channel)", () => {
67
+ const action = {
68
+ type: types.GET_SENDER_DETAILS_SUCCESS,
69
+ payload: mockData.senderDetailsWhatsapp,
70
+ };
71
+ expect(reducer(initialState, action).toJS()).toEqual({
72
+ ...initialState.toJS(),
73
+ senderDetails: {
74
+ status: "SUCCESS",
75
+ domainProperties: mockData.senderDetailsWhatsapp.domainProperties,
76
+ errors: [],
77
+ },
78
+ });
79
+ });
80
+
81
+ it("should handle GET_SENDER_DETAILS_SUCCESS for non-multi-account channel", () => {
82
+ const action = {
83
+ type: types.GET_SENDER_DETAILS_SUCCESS,
84
+ payload: mockData.senderDetailsSMS.hostName,
85
+ };
86
+ expect(reducer(initialState, action).toJS()).toEqual({
87
+ ...initialState.toJS(),
88
+ senderDetails: {
89
+ status: "SUCCESS",
90
+ hostName: mockData.senderDetailsSMS.hostName,
91
+ errors: [],
92
+ },
93
+ });
94
+ });
95
+
96
+ it("should handle GET_SENDER_DETAILS_FAILURE", () => {
97
+ const action = {
98
+ type: types.GET_SENDER_DETAILS_FAILURE,
99
+ payload: mockData.errorMessage,
100
+ };
101
+ expect(reducer(initialState, action).toJS()).toEqual({
102
+ ...initialState.toJS(),
103
+ senderDetails: {
104
+ status: "FAILURE",
105
+ hostName: "",
106
+ errors: mockData.errorMessage,
107
+ },
108
+ });
109
+ });
110
+ });
@@ -144,32 +144,12 @@ export const TWILIO_CATEGORY_OPTIONS = [
144
144
  },
145
145
  ];
146
146
 
147
- export const ICS_CATEGORY_OPTIONS = [
148
- {
149
- key: 'utility',
150
- value: WHATSAPP_CATEGORIES.utility,
151
- label: <FormattedMessage {...messages.utility} />,
152
- tooltipLabel: <FormattedMessage {...messages.utilityTooltip} />,
153
- tagColor: CAP_PURPLE03,
154
- tagTextColor: CAP_PURPLE02,
155
- },
156
- {
157
- key: 'marketing',
158
- value: WHATSAPP_CATEGORIES.marketing,
159
- label: <FormattedMessage {...messages.marketing} />,
160
- tooltipLabel: <FormattedMessage {...messages.marketingTooltip} />,
161
- tagColor: CAP_ORANGE01,
162
- tagTextColor: CAP_ORANGE,
163
- },
164
- ];
165
-
166
147
  export const WHATSAPP_STATUSES = {
167
148
  awaitingApproval: 'awaitingApproval',
168
149
  approved: 'approved',
169
150
  rejected: 'rejected',
170
151
  pending: 'pending',
171
152
  unsubmitted: 'unsubmitted',
172
- paused: 'paused',
173
153
  };
174
154
 
175
155
  export const STATUS_OPTIONS = [
@@ -188,16 +168,6 @@ export const STATUS_OPTIONS = [
188
168
  value: WHATSAPP_STATUSES.rejected,
189
169
  label: <FormattedMessage {...messages.rejected} />,
190
170
  },
191
- {
192
- key: 'pending',
193
- value: WHATSAPP_STATUSES.pending,
194
- label: <FormattedMessage {...messages.pending} />,
195
- },
196
- {
197
- key: 'paused',
198
- value: WHATSAPP_STATUSES.paused,
199
- label: <FormattedMessage {...messages.paused} />,
200
- },
201
171
  ];
202
172
 
203
173
  export const TAG = 'TAG';
@@ -258,7 +228,6 @@ export const WHATSAPP_DOCUMENT_SIZE = 16000000; // 16MB
258
228
  export const HOST_TWILIO = 'twiliowhatsapptrans';
259
229
  export const HOST_KARIX = 'karixwhatsappbulk';
260
230
  export const HOST_GUPSHUP = 'gupshupwhatsappbulk';
261
- export const HOST_ICS = 'icswababulk';
262
231
  export const SIZE_UNITS = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
263
232
  export const DOCUMENT_FORMAT = 'PDF';
264
233
  export const DOCUMENT_SIZE = '16 MB';
@@ -559,11 +528,4 @@ export const LANGUAGE_OPTIONS = [
559
528
  ];
560
529
 
561
530
  export const OTP_CONFIG_URI = "/org/setup/configurations/OTPConfigurations";
562
- export const AI_CONTENT_BOT_DISABLED = "AI_CONTENT_BOT_DISABLED";
563
- export const CORRECT_TEMPLATE_FORMAT_URL = "https://developers.facebook.com/docs/whatsapp/updates-to-pricing/new-template-guidelines";
564
- export const CATEGORY_OPTIONS_MAP = {
565
- [HOST_TWILIO]: TWILIO_CATEGORY_OPTIONS,
566
- [HOST_KARIX]: KARIX_GUPSHUP_CATEGORY_OPTIONS,
567
- [HOST_GUPSHUP]: KARIX_GUPSHUP_CATEGORY_OPTIONS,
568
- [HOST_ICS]: ICS_CATEGORY_OPTIONS,
569
- };
531
+ export const AI_CONTENT_BOT_DISABLED = "AI_CONTENT_BOT_DISABLED";