@capillarytech/creatives-library 7.17.51 → 7.17.52

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": "7.17.51",
4
+ "version": "7.17.52",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -122,7 +122,7 @@ export class Creatives extends React.Component {
122
122
  name = "",
123
123
  sourceAccountIdentifier = "",
124
124
  configs: { token = "" } = {},
125
- } = get(this.props, "Templates.weCrmAccounts[0]", {});
125
+ } = get(this.props, "Templates.selectedZaloAccount", {});
126
126
  this.props.zaloActions.getTemplateInfoById({
127
127
  username: name,
128
128
  oa_id: sourceAccountIdentifier,
@@ -641,10 +641,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
641
641
  onAccountSelect(e) {
642
642
  const value = e.target.value;
643
643
  this.setState({selectedAccount: value}, () => {
644
- const params = {
645
- name: this.state.searchText,
646
- sortBy: this.state.sortBy,
647
- };
644
+ const params = {};
645
+ if (this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
646
+ params.name = this.state.searchText;
647
+ params.sortBy = this.state.sortBy;
648
+ }
648
649
  const selectedChannel = this.state.channel.toLowerCase();
649
650
  if (selectedChannel === 'wechat') {
650
651
  params.wecrmId = this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})].configs.wecrm_app_id;
@@ -664,7 +665,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
664
665
  } else {
665
666
  this.setState({ selectedAccountError: false });
666
667
  }
667
- } else if ([LINE.toLowerCase(), RCS_LOWERCASE].includes(selectedChannel)) {
668
+ } else if ([LINE.toLowerCase(), RCS_LOWERCASE, ZALO_LOWERCASE].includes(selectedChannel)) {
668
669
  this.props.actions.setChannelAccount(selectedChannel?.toUpperCase(), this.props.Templates.weCrmAccounts.find((item) => item.name === this.state.selectedAccount));
669
670
  }
670
671
 
@@ -806,11 +807,19 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
806
807
  if ((this.state.channel || '').toLowerCase() === SMS_LOWERCASE && isTraiDltFeature) {
807
808
  queryParams.traiEnable = true;
808
809
  }
809
- if (this.state.channel.toLowerCase() === ZALO_LOWERCASE) {
810
- queryParams.username = this.props.Templates?.weCrmAccounts[0]?.name;
811
- queryParams.oa_id = this.props.Templates?.weCrmAccounts[0]?.sourceAccountIdentifier;
812
- queryParams.token = this.props.Templates?.weCrmAccounts[0]?.configs?.token;
813
- }
810
+ if (
811
+ this.state.channel.toLowerCase() === ZALO_LOWERCASE &&
812
+ !isEmpty(this.props.Templates?.selectedZaloAccount)
813
+ ) {
814
+ const {
815
+ name = "",
816
+ sourceAccountIdentifier = "",
817
+ configs: { token = "" } = {},
818
+ } = get(this.props, "Templates.selectedZaloAccount", {});
819
+ queryParams.username = name;
820
+ queryParams.oa_id = sourceAccountIdentifier;
821
+ queryParams.token = token;
822
+ }
814
823
  this.setState({ page, templatesCount }, () => {
815
824
  queryParams.page = page;
816
825
  queryParams.perPage = this.state.perPageLimit;
@@ -1947,16 +1956,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1947
1956
  }
1948
1957
  } else {
1949
1958
  const {
1950
- Templates: {
1951
- weCrmAccounts: [
1952
- {
1953
- name,
1954
- sourceAccountIdentifier,
1955
- configs: { token },
1956
- },
1957
- ],
1958
- },
1959
- } = this.props;
1959
+ name = "",
1960
+ sourceAccountIdentifier = "",
1961
+ configs: { token = "" } = {},
1962
+ } = get(this.props, "Templates.selectedZaloAccount", {});
1960
1963
  this.props.zaloActions.getTemplateInfoById({
1961
1964
  username: name,
1962
1965
  oa_id: sourceAccountIdentifier,
@@ -2383,9 +2386,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2383
2386
  const isMobilePushChannel = channel === MOBILE_PUSH;
2384
2387
  const isFacebookChannel = channel === FACEBOOK;
2385
2388
 
2386
- if ([WECHAT, MOBILE_PUSH, LINE].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
2389
+ if ([WECHAT, MOBILE_PUSH, LINE, ZALO].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
2387
2390
  forEach(weCrmAccounts, (account) => {
2388
- if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, LINE].includes(channel)) {
2391
+ if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, LINE, ZALO].includes(channel)) {
2389
2392
  if (query.type === 'embedded' && (!query.module || (query.module && query.module !== 'library'))) {
2390
2393
  if (query.source_account_id && account.sourceAccountIdentifier === query.source_account_id) {
2391
2394
  accountOptions.push(
@@ -39,7 +39,22 @@ exports[`Test Templates container Should render correct component for zalo chann
39
39
  className="select-account"
40
40
  defaultValue=""
41
41
  onChange={[Function]}
42
- panes={Array []}
42
+ panes={
43
+ Array [
44
+ Object {
45
+ "icon": <CapIconAvatar
46
+ backgroundProps={Object {}}
47
+ height="2rem"
48
+ labelProps={Object {}}
49
+ text="c"
50
+ width="auto"
51
+ />,
52
+ "key": "fa66f53ca2bb4b93b02dfc5bd265e2fd",
53
+ "title": "capillary_zns",
54
+ "value": "capillary_zns",
55
+ },
56
+ ]
57
+ }
43
58
  selected=""
44
59
  size="small"
45
60
  />