@capillarytech/creatives-library 8.0.276 → 8.0.278

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 (26) hide show
  1. package/package.json +1 -1
  2. package/utils/tests/imageUrlUpload.test.js +298 -0
  3. package/v2Containers/CreativesContainer/SlideBoxContent.js +2 -0
  4. package/v2Containers/CreativesContainer/SlideBoxFooter.js +5 -2
  5. package/v2Containers/CreativesContainer/index.js +10 -6
  6. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +165 -41
  7. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +6 -0
  8. package/v2Containers/Email/index.js +75 -9
  9. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +14 -8
  10. package/v2Containers/EmailWrapper/components/EmailWrapperView.js +6 -2
  11. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +189 -6
  12. package/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +137 -0
  13. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +7 -3
  14. package/v2Containers/EmailWrapper/index.js +3 -0
  15. package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +26 -0
  16. package/v2Containers/Facebook/Advertisement/index.js +1 -1
  17. package/v2Containers/Line/Container/_lineCreate.scss +1 -0
  18. package/v2Containers/Line/Container/style.js +1 -1
  19. package/v2Containers/MobilePush/Edit/index.js +6 -5
  20. package/v2Containers/SmsTrai/Create/index.scss +1 -1
  21. package/v2Containers/SmsTrai/Edit/index.js +9 -3
  22. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +11682 -86
  23. package/v2Containers/SmsTrai/Edit/tests/index.test.js +5 -0
  24. package/v2Containers/Viber/index.js +7 -0
  25. package/v2Containers/Viber/index.scss +4 -1
  26. package/v2Containers/Viber/style.js +0 -2
@@ -66,6 +66,7 @@ const useEmailWrapper = ({
66
66
  Email,
67
67
  templateData,
68
68
  params,
69
+ isEditEmail = true,
69
70
  }) => {
70
71
  // State management
71
72
  const [templateName, setTemplateName] = useState('');
@@ -194,7 +195,10 @@ const useEmailWrapper = ({
194
195
  return;
195
196
  }
196
197
 
197
- // New flow: Fetch template details if we're in edit mode and don't have template data yet
198
+ // New flow: Fetch template details only when editing (not when creating)
199
+ if (!isEditEmail) {
200
+ return;
201
+ }
198
202
  const hasParamsId = params?.id || location?.query?.id || location?.params?.id || location?.pathname?.includes('/edit/');
199
203
  const hasTemplateDetails = Email?.templateDetails && !isEmpty(Email.templateDetails);
200
204
  const hasTemplateDataProp = templateData && !isEmpty(templateData);
@@ -207,7 +211,7 @@ const useEmailWrapper = ({
207
211
  emailActions.getTemplateDetails(templateId, 'email');
208
212
  }
209
213
  }
210
- }, [params?.id, location?.query?.id, location?.params?.id, location?.pathname, Email?.templateDetails, Email?.getTemplateDetailsInProgress, templateData, emailActions]);
214
+ }, [isEditEmail, params?.id, location?.query?.id, location?.params?.id, location?.pathname, Email?.templateDetails, Email?.getTemplateDetailsInProgress, templateData, emailActions]);
211
215
 
212
216
  // Effect to set BEETemplate when template details are loaded for BEE templates
213
217
  // This ensures Email component can properly initialize BEE editor
@@ -643,7 +647,7 @@ const useEmailWrapper = ({
643
647
  // If template was created in BEE AND BEE is enabled → open in BEE editor
644
648
  // Otherwise → open in HTML editor (fallback)
645
649
  // IMPORTANT: When supportCKEditor is false, default to HTML editor unless explicitly BEE
646
- if (isDragDrop && isBeeEnabled) {
650
+ if ((isDragDrop && isBeeEnabled)) {
647
651
  editorType = 'BEE';
648
652
  selectedEditorMode = null; // BEE uses existing flow
649
653
  } else {
@@ -85,6 +85,7 @@ const EmailWrapper = (props) => {
85
85
  createTemplateInProgress,
86
86
  fetchingCmsData,
87
87
  onHtmlEditorValidationStateChange,
88
+ isEditEmail = true,
88
89
  } = props;
89
90
 
90
91
  // Pass destructured props to the custom hook
@@ -143,6 +144,7 @@ const EmailWrapper = (props) => {
143
144
  Email,
144
145
  templateData,
145
146
  params,
147
+ isEditEmail,
146
148
  });
147
149
 
148
150
  // Render using the presentation component with data from the hook
@@ -195,6 +197,7 @@ const EmailWrapper = (props) => {
195
197
  setIsLoadingContent={setIsLoadingContent}
196
198
  templateData={templateData}
197
199
  params={params}
200
+ isEditEmail={isEditEmail}
198
201
  showTemplateName={showTemplateName}
199
202
  fetchingLiquidTags={fetchingLiquidTags}
200
203
  createTemplateInProgress={createTemplateInProgress}
@@ -1025,6 +1025,32 @@ describe('useEmailWrapper', () => {
1025
1025
  expect(mockEmailActions.getTemplateDetails).not.toHaveBeenCalled();
1026
1026
  }, { timeout: 1000 });
1027
1027
  });
1028
+
1029
+ it('should NOT call getTemplateDetails when isEditEmail is false (create flow)', async () => {
1030
+ const templateId = 'create-flow-id';
1031
+ const createFlowProps = {
1032
+ ...newFlowMockProps,
1033
+ isEditEmail: false,
1034
+ params: { id: templateId },
1035
+ location: {
1036
+ pathname: `/email/edit/${templateId}`,
1037
+ query: { id: templateId },
1038
+ },
1039
+ Email: {
1040
+ ...newFlowMockProps.Email,
1041
+ templateDetails: null,
1042
+ getTemplateDetailsInProgress: false,
1043
+ },
1044
+ };
1045
+
1046
+ renderHook((props) => useEmailWrapper(props), {
1047
+ initialProps: createFlowProps,
1048
+ });
1049
+
1050
+ await waitFor(() => {
1051
+ expect(mockEmailActions.getTemplateDetails).not.toHaveBeenCalled();
1052
+ }, { timeout: 1000 });
1053
+ });
1028
1054
  });
1029
1055
  });
1030
1056
 
@@ -73,7 +73,7 @@ export const Advertisement = (props) => {
73
73
  const FbAdFooter = styled.div`
74
74
  background-color: ${CAP_WHITE};
75
75
  position: fixed;
76
- bottom: 20px;
76
+ bottom: 0;
77
77
  width: 100%;
78
78
  margin-left: -32px;
79
79
  padding: ${CAP_SPACE_32} ${CAP_SPACE_24};
@@ -40,6 +40,7 @@
40
40
  .create-msg,
41
41
  .cancel-msg {
42
42
  position: fixed;
43
+ bottom: 20px;
43
44
  }
44
45
  .cancel-msg {
45
46
  margin-left: 100px;
@@ -38,7 +38,7 @@ export default css`
38
38
  .action-section {
39
39
  background-color: ${CAP_WHITE};
40
40
  position: fixed;
41
- bottom: 20px;
41
+ bottom: 0;
42
42
  width: 100%;
43
43
  margin-left: -32px;
44
44
  padding: ${CAP_SPACE_32} ${CAP_SPACE_24};
@@ -167,7 +167,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
167
167
  };
168
168
  this.props.actions.getMobilepushTemplatesList('mobilepush', params);
169
169
  }
170
- if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.fullSchema)) {
170
+ if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.fullSchema) && _.isEmpty(this.state.formData)) {
171
171
  this.setState({fullSchema: nextProps.metaEntities.layouts[0].definition, schema: (nextProps.location.query.module === 'loyalty') ? nextProps.metaEntities.layouts[0].definition.textSchema : {}}, () => {
172
172
  this.handleEditSchemaOnPropsChange(nextProps, selectedWeChatAccount);
173
173
  const templateId = get(this, "props.params.id");
@@ -388,11 +388,11 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
388
388
  }
389
389
  });
390
390
  } else {
391
- selectedAccount = accounts[0];
391
+ selectedAccount = accounts?.length > 0 ? accounts[0] : {};
392
392
  formData['mobilepush-accounts'] = selectedAccount?.id;
393
393
  }
394
394
  this.props.actions.setWeChatAccount(selectedAccount);
395
- this.setState({formData, accountsOptions: accounts.map((acc) => ({key: acc.id, label: acc.name, value: acc.id}))});
395
+ this.setState({formData, accountsOptions: accounts?.length > 0 ? accounts.map((acc) => ({key: acc.id, label: acc.name, value: acc.id})) : []});
396
396
  };
397
397
 
398
398
  createDefinition = (account) => ({
@@ -2023,7 +2023,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
2023
2023
  <CapSpin spinning={spinning}>
2024
2024
  <CapRow>
2025
2025
  <CapColumn>
2026
- {!this.props.isLoadingMetaEntities && <FormBuilder
2026
+ <FormBuilder
2027
+ key={!_.isEmpty(schema) ? 'has-schema' : 'no-schema'}
2027
2028
  channel={MOBILE_PUSH}
2028
2029
  schema={schema}
2029
2030
  showLiquidErrorInFooter={this.props.showLiquidErrorInFooter}
@@ -2058,7 +2059,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
2058
2059
  hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
2059
2060
  isFullMode={this.props.isFullMode}
2060
2061
  eventContextTags={this.props?.eventContextTags}
2061
- />}
2062
+ />
2062
2063
  </CapColumn>
2063
2064
  {this.props.iosCtasData && this.state.showIosCtaTable &&
2064
2065
  <CapSlideBox
@@ -98,5 +98,5 @@
98
98
  }
99
99
 
100
100
  .create-dlt-msg {
101
- margin-left: 120px;
101
+ margin-left: 170px;
102
102
  }
@@ -106,7 +106,6 @@ export const SmsTraiEdit = (props) => {
106
106
  padding: ${CAP_SPACE_32} ${CAP_SPACE_24};
107
107
  position: fixed;
108
108
  bottom: 2rem;
109
- margin-left: -2rem;
110
109
  .ant-btn {
111
110
  margin-right: ${CAP_SPACE_16};
112
111
  }
@@ -688,17 +687,24 @@ export const SmsTraiEdit = (props) => {
688
687
  <CapButton
689
688
  onClick={handleTestAndPreview}
690
689
  type="secondary"
691
- className="create-msg create-dlt-msg"
690
+ className="create-msg"
692
691
  >
693
692
  <FormattedMessage {...messages.testAndPreviewButtonLabel} />
694
693
  </CapButton>
695
694
  <CapButton
696
695
  onClick={isLiquidSupportFeatureEnabled ? onSubmitWrapper : onDoneCallback}
697
- className="create-msg"
696
+ className="create-msg create-dlt-msg"
698
697
  disabled={isTagValidationError || (isLiquidSupportFeatureEnabled && !isObject(metaEntities?.tagLookupMap))}
699
698
  >
700
699
  <FormattedMessage {...messages.saveButtonLabel} />
701
700
  </CapButton>
701
+ <CapButton
702
+ onClick={handleClose}
703
+ className="cancel-dlt-msg"
704
+ type="secondary"
705
+ >
706
+ <FormattedMessage {...messages.cancelButtonLabel} />
707
+ </CapButton>
702
708
  </SMSTraiFooter>
703
709
  <TestAndPreviewSlidebox
704
710
  show={showTestAndPreviewSlidebox}