@capillarytech/creatives-library 8.0.56 → 8.0.58-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2241,7 +2241,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2241
2241
  errorMessage={val.errorMessage ? val.errorMessage : ''}
2242
2242
  className={`input-primary chart-name-input${ifError ? ' error' : ''}`}
2243
2243
  // fluid={val.fluid}
2244
- style={val.style ? val.style : {}}
2244
+ style={val?.style ? {
2245
+ ...val?.style,
2246
+ display: ((this.props?.location?.query?.module).toLowerCase() === 'dvs') ? 'block' : val?.style?.display
2247
+ } : {}}
2245
2248
  placeholder={val.placeholder}
2246
2249
  onChange={(e) => this.updateFormData(e.target.value, val)}
2247
2250
  defaultValue={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
@@ -2581,7 +2584,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2581
2584
  errorMessage={val.errorMessage ? val.errorMessage : ''}
2582
2585
  className={`input-primary chart-name-input${ifError ? ' error' : ''}`}
2583
2586
  // fluid={val.fluid}
2584
- style={val.style ? val.style : {}}
2587
+ style={val?.style ? {
2588
+ ...val?.style,
2589
+ display: ((this.props?.location?.query?.module).toLowerCase() === 'dvs') ? 'block' : val?.style?.display
2590
+ } : {}}
2585
2591
  placeholder={val.placeholder}
2586
2592
  onChange={(e) => this.updateFormData(e.target.value, val)}
2587
2593
  value={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
package/config/app.js CHANGED
@@ -17,7 +17,8 @@ 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: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
20
+ // api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
21
+ api_endpoint: 'http://localhost:2022/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',
23
24
  auth_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/auth',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.56",
4
+ "version": "8.0.58-alpha.0",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -57,7 +57,8 @@ export function setWeChatAccount(weChatAccount) {
57
57
  weChatAccount,
58
58
  };
59
59
  }
60
- export function setChannelAccount(channel, account) {
60
+ export function setChannelAccount(channel, account, caller) {
61
+ console.log('### setChannelAccount', {channel, account, caller});
61
62
  const channelTypeMapping = {
62
63
  [LINE]: types.SET_LINE_ACCOUNT,
63
64
  [WHATSAPP]: types.SET_WHATSAPP_ACCOUNT,
@@ -366,6 +366,25 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
366
366
 
367
367
  window.addEventListener("message", this.handleFrameTasks);
368
368
  }
369
+
370
+ getHostName(accountHostName, whatsappAccounts) {
371
+ // const whatsappAccounts = domainProperties?.entity?.WHATSAPP || [];
372
+
373
+ for (const account of whatsappAccounts) {
374
+ const { domainName, connectionProperties, hostName } = account.domainProperties || {};
375
+ // if (
376
+ // configs === name ||
377
+ // connectionProperties?.wabaId === sourceAccountIdentifier ||
378
+ // connectionProperties?.userid === sourceAccountIdentifier
379
+ // )
380
+ if (accountHostName === hostName) {
381
+ console.log("### getHostName domainProperties", {domainName, connectionProperties, hostName});
382
+ return hostName;
383
+ }
384
+ }
385
+ return whatsappAccounts[0]?.domainProperties?.hostName || null;
386
+ };
387
+
369
388
  componentWillReceiveProps(nextProps = {}) {
370
389
  const params = {
371
390
  name: this.state.searchText,
@@ -382,6 +401,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
382
401
  if (nextPropsTotalTemplatesCount && nextPropsTotalTemplatesCount !== propsTotalTemplatesCount) {
383
402
  this.setState({ templatesCount: nextPropsTotalTemplatesCount });
384
403
  }
404
+ console.log("### weCrmAccountsList componentWillReceiveProps 1", {selectedChannel: this.state.channel, wecrm: nextProps.Templates});
385
405
  if (!isEqual(nextProps.route.name, this.props.route.name)) {
386
406
  let channel = '';
387
407
  this.props.actions.resetTemplate();
@@ -614,9 +634,22 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
614
634
  }
615
635
  const { weCrmAccounts: weCrmAccountsList = [], senderDetails: { hostName = '' } = {} } = get(nextProps, 'Templates', {});
616
636
  const weCrmChannels = ['wechat', WHATSAPP_LOWERCASE, ZALO_LOWERCASE];
617
-
637
+ let paramsDefault = {};
638
+ if (weCrmAccountsList?.length > 1 && this.state.defaultAccount && (selectedChannel === WHATSAPP_LOWERCASE) && !isEmpty(hostName)) {
639
+ // 2 matching fields are present between domainProperties and wecrm data
640
+ // sourceAccountIdentifier in wecrm data is present in domainProperties inside the connectionProperties either as wabaId or userId
641
+ // domainName of domainProperties data is present in wecrm as name
642
+ const selectedAccount = this.props.Templates.selectedWhatsappAccount;
643
+ // const whatsappHostName = this.getHostName(selectedAccount.name, selectedAccount.sourceAccountIdentifier, this.props.Templates.senderDetails.hostName);
644
+ // selectedAccount.hostName = whatsappHostName;
645
+ // this.props.actions.setChannelAccount(selectedChannel.toUpperCase(), selectedAccount, 'call2');
646
+ // const account = selectedAccount;
647
+ paramsDefault.accountId = selectedAccount?.sourceAccountIdentifier;
648
+
649
+ console.log("### weCrmAccountsList componentWillReceiveProps length2", {selectedChannel, hostName, selectedAccount, wecrm: weCrmAccountsList, senderDetails: nextProps.Templates.senderDetails});
650
+ }
618
651
  if (weCrmAccountsList.length === 1 && this.state.defaultAccount && (weCrmChannels.indexOf(selectedChannel) > -1) && !isEmpty(hostName)) {
619
- let paramsDefault = {};
652
+ // let paramsDefault = {};
620
653
  if (this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
621
654
  paramsDefault = {
622
655
  name: this.state.searchText,
@@ -637,7 +670,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
637
670
  }
638
671
 
639
672
  weCrmAccountsList[0].hostName = hostName;
640
- nextProps.actions.setChannelAccount(selectedChannel.toUpperCase(), weCrmAccountsList[0]);
673
+ console.log("### weCrmAccountsList componentWillReceiveProps length1", {selectedChannel, hostName, wecrm: weCrmAccountsList});
674
+ nextProps.actions.setChannelAccount(selectedChannel.toUpperCase(), weCrmAccountsList[0], 'call1');
641
675
  if (selectedChannel === ZALO_LOWERCASE) {
642
676
  paramsDefault.username = name;
643
677
  paramsDefault.oa_id = sourceAccountIdentifier;
@@ -715,8 +749,16 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
715
749
  params.isAccountSelection = true;
716
750
  params.host = this.props.Templates?.senderDetails?.hostName || this.props.Templates?.selectedZaloAccount?.hostName || this.state.hostName;
717
751
  }
752
+ } else if (selectedChannel === WHATSAPP_LOWERCASE) {
753
+ const selectedAccount = this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})];
754
+ // const whatsappHostName = this.getHostName(selectedAccount.configs?.hostName, this.props.Templates.senderDetails.hostName);
755
+ // selectedAccount.hostName = whatsappHostName;
756
+ selectedAccount.hostName = selectedAccount.configs?.hostName;
757
+ this.props.actions.setChannelAccount(selectedChannel.toUpperCase(), selectedAccount, 'call2');
758
+ params.accountId = selectedAccount?.sourceAccountIdentifier;
759
+
760
+ console.log("### onAccountSelect", {params, selectedChannel, value, templ: this.props.Templates});
718
761
  }
719
-
720
762
  this.setState({activeMode: TEMPLATES_MODE});
721
763
 
722
764
  this.getAllTemplates({params, resetPage: true});
@@ -800,6 +842,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
800
842
  getAllTemplates = ({params, getNextPage, resetPage}, resetTemplates) => {
801
843
  let queryParams = params || {};
802
844
  let page = this.state.page;
845
+ // console.log('### getAllTemplates', {params, resetTemplates, resetPage, getNextPage});
803
846
  const { activeMode } = this.state;
804
847
  if (activeMode === ACCOUNT_SELECTION_MODE) {
805
848
  this.setTemplatesMode();
@@ -823,8 +866,13 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
823
866
  }
824
867
  const channel = this.state.channel;
825
868
  if (([MOBILE_PUSH_LOWERCASE, INAPP_LOWERCASE].includes(channel.toLowerCase())) && !isEmpty(this.props.Templates.selectedWeChatAccount)) {
869
+ console.log('### this.props.Templates.selectedWeChatAccount', channel);
826
870
  queryParams.accountId = this.props.Templates?.selectedWeChatAccount?.id;
827
871
  }
872
+ if (channel?.toLowerCase() === WHATSAPP_LOWERCASE) {
873
+ queryParams.accountId = this.props.Templates?.selectedWeChatAccount?.sourceAccountIdentifier;
874
+ }
875
+ console.log('### getAllTemplates whatsapp if', {queryParams, resetTemplates, copyOf, templates: this.props.Templates});
828
876
  this.props.actions.getAllTemplates(channel, queryParams,`${copyOf}`);
829
877
  } else if ((resetPage || (page === 1 && this.state.templatesCount === 0) || page <= (this.state.templatesCount / this.state.perPageLimit))) {
830
878
  if (getNextPage) {
@@ -850,6 +898,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
850
898
  }
851
899
  if (([MOBILE_PUSH_LOWERCASE, INAPP_LOWERCASE].includes(this.state.channel.toLowerCase())) && !isEmpty(this.props.Templates.selectedWeChatAccount)) {
852
900
  queryParams.accountId = this.props.Templates.selectedWeChatAccount.id;
901
+ console.log('### queryParams.accountId', {channel, queryParams});
853
902
  if (this.state.mode) {
854
903
  queryParams.mode = this.state.mode.toLowerCase();
855
904
  }
@@ -874,6 +923,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
874
923
  queryParams.token = token;
875
924
  queryParams.host = hostName || this.props.Templates?.senderDetails?.hostName ||this.state.hostName;
876
925
  }
926
+ if (this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE) {
927
+ console.log('### getAllTemplates whatsapp', {queryParams, temp: this.props.Templates});
928
+ }
929
+ console.log('### getAllTemplates whatsapp else', {queryParams, resetTemplates, copyOf});
877
930
  this.setState({ page, templatesCount }, () => {
878
931
  queryParams.page = page;
879
932
  queryParams.perPage = this.state.perPageLimit;
@@ -1390,7 +1443,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1390
1443
  const showInAppIllustration = channelLowerCase === INAPP_LOWERCASE && isEmpty(templates);
1391
1444
  const noLoaderAndSearchText = isEmpty(this.state.searchText) && !isLoading;
1392
1445
  return (<div>
1393
- {[WECHAT, MOBILE_PUSH, INAPP].includes(currentChannel) && this.showAccountName()}
1446
+ {[WECHAT, MOBILE_PUSH, INAPP, WHATSAPP].includes(currentChannel) && this.showAccountName()}
1394
1447
  {filterContent}
1395
1448
  {[WHATSAPP, ZALO].includes(currentChannel) && this.selectedFilters()}
1396
1449
  <CapCustomSkeleton loader={isLoading}>
@@ -2565,10 +2618,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2565
2618
  const isInAppChannel = channel === INAPP;
2566
2619
  const isFacebookChannel = channel === FACEBOOK;
2567
2620
 
2568
- if ([WECHAT, MOBILE_PUSH, INAPP, LINE, ZALO].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
2621
+ if ([WECHAT, MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
2569
2622
  forEach(weCrmAccounts, (account) => {
2570
- if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, INAPP, LINE, ZALO].includes(channel)) {
2623
+ if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP].includes(channel)) {
2571
2624
  if (query.type === 'embedded' && (!query.module || (query.module && query.module !== 'library'))) {
2625
+ console.log('### Test renderAccountSelection if', {weCrmAccounts, account, query, channel});
2572
2626
  if (query.source_account_id && account.sourceAccountIdentifier === query.source_account_id) {
2573
2627
  accountOptions.push(
2574
2628
  { key: isMobilePushChannel || isInAppChannel ? account.id : account.uuid,
@@ -2588,6 +2642,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2588
2642
  );
2589
2643
  }
2590
2644
  } else {
2645
+ console.log('### Test renderAccountSelection else', {weCrmAccounts, account, query, channel});
2591
2646
  accountOptions.push(
2592
2647
  {
2593
2648
  key: isMobilePushChannel || isInAppChannel ? account.id : account.uuid,
@@ -2650,9 +2705,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2650
2705
  break;
2651
2706
  }
2652
2707
  let showNoAccountHeader = isEmpty(weCrmAccounts) && !fetchingWeCrmAccounts;
2653
- if (channel === WHATSAPP && this.state.hostName === '') {
2654
- showNoAccountHeader = true;
2655
- }
2708
+ // Test start
2709
+ // if (channel === WHATSAPP && this.state.hostName === '') {
2710
+ // showNoAccountHeader = true;
2711
+ // }
2656
2712
  if (channel === FACEBOOK && !isEmpty(campaignSettings) ) {
2657
2713
  const fbSetting = get(campaignSettings, 'accountSettings.socialAccountSettings.facebookAccountSettings', []);
2658
2714
  const { orgUnitFacebookPageSettingsMap } = fbSetting[0] || {};
@@ -62,7 +62,124 @@ export function* fetchUserList() {
62
62
 
63
63
  export function* fetchWeCrmAccounts(action) {
64
64
  try {
65
- const result = yield call(Api.fetchWeCrmAccounts, action.source);
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
+ }
66
183
  yield put({
67
184
  type: types.GET_WECRM_ACCOUNTS_SUCCESS,
68
185
  data: result.response,
@@ -155,13 +272,15 @@ export function* getTemplateDetails(id, channel) {
155
272
  export function* getSenderDetails({
156
273
  channel,
157
274
  orgUnitId,
275
+ identifiers: { name, sourceAccountIdentifier } = {},
158
276
  } = {}) {
159
277
  try {
160
- const apiResponse = yield call(Api.getSenderDetails, channel, orgUnitId);
278
+ const apiResponse = yield call(Api.getSenderDetails, channel, orgUnitId);
279
+ console.log("### domainProperties apiResponse", {channel, apiResponse, orgUnitId, name, sourceAccountIdentifier});
161
280
  if (!apiResponse?.errors?.length) {
162
281
  yield put({
163
282
  type: types.GET_SENDER_DETAILS_SUCCESS,
164
- payload: get(apiResponse, `entity.${channel}[0].domainProperties.hostName`, ''),
283
+ payload: channel === 'WHATSAPP' ? get(apiResponse, `entity.${channel}`, '') : get(apiResponse, `entity.${channel}[0].domainProperties.hostName`, ''),
165
284
  });
166
285
  } else {
167
286
  yield put({
@@ -232,7 +232,8 @@ export const Whatsapp = (props) => {
232
232
  //edit
233
233
  //gets account details
234
234
  useEffect(() => {
235
- const accountObj = accountData.selectedWhatsappAccount || {};
235
+ const accountObj = accountData.selectedWhatsappAccount || accountData.selectedWeChatAccount || {};
236
+ console.log("### useEff ", { accountData });
236
237
  if (!isEmpty(accountObj)) {
237
238
  const {
238
239
  sourceAccountIdentifier = '',
@@ -244,6 +245,7 @@ export const Whatsapp = (props) => {
244
245
  setAccessToken(configs.accessToken || '');
245
246
  setAccountName(name);
246
247
  setHost(hostName);
248
+ console.log("### useEff2", { sourceAccountIdentifier, configs, name, hostName });
247
249
  }
248
250
  }, [accountData.selectedWhatsappAccount]);
249
251