@capillarytech/creatives-library 7.17.169 → 7.17.170

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/index.js CHANGED
@@ -3,9 +3,6 @@ import capReducer from './v2Containers/Cap/reducer';
3
3
  import capSaga from './v2Containers/Cap/sagas';
4
4
  import Cap from './v2Containers/Cap/index';
5
5
 
6
-
7
-
8
-
9
6
  import LanguageProvider from './v2Containers/LanguageProvider';
10
7
  import LanguageProviderReducer from './v2Containers/LanguageProvider/reducer';
11
8
  import LanguageProviderSaga from './v2Containers/LanguageProvider/sagas';
@@ -19,9 +16,6 @@ import smsCreateReducer from './v2Containers/Sms/Create/reducer';
19
16
  import smsCreateSaga from './v2Containers/Sms/Create/sagas';
20
17
 
21
18
  import SmsEdit from './v2Containers/Sms/Edit/index';
22
-
23
-
24
-
25
19
  import smsEditReducer from './v2Containers/Sms/Edit/reducer';
26
20
  import smsEditSaga from './v2Containers/Sms/Edit/sagas';
27
21
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.17.169",
4
+ "version": "7.17.170",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -77,6 +77,7 @@
77
77
  }
78
78
  }
79
79
 
80
+
80
81
  .form-builder-dragger {
81
82
  .ant-upload-drag {
82
83
  background-color: white;
@@ -41,6 +41,7 @@ import { WHATSAPP_STATUSES, WHATSAPP_MEDIA_TYPES } from '../Whatsapp/constants';
41
41
 
42
42
  import { updateImagesInHtml } from '../../utils/cdnTransformation';
43
43
  import { IOS } from '../InApp/constants';
44
+ import { VIET_GUYS } from '../Zalo/constants';
44
45
 
45
46
  const classPrefix = 'add-creatives-section';
46
47
  const CREATIVES_CONTAINER = 'creativesContainer';
@@ -124,14 +125,19 @@ export class Creatives extends React.Component {
124
125
  sourceAccountIdentifier = "",
125
126
  configs: { token = "" } = {},
126
127
  } = get(this.props, "Templates.selectedZaloAccount", {});
127
- this.props.zaloActions.getTemplateInfoById({
128
- username: name,
129
- oa_id: sourceAccountIdentifier,
130
- token,
131
- id: template?._id,
132
- preview: true,
133
- actionCallback: this.actionCallback,
134
- });
128
+ const { hostName = ''} = get(this.props, "Templates.senderDetails", {});
129
+ if (hostName === VIET_GUYS) {
130
+ this.props.zaloActions.getTemplateInfoById({
131
+ username: name,
132
+ oa_id: sourceAccountIdentifier,
133
+ token,
134
+ id: template?._id,
135
+ preview: true,
136
+ actionCallback: this.actionCallback,
137
+ });
138
+ } else {
139
+ window.open(get(template, 'versions.base.content.zalo.previewUrl'), '_blank');
140
+ }
135
141
  }
136
142
  };
137
143
  onEditTemplate = () => {
@@ -110,7 +110,7 @@ import {
110
110
  HOST_GUPSHUP,
111
111
  } from '../Whatsapp/constants';
112
112
  import { INAPP_LAYOUT_DETAILS } from '../InApp/constants';
113
- import { ZALO_STATUS_OPTIONS, ZALO_STATUSES } from '../Zalo/constants';
113
+ import { VIET_GUYS, ZALO_STATUS_OPTIONS, ZALO_STATUSES } from '../Zalo/constants';
114
114
  import { getWhatsappContent, getWhatsappStatus, getWhatsappCategory, getWhatsappCta, getWhatsappQuickReply, getWhatsappAutoFill } from '../Whatsapp/utils';
115
115
  import { getRCSContent } from '../Rcs/utils';
116
116
  import zaloMessages from '../Zalo/messages';
@@ -305,6 +305,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
305
305
  channel = 'Zalo';
306
306
  activeMode = ACCOUNT_SELECTION_MODE;
307
307
  this.props.actions.getWeCrmAccounts(channel);
308
+ this.props.actions.getSenderDetails({
309
+ channel: ZALO,
310
+ orgUnitId: -1,
311
+ });
308
312
  break;
309
313
  default:
310
314
  channel = '';
@@ -631,6 +635,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
631
635
  paramsDefault.username = name;
632
636
  paramsDefault.oa_id = sourceAccountIdentifier;
633
637
  paramsDefault.token = token;
638
+ paramsDefault.host = hostName;
634
639
  } else {
635
640
  paramsDefault.wecrmId = wecrm_app_id;
636
641
  paramsDefault.wecrmToken = wecrm_token;
@@ -695,11 +700,13 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
695
700
  name = "",
696
701
  sourceAccountIdentifier = "",
697
702
  configs: { token = "" } = {},
703
+ hostName = "",
698
704
  } = setAcc || {};
699
705
  params.username = name;
700
706
  params.oa_id = sourceAccountIdentifier;
701
707
  params.token = token;
702
708
  params.isAccountSelection = true;
709
+ params.host = hostName;
703
710
  }
704
711
  }
705
712
 
@@ -853,10 +860,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
853
860
  name = "",
854
861
  sourceAccountIdentifier = "",
855
862
  configs: { token = "" } = {},
863
+ hostName = "",
856
864
  } = get(this.props, "Templates.selectedZaloAccount", {});
857
865
  queryParams.username = name;
858
866
  queryParams.oa_id = sourceAccountIdentifier;
859
867
  queryParams.token = token;
868
+ queryParams.host = hostName;
860
869
  }
861
870
  this.setState({ page, templatesCount }, () => {
862
871
  queryParams.page = page;
@@ -2103,14 +2112,14 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2103
2112
  sourceAccountIdentifier = "",
2104
2113
  configs: { token = "" } = {},
2105
2114
  } = get(this.props, "Templates.selectedZaloAccount", {});
2106
- this.props.zaloActions.getTemplateInfoById({
2115
+ this.state.hostName === VIET_GUYS ? this.props.zaloActions.getTemplateInfoById({
2107
2116
  username: name,
2108
2117
  oa_id: sourceAccountIdentifier,
2109
2118
  token: token,
2110
2119
  id: template?._id,
2111
2120
  preview: true,
2112
2121
  actionCallback: this.actionCallback,
2113
- });
2122
+ }) : window.open(get(template, 'versions.base.content.zalo.previewUrl'), '_blank');
2114
2123
  }
2115
2124
  }
2116
2125
 
@@ -1,3 +1,4 @@
1
+ import get from 'lodash/get';
1
2
  import { call, put, takeLatest, take, cancel, select } from 'redux-saga/effects';
2
3
  import { LOCATION_CHANGE } from 'react-router-redux';
3
4
  // import { schema, normalize } from 'normalizr';
@@ -176,7 +177,7 @@ export function* getSenderDetails({
176
177
  if (!apiResponse?.errors?.length) {
177
178
  yield put({
178
179
  type: types.GET_SENDER_DETAILS_SUCCESS,
179
- payload: apiResponse?.entity?.WHATSAPP[0]?.domainProperties?.hostName || '',
180
+ payload: get(apiResponse, `entity.${channel}[0].domainProperties.hostName`, ''),
180
181
  });
181
182
  } else {
182
183
  yield put({
@@ -69,6 +69,7 @@ describe('Test Templates container', () => {
69
69
  setChannelAccount,
70
70
  getAllTemplates,
71
71
  getUserList,
72
+ getSenderDetails,
72
73
  }}
73
74
  location={{
74
75
  pathname: '/Zalo',
@@ -1,5 +1,5 @@
1
1
  import { expectSaga } from 'redux-saga-test-plan';
2
- import { take, call, takeLatest, takeEvery } from 'redux-saga/effects';
2
+ import { take, call, takeLatest, takeEvery, put } from 'redux-saga/effects';
3
3
  import * as matchers from 'redux-saga-test-plan/matchers';
4
4
  import * as api from '../../../services/api';
5
5
  import * as types from '../constants';
@@ -10,9 +10,12 @@ import {
10
10
  getAllTemplates,
11
11
  watchGetCdnTransformationConfig,
12
12
  watchGetAllTemplates,
13
+ getSenderDetails,
13
14
  } from '../sagas';
14
15
 
15
16
  import * as mockData from './mockData';
17
+ import { ZALO } from '../../CreativesContainer/constants';
18
+ import { VIET_GUYS } from '../../Zalo/constants';
16
19
 
17
20
  describe('getCdnTransformationConfig saga', () => {
18
21
  it("handle valid response from api", () => {
@@ -134,3 +137,53 @@ describe('watchForTemplates saga', () => {
134
137
  );
135
138
  });
136
139
  });
140
+
141
+ describe('getSenderDetails Saga', () => {
142
+ const channel = 'someChannel';
143
+ const orgUnitId = 'someOrgUnitId';
144
+ const action = { channel, orgUnitId };
145
+
146
+ it('should handle apiResponse with hostName', () => {
147
+ const apiResponse = {
148
+ entity: {
149
+ [channel]: [
150
+ {
151
+ domainProperties: {
152
+ hostName: 'example.com',
153
+ },
154
+ },
155
+ ],
156
+ },
157
+ };
158
+
159
+ const generator = getSenderDetails(action);
160
+ expect(generator.next().value).toEqual(call(api.getSenderDetails, channel, orgUnitId));
161
+ expect(generator.next(apiResponse).value).toEqual(
162
+ put({
163
+ type: types.GET_SENDER_DETAILS_SUCCESS,
164
+ payload: 'example.com',
165
+ })
166
+ );
167
+ });
168
+
169
+ it('should handle apiResponse without hostName', () => {
170
+ const apiResponse = {
171
+ entity: {
172
+ [channel]: [
173
+ {
174
+ domainProperties: {},
175
+ },
176
+ ],
177
+ },
178
+ };
179
+
180
+ const generator = getSenderDetails(action);
181
+ expect(generator.next().value).toEqual(call(api.getSenderDetails, channel, orgUnitId));
182
+ expect(generator.next(apiResponse).value).toEqual(
183
+ put({
184
+ type: types.GET_SENDER_DETAILS_SUCCESS,
185
+ payload: '',
186
+ })
187
+ );
188
+ });
189
+ });
@@ -839,7 +839,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
839
839
  setUnsubscribeRequired(checked);
840
840
  if (isAuthenticationTemplate) {
841
841
  if (checked && !templateMessage?.includes(formatMessage(messages.securitySuffix))) {
842
- setTemplateMessage(`${templateMessage}${formatMessage(messages.securitySuffix)}`);
842
+ setTemplateMessage(`${templateMessage} ${formatMessage(messages.securitySuffix)}`);
843
843
  } else {
844
844
  setTemplateMessage(formatMessage(messages.authenticationMsg));
845
845
  }
@@ -1088,14 +1088,21 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1088
1088
  setTemplateNameError(errorMessage);
1089
1089
  };
1090
1090
 
1091
+ const resetCategoryRelatedStates = () => {
1092
+ setTemplateHeader('');
1093
+ setTemplateFooter('');
1094
+ setExpiryMinutes(0);
1095
+ setUnsubscribeRequired(false);
1096
+ setCtadata({});
1097
+ setQuickReplyData({});
1098
+ setTemplateMediaType(WHATSAPP_MEDIA_TYPES.TEXT)
1099
+ setGupshupMediaFile();
1100
+ setKarixFileHandle('');
1101
+ };
1102
+
1091
1103
  const onTemplateCategoryChange = (value) => {
1092
1104
  if (value === WHATSAPP_CATEGORIES.authentication) {
1093
- setTemplateHeader('');
1094
- setTemplateFooter('');
1095
- setExpiryMinutes(0);
1096
- setUnsubscribeRequired(false);
1097
- setCtadata({});
1098
- setQuickReplyData({});
1105
+ resetCategoryRelatedStates();
1099
1106
  setTemplateMessage(formatMessage(messages.authenticationMsg));
1100
1107
  } else {
1101
1108
  setTemplateMessage('');
@@ -18,6 +18,7 @@ export const LIBRARY = 'library';
18
18
  export const FULL = 'full';
19
19
  export const ALL = 'all';
20
20
  export const OUTBOUND = 'outbound';
21
+ export const VIET_GUYS = 'vietguyszalotrans';
21
22
 
22
23
  const prefix = 'app/v2Containers/Zalo';
23
24
  export const ZALO_TEMPLATE_INFO_REQUEST = `${prefix}/ZALO_TEMPLATE_INFO_REQUEST`;
@@ -4,7 +4,7 @@ import React, { useState, useEffect } from 'react';
4
4
  import { bindActionCreators } from 'redux';
5
5
  import { createStructuredSelector } from 'reselect';
6
6
  import { injectIntl, FormattedMessage } from 'react-intl';
7
- import { get, isEmpty } from 'lodash';
7
+ import { get, isEmpty, update } from 'lodash';
8
8
  import styled from 'styled-components';
9
9
  import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
10
10
  import CapRow from '@capillarytech/cap-ui-library/CapRow';
@@ -23,7 +23,7 @@ import {
23
23
  CAP_SPACE_32,
24
24
  CAP_WHITE,
25
25
  } from '@capillarytech/cap-ui-library/styled/variables';
26
- import { makeSelectZalo, makeSelectAccount } from './selectors';
26
+ import { makeSelectZalo, makeSelectAccount, makeSelectGapitTemplates } from './selectors';
27
27
  import { makeSelectMetaEntities, setInjectedTags } from '../Cap/selectors';
28
28
  import * as zaloActions from './actions';
29
29
  import './index.scss';
@@ -40,6 +40,7 @@ import {
40
40
  ERROR_ALERT,
41
41
  WARNING_ALERT,
42
42
  ZALO_STATUSES,
43
+ VIET_GUYS,
43
44
  } from './constants';
44
45
  import { SMS, ZALO } from '../CreativesContainer/constants';
45
46
  import messages from './messages';
@@ -56,7 +57,7 @@ export const Zalo = (props) => {
56
57
  isFullMode,
57
58
  templateData = {},
58
59
  editData = {},
59
- accountData: { selectedZaloAccount = {} } = {},
60
+ accountData: { selectedZaloAccount = {}, senderDetails = {} } = {},
60
61
  globalActions,
61
62
  location,
62
63
  getDefaultTags,
@@ -65,18 +66,30 @@ export const Zalo = (props) => {
65
66
  injectedTags,
66
67
  getFormData,
67
68
  selectedOfferDetails,
69
+ gapItTemplateData,
68
70
  } = props || {};
71
+ const {hostName = ''} = senderDetails;
69
72
  const { formatMessage } = intl;
70
73
  const [oa_id, setOaId] = useState('');
71
74
  const [token, setToken] = useState('');
72
75
  const [username, setUsername] = useState('');
73
76
  const [templateName, setTemplateName] = useState('');
74
77
  const [templateId, setTemplateId] = useState('');
75
- const [templateListParams, setTemplateListParams] = useState([]);
78
+ // Initialize the state for templateListParams based on the nested properties of templateData.
79
+ // If templateData.versions.base.content.zalo.listParams is available, use it.
80
+ // Otherwise, if hostName is VIET_GUYS and templateData.templateConfigs.varMapped is available,
81
+ // convert it to an array of entries. If not, use templateData.templateConfigs.varMapped or an empty array.
82
+ const [templateListParams, setTemplateListParams] = useState(
83
+ (templateData?.versions?.base?.content?.zalo?.listParams ||
84
+ ((hostName === VIET_GUYS && templateData?.templateConfigs?.varMapped)
85
+ ? Object.entries(templateData?.templateConfigs?.varMapped)
86
+ : templateData?.templateConfigs?.varMapped)) ?? []
87
+ );
76
88
  const [templatePreviewUrl, setTemplatePreviewUrl] = useState('');
77
89
  const [templateStatus, setZaloTemplateStatus] = useState(
78
90
  ZALO_STATUSES.ENABLE,
79
91
  );
92
+ const [gapitAllTemplateData, setGapitAllTemplateData] = useState([]);
80
93
  const [tags, updateTags] = useState([]);
81
94
  const [textAreaId, updateTextAreaId] = useState('');
82
95
  const { zaloTemplateInfoValue = {}, zaloTemplateInfoStatus = REQUEST } =
@@ -117,11 +130,21 @@ export const Zalo = (props) => {
117
130
  setToken(accessToken || zaloToken);
118
131
  setUsername(name || accountName);
119
132
  }
120
- }, [selectedZaloAccount, templateData]);
133
+ setGapitAllTemplateData(gapItTemplateData);
134
+ }, [selectedZaloAccount, templateData, gapItTemplateData]);
135
+
136
+ const updateTemplateData = (gapitTemplateId, templateName, listParams, previewUrl, status) => {
137
+ setTemplateName(templateName);
138
+ setTemplateId(gapitTemplateId);
139
+ setTemplateListParams(listParams);
140
+ setTemplatePreviewUrl(previewUrl);
141
+ setZaloTemplateStatus(status);
142
+ updateTextAreaId(listParams[0]?.name);
143
+ };
121
144
 
122
145
  //gets template details
123
146
  useEffect(() => {
124
- if (zaloTempId && oa_id && token && username) {
147
+ if (zaloTempId && oa_id && token && username && hostName === VIET_GUYS) {
125
148
  actions.getTemplateInfoById({
126
149
  username,
127
150
  oa_id,
@@ -129,6 +152,16 @@ export const Zalo = (props) => {
129
152
  id: zaloTempId,
130
153
  actionCallback,
131
154
  });
155
+ } else if (hostName !== VIET_GUYS) {
156
+ const { _id: gapitTemplateId = '' } = templateData;
157
+ if (gapitTemplateId) {
158
+ const data = gapitAllTemplateData.find(template => template._id == gapitTemplateId);
159
+ const { templateName = "", listParams = [], previewUrl = "", status = "" } = data?.versions?.base?.content?.zalo || {};
160
+ updateTemplateData(gapitTemplateId, templateName, listParams, previewUrl, status);
161
+ } else {
162
+ const { id: gapitTemplateId = '', name: templateName = '', template: previewUrl = '', varMapped: listParams = {} } = templateData?.templateConfigs || {};
163
+ updateTemplateData(gapitTemplateId, templateName, listParams, previewUrl, ZALO_STATUSES.ENABLE);
164
+ }
132
165
  }
133
166
  //cleanup code
134
167
  return () => {
@@ -137,7 +170,7 @@ export const Zalo = (props) => {
137
170
  }, [zaloTempId, oa_id, token, username]);
138
171
 
139
172
  const handleSetValues = (paramsData = []) =>
140
- paramsData.map((paramData) => {
173
+ paramsData?.map((paramData) => {
141
174
  for (const key in varMapped) {
142
175
  if (paramData?.name === key) {
143
176
  paramData.value = varMapped[key];
@@ -147,27 +180,36 @@ export const Zalo = (props) => {
147
180
  });
148
181
 
149
182
  const setDataForEdit = (setValues) => {
150
- const {
151
- name = '',
152
- _id: zaloId = '',
153
- versions: {
154
- base: {
155
- content: {
156
- zalo: {
157
- listParams: paramsData = [],
158
- previewUrl = '',
159
- status = '',
183
+ if(hostName === VIET_GUYS) {
184
+ const {
185
+ name = '',
186
+ _id: zaloId = '',
187
+ versions: {
188
+ base: {
189
+ content: {
190
+ zalo: {
191
+ listParams: paramsData = [],
192
+ previewUrl = '',
193
+ status = '',
194
+ } = {},
160
195
  } = {},
161
196
  } = {},
162
197
  } = {},
163
- } = {},
164
- } = zaloTemplateInfoValue;
165
- setTemplateName(name);
166
- setTemplateId(zaloId);
167
- setTemplateListParams(setValues ? handleSetValues(paramsData) : paramsData);
168
- setTemplatePreviewUrl(previewUrl);
169
- setZaloTemplateStatus(status);
170
- updateTextAreaId(paramsData[0]?.name);
198
+ } = zaloTemplateInfoValue;
199
+ const handledListParams = setValues ? handleSetValues(paramsData) : paramsData;
200
+ updateTemplateData(zaloId, name, handledListParams, previewUrl, status);
201
+ } else {
202
+ if (setValues) {
203
+ const { id: gapitTemplateId = '', name: templateName = '', template: previewUrl = '', varMapped: listParams = {} } = templateData?.templateConfigs || {};
204
+ const handledListParams = handleSetValues(listParams);
205
+ updateTemplateData(gapitTemplateId, templateName, handledListParams, previewUrl, ZALO_STATUSES.ENABLE);
206
+ } else {
207
+ const { _id: gapitTemplateId = '' } = templateData;
208
+ let data = gapitAllTemplateData?.find(template => template?._id == gapitTemplateId);
209
+ const { templateName = "", listParams = [], previewUrl = "", status = "" } = data?.versions?.base?.content?.zalo || {};
210
+ updateTemplateData(gapitTemplateId, templateName, listParams, previewUrl, status);
211
+ }
212
+ }
171
213
  };
172
214
 
173
215
  useEffect(() => {
@@ -339,7 +381,7 @@ export const Zalo = (props) => {
339
381
 
340
382
  const isEditDoneDisabled = () => {
341
383
  let disableCheck = false;
342
- templateListParams.forEach((listParams) => {
384
+ templateListParams?.forEach((listParams) => {
343
385
  const { error, value } = listParams;
344
386
  const errorMessage = !error
345
387
  ? handleErrorValidation(value, listParams)
@@ -351,11 +393,16 @@ export const Zalo = (props) => {
351
393
  return disableCheck;
352
394
  };
353
395
  const createPayload = () => {
354
- const varMap = {};
355
- templateListParams.forEach((listParam) => {
356
- const { name, value } = listParam;
357
- varMap[name] = value;
358
- });
396
+ let varMap = {};
397
+ if (hostName !== VIET_GUYS) {
398
+ varMap = templateListParams;
399
+ } else {
400
+ templateListParams?.forEach((listParam) => {
401
+ const { name = '', value = '' } = listParam;
402
+ varMap[name] = value;
403
+ }
404
+ );
405
+ }
359
406
  const payload = {
360
407
  channel: ZALO,
361
408
  accountId: oa_id,
@@ -370,6 +417,7 @@ export const Zalo = (props) => {
370
417
  varMapped: varMap,
371
418
  },
372
419
  token,
420
+ host: hostName,
373
421
  };
374
422
  return payload;
375
423
  };
@@ -407,7 +455,7 @@ export const Zalo = (props) => {
407
455
  });
408
456
 
409
457
  return (
410
- <CapSpin spinning={zaloTemplateInfoStatus === REQUEST}>
458
+ <CapSpin spinning={zaloTemplateInfoStatus === REQUEST && hostName === VIET_GUYS}>
411
459
  <CapRow type="flex" className="cap-zalo-creatives">
412
460
  <CapColumn span={14}>
413
461
  {templateStatus && (
@@ -485,6 +533,7 @@ const mapStateToProps = createStructuredSelector({
485
533
  accountData: makeSelectAccount(),
486
534
  metaEntities: makeSelectMetaEntities(),
487
535
  injectedTags: setInjectedTags(),
536
+ gapItTemplateData: makeSelectGapitTemplates(),
488
537
  });
489
538
 
490
539
  const mapDispatchToProps = (dispatch) => ({
@@ -9,4 +9,11 @@ const makeSelectZalo = () =>
9
9
  const makeSelectAccount = () =>
10
10
  createSelector(selectAccountDomain(), (substate) => substate && substate.toJS());
11
11
 
12
- export { makeSelectZalo, makeSelectAccount };
12
+ const makeSelectGapitTemplates = () =>
13
+ createSelector(selectAccountDomain(), (substate) => {
14
+ const getAllTemplates = substate && substate.toJS();
15
+ const { templates = []} = getAllTemplates;
16
+ return templates;
17
+ });
18
+
19
+ export { makeSelectZalo, makeSelectAccount, makeSelectGapitTemplates };
@@ -11462,6 +11462,9 @@ export const accountData = {
11462
11462
  modifiedDate: '2023-10-16T00:00:00+05:30',
11463
11463
  },
11464
11464
  },
11465
+ senderDetails: {
11466
+ hostName: 'vietguyszalotrans',
11467
+ },
11465
11468
  };
11466
11469
 
11467
11470
  export const templateData = {
@@ -11479,3 +11482,46 @@ export const templateConfigs = {
11479
11482
  ma_so1: '4',
11480
11483
  },
11481
11484
  };
11485
+
11486
+ export const mockGapItTemplateData = [
11487
+ {
11488
+ _id: '354701',
11489
+ versions: {
11490
+ base: {
11491
+ content: {
11492
+ zalo: {
11493
+ templateName: 'Test',
11494
+ listParams: [
11495
+ {
11496
+ name: "Name",
11497
+ type: "STRING",
11498
+ require: true,
11499
+ maxLength: 80,
11500
+ minLength: 0,
11501
+ acceptNull: false,
11502
+ },
11503
+ {
11504
+ name: "So_dien_thoai",
11505
+ type: "STRING",
11506
+ require: true,
11507
+ maxLength: 30,
11508
+ minLength: 0,
11509
+ acceptNull: false,
11510
+ },
11511
+ {
11512
+ name: "so_du",
11513
+ type: "STRING",
11514
+ require: true,
11515
+ maxLength: 30,
11516
+ minLength: 0,
11517
+ acceptNull: false,
11518
+ },
11519
+ ],
11520
+ previewUrl: 'https://account.zalo.cloud/znspreview/h84m64E6ST_owPQVFzTilg==',
11521
+ status: 'ENABLE',
11522
+ },
11523
+ },
11524
+ },
11525
+ },
11526
+ },
11527
+ ];
@@ -1,5 +1,5 @@
1
1
  import { fromJS } from "immutable";
2
- import { makeSelectZalo, makeSelectAccount } from "../selectors";
2
+ import { makeSelectZalo, makeSelectAccount, makeSelectGapitTemplates } from "../selectors";
3
3
 
4
4
  describe("makeSelectZalo", () => {
5
5
  it("returns the expected object with default values when substate is empty", () => {
@@ -25,4 +25,27 @@ describe("makeSelectZalo", () => {
25
25
  // Assert
26
26
  expect(result).toEqual(expected);
27
27
  });
28
- });
28
+ });
29
+
30
+ describe('makeSelectGapitTemplates', () => {
31
+ it('should return an empty array if templates are not present', () => {
32
+ const state = fromJS({ templates: {} });
33
+ const selector = makeSelectGapitTemplates();
34
+ const result = selector(state);
35
+ expect(result).toEqual([]);
36
+ });
37
+
38
+ it('should return an array of templates if present', () => {
39
+ const state = fromJS({ templates: { templates: ['template1', 'template2'] } });
40
+ const selector = makeSelectGapitTemplates();
41
+ const result = selector(state);
42
+ expect(result).toEqual(['template1', 'template2']);
43
+ });
44
+
45
+ it('should return an empty array if templates is null', () => {
46
+ const state = fromJS({ templates: {} });
47
+ const selector = makeSelectGapitTemplates();
48
+ const result = selector(state);
49
+ expect(result).toEqual([]);
50
+ });
51
+ });