@tap-payments/auth-jsconnect 2.0.55 → 2.0.56

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.
Files changed (53) hide show
  1. package/build/@types/redux.d.ts +4 -0
  2. package/build/constants/app.js +9 -9
  3. package/build/features/app/bank/bankStore.d.ts +2 -2
  4. package/build/features/app/bank/bankStore.js +54 -51
  5. package/build/features/app/brand/brandStore.d.ts +3 -3
  6. package/build/features/app/brand/brandStore.js +133 -114
  7. package/build/features/app/business/businessStore.js +3 -4
  8. package/build/features/app/connect/connectStore.js +3 -2
  9. package/build/features/app/connectExpress/connectExpressStore.d.ts +3 -3
  10. package/build/features/app/connectExpress/connectExpressStore.js +80 -76
  11. package/build/features/app/entity/entityStore.d.ts +3 -3
  12. package/build/features/app/entity/entityStore.js +130 -120
  13. package/build/features/app/individual/individualStore.d.ts +4 -4
  14. package/build/features/app/individual/individualStore.js +227 -219
  15. package/build/features/app/password/passwordStore.d.ts +2 -0
  16. package/build/features/app/password/passwordStore.js +24 -12
  17. package/build/features/app/tax/taxStore.d.ts +2 -2
  18. package/build/features/app/tax/taxStore.js +59 -55
  19. package/build/features/bank/screens/BankDetails/BankDetails.js +7 -6
  20. package/build/features/bank/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +8 -3
  21. package/build/features/brand/screens/BrandActivities/BrandActivities.js +3 -2
  22. package/build/features/brand/screens/BrandActivities/ExpectedCustomers.js +3 -11
  23. package/build/features/brand/screens/BrandInfo/BrandInfo.js +7 -6
  24. package/build/features/brand/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +8 -3
  25. package/build/features/business/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +7 -2
  26. package/build/features/connect/screens/Merchant/Merchant.js +2 -1
  27. package/build/features/connect/screens/Merchant/validation.d.ts +3 -0
  28. package/build/features/connect/screens/Merchant/validation.js +2 -1
  29. package/build/features/connectExpress/screens/CollectBusinessInfo/CollectBusinessInfo.js +5 -4
  30. package/build/features/connectExpress/screens/CollectIndividualInfo/CollectIndividualInfo.js +5 -4
  31. package/build/features/connectExpress/screens/CollectIndividualInfo/Email.js +3 -9
  32. package/build/features/entity/screens/EntityCapital/EntityCapital.js +3 -2
  33. package/build/features/entity/screens/EntityName/EntityName.js +3 -2
  34. package/build/features/entity/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +8 -3
  35. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +19 -18
  36. package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.js +3 -2
  37. package/build/features/individual/screens/IndividualPhoneInfo/PhoneInfo.js +3 -2
  38. package/build/features/individual/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +7 -2
  39. package/build/features/password/screens/CreatePassword/CreatePassword.js +9 -16
  40. package/build/features/password/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +7 -2
  41. package/build/features/password/screens/Verify/Verify.js +7 -20
  42. package/build/features/shared/Button/IndividualActionButtons.js +2 -2
  43. package/build/features/shared/SuccessScreen/SuccessScreen.d.ts +3 -1
  44. package/build/features/shared/SuccessScreen/SuccessScreen.js +3 -2
  45. package/build/features/tax/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +8 -3
  46. package/build/features/tax/screens/TaxDetails/TaxDetails.js +4 -3
  47. package/build/hooks/index.d.ts +1 -0
  48. package/build/hooks/index.js +1 -0
  49. package/build/hooks/useExcludeReadOnlyFelids.d.ts +11 -0
  50. package/build/hooks/useExcludeReadOnlyFelids.js +33 -0
  51. package/build/utils/string.d.ts +1 -1
  52. package/build/utils/string.js +3 -1
  53. package/package.json +1 -1
@@ -12,3 +12,7 @@ export interface ResponseData {
12
12
  [key: string]: any;
13
13
  };
14
14
  }
15
+ export interface AsyncThunkParams<T> {
16
+ formData: T;
17
+ originalFormData: T;
18
+ }
@@ -234,7 +234,7 @@ export var BUSINESS_SCREENS_NAVIGATION = [
234
234
  {
235
235
  name: 'BUSINESS_RESET_PASSWORD_SUCCESS',
236
236
  next: '',
237
- prev: '',
237
+ prev: 'BUSINESS_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
238
238
  order: 8
239
239
  }
240
240
  ];
@@ -290,7 +290,7 @@ export var INDIVIDUAL_SCREENS_NAVIGATION = [
290
290
  {
291
291
  name: 'INDIVIDUAL_RESET_PASSWORD_SUCCESS',
292
292
  next: '',
293
- prev: '',
293
+ prev: 'INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
294
294
  order: 6
295
295
  }
296
296
  ];
@@ -298,13 +298,13 @@ export var PASSWORD_SCREENS_NAVIGATION = [
298
298
  {
299
299
  name: 'PASSWORD_VERIFY_STEP',
300
300
  next: ['PASSWORD_CREATE_PASSWORD_STEP', 'PASSWORD_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'],
301
- prev: '',
301
+ prev: 'PASSWORD_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
302
302
  order: 1
303
303
  },
304
304
  {
305
305
  name: 'PASSWORD_CREATE_PASSWORD_STEP',
306
306
  next: ['PASSWORD_SUCCESS_STEP', 'PASSWORD_RESET_PASSWORD_OTP_STEP'],
307
- prev: '',
307
+ prev: 'PASSWORD_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
308
308
  order: 2
309
309
  },
310
310
  {
@@ -328,7 +328,7 @@ export var PASSWORD_SCREENS_NAVIGATION = [
328
328
  {
329
329
  name: 'PASSWORD_RESET_PASSWORD_SUCCESS',
330
330
  next: '',
331
- prev: '',
331
+ prev: 'PASSWORD_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
332
332
  order: 6
333
333
  }
334
334
  ];
@@ -366,7 +366,7 @@ export var BANK_SCREENS_NAVIGATION = [
366
366
  {
367
367
  name: 'BANK_RESET_PASSWORD_SUCCESS',
368
368
  next: '',
369
- prev: '',
369
+ prev: 'BANK_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
370
370
  order: 5
371
371
  }
372
372
  ];
@@ -404,7 +404,7 @@ export var TAX_SCREENS_NAVIGATION = [
404
404
  {
405
405
  name: 'TAX_RESET_PASSWORD_SUCCESS',
406
406
  next: '',
407
- prev: '',
407
+ prev: 'TAX_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
408
408
  order: 5
409
409
  }
410
410
  ];
@@ -474,7 +474,7 @@ export var ENTITY_SCREENS_NAVIGATION = [
474
474
  {
475
475
  name: 'ENTITY_RESET_PASSWORD_SUCCESS',
476
476
  next: '',
477
- prev: '',
477
+ prev: 'ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
478
478
  order: 5
479
479
  }
480
480
  ];
@@ -518,7 +518,7 @@ export var BRAND_SCREENS_NAVIGATION = [
518
518
  {
519
519
  name: 'BRAND_RESET_PASSWORD_SUCCESS',
520
520
  next: '',
521
- prev: '',
521
+ prev: 'BRAND_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
522
522
  order: 5
523
523
  }
524
524
  ];
@@ -1,6 +1,6 @@
1
1
  import { CancelToken } from 'axios';
2
2
  import { RootState } from '../../../app/store';
3
- import { ActionState, BankFormValues, FlowsTypes, OTPFormValues, ResponseData, SharedState } from '../../../@types';
3
+ import { ActionState, BankFormValues, FlowsTypes, OTPFormValues, ResponseData, SharedState, AsyncThunkParams } from '../../../@types';
4
4
  interface VerifyLeadTokenProps {
5
5
  token: string;
6
6
  isInternally?: boolean;
@@ -36,7 +36,7 @@ export declare const retrieveBoardDetails: import("@reduxjs/toolkit").AsyncThunk
36
36
  export declare const createBankAccount: import("@reduxjs/toolkit").AsyncThunk<{
37
37
  data: any;
38
38
  formData: BankFormValues;
39
- }, BankFormValues, {}>;
39
+ }, AsyncThunkParams<BankFormValues>, {}>;
40
40
  export declare const checkIbanBank: import("@reduxjs/toolkit").AsyncThunk<{
41
41
  data: any;
42
42
  }, {
@@ -51,7 +51,7 @@ import API from '../../../api';
51
51
  import { DocumentPurpose, FlowsTypes } from '../../../@types';
52
52
  import { handleCurrentActiveScreen, handleNextScreenStep, handlePrevScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
53
53
  import { BANK_STEP_NAMES } from '../../../constants';
54
- import { hasNoneEditableValue, isStringMasked, sleep } from '../../../utils';
54
+ import { hasNoneEditableValue, isStringHasOneAsterisk, sleep } from '../../../utils';
55
55
  export var verifyLeadToken = createAsyncThunk('bankVerifyLeadToken', function (_a, thunkApi) {
56
56
  var token = _a.token, isInternally = _a.isInternally;
57
57
  return __awaiter(void 0, void 0, void 0, function () {
@@ -179,57 +179,60 @@ export var retrieveBoardDetails = createAsyncThunk('bank/retrieveBoardDetails',
179
179
  }
180
180
  });
181
181
  }); });
182
- export var createBankAccount = createAsyncThunk('createBankAccount', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
183
- var _a, settings, bank, iban, beneficiaryName, bankName, bankStatementId, confirmPolicy, _b, data_status, document, isIBANMasked, isIBANNonEditable, isBeneficiaryNameNonEditable, isBankNameNonEditable, isBankStatementIdNonEditable, isConfirmPolicyNonEditable, documentResponse, hasDocument, documentId, requestBody, data, documentBody;
184
- var _c, _d, _e, _f, _g, _h, _j, _k, _l;
185
- return __generator(this, function (_m) {
186
- switch (_m.label) {
187
- case 0:
188
- _a = thunkApi.getState(), settings = _a.settings, bank = _a.bank;
189
- iban = params.iban, beneficiaryName = params.beneficiaryName, bankName = params.bankName, bankStatementId = params.bankStatementId, confirmPolicy = params.confirmPolicy;
190
- _b = ((_c = bank.data.verify.responseBody) === null || _c === void 0 ? void 0 : _c.bank_account) || {}, data_status = _b.data_status, document = _b.document;
191
- isIBANMasked = isStringMasked(iban);
192
- isIBANNonEditable = hasNoneEditableValue(data_status, 'iban');
193
- isBeneficiaryNameNonEditable = hasNoneEditableValue(data_status, 'beneficiary_name');
194
- isBankNameNonEditable = hasNoneEditableValue(data_status, 'bank_name');
195
- isBankStatementIdNonEditable = hasNoneEditableValue(data_status, 'bank_statement_file_id');
196
- isConfirmPolicyNonEditable = hasNoneEditableValue(data_status, 'is_acknowledged');
197
- documentResponse = undefined;
198
- hasDocument = (bankStatementId || []).length > 0;
199
- documentId = document === null || document === void 0 ? void 0 : document.id;
200
- requestBody = {
201
- wallet_id: (_h = (_g = (_f = (_e = (_d = bank.data.verify.responseBody) === null || _d === void 0 ? void 0 : _d.business) === null || _e === void 0 ? void 0 : _e.entity) === null || _f === void 0 ? void 0 : _f.merchant) === null || _g === void 0 ? void 0 : _g.wallet) === null || _h === void 0 ? void 0 : _h.id,
202
- bank_account: __assign({ iban: isIBANNonEditable || isIBANMasked ? undefined : iban, beneficiary_name: isBeneficiaryNameNonEditable ? undefined : beneficiaryName, bank_name: isBankNameNonEditable ? undefined : bankName, is_acknowledged: isConfirmPolicyNonEditable ? undefined : confirmPolicy }, (!(isBankStatementIdNonEditable || documentId || !hasDocument) && {
203
- document: {
204
- type: DocumentPurpose.BANK_STATEMENT,
205
- files: bankStatementId || []
206
- }
207
- })),
208
- step_name: BANK_STEP_NAMES.BANK_INFO,
209
- encryption_contract: ['bank_account.iban', 'bank_account.beneficiary_name', 'bank_account.bank_name']
210
- };
211
- return [4, API.entityService.createBankAccount(requestBody)];
212
- case 1:
213
- data = (_m.sent()).data;
214
- if ((_j = data.errors) === null || _j === void 0 ? void 0 : _j.length)
215
- throw new Error(data.errors[0].description);
216
- if (!(!isBankStatementIdNonEditable && documentId && hasDocument)) return [3, 3];
217
- documentBody = {
218
- id: documentId,
219
- files: bankStatementId || []
220
- };
221
- return [4, API.documentService.addFilesToExistingDocument(documentBody)];
222
- case 2:
223
- documentResponse = _m.sent();
224
- _m.label = 3;
225
- case 3:
226
- data.documentData = documentResponse;
227
- thunkApi.dispatch(handleNextScreenStep());
228
- (_l = (_k = settings.data.appConfig).onStepCompleted) === null || _l === void 0 ? void 0 : _l.call(_k, settings.data.activeScreen.name, requestBody);
229
- return [2, { data: data, formData: params }];
230
- }
182
+ export var createBankAccount = createAsyncThunk('createBankAccount', function (_a, thunkApi) {
183
+ var formData = _a.formData, originalFormData = _a.originalFormData;
184
+ return __awaiter(void 0, void 0, void 0, function () {
185
+ var _b, settings, bank, iban, beneficiaryName, bankName, bankStatementId, confirmPolicy, _c, data_status, document, isIBANMasked, isIBANNonEditable, isBeneficiaryNameNonEditable, isBankNameNonEditable, isBankStatementIdNonEditable, isConfirmPolicyNonEditable, documentResponse, hasDocument, documentId, requestBody, data, documentBody;
186
+ var _d, _e, _f, _g, _h, _j, _k, _l, _m;
187
+ return __generator(this, function (_o) {
188
+ switch (_o.label) {
189
+ case 0:
190
+ _b = thunkApi.getState(), settings = _b.settings, bank = _b.bank;
191
+ iban = formData.iban, beneficiaryName = formData.beneficiaryName, bankName = formData.bankName, bankStatementId = formData.bankStatementId, confirmPolicy = formData.confirmPolicy;
192
+ _c = ((_d = bank.data.verify.responseBody) === null || _d === void 0 ? void 0 : _d.bank_account) || {}, data_status = _c.data_status, document = _c.document;
193
+ isIBANMasked = isStringHasOneAsterisk(iban);
194
+ isIBANNonEditable = hasNoneEditableValue(data_status, 'iban');
195
+ isBeneficiaryNameNonEditable = hasNoneEditableValue(data_status, 'beneficiary_name');
196
+ isBankNameNonEditable = hasNoneEditableValue(data_status, 'bank_name');
197
+ isBankStatementIdNonEditable = hasNoneEditableValue(data_status, 'bank_statement_file_id');
198
+ isConfirmPolicyNonEditable = hasNoneEditableValue(data_status, 'is_acknowledged');
199
+ documentResponse = undefined;
200
+ hasDocument = (bankStatementId || []).length > 0;
201
+ documentId = document === null || document === void 0 ? void 0 : document.id;
202
+ requestBody = {
203
+ wallet_id: (_j = (_h = (_g = (_f = (_e = bank.data.verify.responseBody) === null || _e === void 0 ? void 0 : _e.business) === null || _f === void 0 ? void 0 : _f.entity) === null || _g === void 0 ? void 0 : _g.merchant) === null || _h === void 0 ? void 0 : _h.wallet) === null || _j === void 0 ? void 0 : _j.id,
204
+ bank_account: __assign({ iban: isIBANNonEditable || isIBANMasked ? undefined : iban, beneficiary_name: isBeneficiaryNameNonEditable ? undefined : beneficiaryName, bank_name: isBankNameNonEditable ? undefined : bankName, is_acknowledged: isConfirmPolicyNonEditable ? undefined : confirmPolicy }, (!(isBankStatementIdNonEditable || documentId || !hasDocument) && {
205
+ document: {
206
+ type: DocumentPurpose.BANK_STATEMENT,
207
+ files: bankStatementId || []
208
+ }
209
+ })),
210
+ step_name: BANK_STEP_NAMES.BANK_INFO,
211
+ encryption_contract: ['bank_account.iban', 'bank_account.beneficiary_name', 'bank_account.bank_name']
212
+ };
213
+ return [4, API.entityService.createBankAccount(requestBody)];
214
+ case 1:
215
+ data = (_o.sent()).data;
216
+ if ((_k = data.errors) === null || _k === void 0 ? void 0 : _k.length)
217
+ throw new Error(data.errors[0].description);
218
+ if (!(!isBankStatementIdNonEditable && documentId && hasDocument)) return [3, 3];
219
+ documentBody = {
220
+ id: documentId,
221
+ files: bankStatementId || []
222
+ };
223
+ return [4, API.documentService.addFilesToExistingDocument(documentBody)];
224
+ case 2:
225
+ documentResponse = _o.sent();
226
+ _o.label = 3;
227
+ case 3:
228
+ data.documentData = documentResponse;
229
+ thunkApi.dispatch(handleNextScreenStep());
230
+ (_m = (_l = settings.data.appConfig).onStepCompleted) === null || _m === void 0 ? void 0 : _m.call(_l, settings.data.activeScreen.name, requestBody);
231
+ return [2, { data: data, formData: originalFormData }];
232
+ }
233
+ });
231
234
  });
232
- }); });
235
+ });
233
236
  export var checkIbanBank = createAsyncThunk('checkIbanBank', function (_a) {
234
237
  var iban = _a.iban, cancelToken = _a.cancelToken, onSuccess = _a.onSuccess;
235
238
  return __awaiter(void 0, void 0, void 0, function () {
@@ -1,5 +1,5 @@
1
1
  import { RootState } from '../../../app/store';
2
- import { ActionState, BrandActivitiesFormValues, BrandFormValues, FlowsTypes, OTPFormValues, ResponseData, SharedState } from '../../../@types';
2
+ import { ActionState, AsyncThunkParams, BrandActivitiesFormValues, BrandFormValues, FlowsTypes, OTPFormValues, ResponseData, SharedState } from '../../../@types';
3
3
  import { CancelToken } from 'axios';
4
4
  interface VerifyLeadTokenProps {
5
5
  token: string;
@@ -63,14 +63,14 @@ export declare const checkBrandNameAvailability: import("@reduxjs/toolkit").Asyn
63
63
  export declare const updateBrand: import("@reduxjs/toolkit").AsyncThunk<{
64
64
  data: any;
65
65
  formData: Omit<BrandFormValues, "termAndConditionChecked" | "selectedBrandItem">;
66
- }, Omit<BrandFormValues, "termAndConditionChecked" | "selectedBrandItem">, {}>;
66
+ }, AsyncThunkParams<Omit<BrandFormValues, "termAndConditionChecked" | "selectedBrandItem">>, {}>;
67
67
  export declare const retrieveEntityList: import("@reduxjs/toolkit").AsyncThunk<any, {
68
68
  leadId: string;
69
69
  }, {}>;
70
70
  export declare const updateBrandActivities: import("@reduxjs/toolkit").AsyncThunk<{
71
71
  data: any;
72
72
  formData: BrandActivitiesFormValues;
73
- }, BrandActivitiesFormValues, {}>;
73
+ }, AsyncThunkParams<BrandActivitiesFormValues>, {}>;
74
74
  export declare const retrieveDataList: import("@reduxjs/toolkit").AsyncThunk<{
75
75
  customerBases: any;
76
76
  expectedSales: any;
@@ -263,70 +263,73 @@ export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailabi
263
263
  });
264
264
  });
265
265
  });
266
- export var updateBrand = createAsyncThunk('brandUpdateBrand', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
267
- var _a, settings, brand, _b, id, data_status, isNameNonEditable, isChannelServicesNonEditable, isSegmentTypeNonEditable, isSegmentTeamsNonEditable, salesChannels, brandName, segment, teamSize, brandLogoId, segmentId, teamSizeId, getAddress, channel_services, requestBody, brandData, activities, activityList;
268
- var _c, _d, _e, _f;
269
- return __generator(this, function (_g) {
270
- switch (_g.label) {
271
- case 0:
272
- _a = thunkApi.getState(), settings = _a.settings, brand = _a.brand;
273
- _b = ((_c = brand.data.verify.responseBody) === null || _c === void 0 ? void 0 : _c.brand) || {}, id = _b.id, data_status = _b.data_status;
274
- isNameNonEditable = hasNoneEditableValue(data_status, 'name');
275
- isChannelServicesNonEditable = hasNoneEditableValue(data_status, 'channel_services');
276
- isSegmentTypeNonEditable = hasNoneEditableValue(data_status, 'segment.type');
277
- isSegmentTeamsNonEditable = hasNoneEditableValue(data_status, 'segment.teams');
278
- salesChannels = params.salesChannels, brandName = params.brandName, segment = params.segment, teamSize = params.teamSize, brandLogoId = params.brandLogoId;
279
- segmentId = isSegmentTypeNonEditable ? undefined : segment && { id: segment.id };
280
- teamSizeId = isSegmentTeamsNonEditable ? undefined : teamSize && { id: teamSize.id };
281
- getAddress = function (value, isTwitter, isWeb) {
282
- if (isTwitter)
283
- return '@' + value.replaceAll('@', '');
284
- if (isWeb)
285
- return 'https://www.' + value.replaceAll('https://www.', '');
286
- return value;
287
- };
288
- channel_services = isChannelServicesNonEditable
289
- ? undefined
290
- : salesChannels.map(function (channel) {
291
- var _a;
292
- return {
293
- id: channel.id,
294
- address: getAddress(channel.address || '', isTwitter(channel.code), isWebsite(channel.code)),
295
- sub: (_a = channel.sub) === null || _a === void 0 ? void 0 : _a.map(function (sub) {
296
- return { id: sub.id, address: getAddress(sub.address || '', isTwitter(sub.code), isWebsite(sub.code)) };
297
- })
298
- };
299
- });
300
- requestBody = {
301
- id: id,
302
- name: isNameNonEditable || !brandName ? undefined : { en: brandName, ar: brandName },
303
- logo: brandLogoId,
304
- segment: !segmentId && !teamSizeId ? undefined : { type: segmentId, team: teamSizeId },
305
- channel_services: channel_services
306
- };
307
- return [4, API.brandService.updateBrandInfo(requestBody)];
308
- case 1:
309
- brandData = (_g.sent()).brand;
310
- activities = (((_d = brand.data.verify.responseBody) === null || _d === void 0 ? void 0 : _d.entity) || {}).activities;
311
- return [4, thunkApi.dispatch(retrieveDataList())];
312
- case 2:
313
- _g.sent();
314
- if (activities) {
315
- brandData = __assign(__assign({}, brandData), { entity_activities: activities || {} });
316
- }
317
- if (!!activities) return [3, 4];
318
- return [4, API.dataService.getActivities()];
319
- case 3:
320
- activityList = (_g.sent()).list;
321
- brandData = __assign(__assign({}, brandData), { entity_activities: activityList || {} });
322
- _g.label = 4;
323
- case 4:
324
- sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep()); });
325
- (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, id);
326
- return [2, { data: __assign({}, brandData), formData: params }];
327
- }
266
+ export var updateBrand = createAsyncThunk('brandUpdateBrand', function (_a, thunkApi) {
267
+ var formData = _a.formData, originalFormData = _a.originalFormData;
268
+ return __awaiter(void 0, void 0, void 0, function () {
269
+ var _b, settings, brand, _c, id, data_status, isNameNonEditable, isChannelServicesNonEditable, isSegmentTypeNonEditable, isSegmentTeamsNonEditable, salesChannels, brandName, segment, teamSize, brandLogoId, segmentId, teamSizeId, getAddress, channel_services, requestBody, brandData, activities, activityList;
270
+ var _d, _e, _f, _g;
271
+ return __generator(this, function (_h) {
272
+ switch (_h.label) {
273
+ case 0:
274
+ _b = thunkApi.getState(), settings = _b.settings, brand = _b.brand;
275
+ _c = ((_d = brand.data.verify.responseBody) === null || _d === void 0 ? void 0 : _d.brand) || {}, id = _c.id, data_status = _c.data_status;
276
+ isNameNonEditable = hasNoneEditableValue(data_status, 'name');
277
+ isChannelServicesNonEditable = hasNoneEditableValue(data_status, 'channel_services');
278
+ isSegmentTypeNonEditable = hasNoneEditableValue(data_status, 'segment.type');
279
+ isSegmentTeamsNonEditable = hasNoneEditableValue(data_status, 'segment.teams');
280
+ salesChannels = formData.salesChannels, brandName = formData.brandName, segment = formData.segment, teamSize = formData.teamSize, brandLogoId = formData.brandLogoId;
281
+ segmentId = isSegmentTypeNonEditable ? undefined : segment && { id: segment.id };
282
+ teamSizeId = isSegmentTeamsNonEditable ? undefined : teamSize && { id: teamSize.id };
283
+ getAddress = function (value, isTwitter, isWeb) {
284
+ if (isTwitter)
285
+ return '@' + value.replaceAll('@', '');
286
+ if (isWeb)
287
+ return 'https://www.' + value.replaceAll('https://www.', '');
288
+ return value;
289
+ };
290
+ channel_services = isChannelServicesNonEditable
291
+ ? undefined
292
+ : salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.map(function (channel) {
293
+ var _a;
294
+ return {
295
+ id: channel.id,
296
+ address: getAddress(channel.address || '', isTwitter(channel.code), isWebsite(channel.code)),
297
+ sub: (_a = channel.sub) === null || _a === void 0 ? void 0 : _a.map(function (sub) {
298
+ return { id: sub.id, address: getAddress(sub.address || '', isTwitter(sub.code), isWebsite(sub.code)) };
299
+ })
300
+ };
301
+ });
302
+ requestBody = {
303
+ id: id,
304
+ name: isNameNonEditable || !brandName ? undefined : { en: brandName, ar: brandName },
305
+ logo: brandLogoId,
306
+ segment: !segmentId && !teamSizeId ? undefined : { type: segmentId, team: teamSizeId },
307
+ channel_services: channel_services
308
+ };
309
+ return [4, API.brandService.updateBrandInfo(requestBody)];
310
+ case 1:
311
+ brandData = (_h.sent()).brand;
312
+ activities = (((_e = brand.data.verify.responseBody) === null || _e === void 0 ? void 0 : _e.entity) || {}).activities;
313
+ return [4, thunkApi.dispatch(retrieveDataList())];
314
+ case 2:
315
+ _h.sent();
316
+ if (activities) {
317
+ brandData = __assign(__assign({}, brandData), { entity_activities: activities || {} });
318
+ }
319
+ if (!!activities) return [3, 4];
320
+ return [4, API.dataService.getActivities()];
321
+ case 3:
322
+ activityList = (_h.sent()).list;
323
+ brandData = __assign(__assign({}, brandData), { entity_activities: activityList || {} });
324
+ _h.label = 4;
325
+ case 4:
326
+ sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep()); });
327
+ (_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, id);
328
+ return [2, { data: __assign({}, brandData), formData: originalFormData }];
329
+ }
330
+ });
328
331
  });
329
- }); });
332
+ });
330
333
  export var retrieveEntityList = createAsyncThunk('retrieveEntityList', function (params) { return __awaiter(void 0, void 0, void 0, function () {
331
334
  var data;
332
335
  return __generator(this, function (_a) {
@@ -338,57 +341,62 @@ export var retrieveEntityList = createAsyncThunk('retrieveEntityList', function
338
341
  }
339
342
  });
340
343
  }); });
341
- export var updateBrandActivities = createAsyncThunk('brandUpdateBrandActivities', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
342
- var _a, settings, brand, _b, data_status, id, brandActivities, isActivitiesNonEditable, isCustomerBaseLocationNonEditable, isCustomerBaseNonEditable, isTermsNonEditable, isSalesRangeNonEditable, activities, customerLocations, expectedCustomer, expectedSale, removedActivities, payload, requestBody, customerLocation, customerBaseId, salesId, customerBase, brandData;
343
- var _c, _d, _e;
344
- return __generator(this, function (_f) {
345
- switch (_f.label) {
346
- case 0:
347
- _a = thunkApi.getState(), settings = _a.settings, brand = _a.brand;
348
- _b = ((_c = brand.data.verify.responseBody) === null || _c === void 0 ? void 0 : _c.brand) || {}, data_status = _b.data_status, id = _b.id, brandActivities = _b.activities;
349
- isActivitiesNonEditable = hasNoneEditableValue(data_status, 'activities');
350
- isCustomerBaseLocationNonEditable = hasNoneEditableValue(data_status === null || data_status === void 0 ? void 0 : data_status.operations, 'customer_base_location');
351
- isCustomerBaseNonEditable = hasNoneEditableValue(data_status === null || data_status === void 0 ? void 0 : data_status.operations, 'customer_base');
352
- isTermsNonEditable = hasNoneEditableValue(data_status, 'terms');
353
- isSalesRangeNonEditable = hasNoneEditableValue(data_status === null || data_status === void 0 ? void 0 : data_status.operations, 'sales_range');
354
- activities = params.activities, customerLocations = params.customerLocations, expectedCustomer = params.expectedCustomer, expectedSale = params.expectedSale;
355
- removedActivities = (brandActivities || []).filter(function (brandActivity) { return !(activities || []).some(function (activity) { return activity.id === brandActivity.id; }); });
356
- if (!(!isActivitiesNonEditable && (removedActivities === null || removedActivities === void 0 ? void 0 : removedActivities.length) > 0)) return [3, 2];
357
- payload = {
358
- id: id,
359
- activities: removedActivities
360
- };
361
- return [4, API.brandService.removeBrandActivity(payload)];
362
- case 1:
363
- _f.sent();
364
- _f.label = 2;
365
- case 2:
366
- requestBody = {
367
- id: id,
368
- activities: isActivitiesNonEditable ? undefined : activities,
369
- term: isTermsNonEditable ? undefined : ['general', 'refund', 'chargeback'],
370
- step_name: BRAND_STEP_NAMES.BRAND_ACTIVITIES
371
- };
372
- customerLocation = customerLocations.map(function (location) { return ({
373
- id: location.id
374
- }); });
375
- customerBaseId = (expectedCustomer === null || expectedCustomer === void 0 ? void 0 : expectedCustomer.id) && { id: expectedCustomer.id, period: 'monthly' };
376
- salesId = (expectedSale === null || expectedSale === void 0 ? void 0 : expectedSale.id) && { id: expectedSale.id, period: 'monthly' };
377
- customerBase = (customerBaseId || customerLocation.length) && __assign(__assign({}, (customerBaseId && !isCustomerBaseNonEditable && { id: expectedCustomer.id, period: 'monthly' })), (customerLocation.length && !isCustomerBaseLocationNonEditable && { locations: customerLocation }));
378
- if (customerBase && !(isCustomerBaseNonEditable && isCustomerBaseLocationNonEditable))
379
- requestBody = __assign(__assign({}, requestBody), { operations: __assign(__assign({}, requestBody.operations), { customer_base: customerBase }) });
380
- if (salesId && !isSalesRangeNonEditable) {
381
- requestBody = __assign(__assign({}, requestBody), { operations: __assign(__assign({}, requestBody.operations), { sales: salesId }) });
382
- }
383
- return [4, API.brandService.updateBrandInfo(requestBody)];
384
- case 3:
385
- brandData = (_f.sent()).data;
386
- thunkApi.dispatch(handleNextScreenStep());
387
- (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, id);
388
- return [2, { data: __assign({}, brandData), formData: params }];
389
- }
344
+ export var updateBrandActivities = createAsyncThunk('brandUpdateBrandActivities', function (_a, thunkApi) {
345
+ var formData = _a.formData, originalFormData = _a.originalFormData;
346
+ return __awaiter(void 0, void 0, void 0, function () {
347
+ var _b, settings, brand, _c, data_status, id, brandActivities, isActivitiesNonEditable, isCustomerBaseLocationNonEditable, isCustomerBaseNonEditable, isTermsNonEditable, isSalesRangeNonEditable, activities, customerLocations, expectedCustomer, expectedSale, termAndConditionChecked, refundPolicy, transactionPolicy, isTermsUndefined, removedActivities, payload, requestBody, customerLocation, customerBaseId, salesId, customerBase, brandData;
348
+ var _d, _e, _f;
349
+ return __generator(this, function (_g) {
350
+ switch (_g.label) {
351
+ case 0:
352
+ _b = thunkApi.getState(), settings = _b.settings, brand = _b.brand;
353
+ _c = ((_d = brand.data.verify.responseBody) === null || _d === void 0 ? void 0 : _d.brand) || {}, data_status = _c.data_status, id = _c.id, brandActivities = _c.activities;
354
+ isActivitiesNonEditable = hasNoneEditableValue(data_status, 'activities');
355
+ isCustomerBaseLocationNonEditable = hasNoneEditableValue(data_status === null || data_status === void 0 ? void 0 : data_status.operations, 'customer_base_location');
356
+ isCustomerBaseNonEditable = hasNoneEditableValue(data_status === null || data_status === void 0 ? void 0 : data_status.operations, 'customer_base');
357
+ isTermsNonEditable = hasNoneEditableValue(data_status, 'terms');
358
+ isSalesRangeNonEditable = hasNoneEditableValue(data_status === null || data_status === void 0 ? void 0 : data_status.operations, 'sales_range');
359
+ activities = formData.activities, customerLocations = formData.customerLocations, expectedCustomer = formData.expectedCustomer, expectedSale = formData.expectedSale, termAndConditionChecked = formData.termAndConditionChecked, refundPolicy = formData.refundPolicy, transactionPolicy = formData.transactionPolicy;
360
+ isTermsUndefined = termAndConditionChecked === undefined && refundPolicy === undefined && transactionPolicy === undefined;
361
+ removedActivities = (activities === null || activities === void 0 ? void 0 : activities.length) > 0 &&
362
+ (brandActivities || []).filter(function (brandActivity) { return !(activities || []).some(function (activity) { return activity.id === brandActivity.id; }); });
363
+ if (!(!isActivitiesNonEditable && (removedActivities === null || removedActivities === void 0 ? void 0 : removedActivities.length) > 0)) return [3, 2];
364
+ payload = {
365
+ id: id,
366
+ activities: removedActivities
367
+ };
368
+ return [4, API.brandService.removeBrandActivity(payload)];
369
+ case 1:
370
+ _g.sent();
371
+ _g.label = 2;
372
+ case 2:
373
+ requestBody = {
374
+ id: id,
375
+ activities: isActivitiesNonEditable ? undefined : activities,
376
+ term: isTermsNonEditable || isTermsUndefined ? undefined : ['general', 'refund', 'chargeback'],
377
+ step_name: BRAND_STEP_NAMES.BRAND_ACTIVITIES
378
+ };
379
+ customerLocation = (customerLocations || []).map(function (location) { return ({
380
+ id: location.id
381
+ }); });
382
+ customerBaseId = (expectedCustomer === null || expectedCustomer === void 0 ? void 0 : expectedCustomer.id) && { id: expectedCustomer.id, period: 'monthly' };
383
+ salesId = (expectedSale === null || expectedSale === void 0 ? void 0 : expectedSale.id) && { id: expectedSale.id, period: 'monthly' };
384
+ customerBase = (customerBaseId || customerLocation.length) && __assign(__assign({}, (customerBaseId && !isCustomerBaseNonEditable && { id: expectedCustomer.id, period: 'monthly' })), (customerLocation.length && !isCustomerBaseLocationNonEditable && { locations: customerLocation }));
385
+ if (customerBase && !(isCustomerBaseNonEditable && isCustomerBaseLocationNonEditable))
386
+ requestBody = __assign(__assign({}, requestBody), { operations: __assign(__assign({}, requestBody.operations), { customer_base: customerBase }) });
387
+ if (salesId && !isSalesRangeNonEditable) {
388
+ requestBody = __assign(__assign({}, requestBody), { operations: __assign(__assign({}, requestBody.operations), { sales: salesId }) });
389
+ }
390
+ return [4, API.brandService.updateBrandInfo(requestBody)];
391
+ case 3:
392
+ brandData = (_g.sent()).data;
393
+ thunkApi.dispatch(handleNextScreenStep());
394
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, id);
395
+ return [2, { data: __assign({}, brandData), formData: originalFormData }];
396
+ }
397
+ });
390
398
  });
391
- }); });
399
+ });
392
400
  export var retrieveDataList = createAsyncThunk('brandRetrieveDataList', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
393
401
  var settings, countryISO2, dataBody, salesDataBody, _a, customerBases, expectedSales, expectedCustomerSales;
394
402
  return __generator(this, function (_b) {
@@ -617,7 +625,7 @@ export var brandSlice = createSlice({
617
625
  state.loading = false;
618
626
  state.error = null;
619
627
  var _a = action.payload, data = _a.data, formData = _a.formData;
620
- var entity_activities = data.entity_activities, activities = data.activities, operations = data.operations;
628
+ var entity_activities = data.entity_activities, activities = data.activities, operations = data.operations, terms = data.terms;
621
629
  var selectedActivity = entity_activities === null || entity_activities === void 0 ? void 0 : entity_activities.filter(function (activity) {
622
630
  return activities === null || activities === void 0 ? void 0 : activities.find(function (value) { return activity.id === value.id; });
623
631
  });
@@ -631,6 +639,17 @@ export var brandSlice = createSlice({
631
639
  state.data.brandActivities.expectedSale = sales;
632
640
  if (!!customerBase)
633
641
  state.data.brandActivities.expectedCustomer = customerBase;
642
+ terms === null || terms === void 0 ? void 0 : terms.forEach(function (element) {
643
+ if ((element === null || element === void 0 ? void 0 : element.term) === 'general') {
644
+ state.data.brandActivities.termAndConditionChecked = element.agree;
645
+ }
646
+ if ((element === null || element === void 0 ? void 0 : element.term) === 'chargeback') {
647
+ state.data.brandActivities.transactionPolicy = element.agree;
648
+ }
649
+ if ((element === null || element === void 0 ? void 0 : element.term) === 'refund') {
650
+ state.data.brandActivities.refundPolicy = element.agree;
651
+ }
652
+ });
634
653
  state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { activities: entity_activities });
635
654
  })
636
655
  .addCase(updateBrandActivities.rejected, function (state, action) {
@@ -475,10 +475,9 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
475
475
  isNonSA = !isSA(settings.data.businessCountry.iso2);
476
476
  selectedLicense = params.selectedLicense, licenseNumber = params.licenseNumber, entityLegalName = params.entityLegalName, certificateId = params.certificateId, articleId = params.articleId, selectedEntityLicense = params.selectedEntityLicense;
477
477
  isFL = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.FL;
478
- payload = __assign(__assign(__assign(__assign(__assign({ id: ((_b = business.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.lead_id) || '' }, ((selectedEntityLicense === null || selectedEntityLicense === void 0 ? void 0 : selectedEntityLicense.id) &&
479
- (isNonSA ? !isFL : true) && {
480
- entity: { id: selectedEntityLicense.id }
481
- })), (!(selectedEntityLicense === null || selectedEntityLicense === void 0 ? void 0 : selectedEntityLicense.id) && {
478
+ payload = __assign(__assign(__assign(__assign({ id: ((_b = business.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.lead_id) || '', entity: {
479
+ id: (selectedEntityLicense === null || selectedEntityLicense === void 0 ? void 0 : selectedEntityLicense.id) && (isNonSA ? !isFL : true) ? selectedEntityLicense === null || selectedEntityLicense === void 0 ? void 0 : selectedEntityLicense.id : ''
480
+ } }, (!(selectedEntityLicense === null || selectedEntityLicense === void 0 ? void 0 : selectedEntityLicense.id) && {
482
481
  license_number: isNonSA && isFL ? '' : licenseNumber,
483
482
  license_type: isFL ? LicenseType.FL : LicenseType.CR,
484
483
  business_type: selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type
@@ -413,7 +413,7 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
413
413
  });
414
414
  }); });
415
415
  export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
416
- var _a, settings, connect, responseBody, leadBrandId, isNewBrand, brandName, salesChannels, selectedBrandItem, termAndConditionChecked, getAddress, channel_services, payload_1, brandReqBody_1, brand_1, brandNameBody, payload, lead, brandReqBody, brand;
416
+ var _a, settings, connect, responseBody, leadBrandId, isNewBrand, brandName, salesChannels, selectedBrandItem, getAddress, channel_services, payload_1, brandReqBody_1, brand_1, brandNameBody, payload, lead, brandReqBody, brand;
417
417
  var _b, _c, _d, _e, _f, _g, _h, _j, _k;
418
418
  return __generator(this, function (_l) {
419
419
  switch (_l.label) {
@@ -421,7 +421,7 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
421
421
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
422
422
  responseBody = connect.data.otpData.responseBody;
423
423
  leadBrandId = responseBody === null || responseBody === void 0 ? void 0 : responseBody.brand_id;
424
- isNewBrand = params.isNewBrand, brandName = params.brandName, salesChannels = params.salesChannels, selectedBrandItem = params.selectedBrandItem, termAndConditionChecked = params.termAndConditionChecked;
424
+ isNewBrand = params.isNewBrand, brandName = params.brandName, salesChannels = params.salesChannels, selectedBrandItem = params.selectedBrandItem;
425
425
  getAddress = function (value, isTwitter, isWeb) {
426
426
  if (isTwitter)
427
427
  return '@' + value;
@@ -468,6 +468,7 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
468
468
  return [2, { response: brand_1, formData: params }];
469
469
  case 4:
470
470
  brandNameBody = {
471
+ id: '',
471
472
  name: {
472
473
  en: brandName,
473
474
  ar: brandName,
@@ -1,5 +1,5 @@
1
1
  import { RootState } from '../../../app/store';
2
- import { MobileFormValues, NIDFormValues, CivilFormValues, OTPFormValues, IndividualFormValues, SharedState, FlowsTypes, ActionState, CountryCode, AuthForType, BusinessDataFormValues } from '../../../@types';
2
+ import { MobileFormValues, NIDFormValues, CivilFormValues, OTPFormValues, IndividualFormValues, SharedState, FlowsTypes, ActionState, CountryCode, AuthForType, BusinessDataFormValues, AsyncThunkParams } from '../../../@types';
3
3
  import { CancelToken } from 'axios';
4
4
  export declare const retrieveLeadIdentityByIdAsync: import("@reduxjs/toolkit").AsyncThunk<{
5
5
  data: any;
@@ -87,11 +87,11 @@ interface verifyPACIAsyncParams {
87
87
  export declare const updateLeadIndividualAsync: import("@reduxjs/toolkit").AsyncThunk<{
88
88
  response: any;
89
89
  formData: IndividualFormValues;
90
- }, IndividualFormValues, {}>;
90
+ }, AsyncThunkParams<IndividualFormValues>, {}>;
91
91
  export declare const updateLeadBusinessDataAsync: import("@reduxjs/toolkit").AsyncThunk<{
92
92
  response: any;
93
93
  formData: BusinessDataFormValues;
94
- }, BusinessDataFormValues, {}>;
94
+ }, AsyncThunkParams<BusinessDataFormValues>, {}>;
95
95
  interface ResponseData {
96
96
  responseData?: Record<string, any>;
97
97
  }