@capillarytech/creatives-library 8.0.223-alpha.0 → 8.0.223-alpha.1

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.223-alpha.0",
4
+ "version": "8.0.223-alpha.1",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -0,0 +1,23 @@
1
+ import { CapSpin } from "@capillarytech/cap-ui-library";
2
+ import React from "react";
3
+ import { injectIntl } from "react-intl";
4
+ import messages from './messages';
5
+ import "./index.scss";
6
+
7
+ export const CapPageSpinner = (props) => {
8
+
9
+ const renderedContent = () => {
10
+ return (
11
+ <div className="cap-custom-page-spinner">
12
+ <CapSpin spinning={props.spinning}>
13
+ {props.children}
14
+ </CapSpin>
15
+ {<span className="cap-custom-page-spinner-text">{props.spinning && props.intl.formatMessage(messages.text)}</span>}
16
+ </div>
17
+ )
18
+ }
19
+
20
+ return renderedContent();
21
+ };
22
+
23
+ export default injectIntl(CapPageSpinner);
@@ -0,0 +1,15 @@
1
+ .cap-custom-page-spinner {
2
+ display: flex;
3
+ flex-direction: row;
4
+ align-items: center;
5
+ justify-content: center;
6
+ width: 100%;
7
+ padding-top: 20px;
8
+ text-align: center;
9
+ gap: 10px;
10
+
11
+ .cap-custom-page-spinner-text {
12
+ color: #5E6C84;
13
+ font-size: 16px;
14
+ }
15
+ }
@@ -0,0 +1,13 @@
1
+ /*
2
+ * CapPageSpinner Messages
3
+ *
4
+ * This contains all the text for the CapPageSpinner component.
5
+ */
6
+ import { defineMessages } from 'react-intl';
7
+
8
+ export default defineMessages({
9
+ text: {
10
+ id: 'creatives.componentsV2.CapPageSpinner.text',
11
+ defaultMessage: 'Loading More Templates',
12
+ },
13
+ });
@@ -1,5 +1,5 @@
1
1
  .pagination-container{
2
- height: calc(100vh - 182px);
2
+ height: calc(100vh - 400px);
3
3
  overflow-y: auto;
4
4
  overflow-x: hidden;
5
5
  }
@@ -19,7 +19,6 @@ const SendTestMessage = ({
19
19
  formData,
20
20
  isSendingTestMessage,
21
21
  formatMessage,
22
- isContentValid = true,
23
22
  }) => (
24
23
  <CapStepsAccordian
25
24
  showNumberSteps={false}
@@ -44,11 +43,7 @@ const SendTestMessage = ({
44
43
  multiple
45
44
  placeholder={formatMessage(messages.testCustomersPlaceholder)}
46
45
  />
47
- <CapButton
48
- onClick={handleSendTestMessage}
49
- disabled={isEmpty(selectedTestEntities) || (isEmpty(formData['template-subject']) && isEmpty(formData[0]?.['template-subject'])) || isSendingTestMessage || !isContentValid}
50
- title={!isContentValid ? formatMessage(messages.contentInvalid) : ''}
51
- >
46
+ <CapButton onClick={handleSendTestMessage} disabled={isEmpty(selectedTestEntities) || (isEmpty(formData['template-subject']) && isEmpty(formData[0]?.['template-subject'])) || isSendingTestMessage}>
52
47
  <FormattedMessage {...messages.sendTestButton} />
53
48
  </CapButton>
54
49
  </CapRow>),
@@ -68,7 +63,6 @@ SendTestMessage.propTypes = {
68
63
  formData: PropTypes.object.isRequired,
69
64
  isSendingTestMessage: PropTypes.bool.isRequired,
70
65
  formatMessage: PropTypes.func.isRequired,
71
- isContentValid: PropTypes.bool,
72
66
  };
73
67
 
74
68
  export default SendTestMessage;
@@ -52,7 +52,6 @@ import {
52
52
  INITIAL_PAYLOAD, EMAIL, TEST, DESKTOP, ACTIVE, MOBILE,
53
53
  } from './constants';
54
54
  import { GLOBAL_CONVERT_OPTIONS } from '../FormBuilder/constants';
55
- import { validateIfTagClosed } from '../../utils/tagValidations';
56
55
 
57
56
  const TestAndPreviewSlidebox = (props) => {
58
57
  const {
@@ -104,147 +103,10 @@ const TestAndPreviewSlidebox = (props) => {
104
103
  const [selectedTestEntities, setSelectedTestEntities] = useState([]);
105
104
  const [beeContent, setBeeContent] = useState(''); // Track BEE editor content separately
106
105
  const previousBeeContentRef = useRef(''); // Track previous BEE content to prevent unnecessary updates
107
- const [isContentValid, setIsContentValid] = useState(true); // Track if content tags are valid
108
106
 
109
107
  const isUpdatePreviewDisabled = useMemo(() => (
110
- requiredTags.some((tag) => !customValues[tag.fullPath]) || !isContentValid
111
- ), [requiredTags, customValues, isContentValid]);
112
-
113
- // Function to validate tags in content
114
- const validateContentTags = (content) => {
115
- if (!content) return true;
116
-
117
- try {
118
- // Convert HTML to text (same as what's used for tag extraction)
119
- // This ensures we validate the same content that will be used for tag extraction
120
- const textContent = convert(content, GLOBAL_CONVERT_OPTIONS);
121
-
122
- // Check if there are any braces in the content
123
- const hasBraces = textContent.includes('{') || textContent.includes('}');
124
-
125
- // If no braces exist, content is valid (no tag validation needed)
126
- if (!hasBraces) {
127
- return true;
128
- }
129
-
130
- // First check if tags are properly closed using the utility function
131
- // This validates that all opening braces have corresponding closing braces
132
- if (!validateIfTagClosed(textContent)) {
133
- return false;
134
- }
135
-
136
- // Now validate tag format: tags must be in format {{tag_name}}
137
- // Find all valid tag patterns {{tag_name}}
138
- const tagPattern = /{{[^}]*}}/g;
139
- const matches = textContent.match(tagPattern) || [];
140
-
141
- // Remove all valid {{tag}} patterns from content to check for invalid braces
142
- let contentWithoutValidTags = textContent;
143
- matches.forEach((match) => {
144
- contentWithoutValidTags = contentWithoutValidTags.replace(match, '');
145
- });
146
-
147
- // Check if there are any remaining braces (single braces or unclosed braces)
148
- // These would be invalid patterns like {tag}, {first, first}, etc.
149
- if (contentWithoutValidTags.includes('{') || contentWithoutValidTags.includes('}')) {
150
- return false;
151
- }
152
-
153
- // Check each tag for valid format
154
- for (const match of matches) {
155
- // Valid tag format: {{tag_name}} - must start with {{ and end with }}
156
- if (!match.startsWith('{{') || !match.endsWith('}}')) {
157
- return false;
158
- }
159
-
160
- // Extract tag name (content between {{ and }})
161
- const tagName = match.slice(2, -2).trim();
162
-
163
- // Tag name should not be empty
164
- if (!tagName) {
165
- return false;
166
- }
167
-
168
- // Check for invalid patterns in tag name
169
- // Invalid patterns: "first or first", "first and first", etc.
170
- const invalidPatterns = [
171
- /\s+or\s+/i, // " or " as separate word (e.g., "first or first")
172
- /\s+and\s+/i, // " and " as separate word
173
- ];
174
-
175
- for (const pattern of invalidPatterns) {
176
- if (pattern.test(tagName)) {
177
- return false;
178
- }
179
- }
180
-
181
- // Check for unclosed single braces in tag name (e.g., {{first{name}})
182
- const singleOpenBraces = (tagName.match(/{/g) || []).length;
183
- const singleCloseBraces = (tagName.match(/}/g) || []).length;
184
- if (singleOpenBraces !== singleCloseBraces) {
185
- return false;
186
- }
187
- }
188
-
189
- return true;
190
- } catch (error) {
191
- // If conversion fails, fall back to validating the original content
192
- console.warn('Error converting content for validation:', error);
193
- const hasBraces = content.includes('{') || content.includes('}');
194
- if (!hasBraces) {
195
- return true;
196
- }
197
-
198
- // Apply same validation to original content
199
- if (!validateIfTagClosed(content)) {
200
- return false;
201
- }
202
-
203
- const tagPattern = /{{[^}]*}}/g;
204
- const matches = content.match(tagPattern) || [];
205
-
206
- // Remove all valid {{tag}} patterns from content to check for invalid braces
207
- let contentWithoutValidTags = content;
208
- matches.forEach((match) => {
209
- contentWithoutValidTags = contentWithoutValidTags.replace(match, '');
210
- });
211
-
212
- // Check if there are any remaining braces (single braces or unclosed braces)
213
- if (contentWithoutValidTags.includes('{') || contentWithoutValidTags.includes('}')) {
214
- return false;
215
- }
216
-
217
- for (const match of matches) {
218
- if (!match.startsWith('{{') || !match.endsWith('}}')) {
219
- return false;
220
- }
221
-
222
- const tagName = match.slice(2, -2).trim();
223
- if (!tagName) {
224
- return false;
225
- }
226
-
227
- const invalidPatterns = [
228
- /\s+or\s+/i,
229
- /\s+and\s+/i,
230
- ];
231
-
232
- for (const pattern of invalidPatterns) {
233
- if (pattern.test(tagName)) {
234
- return false;
235
- }
236
- }
237
-
238
- const singleOpenBraces = (tagName.match(/{/g) || []).length;
239
- const singleCloseBraces = (tagName.match(/}/g) || []).length;
240
- if (singleOpenBraces !== singleCloseBraces) {
241
- return false;
242
- }
243
- }
244
-
245
- return true;
246
- }
247
- };
108
+ requiredTags.some((tag) => !customValues[tag.fullPath])
109
+ ), [requiredTags, customValues]);
248
110
 
249
111
  // Function to resolve tags in text with custom values
250
112
  const resolveTagsInText = (text, tagValues) => {
@@ -291,10 +153,6 @@ const TestAndPreviewSlidebox = (props) => {
291
153
  if (existingContent && existingContent.trim() !== '') {
292
154
  // We already have content, update local state only if it's different
293
155
  if (existingContent !== previousBeeContentRef.current) {
294
- // Validate content tags for BEE editor
295
- const isValid = validateContentTags(existingContent);
296
- setIsContentValid(isValid);
297
-
298
156
  previousBeeContentRef.current = existingContent;
299
157
  setBeeContent(existingContent);
300
158
  setPreviewDataHtml({
@@ -328,10 +186,6 @@ const TestAndPreviewSlidebox = (props) => {
328
186
  }
329
187
 
330
188
  if (htmlFile) {
331
- // Validate content tags
332
- const isValid = validateContentTags(htmlFile);
333
- setIsContentValid(isValid);
334
-
335
189
  // Update our states
336
190
  previousBeeContentRef.current = htmlFile;
337
191
  setBeeContent(htmlFile);
@@ -340,16 +194,9 @@ const TestAndPreviewSlidebox = (props) => {
340
194
  resolvedTitle: formData['template-subject'] || ''
341
195
  });
342
196
 
343
- // Only extract tags if content is valid
344
- if (isValid) {
345
- const payloadContent = convert(htmlFile, GLOBAL_CONVERT_OPTIONS);
346
- actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
347
- } else {
348
- // Show error notification for invalid content
349
- CapNotification.error({
350
- message: formatMessage(messages.contentInvalid),
351
- });
352
- }
197
+ // Always extract tags when content changes
198
+ const payloadContent = convert(htmlFile, GLOBAL_CONVERT_OPTIONS);
199
+ actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
353
200
  }
354
201
 
355
202
  // Restore original handler
@@ -364,45 +211,23 @@ const TestAndPreviewSlidebox = (props) => {
364
211
  const templateContent = currentTabData?.[activeTab]?.['template-content'];
365
212
 
366
213
  if (templateContent) {
367
- // Validate content tags
368
- const isValid = validateContentTags(templateContent);
369
- setIsContentValid(isValid);
370
-
371
214
  // Update preview with initial content
372
215
  setPreviewDataHtml({
373
216
  resolvedBody: templateContent,
374
217
  resolvedTitle: formData['template-subject'] || ''
375
218
  });
376
219
 
377
- // Only extract tags if content is valid
378
- if (isValid) {
379
- const payloadContent = convert(templateContent, GLOBAL_CONVERT_OPTIONS);
380
- actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
381
- } else {
382
- // Show error notification for invalid content
383
- CapNotification.error({
384
- message: formatMessage(messages.contentInvalid),
385
- });
386
- }
220
+ // Always extract tags when showing
221
+ const payloadContent = convert(templateContent, GLOBAL_CONVERT_OPTIONS);
222
+ actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
387
223
  } else {
388
224
  // Fallback to content prop if no template content
389
- const contentToValidate = getCurrentContent;
390
- const isValid = validateContentTags(contentToValidate);
391
- setIsContentValid(isValid);
392
-
393
- // Only extract tags if content is valid
394
- if (isValid) {
395
- const payloadContent = convert(
396
- contentToValidate,
397
- GLOBAL_CONVERT_OPTIONS
398
- );
399
- actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
400
- } else {
401
- // Show error notification for invalid content
402
- CapNotification.error({
403
- message: formatMessage(messages.contentInvalid),
404
- });
405
- }
225
+ const payloadContent = convert(
226
+ getCurrentContent,
227
+ GLOBAL_CONVERT_OPTIONS
228
+ );
229
+ // Always extract tags when showing
230
+ actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
406
231
  }
407
232
  }
408
233
 
@@ -418,28 +243,17 @@ const TestAndPreviewSlidebox = (props) => {
418
243
  const isDragDrop = currentTabData?.[activeTab]?.is_drag_drop;
419
244
  const templateContent = currentTabData?.[activeTab]?.['template-content'];
420
245
 
421
- if (templateContent && templateContent.trim() !== '' && show) {
422
- // Common function to handle content update with validation
246
+ if (templateContent && templateContent.trim() !== '') {
247
+ // Common function to handle content update
423
248
  const handleContentUpdate = (content) => {
424
- // Validate content tags for each update
425
- const isValid = validateContentTags(content);
426
- setIsContentValid(isValid);
427
-
428
249
  setPreviewDataHtml({
429
250
  resolvedBody: content,
430
251
  resolvedTitle: formData['template-subject'] || ''
431
252
  });
432
253
 
433
- // Only extract tags if content is valid
434
- if (isValid) {
435
- const payloadContent = convert(content, GLOBAL_CONVERT_OPTIONS);
436
- actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
437
- } else {
438
- // Show error notification for invalid content
439
- CapNotification.error({
440
- message: formatMessage(messages.contentInvalid),
441
- });
442
- }
254
+ // Extract tags from content
255
+ const payloadContent = convert(content, GLOBAL_CONVERT_OPTIONS);
256
+ actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
443
257
  };
444
258
 
445
259
  if (isDragDrop) {
@@ -473,7 +287,6 @@ const TestAndPreviewSlidebox = (props) => {
473
287
  setTagsExtracted(false);
474
288
  setPreviewDevice('desktop');
475
289
  setSelectedTestEntities([]);
476
- setIsContentValid(true);
477
290
  actions.clearPrefilledValues();
478
291
  }
479
292
  }, [show]);
@@ -717,22 +530,6 @@ const TestAndPreviewSlidebox = (props) => {
717
530
 
718
531
  // Handle update preview
719
532
  const handleUpdatePreview = async () => {
720
- // Re-validate content to get latest state (in case liquid errors were fixed)
721
- const currentTabData = formData[currentTab - 1];
722
- const activeTab = currentTabData?.activeTab;
723
- const templateContent = currentTabData?.[activeTab]?.['template-content'];
724
- const contentToValidate = templateContent || getCurrentContent;
725
- const isValid = validateContentTags(contentToValidate);
726
- setIsContentValid(isValid);
727
-
728
- // Check if content is valid before updating preview
729
- if (!isValid) {
730
- CapNotification.error({
731
- message: formatMessage(messages.contentInvalid),
732
- });
733
- return;
734
- }
735
-
736
533
  try {
737
534
  // Include unsubscribe tag if content contains it
738
535
  const resolvedTags = { ...customValues };
@@ -762,20 +559,9 @@ const TestAndPreviewSlidebox = (props) => {
762
559
  const currentTabData = formData[currentTab - 1];
763
560
  const activeTab = currentTabData?.activeTab;
764
561
  const templateContent = currentTabData?.[activeTab]?.['template-content'];
765
- const content = templateContent || getCurrentContent;
766
-
767
- // Validate content tags before extracting
768
- const isValid = validateContentTags(content);
769
- setIsContentValid(isValid);
770
-
771
- if (!isValid) {
772
- CapNotification.error({
773
- message: formatMessage(messages.contentInvalid),
774
- });
775
- return;
776
- }
777
562
 
778
563
  // Check for personalization tags (excluding unsubscribe)
564
+ const content = templateContent || getCurrentContent;
779
565
  const tags = content.match(/{{[^}]+}}/g) || [];
780
566
  const hasPersonalizationTags = tags.some(tag => !tag.includes('unsubscribe'));
781
567
 
@@ -804,22 +590,6 @@ const TestAndPreviewSlidebox = (props) => {
804
590
  };
805
591
 
806
592
  const handleSendTestMessage = () => {
807
- // Re-validate content to get latest state (in case liquid errors were fixed)
808
- const currentTabData = formData[currentTab - 1];
809
- const activeTab = currentTabData?.activeTab;
810
- const templateContent = currentTabData?.[activeTab]?.['template-content'];
811
- const contentToValidate = templateContent || getCurrentContent;
812
- const isValid = validateContentTags(contentToValidate);
813
- setIsContentValid(isValid);
814
-
815
- // Check if content is valid before sending test message
816
- if (!isValid) {
817
- CapNotification.error({
818
- message: formatMessage(messages.contentInvalid),
819
- });
820
- return;
821
- }
822
-
823
593
  const allUserIds = [];
824
594
  selectedTestEntities.forEach((entityId) => {
825
595
  const group = testGroups.find((g) => g.groupId === entityId);
@@ -915,7 +685,6 @@ const TestAndPreviewSlidebox = (props) => {
915
685
  formData={formData}
916
686
  isSendingTestMessage={isSendingTestMessage}
917
687
  formatMessage={formatMessage}
918
- isContentValid={isContentValid}
919
688
  />
920
689
  );
921
690
 
@@ -144,12 +144,4 @@ export default defineMessages({
144
144
  id: `${scope}.invalidJSON`,
145
145
  defaultMessage: 'Invalid JSON input',
146
146
  },
147
- contentInvalid: {
148
- id: `${scope}.contentInvalid`,
149
- defaultMessage: 'Content is invalid. Please fix the tags in your content before testing or previewing.',
150
- },
151
- previewUpdateError: {
152
- id: `${scope}.previewUpdateError`,
153
- defaultMessage: 'Failed to update preview',
154
- },
155
147
  });
@@ -31,6 +31,7 @@ import injectReducer from '../../../utils/injectReducer';
31
31
  import { v2GallerySagas } from './sagas';
32
32
  import v2GalleryReducer from './reducer';
33
33
  import { GALLERY_ALLOWED_EXTENSION } from './constants';
34
+ import CapPageSpinner from '../../../v2Components/CapPageSpinner';
34
35
 
35
36
  const {CapCustomCardList} = CapCustomCard;
36
37
  export class Gallery extends React.Component { // eslint-disable-line react/prefer-stateless-function
@@ -323,7 +324,7 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
323
324
  deleteAsset(asset) {
324
325
  this.props.actions.deleteAssetById(asset._id, asset.type);
325
326
  }
326
- getTemplateDataForGrid = ({templates, handlers, filterContent, isLoading, loadingTip}) => {
327
+ getTemplateDataForGrid = ({templates, handlers, filterContent, isLoading, loadingTip, isInitialLoading}) => {
327
328
  const currentChannel = 'gallery';
328
329
  const { searchLoader, searchText } = this.state;
329
330
  const cardDataList = templates?.length ? _.map(templates, (template) => {
@@ -369,8 +370,7 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
369
370
  }) : [];
370
371
  return (<div>
371
372
  {filterContent}
372
- <CapCustomSkeleton loader={isLoading}>
373
- {!isLoading && <div>
373
+ {!(isInitialLoading && isLoading) && <div>
374
374
  {!_.isEmpty(templates) || !_.isEmpty(searchText) ? <div className={`pagination-container ${this.props.isLineAsset ? 'gallery-upload' : ''}`}>
375
375
  <CapCustomCardList key={`${currentChannel}-card-list`} cardList={cardDataList} type={'Email'} />
376
376
  {!_.isEmpty(searchText) && _.isEmpty(templates) && (
@@ -386,7 +386,8 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
386
386
  )}
387
387
  </div>
388
388
  }
389
- </CapCustomSkeleton>
389
+ {<CapCustomSkeleton loader={isInitialLoading && isLoading} />}
390
+ {<CapPageSpinner spinning={!isInitialLoading && isLoading} />}
390
391
 
391
392
  </div>);
392
393
  }
@@ -506,7 +507,7 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
506
507
  onItemClick={this.handleOnHoverItem}
507
508
  enablePagination
508
509
  /> */}
509
- {this.getTemplateDataForGrid({isLoading, loadingTip, channel: this.state.channel, templates: assetList, filterContent, handlers: {selectAsset: this.selectAsset}})}
510
+ {this.getTemplateDataForGrid({isLoading, loadingTip, channel: this.state.channel, templates: assetList, filterContent, handlers: {selectAsset: this.selectAsset}, isInitialLoading: this.state.page === 1 && isLoading})}
510
511
 
511
512
  </Pagination>
512
513
  }
@@ -11,7 +11,6 @@
11
11
  .creatives-templates-list.full-mode{
12
12
  .pagination-container {
13
13
  .cap-custom-card-list-row {
14
- padding-bottom: 10rem;
15
14
  .cap-custom-card-list-col{
16
15
  &:nth-child(3n+3) { //every 4th child
17
16
  margin-right: unset;
@@ -26,7 +25,6 @@
26
25
  .creatives-templates-list.full-mode{
27
26
  .pagination-container {
28
27
  .cap-custom-card-list-row {
29
- padding-bottom: 10rem;
30
28
  .cap-custom-card-list-col{
31
29
  &:nth-child(4n+4) { //every 4th child
32
30
  margin-right: unset;
@@ -58,9 +56,6 @@
58
56
  }
59
57
 
60
58
  .pagination-container {
61
- .cap-custom-card-list-row {
62
- padding-bottom: 10rem;
63
- }
64
59
  .FACEBOOK {
65
60
  .ant-card-body {
66
61
  background-color: $CAP_G09;
@@ -155,6 +155,7 @@ import { makeSelectRcs } from '../Rcs/selectors';
155
155
  import { getRcsStatusType } from '../Rcs/utils';
156
156
  import { v2MobilePushSagas } from '../MobilePushNew/sagas';
157
157
  import { AUTO_CAROUSEL, BIG_PICTURE, FILMSTRIP_CAROUSEL, MANUAL_CAROUSEL } from '../MobilePushNew/constants';
158
+ import CapPageSpinner from '../../v2Components/CapPageSpinner';
158
159
  const withMobilePushNewSaga = injectSaga({ key: 'mobilePushNew', saga: v2MobilePushSagas, mode: DAEMON });
159
160
 
160
161
  const { timeTracker } = GA;
@@ -1190,7 +1191,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1190
1191
  ) : <>{children}</>
1191
1192
  };
1192
1193
 
1193
- getTemplateDataForGrid = ({templates = [], handlers, filterContent, channel, isLoading, loadingTip, previewTemplateId }) => {
1194
+ getTemplateDataForGrid = ({templates = [], handlers, filterContent, channel, isLoading, isInitialLoading, loadingTip, previewTemplateId }) => {
1194
1195
  const currentChannel = channel.toUpperCase();
1195
1196
  const {channel: stateChannel} = this.state;
1196
1197
  const channelLowerCase = stateChannel.toLowerCase();
@@ -1749,11 +1750,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1749
1750
 
1750
1751
  const noLoaderAndSearchText = isEmpty(this.state.searchText) && !isLoading;
1751
1752
 
1752
- return (<div>
1753
+ return (<div>
1753
1754
  {[WECHAT, MOBILE_PUSH, INAPP, WHATSAPP, ZALO].includes(currentChannel) && this.showAccountName()}
1754
1755
  {filterContent}
1755
1756
  {[WHATSAPP, ZALO].includes(currentChannel) && this.selectedFilters()}
1756
- <CapCustomSkeleton loader={isLoading || getAllTemplatesInProgress}>
1757
1757
  {<div>
1758
1758
  {!isEmpty(filteredTemplates) || !isEmpty(this.state.searchText) || !isEmpty(this.props.Templates.templateError) ? (
1759
1759
  <div className={!isEmpty(this.state.searchText) && isEmpty(cardDataList) ? '' : "pagination-container"}>
@@ -1825,9 +1825,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1825
1825
  <ChannelTypeIllustration isFullMode={this.props.isFullMode} createTemplate={this.createTemplate} currentChannel={currentChannel}/>
1826
1826
  </div>
1827
1827
  }
1828
+ {<CapCustomSkeleton loader={isInitialLoading && (isLoading || getAllTemplatesInProgress)} />}
1829
+ {<CapPageSpinner spinning={!isInitialLoading && (isLoading || getAllTemplatesInProgress)} />}
1828
1830
  </div>
1829
1831
  }
1830
- </CapCustomSkeleton>
1831
1832
  </div>);
1832
1833
  }
1833
1834
  filterLineTemplates = (templates) => {
@@ -2900,6 +2901,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2900
2901
  (rcsLoader !== undefined ? rcsLoader : false);
2901
2902
  return isLoading;
2902
2903
  }
2904
+
2905
+ getInitialLoading = () => {
2906
+ const isLoadingValue = this.isLoading();
2907
+ const templates = this.props.TemplatesList || [];
2908
+ const hasTemplates = !isEmpty(templates) || this.state.templatesCount > 0;
2909
+ const isInitialLoading = isLoadingValue && this.state.page === 1 && !hasTemplates;
2910
+
2911
+ return isInitialLoading;
2912
+ }
2903
2913
 
2904
2914
  checkSearchDisabled = () => (this.props.route.name === "mobilepush" && !(this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier && this.props.Templates.selectedWeChatAccount.configs && (this.props.Templates.selectedWeChatAccount.configs.ios === '1' || this.props.Templates.selectedWeChatAccount.configs.android === '1')))
2905
2915
  renderEmailPreviewModal() {
@@ -3244,6 +3254,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
3244
3254
  const pageHeader = "";
3245
3255
  const pageHeaderDvs = "";
3246
3256
  const isLoading = this.isLoading();
3257
+ const isInitialLoading = this.getInitialLoading();
3247
3258
  let previewHeader = this.props.intl.formatMessage(messages.preview);
3248
3259
  // const previewHeader = (this.state.channel.toLowerCase() === 'email' ? <h3>{this.props.intl.formatMessage(messages.emailPreview)}</h3> : <h3>{this.props.intl.formatMessage(messages.ebillPreview)}</h3>);
3249
3260
  if (this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill') {
@@ -3538,6 +3549,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
3538
3549
  {this.getTemplateDataForGrid({
3539
3550
  previewTemplateId: this.state.zaloPreviewItemId,
3540
3551
  isLoading,
3552
+ isInitialLoading,
3541
3553
  loadingTip,
3542
3554
  channel: this.state.channel,
3543
3555
  templates: this.state.searchingZaloTemplate