@capillarytech/creatives-library 7.12.63 → 7.12.65
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/package.json +1 -1
- package/v2Components/CapWhatsappCTA/index.js +12 -24
- package/v2Components/CapWhatsappCTA/index.scss +1 -1
- package/v2Components/CapWhatsappCTA/messages.js +2 -2
- package/v2Containers/Whatsapp/index.js +6 -3
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +0 -20
package/package.json
CHANGED
|
@@ -47,15 +47,12 @@ export const CapWhatsappCTA = (props) => {
|
|
|
47
47
|
deleteHandler,
|
|
48
48
|
isEditFlow,
|
|
49
49
|
hostName,
|
|
50
|
-
isFullMode,
|
|
51
50
|
tags = [],
|
|
52
51
|
injectedTags = {},
|
|
53
52
|
selectedOfferDetails = [],
|
|
54
53
|
} = props;
|
|
55
54
|
const { formatMessage } = intl;
|
|
56
|
-
const validVarRegex = /{{(1)}}/g;
|
|
57
55
|
const invalidVarRegex = /{{(.*?)}}/g;
|
|
58
|
-
const moreThanTwoBracketsRegex = /{{3,}(1)}{3,}/g;
|
|
59
56
|
|
|
60
57
|
const [urlError, setUrlError] = useState(false);
|
|
61
58
|
|
|
@@ -65,8 +62,12 @@ export const CapWhatsappCTA = (props) => {
|
|
|
65
62
|
...clonedCta,
|
|
66
63
|
[type]: value,
|
|
67
64
|
};
|
|
68
|
-
if (type === 'urlType') {
|
|
65
|
+
if (type === 'urlType' && value === STATIC_URL) {
|
|
69
66
|
clonedCta.url = '';
|
|
67
|
+
setUrlError(false);
|
|
68
|
+
} else if (type === 'urlType' && value === DYNAMIC_URL) {
|
|
69
|
+
clonedCta.url = '{{1}}';
|
|
70
|
+
setUrlError(formatMessage(messages.ctaWebsiteUrlErrorMessage));
|
|
70
71
|
}
|
|
71
72
|
updateHandler(clonedCta, index);
|
|
72
73
|
};
|
|
@@ -152,32 +153,19 @@ export const CapWhatsappCTA = (props) => {
|
|
|
152
153
|
|
|
153
154
|
const onUrlTypeChange = (value, index) => {
|
|
154
155
|
updateHelper('urlType', value, index);
|
|
155
|
-
setUrlError(false);
|
|
156
156
|
};
|
|
157
157
|
|
|
158
158
|
const onUrlChange = ({ target }, urlType) => {
|
|
159
|
-
|
|
159
|
+
let { value, id } = target;
|
|
160
|
+
if (urlType === DYNAMIC_URL) {
|
|
161
|
+
value = value.replace(invalidVarRegex, '');
|
|
162
|
+
value = `${value}{{1}}`;
|
|
163
|
+
}
|
|
160
164
|
let errorMessage = false;
|
|
161
165
|
if (!isUrl(value)) {
|
|
162
166
|
errorMessage = formatMessage(messages.ctaWebsiteUrlErrorMessage);
|
|
163
|
-
} else {
|
|
164
|
-
|
|
165
|
-
const validVarSet = [...new Set(validVarArr)];
|
|
166
|
-
const invalidVarArr = value.match(invalidVarRegex) || [];
|
|
167
|
-
const invalidVarSet = [...new Set(invalidVarArr)];
|
|
168
|
-
if (validVarArr?.length > 0 || invalidVarArr?.length > 0) {
|
|
169
|
-
if (urlType === STATIC_URL) {
|
|
170
|
-
errorMessage = formatMessage(messages.staticUrlWithVarErrorMessage);
|
|
171
|
-
} else if (validVarArr?.length > 1) {
|
|
172
|
-
errorMessage = formatMessage(
|
|
173
|
-
messages.dynamicUrlWithMoreVarErrorMessage,
|
|
174
|
-
);
|
|
175
|
-
} else if (invalidVarSet?.length !== validVarSet?.length) {
|
|
176
|
-
errorMessage = formatMessage(messages.dynamicUrlUnknownVars);
|
|
177
|
-
} else if (value.match(moreThanTwoBracketsRegex)?.length > 0) {
|
|
178
|
-
errorMessage = formatMessage(messages.useTwoBracketsOnly);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
167
|
+
} else if (urlType === STATIC_URL && value.match(invalidVarRegex)?.length > 0) {
|
|
168
|
+
errorMessage = formatMessage(messages.staticUrlWithVarErrorMessage);
|
|
181
169
|
}
|
|
182
170
|
setUrlError(errorMessage);
|
|
183
171
|
updateHelper('url', value, id);
|
|
@@ -78,11 +78,11 @@ export default defineMessages({
|
|
|
78
78
|
},
|
|
79
79
|
staticUrlWithVarErrorMessage: {
|
|
80
80
|
id: `${prefix}.staticUrlWithVarErrorMessage`,
|
|
81
|
-
defaultMessage: 'Button with
|
|
81
|
+
defaultMessage: 'Button with url type as static cannot contain variables',
|
|
82
82
|
},
|
|
83
83
|
dynamicUrlWithMoreVarErrorMessage: {
|
|
84
84
|
id: `${prefix}.dynamicUrlWithMoreVarErrorMessage`,
|
|
85
|
-
defaultMessage: 'Button with
|
|
85
|
+
defaultMessage: 'Button with url type as dynamic can have only 1 variable',
|
|
86
86
|
},
|
|
87
87
|
dynamicUrlUnknownVars: {
|
|
88
88
|
id: `${prefix}.dynamicUrlUnknownVars`,
|
|
@@ -532,7 +532,6 @@ export const Whatsapp = (props) => {
|
|
|
532
532
|
deleteHandler={deleteHandler}
|
|
533
533
|
isEditFlow={isEditFlow}
|
|
534
534
|
hostName={host}
|
|
535
|
-
isFullMode={isFullMode}
|
|
536
535
|
/>
|
|
537
536
|
)}
|
|
538
537
|
</>
|
|
@@ -872,7 +871,12 @@ export const Whatsapp = (props) => {
|
|
|
872
871
|
});
|
|
873
872
|
|
|
874
873
|
const actionCallback = ({ errorMessage }) => {
|
|
875
|
-
|
|
874
|
+
let error = '';
|
|
875
|
+
if (host === HOST_KARIX) {
|
|
876
|
+
error = JSON.parse(errorMessage.errorMessage).error.message || 'Error';
|
|
877
|
+
} else {
|
|
878
|
+
error = errorMessage?.message || errorMessage;
|
|
879
|
+
}
|
|
876
880
|
if (!error) {
|
|
877
881
|
CapNotification.success({
|
|
878
882
|
message: formatMessage(messages.whatsappCreateNotification, {
|
|
@@ -1309,7 +1313,6 @@ export const Whatsapp = (props) => {
|
|
|
1309
1313
|
deleteHandler={deleteHandler}
|
|
1310
1314
|
isEditFlow={isEditFlow}
|
|
1311
1315
|
hostName={host}
|
|
1312
|
-
isFullMode={isFullMode}
|
|
1313
1316
|
tags={tags || []}
|
|
1314
1317
|
injectedTags={injectedTags || {}}
|
|
1315
1318
|
selectedOfferDetails={selectedOfferDetails}
|
|
@@ -57988,7 +57988,6 @@ T&C'
|
|
|
57988
57988
|
hostName=""
|
|
57989
57989
|
injectedTags={Object {}}
|
|
57990
57990
|
isEditFlow={true}
|
|
57991
|
-
isFullMode={true}
|
|
57992
57991
|
key=".2"
|
|
57993
57992
|
tags={Array []}
|
|
57994
57993
|
updateHandler={[Function]}
|
|
@@ -59871,7 +59870,6 @@ T&C'
|
|
|
59871
59870
|
}
|
|
59872
59871
|
}
|
|
59873
59872
|
isEditFlow={true}
|
|
59874
|
-
isFullMode={true}
|
|
59875
59873
|
tags={Array []}
|
|
59876
59874
|
updateHandler={[Function]}
|
|
59877
59875
|
>
|
|
@@ -89811,7 +89809,6 @@ T&C'
|
|
|
89811
89809
|
hostName=""
|
|
89812
89810
|
injectedTags={Object {}}
|
|
89813
89811
|
isEditFlow={true}
|
|
89814
|
-
isFullMode={true}
|
|
89815
89812
|
key=".2"
|
|
89816
89813
|
tags={Array []}
|
|
89817
89814
|
updateHandler={[Function]}
|
|
@@ -91694,7 +91691,6 @@ T&C'
|
|
|
91694
91691
|
}
|
|
91695
91692
|
}
|
|
91696
91693
|
isEditFlow={true}
|
|
91697
|
-
isFullMode={true}
|
|
91698
91694
|
tags={Array []}
|
|
91699
91695
|
updateHandler={[Function]}
|
|
91700
91696
|
>
|
|
@@ -105598,7 +105594,6 @@ Click {{unsubscribe}} to unsubscribe",
|
|
|
105598
105594
|
hostName=""
|
|
105599
105595
|
injectedTags={Object {}}
|
|
105600
105596
|
isEditFlow={true}
|
|
105601
|
-
isFullMode={false}
|
|
105602
105597
|
key=".2"
|
|
105603
105598
|
tags={Array []}
|
|
105604
105599
|
updateHandler={[Function]}
|
|
@@ -107481,7 +107476,6 @@ Click {{unsubscribe}} to unsubscribe",
|
|
|
107481
107476
|
}
|
|
107482
107477
|
}
|
|
107483
107478
|
isEditFlow={true}
|
|
107484
|
-
isFullMode={false}
|
|
107485
107479
|
tags={Array []}
|
|
107486
107480
|
updateHandler={[Function]}
|
|
107487
107481
|
>
|
|
@@ -115982,7 +115976,6 @@ exports[`Creatives Whatsapp test1/> should render edit mode in various cases 6`]
|
|
|
115982
115976
|
hostName=""
|
|
115983
115977
|
injectedTags={Object {}}
|
|
115984
115978
|
isEditFlow={true}
|
|
115985
|
-
isFullMode={false}
|
|
115986
115979
|
key=".2"
|
|
115987
115980
|
tags={Array []}
|
|
115988
115981
|
updateHandler={[Function]}
|
|
@@ -117856,7 +117849,6 @@ exports[`Creatives Whatsapp test1/> should render edit mode in various cases 6`]
|
|
|
117856
117849
|
}
|
|
117857
117850
|
}
|
|
117858
117851
|
isEditFlow={true}
|
|
117859
|
-
isFullMode={false}
|
|
117860
117852
|
tags={Array []}
|
|
117861
117853
|
updateHandler={[Function]}
|
|
117862
117854
|
>
|
|
@@ -334054,7 +334046,6 @@ exports[`Creatives Whatsapp test2/> set all valid values and send for approval 1
|
|
|
334054
334046
|
deleteHandler={[Function]}
|
|
334055
334047
|
hostName=""
|
|
334056
334048
|
isEditFlow={false}
|
|
334057
|
-
isFullMode={true}
|
|
334058
334049
|
updateHandler={[Function]}
|
|
334059
334050
|
/>
|
|
334060
334051
|
</React.Fragment>,
|
|
@@ -334118,7 +334109,6 @@ exports[`Creatives Whatsapp test2/> set all valid values and send for approval 1
|
|
|
334118
334109
|
deleteHandler={[Function]}
|
|
334119
334110
|
hostName=""
|
|
334120
334111
|
isEditFlow={false}
|
|
334121
|
-
isFullMode={true}
|
|
334122
334112
|
updateHandler={[Function]}
|
|
334123
334113
|
/>
|
|
334124
334114
|
</React.Fragment>,
|
|
@@ -334274,7 +334264,6 @@ exports[`Creatives Whatsapp test2/> set all valid values and send for approval 1
|
|
|
334274
334264
|
deleteHandler={[Function]}
|
|
334275
334265
|
hostName=""
|
|
334276
334266
|
isEditFlow={false}
|
|
334277
|
-
isFullMode={true}
|
|
334278
334267
|
updateHandler={[Function]}
|
|
334279
334268
|
>
|
|
334280
334269
|
<CapWhatsappCTA
|
|
@@ -336133,7 +336122,6 @@ exports[`Creatives Whatsapp test2/> set all valid values and send for approval 1
|
|
|
336133
336122
|
}
|
|
336134
336123
|
}
|
|
336135
336124
|
isEditFlow={false}
|
|
336136
|
-
isFullMode={true}
|
|
336137
336125
|
updateHandler={[Function]}
|
|
336138
336126
|
>
|
|
336139
336127
|
<CapRow>
|
|
@@ -354122,7 +354110,6 @@ undefined",
|
|
|
354122
354110
|
deleteHandler={[Function]}
|
|
354123
354111
|
hostName=""
|
|
354124
354112
|
isEditFlow={false}
|
|
354125
|
-
isFullMode={true}
|
|
354126
354113
|
updateHandler={[Function]}
|
|
354127
354114
|
/>
|
|
354128
354115
|
</React.Fragment>,
|
|
@@ -354198,7 +354185,6 @@ undefined",
|
|
|
354198
354185
|
deleteHandler={[Function]}
|
|
354199
354186
|
hostName=""
|
|
354200
354187
|
isEditFlow={false}
|
|
354201
|
-
isFullMode={true}
|
|
354202
354188
|
updateHandler={[Function]}
|
|
354203
354189
|
/>
|
|
354204
354190
|
</React.Fragment>,
|
|
@@ -354366,7 +354352,6 @@ undefined",
|
|
|
354366
354352
|
deleteHandler={[Function]}
|
|
354367
354353
|
hostName=""
|
|
354368
354354
|
isEditFlow={false}
|
|
354369
|
-
isFullMode={true}
|
|
354370
354355
|
updateHandler={[Function]}
|
|
354371
354356
|
>
|
|
354372
354357
|
<CapWhatsappCTA
|
|
@@ -356237,7 +356222,6 @@ undefined",
|
|
|
356237
356222
|
}
|
|
356238
356223
|
}
|
|
356239
356224
|
isEditFlow={false}
|
|
356240
|
-
isFullMode={true}
|
|
356241
356225
|
updateHandler={[Function]}
|
|
356242
356226
|
>
|
|
356243
356227
|
<CapRow
|
|
@@ -375274,7 +375258,6 @@ undefined",
|
|
|
375274
375258
|
deleteHandler={[Function]}
|
|
375275
375259
|
hostName=""
|
|
375276
375260
|
isEditFlow={false}
|
|
375277
|
-
isFullMode={true}
|
|
375278
375261
|
updateHandler={[Function]}
|
|
375279
375262
|
/>
|
|
375280
375263
|
</React.Fragment>,
|
|
@@ -375359,7 +375342,6 @@ undefined",
|
|
|
375359
375342
|
deleteHandler={[Function]}
|
|
375360
375343
|
hostName=""
|
|
375361
375344
|
isEditFlow={false}
|
|
375362
|
-
isFullMode={true}
|
|
375363
375345
|
updateHandler={[Function]}
|
|
375364
375346
|
/>
|
|
375365
375347
|
</React.Fragment>,
|
|
@@ -375536,7 +375518,6 @@ undefined",
|
|
|
375536
375518
|
deleteHandler={[Function]}
|
|
375537
375519
|
hostName=""
|
|
375538
375520
|
isEditFlow={false}
|
|
375539
|
-
isFullMode={true}
|
|
375540
375521
|
updateHandler={[Function]}
|
|
375541
375522
|
>
|
|
375542
375523
|
<CapWhatsappCTA
|
|
@@ -377416,7 +377397,6 @@ undefined",
|
|
|
377416
377397
|
}
|
|
377417
377398
|
}
|
|
377418
377399
|
isEditFlow={false}
|
|
377419
|
-
isFullMode={true}
|
|
377420
377400
|
updateHandler={[Function]}
|
|
377421
377401
|
>
|
|
377422
377402
|
<CapRow
|