@capillarytech/creatives-library 8.0.183 → 8.0.184-beta.0
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,18 @@ export function* watchGetCdnTransformationConfig() {
|
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
// Zalo template info watcher - only for preview functionality from Templates component
|
|
230
|
+
export function* watchForGetTemplateInfoById() {
|
|
231
|
+
yield takeLatest(ZALO_TEMPLATE_INFO_REQUEST, function* handleZaloTemplateInfoRequest(action) {
|
|
232
|
+
// Only handle requests that are specifically for preview (have preview flag)
|
|
233
|
+
// Ignore edit requests (handled by Zalo component saga)
|
|
234
|
+
if (action.payload && action.payload.preview && !action.payload.edit) {
|
|
235
|
+
yield call(getTemplateInfoById, action);
|
|
236
|
+
}
|
|
237
|
+
// If it's not a preview request or is an edit request, let the Zalo component handle it
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
229
241
|
|
|
230
242
|
// All sagas to be loaded
|
|
231
243
|
export default [
|
|
@@ -239,6 +251,7 @@ export default [
|
|
|
239
251
|
watchGetOrgLevelCampaignSettings,
|
|
240
252
|
watchGetSenderDetails,
|
|
241
253
|
watchGetCdnTransformationConfig,
|
|
254
|
+
watchForGetTemplateInfoById, // Restored for preview functionality from Templates component
|
|
242
255
|
];
|
|
243
256
|
|
|
244
257
|
export function* v2TemplateSaga() {
|
|
@@ -251,7 +264,7 @@ export function* v2TemplateSaga() {
|
|
|
251
264
|
watchGetCdnTransformationConfig(),
|
|
252
265
|
watchFetchWeCrmAccounts(),
|
|
253
266
|
watchGetSenderDetails(),
|
|
254
|
-
|
|
267
|
+
watchForGetTemplateInfoById(), // Restored for preview functionality from Templates component
|
|
255
268
|
]);
|
|
256
269
|
}
|
|
257
270
|
|
|
@@ -132,15 +132,20 @@ 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
|
-
|
|
137
|
+
const hasRequiredData = zaloTempId && oa_id && token && username && hostName;
|
|
138
|
+
|
|
139
|
+
// Only make API call if we have all required data
|
|
140
|
+
// Add edit flag to distinguish from preview requests handled by Templates saga
|
|
141
|
+
if (hasRequiredData) {
|
|
138
142
|
actions.getTemplateInfoById({
|
|
139
143
|
username,
|
|
140
144
|
oa_id,
|
|
141
145
|
token,
|
|
142
146
|
host: hostName,
|
|
143
147
|
id: zaloTempId,
|
|
148
|
+
edit: true, // Flag to indicate this is an edit request, not preview
|
|
144
149
|
actionCallback,
|
|
145
150
|
});
|
|
146
151
|
}
|