@tap-payments/auth-jsconnect 2.1.23-test → 2.1.25-test

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 (167) hide show
  1. package/build/@types/app.d.ts +48 -1
  2. package/build/@types/app.js +12 -0
  3. package/build/@types/form.d.ts +24 -8
  4. package/build/api/axios.js +2 -2
  5. package/build/api/data.d.ts +8 -0
  6. package/build/api/data.js +16 -0
  7. package/build/api/entity.d.ts +28 -1
  8. package/build/api/entity.js +26 -1
  9. package/build/api/index.d.ts +13 -3
  10. package/build/api/index.js +2 -2
  11. package/build/api/individual.d.ts +4 -0
  12. package/build/api/location.d.ts +5 -0
  13. package/build/api/location.js +19 -0
  14. package/build/app/rootReducer.d.ts +1 -0
  15. package/build/app/rootReducer.js +3 -1
  16. package/build/app/settings.js +1 -1
  17. package/build/app/store.d.ts +2 -0
  18. package/build/assets/locales/ar.json +21 -1
  19. package/build/assets/locales/en.json +21 -1
  20. package/build/components/SimpleList/SimpleList.d.ts +2 -1
  21. package/build/components/SimpleList/SimpleList.js +22 -10
  22. package/build/constants/api.d.ts +3 -0
  23. package/build/constants/api.js +7 -1
  24. package/build/constants/app.d.ts +7 -1
  25. package/build/constants/app.js +51 -8
  26. package/build/constants/validation.d.ts +1 -0
  27. package/build/constants/validation.js +1 -0
  28. package/build/features/app/brand/brandStore.d.ts +97 -0
  29. package/build/features/app/brand/brandStore.js +618 -0
  30. package/build/features/app/entity/entityStore.d.ts +11 -23
  31. package/build/features/app/entity/entityStore.js +212 -295
  32. package/build/features/bank/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +3 -2
  33. package/build/features/brand/Brand.d.ts +7 -0
  34. package/build/features/brand/Brand.js +69 -0
  35. package/build/features/brand/index.d.ts +1 -0
  36. package/build/features/brand/index.js +1 -0
  37. package/build/features/{entity/screens/Customers/CustomerLocations.d.ts → brand/screens/BrandActivities/ActivitiesList.d.ts} +34 -61
  38. package/build/features/{entity/screens/EntityInfoConfirm → brand/screens/BrandActivities}/ActivitiesList.js +59 -40
  39. package/build/features/brand/screens/BrandActivities/BrandActivities.d.ts +5 -0
  40. package/build/features/brand/screens/BrandActivities/BrandActivities.js +72 -0
  41. package/build/features/brand/screens/BrandActivities/CustomerBase.d.ts +82 -0
  42. package/build/features/{entity/screens/Customers/CustomerLocations.js → brand/screens/BrandActivities/CustomerBase.js} +8 -35
  43. package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/ExpectedCustomers.d.ts +0 -0
  44. package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/ExpectedCustomers.js +6 -6
  45. package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/ExpectedSalesRange.d.ts +0 -0
  46. package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/ExpectedSalesRange.js +6 -6
  47. package/build/features/brand/screens/BrandActivities/OperationStartDate.d.ts +20 -0
  48. package/build/features/brand/screens/BrandActivities/OperationStartDate.js +45 -0
  49. package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/RefundPolicy.d.ts +0 -0
  50. package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/RefundPolicy.js +2 -2
  51. package/build/features/brand/screens/BrandActivities/TAC.d.ts +6 -0
  52. package/build/features/brand/screens/BrandActivities/TAC.js +87 -0
  53. package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/TransactionPolicy.d.ts +0 -0
  54. package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/TransactionPolicy.js +0 -0
  55. package/build/features/brand/screens/BrandActivities/index.d.ts +2 -0
  56. package/build/features/brand/screens/BrandActivities/index.js +2 -0
  57. package/build/features/brand/screens/BrandActivities/validation.d.ts +71 -0
  58. package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/validation.js +9 -1
  59. package/build/features/brand/screens/BrandInfo/BrandInfo.d.ts +5 -0
  60. package/build/features/brand/screens/BrandInfo/BrandInfo.js +72 -0
  61. package/build/features/brand/screens/BrandInfo/BrandName.d.ts +8 -0
  62. package/build/features/brand/screens/BrandInfo/BrandName.js +142 -0
  63. package/build/features/brand/screens/BrandInfo/SalesChannels.d.ts +5 -0
  64. package/build/features/brand/screens/BrandInfo/SalesChannels.js +30 -0
  65. package/build/features/brand/screens/BrandInfo/Segments.d.ts +8 -0
  66. package/build/features/brand/screens/BrandInfo/Segments.js +83 -0
  67. package/build/features/brand/screens/BrandInfo/TeamSize.d.ts +8 -0
  68. package/build/features/brand/screens/BrandInfo/TeamSize.js +83 -0
  69. package/build/features/brand/screens/BrandInfo/index.d.ts +2 -0
  70. package/build/features/brand/screens/BrandInfo/index.js +2 -0
  71. package/build/features/brand/screens/BrandInfo/validation.d.ts +41 -0
  72. package/build/features/brand/screens/BrandInfo/validation.js +106 -0
  73. package/build/features/brand/screens/ResetPasswordSuccess/ResetPasswordSuccess.d.ts +5 -0
  74. package/build/features/brand/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +9 -0
  75. package/build/features/brand/screens/ResetPasswordSuccess/index.d.ts +3 -0
  76. package/build/features/brand/screens/ResetPasswordSuccess/index.js +2 -0
  77. package/build/features/brand/screens/Success/Success.d.ts +5 -0
  78. package/build/features/brand/screens/Success/Success.js +20 -0
  79. package/build/features/brand/screens/Success/index.d.ts +3 -0
  80. package/build/features/brand/screens/Success/index.js +2 -0
  81. package/build/features/brand/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.d.ts +3 -0
  82. package/build/features/brand/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +117 -0
  83. package/build/features/brand/screens/SuccessWithFlowButtons/index.d.ts +2 -0
  84. package/build/features/brand/screens/SuccessWithFlowButtons/index.js +2 -0
  85. package/build/features/brand/screens/Verify/OTPInput.d.ts +7 -0
  86. package/build/features/brand/screens/Verify/OTPInput.js +47 -0
  87. package/build/features/brand/screens/Verify/Verify.d.ts +5 -0
  88. package/build/features/brand/screens/Verify/Verify.js +91 -0
  89. package/build/features/brand/screens/Verify/index.d.ts +2 -0
  90. package/build/features/brand/screens/Verify/index.js +2 -0
  91. package/build/features/brand/screens/Verify/validation.d.ts +8 -0
  92. package/build/features/brand/screens/Verify/validation.js +4 -0
  93. package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +4 -2
  94. package/build/features/connect/screens/Merchant/validation.js +2 -2
  95. package/build/features/entity/screens/EntityCapital/ActivityList.d.ts +90 -0
  96. package/build/features/entity/screens/EntityCapital/ActivityList.js +178 -0
  97. package/build/features/entity/screens/EntityCapital/CapitalPaid.d.ts +5 -0
  98. package/build/features/entity/screens/EntityCapital/CapitalPaid.js +47 -0
  99. package/build/features/entity/screens/EntityCapital/CapitalShareCount.d.ts +5 -0
  100. package/build/features/entity/screens/EntityCapital/CapitalShareCount.js +42 -0
  101. package/build/features/entity/screens/EntityCapital/CapitalShareValue.d.ts +5 -0
  102. package/build/features/entity/screens/EntityCapital/CapitalShareValue.js +47 -0
  103. package/build/features/entity/screens/EntityCapital/EntityCapital.d.ts +5 -0
  104. package/build/features/entity/screens/EntityCapital/EntityCapital.js +75 -0
  105. package/build/features/entity/screens/EntityCapital/index.d.ts +2 -0
  106. package/build/features/entity/screens/EntityCapital/index.js +2 -0
  107. package/build/features/entity/screens/EntityCapital/validation.d.ts +62 -0
  108. package/build/features/entity/screens/EntityCapital/validation.js +25 -0
  109. package/build/features/entity/screens/EntityName/EntityName.d.ts +5 -0
  110. package/build/features/entity/screens/EntityName/EntityName.js +87 -0
  111. package/build/features/entity/screens/EntityName/EntityTypeList.d.ts +90 -0
  112. package/build/features/entity/screens/EntityName/EntityTypeList.js +151 -0
  113. package/build/features/entity/screens/EntityName/ExpiryDate.d.ts +19 -0
  114. package/build/features/entity/screens/EntityName/ExpiryDate.js +46 -0
  115. package/build/features/entity/screens/EntityName/IssuingDate.d.ts +19 -0
  116. package/build/features/entity/screens/EntityName/IssuingDate.js +46 -0
  117. package/build/features/entity/screens/EntityName/LegalName.d.ts +5 -0
  118. package/build/features/entity/screens/EntityName/LegalName.js +48 -0
  119. package/build/features/entity/screens/{EntityInfoConfirm → EntityName}/LicenseNumber.d.ts +0 -0
  120. package/build/features/entity/screens/{EntityInfoConfirm → EntityName}/LicenseNumber.js +12 -18
  121. package/build/features/entity/screens/EntityName/UnifiedNumber.d.ts +6 -0
  122. package/build/features/entity/screens/EntityName/UnifiedNumber.js +43 -0
  123. package/build/features/entity/screens/EntityName/index.d.ts +2 -0
  124. package/build/features/entity/screens/EntityName/index.js +2 -0
  125. package/build/features/entity/screens/EntityName/validation.d.ts +48 -0
  126. package/build/features/entity/screens/EntityName/validation.js +112 -0
  127. package/build/features/featuresScreens.d.ts +1 -0
  128. package/build/features/featuresScreens.js +35 -6
  129. package/build/features/individual/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +4 -2
  130. package/build/features/password/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +4 -2
  131. package/build/features/shared/AcceptancePayouts/AcceptancePayouts.js +1 -1
  132. package/build/features/shared/Address/Address.d.ts +11 -0
  133. package/build/features/shared/Address/Address.js +63 -0
  134. package/build/features/shared/Address/CountryList.d.ts +72 -0
  135. package/build/features/shared/Address/CountryList.js +89 -0
  136. package/build/features/{entity/screens/EntityInfoConfirm/ActivitiesList.d.ts → shared/Address/InputSelect.d.ts} +27 -11
  137. package/build/features/shared/Address/InputSelect.js +172 -0
  138. package/build/features/shared/Address/InputText.d.ts +11 -0
  139. package/build/features/shared/Address/InputText.js +12 -0
  140. package/build/features/shared/Address/index.d.ts +2 -0
  141. package/build/features/shared/Address/index.js +2 -0
  142. package/build/features/shared/Input/Input.d.ts +7 -5
  143. package/build/features/shared/Input/Input.js +2 -2
  144. package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +4 -2
  145. package/build/hooks/useAppDispatch.d.ts +1 -0
  146. package/build/index.d.ts +3 -2
  147. package/build/index.js +4 -1
  148. package/package.json +1 -1
  149. package/build/api/ip.d.ts +0 -4
  150. package/build/api/ip.js +0 -12
  151. package/build/features/entity/screens/Customers/Customers.d.ts +0 -5
  152. package/build/features/entity/screens/Customers/Customers.js +0 -90
  153. package/build/features/entity/screens/Customers/index.d.ts +0 -3
  154. package/build/features/entity/screens/Customers/index.js +0 -2
  155. package/build/features/entity/screens/Customers/validation.d.ts +0 -20
  156. package/build/features/entity/screens/EntityInfoConfirm/Article.d.ts +0 -3
  157. package/build/features/entity/screens/EntityInfoConfirm/Article.js +0 -76
  158. package/build/features/entity/screens/EntityInfoConfirm/EntityInfo.d.ts +0 -5
  159. package/build/features/entity/screens/EntityInfoConfirm/EntityInfo.js +0 -84
  160. package/build/features/entity/screens/EntityInfoConfirm/LicenseName.d.ts +0 -5
  161. package/build/features/entity/screens/EntityInfoConfirm/LicenseName.js +0 -32
  162. package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.d.ts +0 -6
  163. package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.js +0 -33
  164. package/build/features/entity/screens/EntityInfoConfirm/index.d.ts +0 -2
  165. package/build/features/entity/screens/EntityInfoConfirm/index.js +0 -2
  166. package/build/features/entity/screens/EntityInfoConfirm/validation.d.ts +0 -141
  167. package/build/features/entity/screens/EntityInfoConfirm/validation.js +0 -83
@@ -0,0 +1,618 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var _a;
49
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
+ import API from '../../../api';
51
+ import { FlowsTypes } from '../../../@types';
52
+ import { handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
53
+ import { BRAND_STEP_NAMES } from '../../../constants';
54
+ import { isKW, isSA, isTwitter, isWebsite } from '../../../utils';
55
+ export var verifyLeadToken = createAsyncThunk('brandVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
56
+ var payload, data, countryIso2, board_id, boardInfoData, boardData, segmentsList, salesChannels, teamSizeList;
57
+ var _a, _b, _c;
58
+ return __generator(this, function (_d) {
59
+ switch (_d.label) {
60
+ case 0:
61
+ payload = {
62
+ service_name: 'tap_email',
63
+ verify_token: token
64
+ };
65
+ return [4, API.leadService.verifyLeadToken(payload)];
66
+ case 1:
67
+ data = (_d.sent()).data;
68
+ if ((data === null || data === void 0 ? void 0 : data.errors) && (data === null || data === void 0 ? void 0 : data.mw_error)) {
69
+ throw new Error(data.errors[0].description);
70
+ }
71
+ countryIso2 = data === null || data === void 0 ? void 0 : data.country_code;
72
+ if (countryIso2)
73
+ thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
74
+ board_id = data === null || data === void 0 ? void 0 : data.id;
75
+ if (!board_id) {
76
+ throw new Error('Internal server error');
77
+ }
78
+ return [4, API.boardService.retrieveBoardInfoStatus(board_id)];
79
+ case 2:
80
+ boardInfoData = _d.sent();
81
+ return [4, API.boardService.retrieveBoardDetails(board_id)];
82
+ case 3:
83
+ boardData = _d.sent();
84
+ if (!countryIso2) {
85
+ countryIso2 = (_a = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _a === void 0 ? void 0 : _a.country;
86
+ if (countryIso2)
87
+ thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
88
+ }
89
+ return [4, API.dataService.getSegments({ page: 0 })];
90
+ case 4:
91
+ segmentsList = _d.sent();
92
+ return [4, API.dataService.getChannelsOfServices({ page: 0 })];
93
+ case 5:
94
+ salesChannels = _d.sent();
95
+ return [4, API.dataService.getTeamSize({ page: 0 })];
96
+ case 6:
97
+ teamSizeList = _d.sent();
98
+ thunkApi.dispatch(handleNextScreenStep('BRAND_INFO_STEP'));
99
+ return [2, {
100
+ data: data,
101
+ boardResponse: {
102
+ user: boardData === null || boardData === void 0 ? void 0 : boardData.user,
103
+ brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand,
104
+ entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity,
105
+ bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account,
106
+ merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
107
+ name: (_b = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _b === void 0 ? void 0 : _b.names,
108
+ contact: (_c = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _c === void 0 ? void 0 : _c.contact,
109
+ flows: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info
110
+ },
111
+ salesChannels: salesChannels,
112
+ segmentsList: segmentsList === null || segmentsList === void 0 ? void 0 : segmentsList.list,
113
+ teamSizeList: teamSizeList === null || teamSizeList === void 0 ? void 0 : teamSizeList.list,
114
+ token: token
115
+ }];
116
+ }
117
+ });
118
+ }); });
119
+ export var resendOTP = createAsyncThunk('brandResendOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
120
+ var brand, payload, data;
121
+ return __generator(this, function (_a) {
122
+ switch (_a.label) {
123
+ case 0:
124
+ brand = thunkApi.getState().brand;
125
+ payload = {
126
+ service_name: 'tap_email',
127
+ verify_token: brand.data.verify.token
128
+ };
129
+ return [4, API.leadService.verifyLeadToken(payload)];
130
+ case 1:
131
+ data = (_a.sent()).data;
132
+ return [2, { data: data }];
133
+ }
134
+ });
135
+ }); });
136
+ export var verifyBrandLeadOTP = createAsyncThunk('verifyBrandLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
137
+ var _a, brand, settings, responseBody, payload, data, board_id, boardInfoData, boardData, segmentsList, salesChannels, teamSizeList;
138
+ var _b, _c, _d, _e, _f, _g;
139
+ return __generator(this, function (_h) {
140
+ switch (_h.label) {
141
+ case 0:
142
+ _a = thunkApi.getState(), brand = _a.brand, settings = _a.settings;
143
+ responseBody = brand.data.verify.responseBody;
144
+ payload = {
145
+ data: params.otp,
146
+ service_name: (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _b === void 0 ? void 0 : _b.service_name,
147
+ verify_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token,
148
+ step_name: BRAND_STEP_NAMES.PHONE_AUTH,
149
+ encryption_contract: ['data']
150
+ };
151
+ return [4, API.leadService.verifyLeadOTP(payload)];
152
+ case 1:
153
+ data = (_h.sent()).data;
154
+ if ((_c = data.errors) === null || _c === void 0 ? void 0 : _c.length)
155
+ throw new Error(data.errors[0].description);
156
+ board_id = responseBody === null || responseBody === void 0 ? void 0 : responseBody.id;
157
+ if (!board_id) {
158
+ throw new Error('Internal server error');
159
+ }
160
+ return [4, API.boardService.retrieveBoardInfoStatus(board_id)];
161
+ case 2:
162
+ boardInfoData = _h.sent();
163
+ return [4, API.boardService.retrieveBoardDetails(board_id)];
164
+ case 3:
165
+ boardData = _h.sent();
166
+ (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, { otp: params.otp });
167
+ return [4, API.dataService.getSegments({ page: 0 })];
168
+ case 4:
169
+ segmentsList = _h.sent();
170
+ return [4, API.dataService.getChannelsOfServices({ page: 0 })];
171
+ case 5:
172
+ salesChannels = _h.sent();
173
+ return [4, API.dataService.getTeamSize({ page: 0 })];
174
+ case 6:
175
+ teamSizeList = _h.sent();
176
+ thunkApi.dispatch(handleNextScreenStep('BRAND_INFO_STEP'));
177
+ return [2, {
178
+ data: data,
179
+ boardResponse: {
180
+ user: boardData === null || boardData === void 0 ? void 0 : boardData.user,
181
+ brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand,
182
+ entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity,
183
+ bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account,
184
+ merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
185
+ name: (_f = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _f === void 0 ? void 0 : _f.names,
186
+ contact: (_g = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _g === void 0 ? void 0 : _g.contact,
187
+ flows: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info
188
+ },
189
+ salesChannels: salesChannels,
190
+ segmentsList: segmentsList === null || segmentsList === void 0 ? void 0 : segmentsList.list,
191
+ teamSizeList: teamSizeList === null || teamSizeList === void 0 ? void 0 : teamSizeList.list,
192
+ formData: params
193
+ }];
194
+ }
195
+ });
196
+ }); });
197
+ export var retrieveBoardDetails = createAsyncThunk('brandRetrieveBrandInfo', function (boardId) { return __awaiter(void 0, void 0, void 0, function () {
198
+ var data;
199
+ var _a, _b;
200
+ return __generator(this, function (_c) {
201
+ switch (_c.label) {
202
+ case 0: return [4, API.boardService.retrieveBoardDetails(boardId)];
203
+ case 1:
204
+ data = _c.sent();
205
+ return [2, {
206
+ data: __assign(__assign({}, data), { user: data === null || data === void 0 ? void 0 : data.user, brand: data === null || data === void 0 ? void 0 : data.brand, bank_account: data === null || data === void 0 ? void 0 : data.bank_account, entity: data === null || data === void 0 ? void 0 : data.entity, merchant: data === null || data === void 0 ? void 0 : data.merchant, name: (_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.names, contact: (_b = data === null || data === void 0 ? void 0 : data.user) === null || _b === void 0 ? void 0 : _b.contact })
207
+ }];
208
+ }
209
+ });
210
+ }); });
211
+ export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailability', function (_a, thunkApi) {
212
+ var cancelToken = _a.cancelToken, name = _a.name, onSuccess = _a.onSuccess;
213
+ return __awaiter(void 0, void 0, void 0, function () {
214
+ var settings, requestBody, data;
215
+ var _b;
216
+ return __generator(this, function (_c) {
217
+ switch (_c.label) {
218
+ case 0:
219
+ settings = thunkApi.getState().settings;
220
+ requestBody = {
221
+ profile_name: name,
222
+ country_code: (_b = settings.data.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2,
223
+ encryption_contract: ['profile_name']
224
+ };
225
+ return [4, API.availabilityServices.checkBrand(requestBody, { cancelToken: cancelToken })];
226
+ case 1:
227
+ data = (_c.sent()).data;
228
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
229
+ if (!data.errors)
230
+ return [2, { response: data, formData: { name: name } }];
231
+ return [2];
232
+ }
233
+ });
234
+ });
235
+ });
236
+ export var updateBrand = createAsyncThunk('brandUpdateBrand', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
237
+ var _a, settings, brand, id, getAddress, channel_services, requestBody, brandData, activities, activityList;
238
+ var _b, _c, _d, _e, _f, _g, _h, _j;
239
+ return __generator(this, function (_k) {
240
+ switch (_k.label) {
241
+ case 0:
242
+ _a = thunkApi.getState(), settings = _a.settings, brand = _a.brand;
243
+ id = (_c = (_b = brand.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.brand) === null || _c === void 0 ? void 0 : _c.id;
244
+ getAddress = function (value, isTwitter, isWeb) {
245
+ if (isTwitter)
246
+ return '@' + value;
247
+ if (isWeb)
248
+ return 'https://' + value;
249
+ return value;
250
+ };
251
+ channel_services = params.salesChannels.map(function (channel) {
252
+ var _a;
253
+ return {
254
+ id: channel.id,
255
+ address: getAddress(channel.address || '', isTwitter(channel.code), isWebsite(channel.code)),
256
+ sub: (_a = channel.sub) === null || _a === void 0 ? void 0 : _a.map(function (sub) {
257
+ return { id: sub.id, address: getAddress(sub.address || '', isTwitter(sub.code), isWebsite(sub.code)) };
258
+ })
259
+ };
260
+ });
261
+ requestBody = {
262
+ id: id,
263
+ name: { en: params === null || params === void 0 ? void 0 : params.brandName, ar: params === null || params === void 0 ? void 0 : params.brandName },
264
+ segment: { type: ((_d = params.segment) === null || _d === void 0 ? void 0 : _d.id) || '', team: ((_e = params.teamSize) === null || _e === void 0 ? void 0 : _e.id) || '' },
265
+ channel_services: channel_services
266
+ };
267
+ return [4, API.brandService.updateBrandInfo(requestBody)];
268
+ case 1:
269
+ brandData = (_k.sent()).data;
270
+ if ((_f = brandData.errors) === null || _f === void 0 ? void 0 : _f.length)
271
+ throw new Error(brandData.errors[0].description);
272
+ activities = (((_g = brand.data.verify.responseBody) === null || _g === void 0 ? void 0 : _g.entity) || {}).activities;
273
+ return [4, thunkApi.dispatch(retrieveDataList())];
274
+ case 2:
275
+ _k.sent();
276
+ if (!!activities) return [3, 4];
277
+ return [4, API.dataService.getActivities()];
278
+ case 3:
279
+ activityList = (_k.sent()).list;
280
+ brandData = __assign(__assign({}, brandData), { entity_activities: activityList || {} });
281
+ _k.label = 4;
282
+ case 4:
283
+ thunkApi.dispatch(handleNextScreenStep());
284
+ (_j = (_h = settings.data.appConfig).onStepCompleted) === null || _j === void 0 ? void 0 : _j.call(_h, settings.data.activeScreen.name, id);
285
+ return [2, { data: __assign({}, brandData), formData: params }];
286
+ }
287
+ });
288
+ }); });
289
+ export var retrieveEntityList = createAsyncThunk('retrieveEntityList', function (params) { return __awaiter(void 0, void 0, void 0, function () {
290
+ var data;
291
+ return __generator(this, function (_a) {
292
+ switch (_a.label) {
293
+ case 0: return [4, API.leadService.retrieveEntityList(params.leadId)];
294
+ case 1:
295
+ data = (_a.sent()).data;
296
+ return [2, data];
297
+ }
298
+ });
299
+ }); });
300
+ export var updateBrandActivities = createAsyncThunk('brandUpdateBrandActivities', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
301
+ var _a, settings, brand, id, customerLocation, customerBase, sales, stepName, requestBody, brandData;
302
+ var _b, _c, _d, _e, _f, _g, _h;
303
+ return __generator(this, function (_j) {
304
+ switch (_j.label) {
305
+ case 0:
306
+ _a = thunkApi.getState(), settings = _a.settings, brand = _a.brand;
307
+ id = (_c = (_b = brand.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.brand) === null || _c === void 0 ? void 0 : _c.id;
308
+ customerLocation = params.customerLocations.map(function (location) { return ({
309
+ id: location === null || location === void 0 ? void 0 : location.id
310
+ }); });
311
+ customerBase = { id: ((_d = params.expectedCustomer) === null || _d === void 0 ? void 0 : _d.id) || '', period: 'monthly', locations: customerLocation };
312
+ sales = { id: ((_e = params.expectedSale) === null || _e === void 0 ? void 0 : _e.id) || '', period: 'monthly' };
313
+ stepName = BRAND_STEP_NAMES.BRAND_ACTIVITIES;
314
+ requestBody = {
315
+ id: id,
316
+ activities: params.activities,
317
+ operations: {
318
+ customer_base: customerBase,
319
+ sales: sales
320
+ },
321
+ term: ['general', 'refund', 'dispute'],
322
+ step_name: stepName
323
+ };
324
+ return [4, API.brandService.updateBrandInfo(requestBody)];
325
+ case 1:
326
+ brandData = (_j.sent()).data;
327
+ if ((_f = brandData.errors) === null || _f === void 0 ? void 0 : _f.length)
328
+ throw new Error(brandData.errors[0].description);
329
+ return [4, thunkApi.dispatch(retrieveDataList())];
330
+ case 2:
331
+ _j.sent();
332
+ thunkApi.dispatch(handleNextScreenStep());
333
+ (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, id);
334
+ return [2, { data: __assign({}, brandData), formData: params }];
335
+ }
336
+ });
337
+ }); });
338
+ export var retrieveDataList = createAsyncThunk('brandRetrieveDataList', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
339
+ var settings, countryISO2, dataBody, salesDataBody, _a, customerBases, expectedSales, expectedCustomerSales;
340
+ return __generator(this, function (_b) {
341
+ switch (_b.label) {
342
+ case 0:
343
+ settings = thunkApi.getState().settings;
344
+ countryISO2 = settings.data.businessCountry.iso2;
345
+ dataBody = {
346
+ page: 0
347
+ };
348
+ salesDataBody = {
349
+ page: 0,
350
+ country_code: [countryISO2]
351
+ };
352
+ return [4, Promise.all([
353
+ API.dataService.getCustomerBases(dataBody),
354
+ API.dataService.getExpectedSales(salesDataBody),
355
+ API.dataService.getExpectedCustomerSales(dataBody)
356
+ ])];
357
+ case 1:
358
+ _a = _b.sent(), customerBases = _a[0].list, expectedSales = _a[1].list, expectedCustomerSales = _a[2].list;
359
+ return [2, {
360
+ customerBases: customerBases,
361
+ expectedSales: expectedSales,
362
+ expectedCustomerSales: expectedCustomerSales,
363
+ countryISO2: countryISO2
364
+ }];
365
+ }
366
+ });
367
+ }); });
368
+ export var updateBoardSuccess = createAsyncThunk('updateBoardBrandSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
369
+ var _a, settings, brand, _b, id, infoId, payload, data, boardInfoData;
370
+ var _c, _d, _e, _f;
371
+ return __generator(this, function (_g) {
372
+ switch (_g.label) {
373
+ case 0:
374
+ _a = thunkApi.getState(), settings = _a.settings, brand = _a.brand;
375
+ _b = brand.data.verify.responseBody || {}, id = _b.board_id, infoId = _b.board_info_id;
376
+ if (!id)
377
+ return [2];
378
+ payload = {
379
+ lang: settings.data.language,
380
+ step_name: BRAND_STEP_NAMES.BRAND_SUCCESS,
381
+ id: id
382
+ };
383
+ return [4, API.boardService.updateBoardInfo(__assign({ id: id, infoId: infoId }, payload))];
384
+ case 1:
385
+ data = _g.sent();
386
+ return [4, API.boardService.retrieveBoardInfoStatus(id)];
387
+ case 2:
388
+ boardInfoData = _g.sent();
389
+ return [4, thunkApi.dispatch(retrieveBoardDetails(id))];
390
+ case 3:
391
+ _g.sent();
392
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
393
+ (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
394
+ thunkApi.dispatch(handleNextScreenStep());
395
+ return [2, { response: __assign(__assign({}, data), { flows: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info }), formData: params }];
396
+ }
397
+ });
398
+ }); });
399
+ var initialState = {
400
+ error: null,
401
+ loading: false,
402
+ customLoading: false,
403
+ uploading: false,
404
+ data: {
405
+ flowName: FlowsTypes.BRAND,
406
+ verify: {
407
+ token: ''
408
+ },
409
+ otpData: {
410
+ otp: ''
411
+ },
412
+ brandData: {
413
+ brandName: '',
414
+ salesChannels: [],
415
+ termAndConditionChecked: false,
416
+ selectedBrandItem: {}
417
+ },
418
+ brandActivities: {
419
+ activities: [],
420
+ customerLocations: [],
421
+ expectedCustomer: undefined,
422
+ expectedSale: undefined,
423
+ termAndConditionChecked: false,
424
+ refundPolicy: false,
425
+ transactionPolicy: false
426
+ }
427
+ }
428
+ };
429
+ export var brandSlice = createSlice({
430
+ name: 'brand/store',
431
+ initialState: initialState,
432
+ reducers: {
433
+ clearError: function (state) {
434
+ state.error = null;
435
+ },
436
+ stopLoader: function (state) {
437
+ state.loading = false;
438
+ },
439
+ resetOTPScreen: function (state) {
440
+ state.data.otpData.otp = '';
441
+ }
442
+ },
443
+ extraReducers: function (builder) {
444
+ builder
445
+ .addCase(verifyLeadToken.pending, function (state) {
446
+ state.error = null;
447
+ state.customLoading = true;
448
+ })
449
+ .addCase(verifyLeadToken.fulfilled, function (state, action) {
450
+ var _a, _b, _c;
451
+ state.error = null;
452
+ state.customLoading = false;
453
+ var _d = action.payload, data = _d.data, token = _d.token, boardResponse = _d.boardResponse, segmentsList = _d.segmentsList, teamSizeList = _d.teamSizeList, salesChannels = _d.salesChannels;
454
+ var brand = boardResponse.brand, entity = boardResponse.entity;
455
+ state.data.brandData.brandName = (_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en;
456
+ var selectedSegment = (_b = segmentsList === null || segmentsList === void 0 ? void 0 : segmentsList.filter(function (segment) {
457
+ var _a;
458
+ return segment.id === ((_a = brand === null || brand === void 0 ? void 0 : brand.segment) === null || _a === void 0 ? void 0 : _a.type);
459
+ })) === null || _b === void 0 ? void 0 : _b[0];
460
+ var selectedTeamSize = (_c = teamSizeList === null || teamSizeList === void 0 ? void 0 : teamSizeList.filter(function (team) {
461
+ var _a;
462
+ return team.id === ((_a = brand === null || brand === void 0 ? void 0 : brand.segment) === null || _a === void 0 ? void 0 : _a.team);
463
+ })) === null || _c === void 0 ? void 0 : _c[0];
464
+ state.data.brandData.segment = selectedSegment;
465
+ state.data.brandData.teamSize = selectedTeamSize;
466
+ state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), state.data.verify.responseBody), boardResponse), { board_id: data.id, channel_list: salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.list, salesChannels: brand === null || brand === void 0 ? void 0 : brand.channel_services, activities: entity === null || entity === void 0 ? void 0 : entity.activities, segmentsList: segmentsList, teamSizeList: teamSizeList });
467
+ state.data.verify.token = token;
468
+ })
469
+ .addCase(verifyLeadToken.rejected, function (state, action) {
470
+ state.error = action.error.message;
471
+ state.customLoading = false;
472
+ })
473
+ .addCase(resendOTP.pending, function (state) {
474
+ state.error = null;
475
+ })
476
+ .addCase(resendOTP.fulfilled, function (state, action) {
477
+ state.error = null;
478
+ var data = action.payload.data;
479
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), data);
480
+ })
481
+ .addCase(resendOTP.rejected, function (state, action) {
482
+ state.error = action.error.message;
483
+ })
484
+ .addCase(verifyBrandLeadOTP.pending, function (state) {
485
+ state.loading = true;
486
+ state.error = null;
487
+ })
488
+ .addCase(verifyBrandLeadOTP.fulfilled, function (state, action) {
489
+ var _a, _b, _c;
490
+ state.loading = false;
491
+ state.error = null;
492
+ var _d = action.payload, data = _d.data, boardResponse = _d.boardResponse, formData = _d.formData, segmentsList = _d.segmentsList, teamSizeList = _d.teamSizeList, salesChannels = _d.salesChannels;
493
+ var brand = boardResponse.brand, entity = boardResponse.entity;
494
+ state.data.otpData = formData;
495
+ state.data.otpData.responseBody = data;
496
+ state.data.brandData.brandName = (_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en;
497
+ var selectedSegment = (_b = segmentsList === null || segmentsList === void 0 ? void 0 : segmentsList.filter(function (segment) {
498
+ var _a;
499
+ return segment.code === ((_a = brand === null || brand === void 0 ? void 0 : brand.segment) === null || _a === void 0 ? void 0 : _a.type);
500
+ })) === null || _b === void 0 ? void 0 : _b[0];
501
+ var selectedTeamSize = (_c = teamSizeList === null || teamSizeList === void 0 ? void 0 : teamSizeList.filter(function (team) {
502
+ var _a;
503
+ return team.id === ((_a = brand === null || brand === void 0 ? void 0 : brand.segment) === null || _a === void 0 ? void 0 : _a.team);
504
+ })) === null || _c === void 0 ? void 0 : _c[0];
505
+ state.data.brandData.segment = selectedSegment;
506
+ state.data.brandData.teamSize = selectedTeamSize;
507
+ state.data.verify.responseBody = __assign(__assign(__assign({}, state.data.verify.responseBody), boardResponse), { board_id: data.id, channel_list: salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.list, activities: entity === null || entity === void 0 ? void 0 : entity.activities, salesChannels: brand === null || brand === void 0 ? void 0 : brand.channel_services, segmentsList: segmentsList, teamSizeList: teamSizeList });
508
+ })
509
+ .addCase(verifyBrandLeadOTP.rejected, function (state, action) {
510
+ state.loading = false;
511
+ state.error = action.error.message;
512
+ })
513
+ .addCase(checkBrandNameAvailability.fulfilled, function (state, action) {
514
+ var _a;
515
+ state.error = null;
516
+ state.data.brandData.responseBody = __assign(__assign({}, state.data.brandData.responseBody), (_a = action.payload) === null || _a === void 0 ? void 0 : _a.response);
517
+ })
518
+ .addCase(checkBrandNameAvailability.pending, function (state) {
519
+ state.error = null;
520
+ })
521
+ .addCase(checkBrandNameAvailability.rejected, function (state, action) {
522
+ if (action.error.message === 'Aborted')
523
+ return;
524
+ state.error = action.error.message;
525
+ })
526
+ .addCase(updateBrand.pending, function (state) {
527
+ state.loading = true;
528
+ state.error = null;
529
+ })
530
+ .addCase(updateBrand.fulfilled, function (state, action) {
531
+ state.loading = false;
532
+ state.error = null;
533
+ var data = action.payload.data;
534
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { activities: data === null || data === void 0 ? void 0 : data.entity_activities });
535
+ })
536
+ .addCase(updateBrandActivities.rejected, function (state, action) {
537
+ state.loading = false;
538
+ state.error = action.error.message;
539
+ })
540
+ .addCase(updateBrandActivities.pending, function (state) {
541
+ state.loading = true;
542
+ state.error = null;
543
+ })
544
+ .addCase(updateBrandActivities.fulfilled, function (state, action) {
545
+ state.loading = false;
546
+ state.error = null;
547
+ })
548
+ .addCase(updateBrand.rejected, function (state, action) {
549
+ state.loading = false;
550
+ state.error = action.error.message;
551
+ })
552
+ .addCase(retrieveDataList.pending, function (state) {
553
+ state.loading = true;
554
+ state.error = null;
555
+ })
556
+ .addCase(retrieveDataList.fulfilled, function (state, action) {
557
+ var _a, _b;
558
+ state.loading = false;
559
+ state.error = null;
560
+ var _c = action.payload, customerBases = _c.customerBases, expectedSales = _c.expectedSales, expectedCustomerSales = _c.expectedCustomerSales, countryISO2 = _c.countryISO2;
561
+ var regional = customerBases.at(1);
562
+ var local = customerBases.at(0);
563
+ var expectedSale = (_b = (_a = expectedSales.at(0)) === null || _a === void 0 ? void 0 : _a.sub) === null || _b === void 0 ? void 0 : _b.at(4);
564
+ var expectedCustomerSale = expectedCustomerSales.at(3);
565
+ state.data.brandActivities.responseBody = __assign(__assign({}, state.data.brandActivities.responseBody), { customerBases: customerBases, expectedSales: expectedSales, expectedCustomerSales: expectedCustomerSales });
566
+ if (local && isKW(countryISO2))
567
+ state.data.brandActivities.customerLocations = [local];
568
+ if (regional && local && isSA(countryISO2))
569
+ state.data.brandActivities.customerLocations = [regional, local];
570
+ if (!!expectedSale)
571
+ state.data.brandActivities.expectedSale = expectedSale;
572
+ if (!!expectedCustomerSale)
573
+ state.data.brandActivities.expectedCustomer = expectedCustomerSale;
574
+ })
575
+ .addCase(retrieveDataList.rejected, function (state, action) {
576
+ state.loading = false;
577
+ state.error = action.error.message;
578
+ })
579
+ .addCase(retrieveBoardDetails.pending, function (state) {
580
+ state.error = null;
581
+ state.loading = true;
582
+ })
583
+ .addCase(retrieveBoardDetails.fulfilled, function (state, action) {
584
+ state.error = null;
585
+ state.loading = false;
586
+ var data = (action.payload || {}).data;
587
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), data);
588
+ })
589
+ .addCase(retrieveBoardDetails.rejected, function (state, action) {
590
+ state.error = action.error.message;
591
+ state.loading = false;
592
+ })
593
+ .addCase(updateBoardSuccess.fulfilled, function (state, action) {
594
+ var _a;
595
+ state.loading = false;
596
+ state.error = null;
597
+ var response = (action.payload || {}).response;
598
+ var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
599
+ if (description) {
600
+ state.error = description;
601
+ return;
602
+ }
603
+ var flows = response.flows;
604
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows });
605
+ })
606
+ .addCase(updateBoardSuccess.pending, function (state) {
607
+ state.loading = true;
608
+ state.error = null;
609
+ })
610
+ .addCase(updateBoardSuccess.rejected, function (state, action) {
611
+ state.loading = false;
612
+ state.error = action.error.message;
613
+ });
614
+ }
615
+ });
616
+ export var clearError = (_a = brandSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen;
617
+ export default brandSlice.reducer;
618
+ export var brandSelector = function (state) { return state.brand; };