@capillarytech/creatives-library 8.0.183 → 8.0.184
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
CHANGED
|
@@ -149,6 +149,22 @@ const MediaUploaders = ({
|
|
|
149
149
|
)));
|
|
150
150
|
}, [getCurrentCarouselData, setCurrentCarouselData]);
|
|
151
151
|
|
|
152
|
+
// Create carousel button tag select callback at component level to avoid hooks violation
|
|
153
|
+
const createCarouselButtonTagSelectCallback = useCallback((cardIndex) => {
|
|
154
|
+
return (value) => {
|
|
155
|
+
const currentData = getCurrentCarouselData();
|
|
156
|
+
const card = currentData[cardIndex];
|
|
157
|
+
const button = card?.buttons?.[0];
|
|
158
|
+
if (button) {
|
|
159
|
+
const newUrl = `${button?.externalLinkValue}{{${value}}}`;
|
|
160
|
+
// Update carousel card directly using updateCarouselCard
|
|
161
|
+
const updatedButtons = [...card?.buttons];
|
|
162
|
+
updatedButtons[0] = { ...updatedButtons[0], externalLinkValue: newUrl };
|
|
163
|
+
updateCarouselCard(cardIndex, { buttons: updatedButtons });
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}, [getCurrentCarouselData, updateCarouselCard]);
|
|
167
|
+
|
|
152
168
|
// Clear previous media data when switching media types
|
|
153
169
|
useEffect(() => {
|
|
154
170
|
// Clear carousel data when switching to non-carousel media types
|
|
@@ -569,13 +585,8 @@ const MediaUploaders = ({
|
|
|
569
585
|
|
|
570
586
|
const button = card?.buttons[0]; // We're handling only one button for now
|
|
571
587
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
const newUrl = `${button?.externalLinkValue}{{${value}}}`;
|
|
575
|
-
handleCarouselExternalLinkChange(cardIndex, newUrl);
|
|
576
|
-
},
|
|
577
|
-
[handleCarouselExternalLinkChange, button?.externalLinkValue]
|
|
578
|
-
);
|
|
588
|
+
// Use the callback creator instead of useCallback inside render function
|
|
589
|
+
const onButtonTagSelect = createCarouselButtonTagSelectCallback(cardIndex);
|
|
579
590
|
|
|
580
591
|
return (
|
|
581
592
|
<>
|
|
@@ -647,7 +658,7 @@ const MediaUploaders = ({
|
|
|
647
658
|
)}
|
|
648
659
|
{button?.linkType === EXTERNAL_LINK && (
|
|
649
660
|
<CapColumn span={14}>
|
|
650
|
-
<CapRow>
|
|
661
|
+
<CapRow className="buttons-heading-container">
|
|
651
662
|
<CapHeading type="h4" className="buttons-heading">
|
|
652
663
|
{formatMessage(messages.externalLink)}
|
|
653
664
|
</CapHeading>
|
|
@@ -148,10 +148,15 @@
|
|
|
148
148
|
margin-bottom: $CAP_SPACE_16;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
.buttons-heading-container {
|
|
152
|
+
display: flex;
|
|
153
|
+
justify-content: space-between;
|
|
154
|
+
}
|
|
155
|
+
|
|
151
156
|
.buttons-heading {
|
|
152
157
|
margin-bottom: $CAP_SPACE_12;
|
|
153
158
|
margin-top: $CAP_SPACE_12;
|
|
154
|
-
margin-right:
|
|
159
|
+
margin-right: 43%;
|
|
155
160
|
}
|
|
156
161
|
|
|
157
162
|
.helper-text {
|
|
@@ -7,8 +7,8 @@ import * as Api from '../../services/api';
|
|
|
7
7
|
import * as types from './constants';
|
|
8
8
|
import { saveCdnConfigs, removeAllCdnLocalStorageItems } from '../../utils/cdnTransformation';
|
|
9
9
|
import { COPY_OF } from '../../constants/unified';
|
|
10
|
-
|
|
11
|
-
import {
|
|
10
|
+
import { ZALO_TEMPLATE_INFO_REQUEST } from '../Zalo/constants';
|
|
11
|
+
import { getTemplateInfoById } from '../Zalo/saga';
|
|
12
12
|
// Individual exports for testing
|
|
13
13
|
export function* getAllTemplates(channel, queryParams) {
|
|
14
14
|
try {
|
|
@@ -226,6 +226,16 @@ export function* watchGetCdnTransformationConfig() {
|
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
// Zalo template info watcher - only for preview if previewUrl is empty from Templates component
|
|
230
|
+
export function* watchForGetTemplateInfoById() {
|
|
231
|
+
yield takeLatest(ZALO_TEMPLATE_INFO_REQUEST, function* handleZaloTemplateInfoRequest(action) {
|
|
232
|
+
// Ignore edit requests (Already handled by Zalo component saga)
|
|
233
|
+
if (!action?.payload?.edit) {
|
|
234
|
+
yield call(getTemplateInfoById, action);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
229
239
|
|
|
230
240
|
// All sagas to be loaded
|
|
231
241
|
export default [
|
|
@@ -239,6 +249,7 @@ export default [
|
|
|
239
249
|
watchGetOrgLevelCampaignSettings,
|
|
240
250
|
watchGetSenderDetails,
|
|
241
251
|
watchGetCdnTransformationConfig,
|
|
252
|
+
watchForGetTemplateInfoById, // Restored for preview functionality from Templates component
|
|
242
253
|
];
|
|
243
254
|
|
|
244
255
|
export function* v2TemplateSaga() {
|
|
@@ -251,7 +262,7 @@ export function* v2TemplateSaga() {
|
|
|
251
262
|
watchGetCdnTransformationConfig(),
|
|
252
263
|
watchFetchWeCrmAccounts(),
|
|
253
264
|
watchGetSenderDetails(),
|
|
254
|
-
|
|
265
|
+
watchForGetTemplateInfoById(), // Restored for preview functionality from Templates component
|
|
255
266
|
]);
|
|
256
267
|
}
|
|
257
268
|
|
|
@@ -132,8 +132,9 @@ export const Zalo = (props) => {
|
|
|
132
132
|
}
|
|
133
133
|
}, [selectedZaloAccount, templateData]);
|
|
134
134
|
|
|
135
|
-
//gets template details
|
|
135
|
+
//gets template details - prevent duplicate calls with Templates saga
|
|
136
136
|
useEffect(() => {
|
|
137
|
+
// Add edit flag to distinguish from preview requests handled by Templates saga
|
|
137
138
|
if (zaloTempId && oa_id && token && username && hostName) {
|
|
138
139
|
actions.getTemplateInfoById({
|
|
139
140
|
username,
|
|
@@ -141,6 +142,7 @@ export const Zalo = (props) => {
|
|
|
141
142
|
token,
|
|
142
143
|
host: hostName,
|
|
143
144
|
id: zaloTempId,
|
|
145
|
+
edit: true, // Flag to indicate this is an edit request, not preview
|
|
144
146
|
actionCallback,
|
|
145
147
|
});
|
|
146
148
|
}
|