@capillarytech/creatives-library 8.0.60-alpha.3 → 8.0.60-alpha.7
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/config/app.js +1 -0
- package/package.json +1 -1
- package/utils/tagValidations.js +0 -32
- package/utils/tests/tagValidations.test.js +1 -270
- package/v2Containers/Assets/images/whatsappOrZaloAccountIllustration.svg +11 -0
- package/v2Containers/Cap/reducer.js +3 -15
- package/v2Containers/Templates/constants.js +5 -0
- package/v2Containers/Templates/index.js +255 -94
- package/v2Containers/Templates/messages.js +12 -0
- package/v2Containers/Templates/reducer.js +7 -2
- package/v2Containers/Templates/sagas.js +177 -1
- package/v2Containers/Whatsapp/index.js +1 -0
package/config/app.js
CHANGED
|
@@ -17,6 +17,7 @@ const config = {
|
|
|
17
17
|
accountConfig: (strs, accountId) => `${window.location.origin}/org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
|
|
18
18
|
},
|
|
19
19
|
development: {
|
|
20
|
+
// api_endpoint: 'http://localhost:2022/arya/api/v1/creatives',
|
|
20
21
|
api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
|
|
21
22
|
campaigns_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/campaigns',
|
|
22
23
|
campaigns_api_org_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/org/campaign',
|
package/package.json
CHANGED
package/utils/tagValidations.js
CHANGED
|
@@ -294,36 +294,4 @@ export const getTagMapValue = (object = {}) => {
|
|
|
294
294
|
).reduce((acc, current) => {
|
|
295
295
|
return { ...acc?.subtags ?? {}, ...current?.subtags ?? {} };
|
|
296
296
|
}, {});
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Extracts and merges all subtags and top-level keys from the provided object into a single flat map.
|
|
302
|
-
*
|
|
303
|
-
* @param {Object} object - The input object containing top-level keys with optional subtags.
|
|
304
|
-
* @returns {Object} - A flat map containing all top-level keys and their subtags.
|
|
305
|
-
*/
|
|
306
|
-
export const getForwardedMapValues = (object = {}) => {
|
|
307
|
-
return Object?.entries(object)?.reduce((acc, [key, current]) => {
|
|
308
|
-
// Check if current has 'subtags' and it's an object
|
|
309
|
-
if (current && current?.subtags && typeof current?.subtags === 'object') {
|
|
310
|
-
// Add the top-level key with its 'name' and 'desc'
|
|
311
|
-
acc[key] = {
|
|
312
|
-
name: current?.name,
|
|
313
|
-
desc: current?.desc,
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
// Merge the subtags into the accumulator
|
|
317
|
-
acc = { ...acc, ...current?.subtags };
|
|
318
|
-
} else if (current && typeof current === 'object') {
|
|
319
|
-
// If no 'subtags', add the top-level key with its 'name' and 'desc'
|
|
320
|
-
acc[key] = {
|
|
321
|
-
name: current?.name,
|
|
322
|
-
desc: current?.desc,
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// If the current entry is not an object or lacks 'name'/'desc', skip it
|
|
327
|
-
return acc;
|
|
328
|
-
}, {});
|
|
329
297
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import '@testing-library/jest-dom';
|
|
3
|
-
import { checkSupport, extractNames, getTagMapValue,
|
|
3
|
+
import { checkSupport, extractNames, getTagMapValue, preprocessHtml, validateIfTagClosed,validateTags, skipTags } from '../tagValidations';
|
|
4
4
|
import { eventContextTags } from '../../v2Containers/TagList/tests/mockdata';
|
|
5
5
|
|
|
6
6
|
describe("check if curly brackets are balanced", () => {
|
|
@@ -496,273 +496,4 @@ describe("skipTags", () => {
|
|
|
496
496
|
const result = skipTags(tag);
|
|
497
497
|
expect(result).toEqual(true);
|
|
498
498
|
});
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
describe('getForwardedMapValues', () => {
|
|
503
|
-
test('should return an empty object when input is empty', () => {
|
|
504
|
-
const input = {};
|
|
505
|
-
const expected = {};
|
|
506
|
-
expect(getForwardedMapValues(input)).toEqual(expected);
|
|
507
|
-
});
|
|
508
|
-
|
|
509
|
-
test('should correctly process objects with subtags', () => {
|
|
510
|
-
const input = {
|
|
511
|
-
customer: {
|
|
512
|
-
name: 'Customer',
|
|
513
|
-
desc: 'Customer Description',
|
|
514
|
-
subtags: {
|
|
515
|
-
cumulative_points_currency: {
|
|
516
|
-
name: 'Lifetime Points (in ₹)',
|
|
517
|
-
desc: 'Lifetime Points in ₹ Description',
|
|
518
|
-
},
|
|
519
|
-
mobile_number: {
|
|
520
|
-
name: 'Mobile Number',
|
|
521
|
-
desc: 'Mobile Number Description',
|
|
522
|
-
},
|
|
523
|
-
},
|
|
524
|
-
},
|
|
525
|
-
store: {
|
|
526
|
-
name: 'Store',
|
|
527
|
-
desc: 'Store Description',
|
|
528
|
-
subtags: {
|
|
529
|
-
store_name: {
|
|
530
|
-
name: 'Store Name',
|
|
531
|
-
desc: 'Store Name Description',
|
|
532
|
-
},
|
|
533
|
-
store_address: {
|
|
534
|
-
name: 'Store Address',
|
|
535
|
-
desc: 'Store Address Description',
|
|
536
|
-
},
|
|
537
|
-
},
|
|
538
|
-
},
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
const expected = {
|
|
542
|
-
customer: {
|
|
543
|
-
name: 'Customer',
|
|
544
|
-
desc: 'Customer Description',
|
|
545
|
-
},
|
|
546
|
-
cumulative_points_currency: {
|
|
547
|
-
name: 'Lifetime Points (in ₹)',
|
|
548
|
-
desc: 'Lifetime Points in ₹ Description',
|
|
549
|
-
},
|
|
550
|
-
mobile_number: {
|
|
551
|
-
name: 'Mobile Number',
|
|
552
|
-
desc: 'Mobile Number Description',
|
|
553
|
-
},
|
|
554
|
-
store: {
|
|
555
|
-
name: 'Store',
|
|
556
|
-
desc: 'Store Description',
|
|
557
|
-
},
|
|
558
|
-
store_name: {
|
|
559
|
-
name: 'Store Name',
|
|
560
|
-
desc: 'Store Name Description',
|
|
561
|
-
},
|
|
562
|
-
store_address: {
|
|
563
|
-
name: 'Store Address',
|
|
564
|
-
desc: 'Store Address Description',
|
|
565
|
-
},
|
|
566
|
-
};
|
|
567
|
-
|
|
568
|
-
expect(getForwardedMapValues(input)).toEqual(expected);
|
|
569
|
-
});
|
|
570
|
-
|
|
571
|
-
test('should correctly process objects without subtags', () => {
|
|
572
|
-
const input = {
|
|
573
|
-
points_on_event: {
|
|
574
|
-
name: 'Points on event',
|
|
575
|
-
desc: 'Points on event Description',
|
|
576
|
-
},
|
|
577
|
-
unsubscribe: {
|
|
578
|
-
name: 'Unsubscribe',
|
|
579
|
-
desc: 'Unsubscribe Description',
|
|
580
|
-
},
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
const expected = {
|
|
584
|
-
points_on_event: {
|
|
585
|
-
name: 'Points on event',
|
|
586
|
-
desc: 'Points on event Description',
|
|
587
|
-
},
|
|
588
|
-
unsubscribe: {
|
|
589
|
-
name: 'Unsubscribe',
|
|
590
|
-
desc: 'Unsubscribe Description',
|
|
591
|
-
},
|
|
592
|
-
};
|
|
593
|
-
|
|
594
|
-
expect(getForwardedMapValues(input)).toEqual(expected);
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
test('should handle a mix of entries with and without subtags', () => {
|
|
598
|
-
const input = {
|
|
599
|
-
customer: {
|
|
600
|
-
name: 'Customer',
|
|
601
|
-
desc: 'Customer Description',
|
|
602
|
-
subtags: {
|
|
603
|
-
cumulative_points_currency: {
|
|
604
|
-
name: 'Lifetime Points (in ₹)',
|
|
605
|
-
desc: 'Lifetime Points in ₹ Description',
|
|
606
|
-
},
|
|
607
|
-
},
|
|
608
|
-
},
|
|
609
|
-
points_on_event: {
|
|
610
|
-
name: 'Points on event',
|
|
611
|
-
desc: 'Points on event Description',
|
|
612
|
-
},
|
|
613
|
-
store: {
|
|
614
|
-
name: 'Store',
|
|
615
|
-
desc: 'Store Description',
|
|
616
|
-
subtags: {
|
|
617
|
-
store_name: {
|
|
618
|
-
name: 'Store Name',
|
|
619
|
-
desc: 'Store Name Description',
|
|
620
|
-
},
|
|
621
|
-
},
|
|
622
|
-
},
|
|
623
|
-
};
|
|
624
|
-
|
|
625
|
-
const expected = {
|
|
626
|
-
customer: {
|
|
627
|
-
name: 'Customer',
|
|
628
|
-
desc: 'Customer Description',
|
|
629
|
-
},
|
|
630
|
-
cumulative_points_currency: {
|
|
631
|
-
name: 'Lifetime Points (in ₹)',
|
|
632
|
-
desc: 'Lifetime Points in ₹ Description',
|
|
633
|
-
},
|
|
634
|
-
points_on_event: {
|
|
635
|
-
name: 'Points on event',
|
|
636
|
-
desc: 'Points on event Description',
|
|
637
|
-
},
|
|
638
|
-
store: {
|
|
639
|
-
name: 'Store',
|
|
640
|
-
desc: 'Store Description',
|
|
641
|
-
},
|
|
642
|
-
store_name: {
|
|
643
|
-
name: 'Store Name',
|
|
644
|
-
desc: 'Store Name Description',
|
|
645
|
-
},
|
|
646
|
-
};
|
|
647
|
-
|
|
648
|
-
expect(getForwardedMapValues(input)).toEqual(expected);
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
test('should ignore entries that are not objects', () => {
|
|
652
|
-
const input = {
|
|
653
|
-
valid_entry: {
|
|
654
|
-
name: 'Valid Entry',
|
|
655
|
-
desc: 'Valid Entry Description',
|
|
656
|
-
},
|
|
657
|
-
invalid_entry: 'This is a string, not an object',
|
|
658
|
-
another_invalid_entry: null,
|
|
659
|
-
};
|
|
660
|
-
|
|
661
|
-
const expected = {
|
|
662
|
-
valid_entry: {
|
|
663
|
-
name: 'Valid Entry',
|
|
664
|
-
desc: 'Valid Entry Description',
|
|
665
|
-
},
|
|
666
|
-
};
|
|
667
|
-
|
|
668
|
-
expect(getForwardedMapValues(input)).toEqual(expected);
|
|
669
|
-
});
|
|
670
|
-
|
|
671
|
-
test('should handle entries missing name or desc', () => {
|
|
672
|
-
const input = {
|
|
673
|
-
incomplete_entry1: {
|
|
674
|
-
name: 'Incomplete Entry 1',
|
|
675
|
-
// desc is missing
|
|
676
|
-
subtags: {
|
|
677
|
-
subtag1: {
|
|
678
|
-
name: 'Subtag 1',
|
|
679
|
-
desc: 'Subtag 1 Description',
|
|
680
|
-
},
|
|
681
|
-
},
|
|
682
|
-
},
|
|
683
|
-
incomplete_entry2: {
|
|
684
|
-
// name is missing
|
|
685
|
-
desc: 'Incomplete Entry 2 Description',
|
|
686
|
-
},
|
|
687
|
-
};
|
|
688
|
-
|
|
689
|
-
const expected = {
|
|
690
|
-
incomplete_entry1: {
|
|
691
|
-
name: 'Incomplete Entry 1',
|
|
692
|
-
desc: undefined,
|
|
693
|
-
},
|
|
694
|
-
subtag1: {
|
|
695
|
-
name: 'Subtag 1',
|
|
696
|
-
desc: 'Subtag 1 Description',
|
|
697
|
-
},
|
|
698
|
-
incomplete_entry2: {
|
|
699
|
-
name: undefined,
|
|
700
|
-
desc: 'Incomplete Entry 2 Description',
|
|
701
|
-
},
|
|
702
|
-
};
|
|
703
|
-
|
|
704
|
-
expect(getForwardedMapValues(input)).toEqual(expected);
|
|
705
|
-
});
|
|
706
|
-
|
|
707
|
-
test('should handle deeply nested subtags by only flattening one level', () => {
|
|
708
|
-
const input = {
|
|
709
|
-
parent: {
|
|
710
|
-
name: 'Parent',
|
|
711
|
-
desc: 'Parent Description',
|
|
712
|
-
subtags: {
|
|
713
|
-
child: {
|
|
714
|
-
name: 'Child',
|
|
715
|
-
desc: 'Child Description',
|
|
716
|
-
subtags: {
|
|
717
|
-
grandchild: {
|
|
718
|
-
name: 'Grandchild',
|
|
719
|
-
desc: 'Grandchild Description',
|
|
720
|
-
},
|
|
721
|
-
},
|
|
722
|
-
},
|
|
723
|
-
},
|
|
724
|
-
},
|
|
725
|
-
};
|
|
726
|
-
|
|
727
|
-
const expected = {
|
|
728
|
-
parent: {
|
|
729
|
-
name: 'Parent',
|
|
730
|
-
desc: 'Parent Description',
|
|
731
|
-
},
|
|
732
|
-
child: {
|
|
733
|
-
name: 'Child',
|
|
734
|
-
desc: 'Child Description',
|
|
735
|
-
subtags: {
|
|
736
|
-
grandchild: {
|
|
737
|
-
name: 'Grandchild',
|
|
738
|
-
desc: 'Grandchild Description',
|
|
739
|
-
},
|
|
740
|
-
},
|
|
741
|
-
},
|
|
742
|
-
};
|
|
743
|
-
|
|
744
|
-
expect(getForwardedMapValues(input)).toEqual(expected);
|
|
745
|
-
});
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
test('should not mutate the original input object', () => {
|
|
749
|
-
const input = {
|
|
750
|
-
customer: {
|
|
751
|
-
name: 'Customer',
|
|
752
|
-
desc: 'Customer Description',
|
|
753
|
-
subtags: {
|
|
754
|
-
cumulative_points_currency: {
|
|
755
|
-
name: 'Lifetime Points (in ₹)',
|
|
756
|
-
desc: 'Lifetime Points in ₹ Description',
|
|
757
|
-
},
|
|
758
|
-
},
|
|
759
|
-
},
|
|
760
|
-
};
|
|
761
|
-
|
|
762
|
-
const inputCopy = JSON.parse(JSON.stringify(input)); // Deep copy
|
|
763
|
-
|
|
764
|
-
getForwardedMapValues(input);
|
|
765
|
-
|
|
766
|
-
expect(input).toEqual(inputCopy);
|
|
767
|
-
});
|
|
768
499
|
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg width="152" height="152" viewBox="0 0 152 152" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M86.9122 17.3023C106.492 7.08226 130.722 14.6223 141.322 44.7423C148.432 64.9823 149.082 88.5923 137.812 106.942C132.312 115.902 123.992 123.602 112.212 129.052C107.701 131.125 102.981 132.707 98.1322 133.772C97.6822 133.882 97.1622 133.992 96.6822 134.072C78.9322 137.702 59.5622 135.072 43.2022 128.072L42.8522 127.912C28.4122 121.622 16.3222 111.892 9.85221 99.9723C9.83606 99.944 9.8199 99.9125 9.80309 99.8796C9.77827 99.8312 9.75202 99.78 9.72221 99.7323C-0.927788 79.8523 8.75221 66.6223 16.0722 60.1623C18.7689 57.8105 21.8026 55.8757 25.0722 54.4223C34.0723 50.3945 42.7163 45.6142 50.9122 40.1323C62.9722 31.8323 75.7522 23.1323 86.9122 17.3023ZM35.1022 30.6523C35.1022 30.6523 27.7822 38.6523 32.4922 42.8423C36.1322 46.1023 47.4922 40.2323 48.1222 34.7123C48.6322 30.7523 42.4222 23.6723 35.1322 30.6523H35.1022ZM25.2122 46.1223C25.2122 46.1223 21.8422 45.2723 21.9622 49.1923C22.0822 53.1123 25.7522 51.3623 26.8322 50.5823C27.9122 49.8023 29.6322 46.9623 25.2122 46.1223Z" fill="#FFD24B"/>
|
|
3
|
+
<path d="M57.0425 61.592C53.7025 61.502 55.3525 61.242 59.4725 60.382C62.9825 59.652 67.6325 58.492 70.1325 56.702C79.1325 50.262 88.1325 50.122 93.2325 62.242C104.012 87.922 114.522 113.502 99.8525 134.772C99.8525 134.772 103.963 115.032 100.222 104.772C100.222 104.772 93.3525 114.152 82.9025 113.462C82.9025 113.462 99.9025 90.822 91.9025 83.042C91.9025 83.042 72.5125 73.042 74.4325 91.732C74.4325 91.732 76.6125 103.852 80.9825 109.802C80.9825 109.802 73.3325 109.342 69.1225 103.632C69.1225 103.632 66.7425 112.902 69.8825 135.632C69.8825 135.632 55.2025 118.202 68.1125 84.102C70.4025 78.122 84.2125 62.362 57.0425 61.592Z" fill="#103344"/>
|
|
4
|
+
<path d="M69.4523 132.793C66.3123 110.103 69.2123 103.603 69.2123 103.603C72.1223 107.543 76.6723 108.983 79.2123 109.503C79.5447 109.528 79.8631 109.364 80.0346 109.078C80.2061 108.792 80.2014 108.434 80.0223 108.153C76.3623 101.873 74.5323 91.7027 74.5323 91.7027C72.0523 72.0127 89.9823 77.7027 92.6923 81.8127C98.4323 90.6527 87.6323 106.813 83.9723 112.013C83.7754 112.277 83.7369 112.628 83.8718 112.928C84.0067 113.229 84.2938 113.434 84.6223 113.463C94.1323 113.123 100.272 104.743 100.272 104.743C104.012 115.033 99.8023 134.473 99.8023 134.473L99.3723 138.563L69.9123 135.623L69.4523 132.793Z" fill="white"/>
|
|
5
|
+
<path d="M90.2121 132.703C90.2068 135.463 88.2475 137.833 85.5375 138.357C82.8275 138.881 80.1259 137.412 79.0921 134.853C78.8219 134.182 78.6828 133.466 78.6821 132.743C78.6821 129.563 81.2721 123.643 84.4521 123.643C85.7743 123.783 86.9599 124.52 87.6721 125.643C88.0469 126.142 88.3813 126.67 88.6721 127.223C88.698 127.288 88.7281 127.351 88.7621 127.413C89.6281 129.048 90.1231 130.854 90.2121 132.703Z" fill="#A61426"/>
|
|
6
|
+
<path d="M89.8224 131.882C89.822 134.474 88.0962 136.749 85.6001 137.447C83.104 138.146 80.4481 137.097 79.1024 134.882C78.8322 134.211 78.693 133.495 78.6924 132.772C78.6924 129.592 81.2824 123.672 84.4624 123.672C85.7845 123.813 86.9702 124.549 87.6824 125.672C88.0571 126.171 88.3915 126.7 88.6824 127.252C88.7083 127.317 88.7383 127.381 88.7724 127.442C89.3938 128.844 89.7498 130.35 89.8224 131.882Z" fill="#D5192E"/>
|
|
7
|
+
<path d="M89.2124 130.993C89.2124 132.523 88.6045 133.99 87.5224 135.073C86.4403 136.155 84.9727 136.763 83.4424 136.763C81.7946 136.765 80.2265 136.054 79.1424 134.813C78.8722 134.142 78.7331 133.426 78.7324 132.703C78.7324 129.523 81.3224 123.603 84.5024 123.603C85.8246 123.743 87.0102 124.48 87.7224 125.603C88.6118 127.267 89.1207 129.108 89.2124 130.993Z" fill="#ED1D34"/>
|
|
8
|
+
<circle cx="78.2624" cy="58.3127" r="1.34" fill="white"/>
|
|
9
|
+
<circle cx="78.262" cy="58.3118" r="0.68" fill="black"/>
|
|
10
|
+
<ellipse cx="82.5535" cy="126.552" rx="1.51" ry="0.9" transform="rotate(-62.05 82.5535 126.552)" fill="#F47988"/>
|
|
11
|
+
</svg>
|
|
@@ -7,7 +7,7 @@ import * as types from './constants';
|
|
|
7
7
|
import initialState from '../../initialState';
|
|
8
8
|
import { FAILURE } from '../App/constants';
|
|
9
9
|
import { TAG } from '../Whatsapp/constants';
|
|
10
|
-
import { getTagMapValue
|
|
10
|
+
import { getTagMapValue } from '../../utils/tagValidations';
|
|
11
11
|
|
|
12
12
|
function capReducer(state = fromJS(initialState.cap), action) {
|
|
13
13
|
switch (action.type) {
|
|
@@ -117,8 +117,7 @@ function capReducer(state = fromJS(initialState.cap), action) {
|
|
|
117
117
|
const combinedTagMap = {
|
|
118
118
|
...standardTagMap,
|
|
119
119
|
...customSubtags,
|
|
120
|
-
...extendedSubtags
|
|
121
|
-
...state.getIn(['metaEntities', 'tagLookupMap'])?.toJS(),
|
|
120
|
+
...extendedSubtags
|
|
122
121
|
};
|
|
123
122
|
const stateMeta = state.get("metaEntities");
|
|
124
123
|
return state
|
|
@@ -143,18 +142,7 @@ function capReducer(state = fromJS(initialState.cap), action) {
|
|
|
143
142
|
metaEntities.tags.custom = _.filter(state.get('metaEntities').tags.custom, (tag) => action.tagList.indexOf(tag.name) === -1);
|
|
144
143
|
return state.setIn(['metaEntities'], metaEntities);
|
|
145
144
|
case types.SET_INJECTED_TAGS:
|
|
146
|
-
|
|
147
|
-
// Deep clone the tagLookupMap to avoid direct mutations
|
|
148
|
-
let updatedMetaEntitiesTagLookUp = _.cloneDeep(state.getIn(['metaEntities', 'tagLookupMap']));
|
|
149
|
-
const formattedInjectedTags = getForwardedMapValues(action?.injectedTags);
|
|
150
|
-
// Merge the injectedTags with the existing tagLookupMap
|
|
151
|
-
updatedMetaEntitiesTagLookUp = {
|
|
152
|
-
...formattedInjectedTags || {},
|
|
153
|
-
...updatedMetaEntitiesTagLookUp || {},
|
|
154
|
-
};
|
|
155
|
-
return state
|
|
156
|
-
.set('injectedTags', action.injectedTags)
|
|
157
|
-
.setIn(['metaEntities', 'tagLookupMap'], fromJS(updatedMetaEntitiesTagLookUp));
|
|
145
|
+
return state.set('injectedTags', action.injectedTags);
|
|
158
146
|
case types.GET_TOPBAR_MENU_DATA_REQUEST:
|
|
159
147
|
return state.set('topbarMenuData', fromJS({ status: 'request' }));
|
|
160
148
|
case types.GET_TOPBAR_MENU_DATA_SUCCESS:
|
|
@@ -73,3 +73,8 @@ export const GET_SENDER_DETAILS_FAILURE =
|
|
|
73
73
|
export const GET_CDN_TRANSFORMATION_CONFIG_REQUEST = 'app/v2Containers/Templates/GET_CDN_TRANSFORMATION_CONFIG_REQUEST';
|
|
74
74
|
export const GET_CDN_TRANSFORMATION_CONFIG_SUCCESS = 'app/v2Containers/Templates/GET_CDN_TRANSFORMATION_CONFIG_SUCCESS';
|
|
75
75
|
export const GET_CDN_TRANSFORMATION_CONFIG_FAILURE = 'app/v2Containers/Templates/GET_CDN_TRANSFORMATION_CONFIG_FAILURE';
|
|
76
|
+
|
|
77
|
+
export const ACCOUNT_MAPPING_ON_CHANNEL = {
|
|
78
|
+
whatsapp: 'selectedWhatsappAccount',
|
|
79
|
+
zalo: 'selectedZaloAccount',
|
|
80
|
+
};
|
|
@@ -97,7 +97,7 @@ import {
|
|
|
97
97
|
FACEBOOK as FACEBOOK_CHANNEL,
|
|
98
98
|
CREATE,
|
|
99
99
|
} from '../App/constants';
|
|
100
|
-
import {MAX_WHATSAPP_TEMPLATES, WARNING_WHATSAPP_TEMPLATES } from './constants';
|
|
100
|
+
import {MAX_WHATSAPP_TEMPLATES, WARNING_WHATSAPP_TEMPLATES , ACCOUNT_MAPPING_ON_CHANNEL} from './constants';
|
|
101
101
|
import { COPY_OF } from '../../containers/App/constants';
|
|
102
102
|
import {
|
|
103
103
|
TWILIO_CATEGORY_OPTIONS,
|
|
@@ -126,6 +126,7 @@ import emailIllustration from '../Assets/images/emailIllustration.svg';
|
|
|
126
126
|
import smsIllustration from '../Assets/images/smsIllustration.svg';
|
|
127
127
|
import pushIllustration from '../Assets/images/pushIllustration.svg';
|
|
128
128
|
import whatsappIllustration from '../Assets/images/whatsappIllustration.png';
|
|
129
|
+
import whatsappOrZaloAccountIllustration from '../Assets/images/whatsappOrZaloAccountIllustration.svg';
|
|
129
130
|
import rcsIllustration from '../Assets/images/rcsIllustration.png';
|
|
130
131
|
import zaloillustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
|
|
131
132
|
import inAppIllustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
|
|
@@ -250,6 +251,22 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
250
251
|
this.delayTimer = 0;
|
|
251
252
|
}
|
|
252
253
|
|
|
254
|
+
getHostName(selectedSourceAccountIdentifier, domainPropertiesData = []) {
|
|
255
|
+
if (isEmpty(domainPropertiesData) || !selectedSourceAccountIdentifier) {
|
|
256
|
+
return '';
|
|
257
|
+
}
|
|
258
|
+
for (const domainData of domainPropertiesData) {
|
|
259
|
+
const { hostName, connectionProperties: { account_sid, wabaId, userid, sourceAccountIdentifier, oa_id } = {}} = domainData?.domainProperties || {};
|
|
260
|
+
// If sourceAccountIdentifier is not present in the domainProperties, then it will try to find in account_sid, wabaId, user_id.
|
|
261
|
+
// wabaId, user_id is, account_sid are for Karix, Gupshup, and Twilio (Whatsapp) respectively and oa_id is for Zalo.
|
|
262
|
+
const sourceAccountIdentifiersArray = [account_sid, wabaId, userid, oa_id, sourceAccountIdentifier];
|
|
263
|
+
if (sourceAccountIdentifiersArray.includes(selectedSourceAccountIdentifier)) {
|
|
264
|
+
this.setState({hostName});
|
|
265
|
+
return hostName;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
253
270
|
componentWillMount() {
|
|
254
271
|
if (this.state.channel === '') {
|
|
255
272
|
let channel = '';
|
|
@@ -612,11 +629,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
612
629
|
if (!isEmpty(nextProps.Templates.templateDetails) && !isEqual(nextProps.Templates.templateDetails, this.props.Templates.templateDetails)) {
|
|
613
630
|
this.setState({ previewTemplate: nextProps.Templates.templateDetails });
|
|
614
631
|
}
|
|
615
|
-
const { weCrmAccounts: weCrmAccountsList = [], senderDetails
|
|
616
|
-
const weCrmChannels = [
|
|
632
|
+
const { weCrmAccounts: weCrmAccountsList = [], senderDetails = {} } = get(nextProps, 'Templates', {});
|
|
633
|
+
const weCrmChannels = [WHATSAPP_LOWERCASE, ZALO_LOWERCASE];
|
|
617
634
|
|
|
618
|
-
|
|
619
|
-
|
|
635
|
+
// Keeping the wechat flow separate as it has different logic for setting the account.
|
|
636
|
+
if (weCrmAccountsList?.length === 1 && this.state?.defaultAccount && selectedChannel === WECHAT_LOWERCASE && !isEmpty(senderDetails?.hostName)) {
|
|
620
637
|
if (this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
|
|
621
638
|
paramsDefault = {
|
|
622
639
|
name: this.state.searchText,
|
|
@@ -624,39 +641,109 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
624
641
|
};
|
|
625
642
|
}
|
|
626
643
|
|
|
627
|
-
const {
|
|
644
|
+
const { sourceAccountIdentifier, configs } = weCrmAccountsList?.[0] || {};
|
|
628
645
|
const {
|
|
629
|
-
token,
|
|
630
646
|
wecrm_app_id,
|
|
631
647
|
wecrm_token
|
|
632
648
|
} = configs || {};
|
|
633
|
-
if (weCrmChannels.includes(selectedChannel)) {
|
|
634
|
-
if ([WHATSAPP_LOWERCASE, ZALO_LOWERCASE].includes(selectedChannel)) {
|
|
635
|
-
if (hostName === '') {
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
649
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
paramsDefault.oa_id = sourceAccountIdentifier;
|
|
644
|
-
paramsDefault.token = token;
|
|
645
|
-
paramsDefault.host = hostName || this.props.Templates?.senderDetails?.hostName || this.props.Templates?.selectedZaloAccount?.hostName || this.state.hostName;
|
|
646
|
-
}
|
|
647
|
-
} else {
|
|
648
|
-
paramsDefault.wecrmId = wecrm_app_id;
|
|
649
|
-
paramsDefault.wecrmToken = wecrm_token;
|
|
650
|
-
paramsDefault.originalId = sourceAccountIdentifier;
|
|
651
|
-
nextProps.actions.setWeChatAccount(
|
|
652
|
-
weCrmAccountsList[0],
|
|
653
|
-
);
|
|
654
|
-
}
|
|
655
|
-
|
|
650
|
+
const paramsDefault = {
|
|
651
|
+
wecrmId: wecrm_app_id,
|
|
652
|
+
wecrmToken: wecrm_token,
|
|
653
|
+
originalId: sourceAccountIdentifier,
|
|
656
654
|
}
|
|
655
|
+
nextProps.actions.setWeChatAccount(
|
|
656
|
+
weCrmAccountsList[0],
|
|
657
|
+
);
|
|
658
|
+
|
|
657
659
|
this.setState({ defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: weCrmAccountsList[0].name, hostName: weCrmAccountsList[0].hostName });
|
|
658
|
-
this.getAllTemplates({params: paramsDefault}, true);
|
|
660
|
+
this.getAllTemplates({ params: paramsDefault }, true);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
if (weCrmAccountsList?.length && this.state?.defaultAccount && (weCrmChannels.includes(selectedChannel))) {
|
|
664
|
+
const isSingleAccount = weCrmAccountsList?.length === 1;
|
|
665
|
+
const selectedAccount = this.props.Templates[ACCOUNT_MAPPING_ON_CHANNEL[selectedChannel]] || {};
|
|
666
|
+
const hostName = this.getHostName(isSingleAccount ? weCrmAccountsList[0]?.sourceAccountIdentifier : selectedAccount?.sourceAccountIdentifier, senderDetails?.domainProperties);
|
|
667
|
+
|
|
668
|
+
if (!isEmpty(hostName)) {
|
|
669
|
+
let paramsDefault = {};
|
|
670
|
+
if (this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
|
|
671
|
+
paramsDefault = {
|
|
672
|
+
name: this.state.searchText,
|
|
673
|
+
sortBy: this.state.sortBy,
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
const {name, sourceAccountIdentifier, configs } = weCrmAccountsList?.[0] || {};
|
|
678
|
+
if (isSingleAccount) {
|
|
679
|
+
weCrmAccountsList[0].hostName = hostName;
|
|
680
|
+
} else {
|
|
681
|
+
selectedAccount.hostName = hostName;
|
|
682
|
+
}
|
|
683
|
+
nextProps.actions.setChannelAccount(selectedChannel?.toUpperCase(), isSingleAccount ? weCrmAccountsList[0] : selectedAccount);
|
|
684
|
+
if (selectedChannel === ZALO_LOWERCASE) {
|
|
685
|
+
paramsDefault.username = name;
|
|
686
|
+
paramsDefault.oa_id = sourceAccountIdentifier;
|
|
687
|
+
paramsDefault.token = configs?.token;
|
|
688
|
+
paramsDefault.host = hostName || this.props.Templates?.selectedZaloAccount?.hostName;
|
|
689
|
+
}
|
|
690
|
+
if (selectedChannel === WHATSAPP_LOWERCASE) {
|
|
691
|
+
paramsDefault.accountId = sourceAccountIdentifier;
|
|
692
|
+
paramsDefault.host = hostName || this.props.Templates?.selectedWhatsappAccount?.hostName;
|
|
693
|
+
}
|
|
694
|
+
this.setState({ defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: isSingleAccount ? weCrmAccountsList[0]?.name : selectedAccount?.name });
|
|
695
|
+
/**
|
|
696
|
+
* Incase of multiple accounts, getAllTemplates is called on selecting the account. It's handled in onAccountSelect function.
|
|
697
|
+
* But for single account, onAccountSelect function won't get executed and getAllTemplates will be excuted.
|
|
698
|
+
*/
|
|
699
|
+
if (weCrmAccountsList?.length === 1) {
|
|
700
|
+
this.getAllTemplates({params: paramsDefault}, true);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
659
703
|
}
|
|
704
|
+
|
|
705
|
+
// if (weCrmAccountsList.length === 1 && this.state.defaultAccount && (weCrmChannels.indexOf(selectedChannel) > -1) && !isEmpty(hostName)) {
|
|
706
|
+
// let paramsDefault = {};
|
|
707
|
+
// if (this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
|
|
708
|
+
// paramsDefault = {
|
|
709
|
+
// name: this.state.searchText,
|
|
710
|
+
// sortBy: this.state.sortBy,
|
|
711
|
+
// };
|
|
712
|
+
// }
|
|
713
|
+
|
|
714
|
+
// const {name, sourceAccountIdentifier, configs } = weCrmAccountsList?.[0] || {};
|
|
715
|
+
// const {
|
|
716
|
+
// token,
|
|
717
|
+
// wecrm_app_id,
|
|
718
|
+
// wecrm_token
|
|
719
|
+
// } = configs || {};
|
|
720
|
+
// if (weCrmChannels.includes(selectedChannel)) {
|
|
721
|
+
// if ([WHATSAPP_LOWERCASE, ZALO_LOWERCASE].includes(selectedChannel)) {
|
|
722
|
+
// if (hostName === '') {
|
|
723
|
+
// return;
|
|
724
|
+
// }
|
|
725
|
+
|
|
726
|
+
// weCrmAccountsList[0].hostName = hostName;
|
|
727
|
+
// nextProps.actions.setChannelAccount(selectedChannel.toUpperCase(), weCrmAccountsList[0]);
|
|
728
|
+
// if (selectedChannel === ZALO_LOWERCASE) {
|
|
729
|
+
// paramsDefault.username = name;
|
|
730
|
+
// paramsDefault.oa_id = sourceAccountIdentifier;
|
|
731
|
+
// paramsDefault.token = token;
|
|
732
|
+
// paramsDefault.host = hostName || this.props.Templates?.senderDetails?.hostName || this.props.Templates?.selectedZaloAccount?.hostName || this.state.hostName;
|
|
733
|
+
// }
|
|
734
|
+
// } else {
|
|
735
|
+
// paramsDefault.wecrmId = wecrm_app_id;
|
|
736
|
+
// paramsDefault.wecrmToken = wecrm_token;
|
|
737
|
+
// paramsDefault.originalId = sourceAccountIdentifier;
|
|
738
|
+
// nextProps.actions.setWeChatAccount(
|
|
739
|
+
// weCrmAccountsList[0],
|
|
740
|
+
// );
|
|
741
|
+
// }
|
|
742
|
+
|
|
743
|
+
// }
|
|
744
|
+
// this.setState({ defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: weCrmAccountsList[0].name, hostName: weCrmAccountsList[0].hostName });
|
|
745
|
+
// this.getAllTemplates({params: paramsDefault}, true);
|
|
746
|
+
// }
|
|
660
747
|
const zaloPreviewUrl = get(nextProps, 'Zalo.zaloTemplatePreviewData.versions.base.content.zalo.previewUrl', '');
|
|
661
748
|
if (zaloPreviewUrl && this.state.channel.toLowerCase() === ZALO_LOWERCASE) {
|
|
662
749
|
handlePreviewInNewTab(zaloPreviewUrl);
|
|
@@ -681,6 +768,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
681
768
|
params.sortBy = this.state.sortBy;
|
|
682
769
|
}
|
|
683
770
|
const selectedChannel = this.state.channel.toLowerCase();
|
|
771
|
+
const isZaloOrWhatsapp = [ZALO_LOWERCASE, WHATSAPP_LOWERCASE].includes(selectedChannel);
|
|
684
772
|
if (selectedChannel === 'wechat') {
|
|
685
773
|
params.wecrmId = this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})].configs.wecrm_app_id;
|
|
686
774
|
params.wecrmToken = this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})].configs.wecrm_token;
|
|
@@ -700,26 +788,52 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
700
788
|
} else {
|
|
701
789
|
this.setState({ selectedAccountError: false });
|
|
702
790
|
}
|
|
703
|
-
} else if ([LINE.toLowerCase(), RCS_LOWERCASE, ZALO_LOWERCASE].includes(selectedChannel)) {
|
|
791
|
+
} else if ([LINE.toLowerCase(), RCS_LOWERCASE, ZALO_LOWERCASE, WHATSAPP_LOWERCASE].includes(selectedChannel)) {
|
|
704
792
|
const setAcc = this.props?.Templates?.weCrmAccounts?.find((item) => item?.name === this.state.selectedAccount);
|
|
793
|
+
console.log(">>> get onAccountSelect", { isZaloOrWhatsapp, selectedChannel, setAcc, slectedAcc: this.state.selectedAccount, value, templ: this.props.Templates?.weCrmAccounts});
|
|
794
|
+
const { domainProperties = [] } = this.props?.Templates?.senderDetails || {};
|
|
795
|
+
let hostName = '';
|
|
796
|
+
if (isZaloOrWhatsapp) {
|
|
797
|
+
hostName = this.getHostName(setAcc?.sourceAccountIdentifier, domainProperties);
|
|
798
|
+
setAcc.hostName = hostName;
|
|
799
|
+
}
|
|
705
800
|
this.props.actions.setChannelAccount(selectedChannel?.toUpperCase(), setAcc);
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
801
|
+
|
|
802
|
+
const {
|
|
803
|
+
name = "",
|
|
804
|
+
sourceAccountIdentifier = "",
|
|
805
|
+
configs: { token = "" } = {},
|
|
806
|
+
} = setAcc || {};
|
|
807
|
+
|
|
808
|
+
if(selectedChannel === ZALO_LOWERCASE && hostName) {
|
|
712
809
|
params.username = name;
|
|
713
810
|
params.oa_id = sourceAccountIdentifier;
|
|
714
811
|
params.token = token;
|
|
715
812
|
params.isAccountSelection = true;
|
|
716
|
-
params.host = this.props.Templates?.senderDetails?.hostName || this.props.Templates?.selectedZaloAccount?.hostName || this.state.hostName;
|
|
813
|
+
// params.host = this.props.Templates?.senderDetails?.hostName || this.props.Templates?.selectedZaloAccount?.hostName || this.state.hostName;
|
|
814
|
+
params.host = hostName;
|
|
815
|
+
// this.getHostName(sourceAccountIdentifier, domainProperties) || this.props.Templates?.selectedZaloAccount?.hostName;
|
|
816
|
+
}
|
|
817
|
+
if (selectedChannel === WHATSAPP_LOWERCASE && hostName) {
|
|
818
|
+
params.accountId = sourceAccountIdentifier;
|
|
819
|
+
params.host = hostName;
|
|
820
|
+
// this.getHostName(sourceAccountIdentifier, domainProperties) || this.props.Templates?.selectedWhatsappAccount?.hostName;
|
|
717
821
|
}
|
|
822
|
+
console.log(">>> onAccountSelect", {params,sourceAccountIdentifier, hostName, setAcc, name,shn: this.state.hostName, token, setAcc, selectedChannel, value, templ: this.props.Templates});
|
|
718
823
|
}
|
|
719
824
|
|
|
720
|
-
this.setState({activeMode: TEMPLATES_MODE});
|
|
825
|
+
// this.setState({activeMode: TEMPLATES_MODE});
|
|
826
|
+
console.log(">>> GETALLTEMPLATES onaccount select 1", {params})
|
|
827
|
+
// this.getAllTemplates({params, resetPage: true});
|
|
721
828
|
|
|
722
|
-
|
|
829
|
+
// Always set activeMode before getAllTemplates call
|
|
830
|
+
this.setState({ activeMode: TEMPLATES_MODE }, () => {
|
|
831
|
+
// Restrict getAllTemplates call only if selectedChannel is ZALO or WHATSAPP and hostName is empty
|
|
832
|
+
if (!(isZaloOrWhatsapp && !params?.host)) {
|
|
833
|
+
console.log(">>> GETALLTEMPLATES onaccount select ", { params });
|
|
834
|
+
this.getAllTemplates({ params, resetPage: true });
|
|
835
|
+
}
|
|
836
|
+
});
|
|
723
837
|
});
|
|
724
838
|
}
|
|
725
839
|
onPaginationChange = () => {
|
|
@@ -797,10 +911,17 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
797
911
|
|
|
798
912
|
moment.locale(locale);
|
|
799
913
|
};
|
|
914
|
+
|
|
915
|
+
setWhatsappQueryParams = (queryParams, params) => {
|
|
916
|
+
queryParams.accountId = params?.accountId || this.props.Templates?.selectedWhatsappAccount?.sourceAccountIdentifier;
|
|
917
|
+
queryParams.host = params?.host || this.state?.hostName;
|
|
918
|
+
};
|
|
919
|
+
|
|
800
920
|
getAllTemplates = ({params, getNextPage, resetPage}, resetTemplates) => {
|
|
801
921
|
let queryParams = params || {};
|
|
802
922
|
let page = this.state.page;
|
|
803
923
|
const { activeMode } = this.state;
|
|
924
|
+
console.log(">>> getAllTemplates", {params, getNextPage, resetPage, resetTemplates, elseif: (resetPage || (page === 1 && this.state.templatesCount === 0) || page <= (this.state.templatesCount / this.state.perPageLimit))})
|
|
804
925
|
if (activeMode === ACCOUNT_SELECTION_MODE) {
|
|
805
926
|
this.setTemplatesMode();
|
|
806
927
|
}
|
|
@@ -825,6 +946,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
825
946
|
if (([MOBILE_PUSH_LOWERCASE, INAPP_LOWERCASE].includes(channel.toLowerCase())) && !isEmpty(this.props.Templates.selectedWeChatAccount)) {
|
|
826
947
|
queryParams.accountId = this.props.Templates?.selectedWeChatAccount?.id;
|
|
827
948
|
}
|
|
949
|
+
if (this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE) {
|
|
950
|
+
this.setWhatsappQueryParams(queryParams, params);
|
|
951
|
+
}
|
|
828
952
|
this.props.actions.getAllTemplates(channel, queryParams,`${copyOf}`);
|
|
829
953
|
} else if ((resetPage || (page === 1 && this.state.templatesCount === 0) || page <= (this.state.templatesCount / this.state.perPageLimit))) {
|
|
830
954
|
if (getNextPage) {
|
|
@@ -874,6 +998,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
874
998
|
queryParams.token = token;
|
|
875
999
|
queryParams.host = hostName || this.props.Templates?.senderDetails?.hostName ||this.state.hostName;
|
|
876
1000
|
}
|
|
1001
|
+
if (this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE) {
|
|
1002
|
+
this.setWhatsappQueryParams(queryParams, params);
|
|
1003
|
+
}
|
|
877
1004
|
this.setState({ page, templatesCount }, () => {
|
|
878
1005
|
queryParams.page = page;
|
|
879
1006
|
queryParams.perPage = this.state.perPageLimit;
|
|
@@ -1010,6 +1137,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1010
1137
|
};
|
|
1011
1138
|
|
|
1012
1139
|
getTemplateDataForGrid = ({templates = [], handlers, filterContent, channel, isLoading, loadingTip}) => {
|
|
1140
|
+
console.log("@@@ getTemplateDataForGrid", {templates, handlers, filterContent, channel, isLoading, loadingTip})
|
|
1013
1141
|
const currentChannel = channel.toUpperCase();
|
|
1014
1142
|
const {channel: stateChannel} = this.state;
|
|
1015
1143
|
const channelLowerCase = stateChannel.toLowerCase();
|
|
@@ -1020,7 +1148,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1020
1148
|
filteredTemplates = this.filterWechatTemplates(templates);
|
|
1021
1149
|
break;
|
|
1022
1150
|
case WHATSAPP:
|
|
1023
|
-
filteredTemplates = this.filterWhatsappTemplates(templates);
|
|
1151
|
+
filteredTemplates = this.state?.hostName ? this.filterWhatsappTemplates(templates) : [];
|
|
1024
1152
|
break;
|
|
1025
1153
|
case LINE:
|
|
1026
1154
|
filteredTemplates = this.filterLineTemplates(templates);
|
|
@@ -1381,16 +1509,17 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1381
1509
|
|
|
1382
1510
|
const accountId = get(this.props, 'Templates.selectedWeChatAccount.uuid');
|
|
1383
1511
|
const accounts = get(this.props, 'Templates.weCrmAccounts');
|
|
1384
|
-
const noWhatsappZaloTemplates = this.isFullMode() && isEmpty(templates);
|
|
1512
|
+
const noWhatsappZaloTemplates = this.isFullMode() && isEmpty(templates) || !this.state.hostName;
|
|
1385
1513
|
const noFilteredWhatsappZaloTemplates = this.isFullMode() && !isEmpty(templates) && isEmpty(filteredTemplates);
|
|
1386
1514
|
const noApprovedWhatsappZaloTemplates = !this.isFullMode() && isEmpty(filteredTemplates);
|
|
1387
|
-
const showWhatsappIllustration = !isEmpty(this.props.Templates.selectedWhatsappAccount) && [WHATSAPP_LOWERCASE].includes(channelLowerCase);
|
|
1515
|
+
const showWhatsappIllustration = (!isEmpty(this.props.Templates.selectedWhatsappAccount) && [WHATSAPP_LOWERCASE].includes(channelLowerCase)) || !this.state.hostName ;
|
|
1388
1516
|
const showZaloIllustration = !isEmpty(this.props.Templates.selectedZaloAccount) && [ZALO_LOWERCASE].includes(channelLowerCase);
|
|
1389
1517
|
const showRcsIllustration = channelLowerCase === RCS_LOWERCASE && isEmpty(templates);
|
|
1390
1518
|
const showInAppIllustration = channelLowerCase === INAPP_LOWERCASE && isEmpty(templates);
|
|
1391
1519
|
const noLoaderAndSearchText = isEmpty(this.state.searchText) && !isLoading;
|
|
1520
|
+
console.log(">>> state ", {showWhatsappIllustration, noLoaderAndSearchText, channelLowerCase, host: this.state.hostName, templates: this.props.Templates})
|
|
1392
1521
|
return (<div>
|
|
1393
|
-
{[WECHAT, MOBILE_PUSH, INAPP].includes(currentChannel) && this.showAccountName()}
|
|
1522
|
+
{[WECHAT, MOBILE_PUSH, INAPP, WHATSAPP, ZALO].includes(currentChannel) && this.showAccountName()}
|
|
1394
1523
|
{filterContent}
|
|
1395
1524
|
{[WHATSAPP, ZALO].includes(currentChannel) && this.selectedFilters()}
|
|
1396
1525
|
<CapCustomSkeleton loader={isLoading}>
|
|
@@ -1427,15 +1556,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1427
1556
|
isEmpty(filteredTemplates) &&
|
|
1428
1557
|
isEmpty(this.state.searchText) &&
|
|
1429
1558
|
<div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto'} : {}}>
|
|
1430
|
-
<CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />
|
|
1559
|
+
<CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel, this.state.hostName)} />
|
|
1431
1560
|
</div>
|
|
1432
1561
|
)
|
|
1433
1562
|
}
|
|
1434
1563
|
{(showWhatsappIllustration || showZaloIllustration) && (
|
|
1435
1564
|
noLoaderAndSearchText &&
|
|
1436
1565
|
<div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto' } : {}}>
|
|
1437
|
-
{noWhatsappZaloTemplates && <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />}
|
|
1438
|
-
{noFilteredWhatsappZaloTemplates && this.whatsappZaloIllustrationText('noFilteredWhatsappZaloTemplatesTitle', 'noFilteredWhatsappZaloTemplatesDesc')}
|
|
1566
|
+
{noWhatsappZaloTemplates && <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel, isEmpty(this.state.hostName))} />}
|
|
1567
|
+
{noFilteredWhatsappZaloTemplates && this.state?.hostName && this.whatsappZaloIllustrationText('noFilteredWhatsappZaloTemplatesTitle', 'noFilteredWhatsappZaloTemplatesDesc')}
|
|
1439
1568
|
{noApprovedWhatsappZaloTemplates && this.whatsappZaloIllustrationText('noApprovedWhatsappZaloTemplatesTitle', showWhatsappIllustration ? 'noApprovedWhatsappTemplatesDesc' : 'zaloDescIllustration')}
|
|
1440
1569
|
</div>
|
|
1441
1570
|
)
|
|
@@ -1840,6 +1969,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1840
1969
|
}
|
|
1841
1970
|
if (this.state.channel.toLowerCase() === MOBILE_PUSH_LOWERCASE) {
|
|
1842
1971
|
params.accountId = this.props.Templates.selectedWeChatAccount.id;
|
|
1972
|
+
} else if (this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE) {
|
|
1973
|
+
params.accountId = this.props.Templates?.selectedWhatsappAccount?.sourceAccountIdentifier;
|
|
1974
|
+
params.host = this.state?.hostName;
|
|
1843
1975
|
}
|
|
1844
1976
|
this.delay(() => {
|
|
1845
1977
|
this.getAllTemplates({params, resetPage: true});
|
|
@@ -2443,7 +2575,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2443
2575
|
(rcsLoader !== undefined ? rcsLoader : false);
|
|
2444
2576
|
return isLoading;
|
|
2445
2577
|
}
|
|
2446
|
-
getChannelTypeIllustrationInfo = (type) => {
|
|
2578
|
+
getChannelTypeIllustrationInfo = (type, hostNameNotFound) => {
|
|
2447
2579
|
const { isFullMode, intl } = this.props;
|
|
2448
2580
|
const templateIntlMsg = intl.formatMessage(messages.template);
|
|
2449
2581
|
const templateText = isFullMode ? templateIntlMsg : '';
|
|
@@ -2469,16 +2601,28 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2469
2601
|
illustrationImage: pushIllustration,
|
|
2470
2602
|
title: <FormattedMessage {...messages.pushTitleIllustartion} values={{ template: templateText }} />,
|
|
2471
2603
|
};
|
|
2472
|
-
case WHATSAPP:
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2604
|
+
case WHATSAPP: {
|
|
2605
|
+
if (hostNameNotFound) {
|
|
2606
|
+
return {
|
|
2607
|
+
illustrationImage: whatsappOrZaloAccountIllustration,
|
|
2608
|
+
title: <FormattedMessage {...messages.whatsappAccountNotConfiguredTitle} />,
|
|
2609
|
+
description: <FormattedMessage {...messages.accountNotConfiguredDescription} />,
|
|
2610
|
+
descriptionPosition: 'bottom',
|
|
2611
|
+
descriptionClassName: 'illustration-desc zalo-illustration',
|
|
2612
|
+
buttonClassName: "zalo-illustration-button",
|
|
2613
|
+
};
|
|
2614
|
+
} else {
|
|
2615
|
+
return {
|
|
2616
|
+
buttonLabel: <FormattedMessage {...messages.newWhatsappTemplate} values={{ template: templateText }} />,
|
|
2617
|
+
onClick: this.createTemplate,
|
|
2618
|
+
illustrationImage: whatsappIllustration,
|
|
2619
|
+
title: <FormattedMessage {...messages.whatsappTitleIllustration} values={{ template: templateText }} />,
|
|
2620
|
+
description: <FormattedMessage {...messages.whatsappDescIllustration} />,
|
|
2621
|
+
descriptionPosition: 'bottom',
|
|
2622
|
+
descriptionClassName: 'illustration-desc',
|
|
2623
|
+
};
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2482
2626
|
case RCS:
|
|
2483
2627
|
return {
|
|
2484
2628
|
buttonLabel: <FormattedMessage {...messages.newRCSTemplate} values={{ template: templateText }} />,
|
|
@@ -2489,15 +2633,27 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2489
2633
|
descriptionPosition: 'bottom',
|
|
2490
2634
|
descriptionClassName: 'illustration-desc rcs-illustration',
|
|
2491
2635
|
};
|
|
2492
|
-
case ZALO:
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2636
|
+
case ZALO:{
|
|
2637
|
+
if (hostNameNotFound) {
|
|
2638
|
+
return {
|
|
2639
|
+
illustrationImage: whatsappOrZaloAccountIllustration,
|
|
2640
|
+
title: <FormattedMessage {...messages.zaloAccountNotConfiguredTitle} />,
|
|
2641
|
+
description: <FormattedMessage {...messages.accountNotConfiguredDescription} />,
|
|
2642
|
+
descriptionPosition: 'bottom',
|
|
2643
|
+
descriptionClassName: 'illustration-desc zalo-illustration',
|
|
2644
|
+
buttonClassName: "zalo-illustration-button",
|
|
2645
|
+
};
|
|
2646
|
+
} else {
|
|
2647
|
+
return {
|
|
2648
|
+
illustrationImage: zaloillustration,
|
|
2649
|
+
title: <FormattedMessage {...messages.zaloTitleIllustration} />,
|
|
2650
|
+
description: <FormattedMessage {...messages.zaloDescIllustration} />,
|
|
2651
|
+
descriptionPosition: 'bottom',
|
|
2652
|
+
descriptionClassName: 'illustration-desc zalo-illustration',
|
|
2653
|
+
buttonClassName: "zalo-illustration-button",
|
|
2654
|
+
};
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2501
2657
|
case INAPP:
|
|
2502
2658
|
return {
|
|
2503
2659
|
illustrationImage: inAppIllustration,
|
|
@@ -2552,7 +2708,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2552
2708
|
return modal;
|
|
2553
2709
|
};
|
|
2554
2710
|
|
|
2555
|
-
renderAccountSelection = () => {
|
|
2711
|
+
renderAccountSelection = (linenum) => {
|
|
2556
2712
|
const accountOptions = [];
|
|
2557
2713
|
const { selectedAccount } = this.state;
|
|
2558
2714
|
let { channel = '' } = this.state;
|
|
@@ -2564,10 +2720,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2564
2720
|
const isMobilePushChannel = channel === MOBILE_PUSH;
|
|
2565
2721
|
const isInAppChannel = channel === INAPP;
|
|
2566
2722
|
const isFacebookChannel = channel === FACEBOOK;
|
|
2567
|
-
|
|
2568
|
-
if ([WECHAT, MOBILE_PUSH, INAPP, LINE, ZALO].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
|
|
2723
|
+
if ([WECHAT, MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
|
|
2569
2724
|
forEach(weCrmAccounts, (account) => {
|
|
2570
|
-
if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, INAPP, LINE, ZALO].includes(channel)) {
|
|
2725
|
+
if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP].includes(channel)) {
|
|
2571
2726
|
if (query.type === 'embedded' && (!query.module || (query.module && query.module !== 'library'))) {
|
|
2572
2727
|
if (query.source_account_id && account.sourceAccountIdentifier === query.source_account_id) {
|
|
2573
2728
|
accountOptions.push(
|
|
@@ -2650,9 +2805,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2650
2805
|
break;
|
|
2651
2806
|
}
|
|
2652
2807
|
let showNoAccountHeader = isEmpty(weCrmAccounts) && !fetchingWeCrmAccounts;
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2808
|
+
// This is not required as whatsapp will have account selection for multiple accounts
|
|
2809
|
+
// if (channel === WHATSAPP && this.state.hostName === '') {
|
|
2810
|
+
// showNoAccountHeader = true;
|
|
2811
|
+
// }
|
|
2656
2812
|
if (channel === FACEBOOK && !isEmpty(campaignSettings) ) {
|
|
2657
2813
|
const fbSetting = get(campaignSettings, 'accountSettings.socialAccountSettings.facebookAccountSettings', []);
|
|
2658
2814
|
const { orgUnitFacebookPageSettingsMap } = fbSetting[0] || {};
|
|
@@ -2671,6 +2827,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2671
2827
|
if (channel === WECHAT && !commonUtil.hasWechatFeatureEnabled()) {
|
|
2672
2828
|
showNoAccountHeader = true;
|
|
2673
2829
|
}
|
|
2830
|
+
console.log("### renderAccountSelection -> showNoAccountHeader", {linenum, hostName: this.state.hostName, showNoAccountHeader, selectedAccount, accountOptions, accountHeader, noAccountHeader })
|
|
2674
2831
|
return (<CapSkeleton loading={fetchingWeCrmAccounts} active paragraph={{ rows: 10 }}>
|
|
2675
2832
|
{showNoAccountHeader ? <FormattedMessage {...noAccountHeader} /> :
|
|
2676
2833
|
<div style={{ overflowX: "auto", paddingBottom: CAP_SPACE_16 }}>
|
|
@@ -2846,7 +3003,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2846
3003
|
|
|
2847
3004
|
|
|
2848
3005
|
if (activeMode === ACCOUNT_SELECTION_MODE && showForChannels ) {
|
|
2849
|
-
return this.renderAccountSelection();
|
|
3006
|
+
return this.renderAccountSelection(3006);
|
|
2850
3007
|
}
|
|
2851
3008
|
|
|
2852
3009
|
|
|
@@ -2874,7 +3031,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2874
3031
|
);
|
|
2875
3032
|
//TODO -> uncomment the following line
|
|
2876
3033
|
// const isfilterContentVisisble = !isEmpty(this.props.TemplatesList) || !isEmpty(this.state.searchText) || !isEmpty(this.props.Templates.templateError);
|
|
2877
|
-
|
|
3034
|
+
let isfilterContentVisisble = true;
|
|
2878
3035
|
const isWechatEmbedded = !this.props.isFullMode && channel.toUpperCase() === WECHAT;
|
|
2879
3036
|
const channelLowerCase = (channel || '').toLowerCase();
|
|
2880
3037
|
const isTraiDltFeature = this.checkDLTfeatureEnable();
|
|
@@ -2889,7 +3046,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2889
3046
|
className="create-new-link"
|
|
2890
3047
|
/>
|
|
2891
3048
|
)
|
|
2892
|
-
: this.state
|
|
3049
|
+
: this.state?.channel?.toLowerCase() === ZALO_LOWERCASE || (channelLowerCase === WHATSAPP_LOWERCASE && isEmpty(this.state?.hostName)) ? <></> : (
|
|
2893
3050
|
<CapButton
|
|
2894
3051
|
className={`create-new-${channelLowerCase} margin-l-8 margin-b-12`}
|
|
2895
3052
|
type={"primary"}
|
|
@@ -2903,7 +3060,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2903
3060
|
const isWhatsappCountExeeded = templatesCount >= MAX_WHATSAPP_TEMPLATES;
|
|
2904
3061
|
const showWhatsappCountWarning = templatesCount >= WARNING_WHATSAPP_TEMPLATES;
|
|
2905
3062
|
const whatsappCountExceedText = <FormattedMessage {...messages.whatsappMaxTemplates} values={{ maxCount: MAX_WHATSAPP_TEMPLATES }}/>;
|
|
2906
|
-
|
|
3063
|
+
if (([WHATSAPP_LOWERCASE, ZALO_LOWERCASE].includes(this.state?.channel?.toLocaleLowerCase()) && isEmpty(this.state?.hostName))) {
|
|
3064
|
+
isfilterContentVisisble = false;
|
|
3065
|
+
}
|
|
2907
3066
|
const filterContent = (( isfilterContentVisisble || [WECHAT, MOBILE_PUSH, INAPP].includes(this.state.channel.toUpperCase())) && <div className="action-container">
|
|
2908
3067
|
{isfilterContentVisisble && <CapInput.Search
|
|
2909
3068
|
className="search-text"
|
|
@@ -2932,7 +3091,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2932
3091
|
channel.toUpperCase() === ZALO && (
|
|
2933
3092
|
<div className="zalo-filters">
|
|
2934
3093
|
{
|
|
2935
|
-
this.props
|
|
3094
|
+
this.props?.isFullMode && this.state?.hostName ? (
|
|
2936
3095
|
<CapSelectFilter
|
|
2937
3096
|
placement="bottomLeft"
|
|
2938
3097
|
data={ZALO_STATUS_OPTIONS}
|
|
@@ -2951,7 +3110,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2951
3110
|
channel.toUpperCase() === WHATSAPP && (
|
|
2952
3111
|
<div className="whatsapp-filters">
|
|
2953
3112
|
{
|
|
2954
|
-
this.props
|
|
3113
|
+
this.props?.isFullMode && this.state?.hostName ? (
|
|
2955
3114
|
<CapSelectFilter
|
|
2956
3115
|
placement="bottomLeft"
|
|
2957
3116
|
data={STATUS_OPTIONS}
|
|
@@ -2963,18 +3122,20 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2963
3122
|
/>
|
|
2964
3123
|
) : null
|
|
2965
3124
|
}
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
3125
|
+
{this.state?.hostName ? (
|
|
3126
|
+
<CapSelectFilter
|
|
3127
|
+
placement="bottomLeft"
|
|
3128
|
+
data={this.state.hostName === HOST_TWILIO
|
|
3129
|
+
? TWILIO_CATEGORY_OPTIONS
|
|
3130
|
+
: KARIX_GUPSHUP_CATEGORY_OPTIONS}
|
|
3131
|
+
onSelect={this.setWhatsappCategory}
|
|
3132
|
+
selectedValue={this.state.selectedWhatsappCategory}
|
|
3133
|
+
placeholder="Category"
|
|
3134
|
+
showBadge
|
|
3135
|
+
width="105px"
|
|
3136
|
+
overlayStyle={{ overflowY: "hidden" }}
|
|
3137
|
+
/>
|
|
3138
|
+
) : null}
|
|
2978
3139
|
</div>
|
|
2979
3140
|
|
|
2980
3141
|
)
|
|
@@ -3047,7 +3208,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
3047
3208
|
}
|
|
3048
3209
|
<div style={{display: "flex", justifyContent: "space-between", alignItems: 'center'}}>
|
|
3049
3210
|
{
|
|
3050
|
-
this.state
|
|
3211
|
+
this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE && (isWhatsappCountExeeded)? (
|
|
3051
3212
|
<CapTooltip title={whatsappCountExceedText}>
|
|
3052
3213
|
<div className="button-disabled-tooltip-wrapper">
|
|
3053
3214
|
{createButton}
|
|
@@ -3088,7 +3249,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
3088
3249
|
|
|
3089
3250
|
return (
|
|
3090
3251
|
<>
|
|
3091
|
-
{activeMode === ACCOUNT_CHANGE_MODE && this.renderAccountSelection()}
|
|
3252
|
+
{activeMode === ACCOUNT_CHANGE_MODE && this.renderAccountSelection(3252)}
|
|
3092
3253
|
<div className={`creatives-templates-list ${this.props.isFullMode ? 'full-mode' : 'library-mode'}`}>
|
|
3093
3254
|
<input type="file" id="filename" style={{ display: 'none'}} accept=".zip, .html, .htm" onChange={(event) => this.handleFileUpload(event, {files: event.target.files})} />
|
|
3094
3255
|
|
|
@@ -354,6 +354,18 @@ export default defineMessages({
|
|
|
354
354
|
id: `${scope}.whatsappDescIllustration`,
|
|
355
355
|
defaultMessage: 'These templates can be reused when creating a\nnew message content.',
|
|
356
356
|
},
|
|
357
|
+
"whatsappAccountNotConfiguredTitle": {
|
|
358
|
+
id: `${scope}.whatsappAccountNotConfiguredTitle`,
|
|
359
|
+
defaultMessage: 'Whatsapp account is not configured',
|
|
360
|
+
},
|
|
361
|
+
"accountNotConfiguredDescription": {
|
|
362
|
+
id: `${scope}.accountNotConfiguredDescription`,
|
|
363
|
+
defaultMessage: 'Please contact your Customer Success Manager to fix the issue.',
|
|
364
|
+
},
|
|
365
|
+
"zaloAccountNotConfiguredTitle": {
|
|
366
|
+
id: `${scope}.zaloAccountNotConfiguredTitle`,
|
|
367
|
+
defaultMessage: 'Zalo account is not configured',
|
|
368
|
+
},
|
|
357
369
|
"zaloTitleIllustration": {
|
|
358
370
|
id: `${scope}.zaloTitleIllustration`,
|
|
359
371
|
defaultMessage: 'There are no approved templates available',
|
|
@@ -180,12 +180,17 @@ function templatesReducer(state = initialState, action) {
|
|
|
180
180
|
return state.set('fetchedOrgLevelCampaignSettings', false);
|
|
181
181
|
case types.GET_SENDER_DETAILS_REQUEST:
|
|
182
182
|
return state.set('senderDetails', { status: 'REQUEST' });
|
|
183
|
-
case types.GET_SENDER_DETAILS_SUCCESS:
|
|
183
|
+
case types.GET_SENDER_DETAILS_SUCCESS: {
|
|
184
|
+
const { channel, domainProperties = {} } = action?.payload || {};
|
|
185
|
+
const isMultiAccountChannel = ['WHATSAPP', 'ZALO'].includes(channel);
|
|
186
|
+
const senderDetailsKey = isMultiAccountChannel ? 'domainProperties' : 'hostName';
|
|
187
|
+
// For Whatsapp and Zalo we need to store domainProperties instead of only hostName
|
|
184
188
|
return state.set('senderDetails', {
|
|
185
189
|
status: 'SUCCESS',
|
|
186
|
-
|
|
190
|
+
[senderDetailsKey]: isMultiAccountChannel ? domainProperties : action?.payload,
|
|
187
191
|
errors: [],
|
|
188
192
|
});
|
|
193
|
+
}
|
|
189
194
|
case types.GET_SENDER_DETAILS_FAILURE:
|
|
190
195
|
return state.set('senderDetails', {
|
|
191
196
|
status: 'FAILURE',
|
|
@@ -63,6 +63,176 @@ export function* fetchUserList() {
|
|
|
63
63
|
export function* fetchWeCrmAccounts(action) {
|
|
64
64
|
try {
|
|
65
65
|
const result = yield call(Api.fetchWeCrmAccounts, action.source);
|
|
66
|
+
// const result = {
|
|
67
|
+
// "success": true,
|
|
68
|
+
// "status": {
|
|
69
|
+
// "isError": false,
|
|
70
|
+
// "code": 200,
|
|
71
|
+
// "message": "success"
|
|
72
|
+
// },
|
|
73
|
+
// "message": "WeCRM Account details fetched",
|
|
74
|
+
// "response": [
|
|
75
|
+
// {
|
|
76
|
+
// "id": 13694,
|
|
77
|
+
// "uuid": "c41edad79aab48dcb1030722509ab322",
|
|
78
|
+
// "name": "CapillaryWABA",
|
|
79
|
+
// "sourceAccountIdentifier": "107499611940863",
|
|
80
|
+
// "toMirror": true,
|
|
81
|
+
// "sourceTypeId": 19,
|
|
82
|
+
// "sourceTypeName": "WHATSAPP",
|
|
83
|
+
// "isActive": true,
|
|
84
|
+
// "commChannels": [
|
|
85
|
+
// "whatsapp"
|
|
86
|
+
// ],
|
|
87
|
+
// "configs": {
|
|
88
|
+
// "accessToken": "Bearer gDwEuRIm9icV6phixociSw==",
|
|
89
|
+
// "promotionalMessagingSSID": "919611759663",
|
|
90
|
+
// "transactionalMessagingSSID": "919611759663",
|
|
91
|
+
// hostName: "karixwhatsappbulk"
|
|
92
|
+
// },
|
|
93
|
+
// "attribution": {
|
|
94
|
+
// "createDate": "2025-01-10T00:00:00+05:30",
|
|
95
|
+
// "createdBy": {
|
|
96
|
+
// "id": 50716406,
|
|
97
|
+
// "code": "1724755070_",
|
|
98
|
+
// "description": "",
|
|
99
|
+
// "name": "1724755070_Aneel",
|
|
100
|
+
// "type": "ADMIN_USER",
|
|
101
|
+
// "referenceId": -1,
|
|
102
|
+
// "adminType": "GENERAL",
|
|
103
|
+
// "isActive": true,
|
|
104
|
+
// "isOuEnabled": false,
|
|
105
|
+
// "timeZoneId": 0,
|
|
106
|
+
// "currencyId": 0,
|
|
107
|
+
// "languageId": 0,
|
|
108
|
+
// "default": false
|
|
109
|
+
// },
|
|
110
|
+
// "modifiedBy": {
|
|
111
|
+
// "id": 50716406,
|
|
112
|
+
// "code": "1724755070_",
|
|
113
|
+
// "description": "",
|
|
114
|
+
// "name": "1724755070_Aneel",
|
|
115
|
+
// "type": "ADMIN_USER",
|
|
116
|
+
// "referenceId": -1,
|
|
117
|
+
// "adminType": "GENERAL",
|
|
118
|
+
// "isActive": true,
|
|
119
|
+
// "isOuEnabled": false,
|
|
120
|
+
// "timeZoneId": 0,
|
|
121
|
+
// "currencyId": 0,
|
|
122
|
+
// "languageId": 0,
|
|
123
|
+
// "default": false
|
|
124
|
+
// },
|
|
125
|
+
// "modifiedDate": "2025-01-10T00:00:00+05:30"
|
|
126
|
+
// }
|
|
127
|
+
// },
|
|
128
|
+
// {
|
|
129
|
+
// "id": 13695,
|
|
130
|
+
// "uuid": "e0cd92248fc54b7eb04c470e7434f8c3",
|
|
131
|
+
// "name": "gupshup_otp_nightly",
|
|
132
|
+
// "sourceAccountIdentifier": "2000239981",
|
|
133
|
+
// "toMirror": true,
|
|
134
|
+
// "sourceTypeId": 19,
|
|
135
|
+
// "sourceTypeName": "WHATSAPP",
|
|
136
|
+
// "isActive": true,
|
|
137
|
+
// "commChannels": [
|
|
138
|
+
// "whatsapp"
|
|
139
|
+
// ],
|
|
140
|
+
// "configs": {
|
|
141
|
+
// "accessToken": "qrtCAJCz",
|
|
142
|
+
// "promotionalMessagingSSID": "919289221771",
|
|
143
|
+
// "transactionalMessagingSSID": "919289221771",
|
|
144
|
+
// hostName: "gupshupwhatsappbulk"
|
|
145
|
+
// },
|
|
146
|
+
// "attribution": {
|
|
147
|
+
// "createDate": "2025-01-13T00:00:00+05:30",
|
|
148
|
+
// "createdBy": {
|
|
149
|
+
// "id": 50716406,
|
|
150
|
+
// "code": "1724755070_",
|
|
151
|
+
// "description": "",
|
|
152
|
+
// "name": "1724755070_Aneel",
|
|
153
|
+
// "type": "ADMIN_USER",
|
|
154
|
+
// "referenceId": -1,
|
|
155
|
+
// "adminType": "GENERAL",
|
|
156
|
+
// "isActive": true,
|
|
157
|
+
// "isOuEnabled": false,
|
|
158
|
+
// "timeZoneId": 0,
|
|
159
|
+
// "currencyId": 0,
|
|
160
|
+
// "languageId": 0,
|
|
161
|
+
// "default": false
|
|
162
|
+
// },
|
|
163
|
+
// "modifiedBy": {
|
|
164
|
+
// "id": 50716406,
|
|
165
|
+
// "code": "1724755070_",
|
|
166
|
+
// "description": "",
|
|
167
|
+
// "name": "1724755070_Aneel",
|
|
168
|
+
// "type": "ADMIN_USER",
|
|
169
|
+
// "referenceId": -1,
|
|
170
|
+
// "adminType": "GENERAL",
|
|
171
|
+
// "isActive": true,
|
|
172
|
+
// "isOuEnabled": false,
|
|
173
|
+
// "timeZoneId": 0,
|
|
174
|
+
// "currencyId": 0,
|
|
175
|
+
// "languageId": 0,
|
|
176
|
+
// "default": false
|
|
177
|
+
// },
|
|
178
|
+
// "modifiedDate": "2025-01-13T00:00:00+05:30"
|
|
179
|
+
// }
|
|
180
|
+
// },
|
|
181
|
+
// {
|
|
182
|
+
// "id": 13696,
|
|
183
|
+
// "uuid": "e0cd92248fc54b7eb04c470e7434f8c4",
|
|
184
|
+
// "name": "Gupshup_Dummy",
|
|
185
|
+
// "sourceAccountIdentifier": "20002399812",
|
|
186
|
+
// "toMirror": true,
|
|
187
|
+
// "sourceTypeId": 19,
|
|
188
|
+
// "sourceTypeName": "WHATSAPP",
|
|
189
|
+
// "isActive": true,
|
|
190
|
+
// "commChannels": [
|
|
191
|
+
// "whatsapp"
|
|
192
|
+
// ],
|
|
193
|
+
// "configs": {
|
|
194
|
+
// "accessToken": "qrtCAJCz",
|
|
195
|
+
// "promotionalMessagingSSID": "919289221771",
|
|
196
|
+
// "transactionalMessagingSSID": "919289221771",
|
|
197
|
+
// hostName: "gupshupwhatsappbulk"
|
|
198
|
+
// },
|
|
199
|
+
// "attribution": {
|
|
200
|
+
// "createDate": "2025-01-13T00:00:00+05:30",
|
|
201
|
+
// "createdBy": {
|
|
202
|
+
// "id": 50716406,
|
|
203
|
+
// "code": "1724755070_",
|
|
204
|
+
// "description": "",
|
|
205
|
+
// "name": "1724755070_Aneel",
|
|
206
|
+
// "type": "ADMIN_USER",
|
|
207
|
+
// "referenceId": -1,
|
|
208
|
+
// "adminType": "GENERAL",
|
|
209
|
+
// "isActive": true,
|
|
210
|
+
// "isOuEnabled": false,
|
|
211
|
+
// "timeZoneId": 0,
|
|
212
|
+
// "currencyId": 0,
|
|
213
|
+
// "languageId": 0,
|
|
214
|
+
// "default": false
|
|
215
|
+
// },
|
|
216
|
+
// "modifiedBy": {
|
|
217
|
+
// "id": 50716406,
|
|
218
|
+
// "code": "1724755070_",
|
|
219
|
+
// "description": "",
|
|
220
|
+
// "name": "1724755070_Aneel",
|
|
221
|
+
// "type": "ADMIN_USER",
|
|
222
|
+
// "referenceId": -1,
|
|
223
|
+
// "adminType": "GENERAL",
|
|
224
|
+
// "isActive": true,
|
|
225
|
+
// "isOuEnabled": false,
|
|
226
|
+
// "timeZoneId": 0,
|
|
227
|
+
// "currencyId": 0,
|
|
228
|
+
// "languageId": 0,
|
|
229
|
+
// "default": false
|
|
230
|
+
// },
|
|
231
|
+
// "modifiedDate": "2025-01-13T00:00:00+05:30"
|
|
232
|
+
// }
|
|
233
|
+
// }
|
|
234
|
+
// ]
|
|
235
|
+
// }
|
|
66
236
|
yield put({
|
|
67
237
|
type: types.GET_WECRM_ACCOUNTS_SUCCESS,
|
|
68
238
|
data: result.response,
|
|
@@ -161,8 +331,14 @@ export function* getSenderDetails({
|
|
|
161
331
|
if (!apiResponse?.errors?.length) {
|
|
162
332
|
yield put({
|
|
163
333
|
type: types.GET_SENDER_DETAILS_SUCCESS,
|
|
164
|
-
payload: get(apiResponse, `entity.${channel}[0].domainProperties.hostName`, ''),
|
|
334
|
+
// payload: get(apiResponse, `entity.${channel}[0].domainProperties.hostName`, ''),
|
|
335
|
+
payload: ['WHATSAPP', 'ZALO'].includes(channel) ?
|
|
336
|
+
{ channel,
|
|
337
|
+
domainProperties: get(apiResponse, `entity.${channel}`, '')
|
|
338
|
+
} :
|
|
339
|
+
get(apiResponse, `entity.${channel}[0].domainProperties.hostName`, ''),
|
|
165
340
|
});
|
|
341
|
+
|
|
166
342
|
} else {
|
|
167
343
|
yield put({
|
|
168
344
|
type: types.GET_SENDER_DETAILS_FAILURE,
|
|
@@ -240,6 +240,7 @@ export const Whatsapp = (props) => {
|
|
|
240
240
|
name = '',
|
|
241
241
|
hostName = '',
|
|
242
242
|
} = accountObj;
|
|
243
|
+
console.log('accountObj', {hostName, sourceAccountIdentifier, configs, accountObj});
|
|
243
244
|
setAccountId(sourceAccountIdentifier);
|
|
244
245
|
setAccessToken(configs.accessToken || '');
|
|
245
246
|
setAccountName(name);
|