@tap-payments/auth-jsconnect 2.5.5 → 2.5.6

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 (92) hide show
  1. package/build/@types/app.d.ts +5 -1
  2. package/build/@types/redux.d.ts +1 -0
  3. package/build/api/data.d.ts +4 -17
  4. package/build/api/data.js +5 -45
  5. package/build/api/entity.d.ts +3 -2
  6. package/build/api/entity.js +12 -4
  7. package/build/api/index.d.ts +5 -21
  8. package/build/components/Providers/ThemeProvider.js +1 -1
  9. package/build/constants/api.d.ts +2 -7
  10. package/build/constants/api.js +5 -15
  11. package/build/constants/app.js +7 -1
  12. package/build/features/app/auth/authStore.js +24 -21
  13. package/build/features/app/bank/bankStore.d.ts +13 -19
  14. package/build/features/app/bank/bankStore.js +183 -165
  15. package/build/features/app/board/boardStore.js +16 -10
  16. package/build/features/app/brand/brandStore.d.ts +17 -31
  17. package/build/features/app/brand/brandStore.js +250 -261
  18. package/build/features/app/business/businessStore.js +16 -16
  19. package/build/features/app/connect/connectStore.js +7 -7
  20. package/build/features/app/connectExpress/connectExpressStore.d.ts +5 -1
  21. package/build/features/app/connectExpress/connectExpressStore.js +64 -27
  22. package/build/features/app/entity/entityStore.d.ts +20 -34
  23. package/build/features/app/entity/entityStore.js +204 -249
  24. package/build/features/app/individual/individualStore.d.ts +17 -36
  25. package/build/features/app/individual/individualStore.js +228 -270
  26. package/build/features/app/password/passwordStore.d.ts +21 -25
  27. package/build/features/app/password/passwordStore.js +203 -220
  28. package/build/features/app/tax/taxStore.d.ts +13 -7
  29. package/build/features/app/tax/taxStore.js +168 -147
  30. package/build/features/auth/Auth.d.ts +0 -2
  31. package/build/features/auth/Auth.js +7 -7
  32. package/build/features/auth/screens/AuthSwitch/AuthSwitch.js +1 -1
  33. package/build/features/bank/Bank.js +5 -3
  34. package/build/features/bank/screens/BankDetails/BankDetails.js +17 -4
  35. package/build/features/board/Board.d.ts +2 -0
  36. package/build/features/board/Board.js +13 -7
  37. package/build/features/board/screens/PrepareDataLoading/PrepareDataLoading.d.ts +4 -0
  38. package/build/features/board/screens/PrepareDataLoading/PrepareDataLoading.js +10 -0
  39. package/build/features/board/screens/PrepareDataLoading/index.d.ts +2 -0
  40. package/build/features/board/screens/PrepareDataLoading/index.js +2 -0
  41. package/build/features/board/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +12 -2
  42. package/build/features/brand/Brand.js +5 -3
  43. package/build/features/brand/screens/BrandActivities/ActivitiesList.d.ts +2 -2
  44. package/build/features/brand/screens/BrandActivities/BrandActivities.js +48 -11
  45. package/build/features/brand/screens/BrandActivities/CustomerBase.d.ts +3 -3
  46. package/build/features/brand/screens/BrandActivities/RefundPolicy.d.ts +2 -2
  47. package/build/features/brand/screens/BrandInfo/BrandInfo.js +22 -4
  48. package/build/features/brand/screens/BrandSegmentInfo/BrandSegmentInfo.js +22 -6
  49. package/build/features/business/Business.js +5 -3
  50. package/build/features/business/screens/Activities/Activities.js +9 -1
  51. package/build/features/business/screens/Activities/ActivitiesList.d.ts +2 -2
  52. package/build/features/business/screens/Activities/OperationStartDate.d.ts +1 -1
  53. package/build/features/business/screens/BrandDetails/SalesChannel.d.ts +1 -1
  54. package/build/features/business/screens/Customers/CustomerLocations.d.ts +3 -3
  55. package/build/features/business/screens/Customers/Customers.js +9 -1
  56. package/build/features/business/screens/Customers/RefundPolicy.d.ts +2 -2
  57. package/build/features/connect/Connect.js +5 -4
  58. package/build/features/connect/screens/BusinessCountry/BusinessCountry.js +7 -1
  59. package/build/features/connectExpress/ConnectExpress.js +5 -4
  60. package/build/features/entity/Entity.js +5 -3
  61. package/build/features/entity/screens/EntityCapital/ActivityList.d.ts +2 -2
  62. package/build/features/entity/screens/EntityCapital/EntityCapital.js +33 -9
  63. package/build/features/entity/screens/EntityName/EntityName.js +31 -14
  64. package/build/features/entity/screens/EntityName/EntityTypeList.d.ts +2 -2
  65. package/build/features/entity/screens/EntityName/ExpiryDate.d.ts +1 -1
  66. package/build/features/entity/screens/EntityName/IssuingDate.d.ts +1 -1
  67. package/build/features/featuresScreens.js +5 -0
  68. package/build/features/individual/Individual.js +5 -3
  69. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.d.ts +1 -1
  70. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +43 -10
  71. package/build/features/individual/screens/IndividualList/IndividualList.d.ts +2 -2
  72. package/build/features/individual/screens/IndividualList/IndividualList.js +7 -0
  73. package/build/features/individual/screens/IndividualList/UserList.js +3 -3
  74. package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.d.ts +1 -1
  75. package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.js +73 -18
  76. package/build/features/password/Password.js +6 -4
  77. package/build/features/shared/Address/CountryList.d.ts +2 -2
  78. package/build/features/shared/Address/InputSelect.d.ts +2 -2
  79. package/build/features/shared/Button/FlowsButtons.js +10 -2
  80. package/build/features/shared/Input/Input.d.ts +1 -1
  81. package/build/features/signIn/SignIn.js +15 -5
  82. package/build/features/tax/Tax.js +5 -3
  83. package/build/features/tax/screens/TaxDetails/TaxDetails.js +7 -2
  84. package/build/hooks/index.d.ts +1 -0
  85. package/build/hooks/index.js +1 -0
  86. package/build/hooks/useAppConfig.js +1 -1
  87. package/build/hooks/useAppTheme.js +4 -3
  88. package/build/hooks/useFormDirtyCheck.d.ts +10 -0
  89. package/build/hooks/useFormDirtyCheck.js +66 -0
  90. package/build/theme/theme.d.ts +1 -1
  91. package/build/theme/theme.js +2 -2
  92. package/package.json +1 -1
@@ -62,14 +62,14 @@ import API from '../../../api';
62
62
  import { FlowsTypes } from '../../../@types';
63
63
  import { handleNextScreenStep, handlePrevScreenStep, handlePublicKey, handleSetCountryByIso2, onCloseComplete } from '../../../app/settings';
64
64
  import { BRAND_STEP_NAMES, EXPECTED_SALES_LIST } from '../../../constants';
65
- import { hasNoneEditableValue, isKW, isTwitter, isWebsite, mapSalesChannel, retrieveIndividualData, sleep } from '../../../utils';
66
- export var verifyLeadToken = createAsyncThunk('brandVerifyLeadToken', function (_a, thunkApi) {
65
+ import { hasNoneEditableValue, isKW, isTwitter, isWebsite, mapSalesChannel, retrieveIndividualData, sendCustomEventToGTM, sleep } from '../../../utils';
66
+ export var verifyLeadToken = createAsyncThunk('brand/verifyLeadToken', function (_a, thunkApi) {
67
67
  var token = _a.token, isInternally = _a.isInternally;
68
68
  return __awaiter(void 0, void 0, void 0, function () {
69
- var payload, data, countryIso2, _b, board_id, board_info_id, config, publicKey, salesChannels, boardData, boardInfoData, individualData, _c, id_1, type_1, serviceCallBack, _d, boardRes, individualRes;
70
- var _e, _f, _g, _h;
71
- return __generator(this, function (_j) {
72
- switch (_j.label) {
69
+ var payload, data, _b, config, brand_id, entity_id, board_id, country_code, publicKey, salesChannels, brandData, data_1;
70
+ var _c, _d, _e;
71
+ return __generator(this, function (_f) {
72
+ switch (_f.label) {
73
73
  case 0:
74
74
  payload = __assign({ service_name: 'tap_email', verify_token: token }, (isInternally && {
75
75
  notification: {
@@ -78,69 +78,47 @@ export var verifyLeadToken = createAsyncThunk('brandVerifyLeadToken', function (
78
78
  }));
79
79
  return [4, API.leadService.verifyLeadToken(payload)];
80
80
  case 1:
81
- data = (_j.sent()).data;
82
- if ((data === null || data === void 0 ? void 0 : data.errors) && (data === null || data === void 0 ? void 0 : data.mw_error)) {
83
- throw new Error(data.errors[0].description);
84
- }
85
- countryIso2 = data === null || data === void 0 ? void 0 : data.country_code;
86
- if (countryIso2)
87
- thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
88
- _b = data || {}, board_id = _b.id, board_info_id = _b.board_info_id, config = _b.config;
81
+ data = (_f.sent()).data;
82
+ if (((_c = data === null || data === void 0 ? void 0 : data.errors) === null || _c === void 0 ? void 0 : _c.length) || (data === null || data === void 0 ? void 0 : data.mw_error))
83
+ throw new Error(data.errors[0].description || (data === null || data === void 0 ? void 0 : data.mw_error));
84
+ _b = data || {}, config = _b.config, brand_id = _b.brand_id, entity_id = _b.entity_id, board_id = _b.id, country_code = _b.country_code;
89
85
  publicKey = config === null || config === void 0 ? void 0 : config.public_key;
90
- if (publicKey) {
86
+ if (country_code)
87
+ thunkApi.dispatch(handleSetCountryByIso2(country_code));
88
+ if (publicKey)
91
89
  thunkApi.dispatch(handlePublicKey(publicKey));
92
- }
93
- if (!board_id) {
94
- throw new Error('Internal server error');
95
- }
96
- individualData = undefined;
90
+ brandData = undefined;
97
91
  if (isInternally)
98
92
  data.step_name = BRAND_STEP_NAMES.BRAND_INFO;
99
93
  if (!(data.step_name !== BRAND_STEP_NAMES.PHONE_AUTH || isInternally)) return [3, 7];
100
- if (!board_info_id) return [3, 3];
101
- return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
94
+ if (!(!brand_id || !country_code)) return [3, 3];
95
+ return [4, API.boardService.retrieveBoardDetails(board_id)];
102
96
  case 2:
103
- boardInfoData = _j.sent();
104
- _j.label = 3;
105
- case 3: return [4, API.boardService.retrieveBoardDetails(board_id)];
97
+ data_1 = _f.sent();
98
+ if (!country_code && ((_d = data_1 === null || data_1 === void 0 ? void 0 : data_1.entity) === null || _d === void 0 ? void 0 : _d.country))
99
+ thunkApi.dispatch(handleSetCountryByIso2(data_1.entity.country));
100
+ if (!((_e = data_1 === null || data_1 === void 0 ? void 0 : data_1.brand) === null || _e === void 0 ? void 0 : _e.id))
101
+ throw new Error('brand_id_missing');
102
+ brandData = data_1 === null || data_1 === void 0 ? void 0 : data_1.brand;
103
+ return [3, 5];
104
+ case 3: return [4, API.brandService.retrieveBrand(brand_id)];
106
105
  case 4:
107
- boardData = _j.sent();
108
- _c = ((_e = boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification) === null || _e === void 0 ? void 0 : _e.recipient) || {}, id_1 = _c.id, type_1 = _c.type;
109
- serviceCallBack = function () { return API.individualService.retrieveIndividual(id_1, type_1); };
110
- return [4, retrieveIndividualData(type_1, boardData, serviceCallBack)];
111
- case 5:
112
- _d = _j.sent(), boardRes = _d.boardRes, individualRes = _d.individualRes;
113
- boardData = boardRes;
114
- individualData = individualRes;
115
- if (!countryIso2 && ((_f = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _f === void 0 ? void 0 : _f.country)) {
116
- countryIso2 = boardData.entity.country;
117
- thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
118
- }
119
- return [4, API.dataService.getChannelsOfServices({ page: 0 })];
106
+ brandData = _f.sent();
107
+ _f.label = 5;
108
+ case 5: return [4, API.dataService.getChannelsOfServices({ page: 0 })];
120
109
  case 6:
121
- salesChannels = _j.sent();
110
+ salesChannels = _f.sent();
122
111
  if (isInternally)
123
112
  sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('BRAND_INFO_STEP')); });
124
113
  else
125
114
  thunkApi.dispatch(handleNextScreenStep('BRAND_INFO_STEP'));
126
- _j.label = 7;
115
+ _f.label = 7;
127
116
  case 7: return [2, {
128
117
  data: data,
129
- individualData: individualData,
130
- boardResponse: {
131
- user: boardData === null || boardData === void 0 ? void 0 : boardData.user,
132
- brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand,
133
- entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity,
134
- bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account,
135
- merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
136
- name: (_g = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _g === void 0 ? void 0 : _g.names,
137
- contact: (_h = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _h === void 0 ? void 0 : _h.contact,
138
- individuals: boardData === null || boardData === void 0 ? void 0 : boardData.individuals,
139
- business: boardData === null || boardData === void 0 ? void 0 : boardData.business,
140
- notification: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification
141
- },
118
+ brandData: brandData === null || brandData === void 0 ? void 0 : brandData.brand,
142
119
  salesChannels: salesChannels,
143
- token: token
120
+ token: token,
121
+ entityInfoId: entity_id
144
122
  }];
145
123
  }
146
124
  });
@@ -163,85 +141,65 @@ export var resendOTP = createAsyncThunk('brandResendOTP', function (params, thun
163
141
  }
164
142
  });
165
143
  }); });
166
- export var verifyBrandLeadOTP = createAsyncThunk('verifyBrandLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
167
- var _a, brand, settings, responseBody, payload, data, countryIso2, publicKey, _b, board_id, board_info_id, boardInfoData, individualData, boardData, _c, id, type, serviceCallBack, _d, boardRes, individualRes, salesChannels;
168
- var _e, _f, _g, _h, _j, _k, _l, _m, _o;
169
- return __generator(this, function (_p) {
170
- switch (_p.label) {
144
+ export var verifyBrandLeadOTP = createAsyncThunk('brand/verifyLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
145
+ var _a, brand, settings, responseBody, payload, data, publicKey, countryIso2, _b, brand_id, entity_id, boardId, brandData, data_2, salesChannels;
146
+ var _c, _d, _e, _f, _g, _h, _j;
147
+ return __generator(this, function (_k) {
148
+ switch (_k.label) {
171
149
  case 0:
172
150
  _a = thunkApi.getState(), brand = _a.brand, settings = _a.settings;
173
151
  responseBody = brand.data.verify.responseBody;
174
152
  payload = {
175
153
  data: params.otp,
176
- service_name: (_e = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _e === void 0 ? void 0 : _e.service_name,
154
+ service_name: (_c = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _c === void 0 ? void 0 : _c.service_name,
177
155
  verify_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token,
178
156
  step_name: BRAND_STEP_NAMES.PHONE_AUTH,
179
157
  encryption_contract: ['data']
180
158
  };
181
159
  return [4, API.leadService.verifyLeadOTP(payload)];
182
160
  case 1:
183
- data = (_p.sent()).data;
184
- if ((_f = data.errors) === null || _f === void 0 ? void 0 : _f.length)
161
+ data = (_k.sent()).data;
162
+ if ((_d = data.errors) === null || _d === void 0 ? void 0 : _d.length)
185
163
  throw new Error(data.errors[0].description);
186
- countryIso2 = data === null || data === void 0 ? void 0 : data.country_code;
164
+ publicKey = (_e = data === null || data === void 0 ? void 0 : data.config) === null || _e === void 0 ? void 0 : _e.public_key;
165
+ countryIso2 = (data === null || data === void 0 ? void 0 : data.country_code) || (responseBody === null || responseBody === void 0 ? void 0 : responseBody.country_code);
166
+ if (publicKey)
167
+ thunkApi.dispatch(handlePublicKey(publicKey));
187
168
  if (countryIso2)
188
169
  thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
189
- publicKey = (_g = data === null || data === void 0 ? void 0 : data.config) === null || _g === void 0 ? void 0 : _g.public_key;
190
- if (publicKey) {
191
- thunkApi.dispatch(handlePublicKey(publicKey));
192
- }
193
- _b = responseBody || {}, board_id = _b.id, board_info_id = _b.board_info_id;
194
- if (!board_id) {
195
- throw new Error('Internal server error');
196
- }
197
- individualData = undefined;
198
- if (!board_info_id) return [3, 3];
199
- return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
170
+ _b = data || {}, brand_id = _b.brand_id, entity_id = _b.entity_id, boardId = _b.id;
171
+ brandData = undefined;
172
+ if (!(!brand_id || !countryIso2)) return [3, 3];
173
+ return [4, API.boardService.retrieveBoardDetails(boardId)];
200
174
  case 2:
201
- boardInfoData = _p.sent();
202
- _p.label = 3;
203
- case 3: return [4, API.boardService.retrieveBoardDetails(board_id)];
175
+ data_2 = _k.sent();
176
+ if (!countryIso2 && ((_f = data_2 === null || data_2 === void 0 ? void 0 : data_2.entity) === null || _f === void 0 ? void 0 : _f.country))
177
+ thunkApi.dispatch(handleSetCountryByIso2(data_2.entity.country));
178
+ if (!((_g = data_2 === null || data_2 === void 0 ? void 0 : data_2.brand) === null || _g === void 0 ? void 0 : _g.id))
179
+ throw new Error('brand_id_missing');
180
+ brandData = data_2;
181
+ return [3, 5];
182
+ case 3: return [4, API.brandService.retrieveBrand(brand_id)];
204
183
  case 4:
205
- boardData = _p.sent();
206
- _c = ((_h = boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification) === null || _h === void 0 ? void 0 : _h.recipient) || {}, id = _c.id, type = _c.type;
207
- serviceCallBack = function () { return API.individualService.retrieveIndividual(id, type); };
208
- return [4, retrieveIndividualData(type, boardData, serviceCallBack)];
209
- case 5:
210
- _d = _p.sent(), boardRes = _d.boardRes, individualRes = _d.individualRes;
211
- boardData = boardRes;
212
- individualData = individualRes;
213
- if (!countryIso2 && ((_j = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _j === void 0 ? void 0 : _j.country)) {
214
- countryIso2 = boardData.entity.country;
215
- thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
216
- }
217
- (_l = (_k = settings.data.appConfig).onStepCompleted) === null || _l === void 0 ? void 0 : _l.call(_k, settings.data.activeScreen.name, { otp: params.otp });
218
- return [4, API.dataService.getChannelsOfServices({ page: 0 })];
184
+ brandData = _k.sent();
185
+ _k.label = 5;
186
+ case 5: return [4, API.dataService.getChannelsOfServices({ page: 0 })];
219
187
  case 6:
220
- salesChannels = _p.sent();
188
+ salesChannels = _k.sent();
189
+ (_j = (_h = settings.data.appConfig).onStepCompleted) === null || _j === void 0 ? void 0 : _j.call(_h, settings.data.activeScreen.name, { otp: params.otp });
221
190
  sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('BRAND_INFO_STEP')); });
222
191
  return [2, {
223
192
  data: data,
224
- individualData: individualData,
225
- boardResponse: {
226
- user: boardData === null || boardData === void 0 ? void 0 : boardData.user,
227
- brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand,
228
- entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity,
229
- bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account,
230
- merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
231
- name: (_m = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _m === void 0 ? void 0 : _m.names,
232
- contact: (_o = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _o === void 0 ? void 0 : _o.contact,
233
- individuals: boardData === null || boardData === void 0 ? void 0 : boardData.individuals,
234
- business: boardData === null || boardData === void 0 ? void 0 : boardData.business,
235
- notification: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification
236
- },
193
+ brandData: brandData === null || brandData === void 0 ? void 0 : brandData.brand,
237
194
  salesChannels: salesChannels,
195
+ entityInfoId: entity_id,
238
196
  formData: params
239
197
  }];
240
198
  }
241
199
  });
242
200
  }); });
243
201
  export var retrieveSegmentDataList = createAsyncThunk('brandRetrieveSegmentDataList', function () { return __awaiter(void 0, void 0, void 0, function () {
244
- var dataBody, _a, segmentLocation, segmentProfit, segmentTech;
202
+ var dataBody, _a, team, location, profit, tech;
245
203
  return __generator(this, function (_b) {
246
204
  switch (_b.label) {
247
205
  case 0:
@@ -249,50 +207,64 @@ export var retrieveSegmentDataList = createAsyncThunk('brandRetrieveSegmentDataL
249
207
  page: 0,
250
208
  limit: 50
251
209
  };
252
- return [4, Promise.all([
253
- API.dataService.getSegmentLocation(dataBody),
254
- API.dataService.getSegmentProfit(dataBody),
255
- API.dataService.getSegmentTech(dataBody)
256
- ])];
210
+ return [4, API.dataService.getSegments(dataBody)];
257
211
  case 1:
258
- _a = _b.sent(), segmentLocation = _a[0].list, segmentProfit = _a[1].list, segmentTech = _a[2].list;
212
+ _a = _b.sent(), team = _a.team, location = _a.location, profit = _a.profit, tech = _a.tech;
259
213
  return [2, {
260
- segmentLocation: segmentLocation,
261
- segmentProfit: segmentProfit,
262
- segmentTech: segmentTech
214
+ segmentLocation: (location === null || location === void 0 ? void 0 : location.list) || [],
215
+ segmentProfit: (profit === null || profit === void 0 ? void 0 : profit.list) || [],
216
+ segmentTech: (tech === null || tech === void 0 ? void 0 : tech.list) || [],
217
+ segmentTeam: (team === null || team === void 0 ? void 0 : team.list) || []
263
218
  }];
264
219
  }
265
220
  });
266
221
  }); });
267
- export var retrieveBoardStatus = createAsyncThunk('brand/retrieveBoardStatus', function (parmas, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
268
- var brand, board_id, data;
269
- return __generator(this, function (_a) {
270
- switch (_a.label) {
222
+ export var retrieveBoardStatus = createAsyncThunk('brand/retrieveBoardStatus', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
223
+ var brand, _a, board_id, board_info_id, recipient, _b, id, type, data;
224
+ return __generator(this, function (_c) {
225
+ switch (_c.label) {
271
226
  case 0:
272
227
  brand = thunkApi.getState().brand;
273
- board_id = (brand.data.verify.responseBody || {}).board_id;
274
- return [4, API.boardService.retrieveBoardInfoStatus(board_id)];
228
+ _a = brand.data.verify.responseBody || {}, board_id = _a.board_id, board_info_id = _a.board_info_id, recipient = _a.recipient;
229
+ if (!board_id || !board_info_id)
230
+ throw new Error('Internal server error');
231
+ _b = recipient || {}, id = _b.id, type = _b.type;
232
+ return [4, Promise.all([
233
+ API.boardService.retrieveBoardInfoStatus(board_id),
234
+ thunkApi.dispatch(retrieveBoardDetails({ boardId: board_id, individualId: id, individualType: type })).unwrap()
235
+ ])];
275
236
  case 1:
276
- data = _a.sent();
237
+ data = (_c.sent())[0];
277
238
  thunkApi.dispatch(handlePrevScreenStep());
278
239
  return [2, { flows: (data === null || data === void 0 ? void 0 : data.info) || [] }];
279
240
  }
280
241
  });
281
242
  }); });
282
- export var retrieveBoardDetails = createAsyncThunk('brandRetrieveBrandInfo', function (boardId) { return __awaiter(void 0, void 0, void 0, function () {
283
- var data;
284
- var _a, _b;
285
- return __generator(this, function (_c) {
286
- switch (_c.label) {
287
- case 0: return [4, API.boardService.retrieveBoardDetails(boardId)];
288
- case 1:
289
- data = _c.sent();
290
- return [2, {
291
- 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, individuals: data === null || data === void 0 ? void 0 : data.individuals, contact: (_b = data === null || data === void 0 ? void 0 : data.user) === null || _b === void 0 ? void 0 : _b.contact, board_status: data === null || data === void 0 ? void 0 : data.status })
292
- }];
293
- }
243
+ export var retrieveBoardDetails = createAsyncThunk('brand/retrieveBoardDetails', function (_a) {
244
+ var boardId = _a.boardId, id = _a.individualId, type = _a.individualType;
245
+ return __awaiter(void 0, void 0, void 0, function () {
246
+ var data, individualData, boardData, serviceCallBack, _b, boardRes, individualRes;
247
+ var _c, _d, _e;
248
+ return __generator(this, function (_f) {
249
+ switch (_f.label) {
250
+ case 0: return [4, API.boardService.retrieveBoardDetails(boardId)];
251
+ case 1:
252
+ data = _f.sent();
253
+ individualData = data === null || data === void 0 ? void 0 : data.user;
254
+ boardData = data;
255
+ if (!(((_c = data === null || data === void 0 ? void 0 : data.user) === null || _c === void 0 ? void 0 : _c.id) !== id)) return [3, 3];
256
+ serviceCallBack = function () { return API.individualService.retrieveIndividual(id, type); };
257
+ return [4, retrieveIndividualData(type, data, serviceCallBack)];
258
+ case 2:
259
+ _b = _f.sent(), boardRes = _b.boardRes, individualRes = _b.individualRes;
260
+ individualData = individualRes;
261
+ boardData = boardRes;
262
+ _f.label = 3;
263
+ case 3: return [2, __assign(__assign({}, boardData), { brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand, bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account, entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity, merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant, name: (_d = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _d === void 0 ? void 0 : _d.names, individuals: boardData === null || boardData === void 0 ? void 0 : boardData.individuals, contact: (_e = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _e === void 0 ? void 0 : _e.contact, user: individualData, board_status: boardData === null || boardData === void 0 ? void 0 : boardData.status })];
264
+ }
265
+ });
294
266
  });
295
- }); });
267
+ });
296
268
  export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailability', function (_a, thunkApi) {
297
269
  var cancelToken = _a.cancelToken, name = _a.name, onSuccess = _a.onSuccess;
298
270
  return __awaiter(void 0, void 0, void 0, function () {
@@ -319,9 +291,9 @@ export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailabi
319
291
  });
320
292
  });
321
293
  export var updateBrand = createAsyncThunk('brandUpdateBrand', function (_a, thunkApi) {
322
- var formData = _a.formData, originalFormData = _a.originalFormData;
294
+ var formData = _a.formData, originalFormData = _a.originalFormData, isDirty = _a.isDirty;
323
295
  return __awaiter(void 0, void 0, void 0, function () {
324
- var _b, settings, brand, brandRes, _c, id, data_status, isNameENNonEditable, isNameARNonEditable, isChannelServicesNonEditable, salesChannels, brandName, brandLogoId, getAddress, channel_services, brandNameIsEditable, requestBody, brandData, _d, segmentLocation, segmentProfit, segmentTech, teamSizeList;
296
+ var _b, settings, brand, brandRes, _c, id, data_status, isNameENNonEditable, isNameARNonEditable, isChannelServicesNonEditable, salesChannels, brandName, brandLogoId, brandData, getAddress, channel_services, brandNameIsEditable, requestBody, brand_1, _d, segmentLocation, segmentProfit, segmentTech, segmentTeam;
325
297
  var _e, _f;
326
298
  return __generator(this, function (_g) {
327
299
  switch (_g.label) {
@@ -333,6 +305,7 @@ export var updateBrand = createAsyncThunk('brandUpdateBrand', function (_a, thun
333
305
  isNameARNonEditable = hasNoneEditableValue(data_status, 'name.ar');
334
306
  isChannelServicesNonEditable = hasNoneEditableValue(data_status, 'channel_services');
335
307
  salesChannels = formData.salesChannels, brandName = formData.brandName, brandLogoId = formData.brandLogoId;
308
+ brandData = brandRes;
336
309
  getAddress = function (value, isTwitter, isWeb) {
337
310
  if (isTwitter)
338
311
  return '@' + value.replaceAll('@', '');
@@ -359,21 +332,21 @@ export var updateBrand = createAsyncThunk('brandUpdateBrand', function (_a, thun
359
332
  ar: !isNameARNonEditable ? brandName : undefined
360
333
  }
361
334
  })), { logo: brandLogoId, channel_services: channel_services });
335
+ if (!isDirty) return [3, 2];
362
336
  return [4, API.brandService.updateBrandInfo(requestBody)];
363
337
  case 1:
364
- brandData = (_g.sent()).brand;
365
- return [4, thunkApi.dispatch(retrieveSegmentDataList()).unwrap()];
366
- case 2:
367
- _d = _g.sent(), segmentLocation = _d.segmentLocation, segmentProfit = _d.segmentProfit, segmentTech = _d.segmentTech;
368
- return [4, API.dataService.getTeamSize({ page: 0 })];
338
+ brand_1 = (_g.sent()).brand;
339
+ brandData = brand_1;
340
+ _g.label = 2;
341
+ case 2: return [4, thunkApi.dispatch(retrieveSegmentDataList()).unwrap()];
369
342
  case 3:
370
- teamSizeList = _g.sent();
343
+ _d = _g.sent(), segmentLocation = _d.segmentLocation, segmentProfit = _d.segmentProfit, segmentTech = _d.segmentTech, segmentTeam = _d.segmentTeam;
371
344
  sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep()); });
372
345
  (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, id);
373
346
  return [2, {
374
347
  data: __assign({}, brandData),
375
348
  formData: originalFormData,
376
- teamSizeList: teamSizeList === null || teamSizeList === void 0 ? void 0 : teamSizeList.list,
349
+ teamSizeList: segmentTeam,
377
350
  segmentLocationList: segmentLocation,
378
351
  segmentProfitList: segmentProfit,
379
352
  segmentTechList: segmentTech
@@ -383,16 +356,16 @@ export var updateBrand = createAsyncThunk('brandUpdateBrand', function (_a, thun
383
356
  });
384
357
  });
385
358
  export var updateSegmentBrand = createAsyncThunk('brandUpdateBrandSegment', function (_a, thunkApi) {
386
- var formData = _a.formData, originalFormData = _a.originalFormData;
359
+ var formData = _a.formData, originalFormData = _a.originalFormData, isDirty = _a.isDirty;
387
360
  return __awaiter(void 0, void 0, void 0, function () {
388
- var _b, settings, brand, brandRes, _c, id, data_status, isSegmentLocationNonEditable, isSegmentProfitNonEditable, isSegmentTechNonEditable, isSegmentTeamsNonEditable, segmentLocation, segmentProfit, segmentTech, teamSize, segmentLocationId, segmentProfitId, segmentTechId, teamSizeId, hasSegment, requestBody, brandData, activities, activityList;
389
- var _d, _e, _f;
361
+ var _b, settings, brand, _c, brandRes, entityInfoId, _d, id, data_status, isSegmentLocationNonEditable, isSegmentProfitNonEditable, isSegmentTechNonEditable, isSegmentTeamsNonEditable, segmentLocation, segmentProfit, segmentTech, teamSize, segmentLocationId, segmentProfitId, segmentTechId, teamSizeId, hasSegment, requestBody, entityData, brandData, brand_2, entity, activityList;
362
+ var _e, _f;
390
363
  return __generator(this, function (_g) {
391
364
  switch (_g.label) {
392
365
  case 0:
393
366
  _b = thunkApi.getState(), settings = _b.settings, brand = _b.brand;
394
- brandRes = (brand.data.verify.responseBody || {}).brand;
395
- _c = brandRes || {}, id = _c.id, data_status = _c.data_status;
367
+ _c = brand.data.verify.responseBody || {}, brandRes = _c.brand, entityInfoId = _c.entityInfoId;
368
+ _d = brandRes || {}, id = _d.id, data_status = _d.data_status;
396
369
  isSegmentLocationNonEditable = hasNoneEditableValue(data_status, 'segment.location_type');
397
370
  isSegmentProfitNonEditable = hasNoneEditableValue(data_status, 'segment.profit_type');
398
371
  isSegmentTechNonEditable = hasNoneEditableValue(data_status, 'segment.tech_type');
@@ -406,26 +379,37 @@ export var updateSegmentBrand = createAsyncThunk('brandUpdateBrandSegment', func
406
379
  requestBody = __assign({ id: id }, (hasSegment && {
407
380
  segment: { location_type: segmentLocationId, profit_type: segmentProfitId, tech_type: segmentTechId, team: teamSizeId }
408
381
  }));
382
+ entityData = undefined;
383
+ brandData = brandRes;
384
+ if (!isDirty) return [3, 2];
409
385
  return [4, API.brandService.updateBrandInfo(requestBody)];
410
386
  case 1:
411
- brandData = (_g.sent()).brand;
412
- activities = (((_d = brand.data.verify.responseBody) === null || _d === void 0 ? void 0 : _d.entity) || {}).activities;
413
- return [4, thunkApi.dispatch(retrieveDataList())];
387
+ brand_2 = (_g.sent()).brand;
388
+ brandData = brand_2;
389
+ _g.label = 2;
414
390
  case 2:
415
- _g.sent();
416
- if (activities) {
417
- brandData = __assign(__assign({}, brandData), { entity_activities: activities || {} });
418
- }
419
- if (!!activities) return [3, 4];
420
- return [4, API.dataService.getActivities()];
391
+ if (!entityInfoId) return [3, 4];
392
+ return [4, API.entityService.retrieveEntity(entityInfoId)];
421
393
  case 3:
422
- activityList = (_g.sent()).list;
423
- brandData = __assign(__assign({}, brandData), { entity_activities: activityList || {} });
394
+ entity = (_g.sent()).entity;
395
+ entityData = entity;
424
396
  _g.label = 4;
425
397
  case 4:
398
+ if (entityData === null || entityData === void 0 ? void 0 : entityData.activities) {
399
+ entityData = __assign(__assign({}, entityData), { entity_activities: entityData.activities });
400
+ }
401
+ if (!!(entityData === null || entityData === void 0 ? void 0 : entityData.activities)) return [3, 6];
402
+ return [4, API.dataService.getActivities()];
403
+ case 5:
404
+ activityList = (_g.sent()).list;
405
+ entityData = __assign(__assign({}, entityData), { entity_activities: activityList });
406
+ _g.label = 6;
407
+ case 6: return [4, thunkApi.dispatch(retrieveDataList())];
408
+ case 7:
409
+ _g.sent();
426
410
  sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep()); });
427
411
  (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, id);
428
- return [2, { data: __assign({}, brandData), formData: originalFormData }];
412
+ return [2, { data: __assign({}, brandData), entityData: entityData, formData: originalFormData }];
429
413
  }
430
414
  });
431
415
  });
@@ -442,15 +426,15 @@ export var retrieveEntityList = createAsyncThunk('retrieveEntityList', function
442
426
  });
443
427
  }); });
444
428
  export var updateBrandActivities = createAsyncThunk('brandUpdateBrandActivities', function (_a, thunkApi) {
445
- var formData = _a.formData, originalFormData = _a.originalFormData;
429
+ var formData = _a.formData, originalFormData = _a.originalFormData, isDirty = _a.isDirty;
446
430
  return __awaiter(void 0, void 0, void 0, function () {
447
- var _b, settings, brand, _c, brandRes, notification, _d, data_status, id, brandActivities, terms, isActivitiesNonEditable, isCustomerBaseLocationNonEditable, isCustomerBaseNonEditable, isTermsNonEditable, isSalesRangeNonEditable, activities, customerLocations, expectedCustomer, expectedSale, termAndConditionChecked, refundPolicy, transactionPolicy, isTermsUndefined, isAllTermsAgreed, isTermsAvailable, removedActivities, payload, requestBody, customerLocation, customerBaseId, salesId, customerBase, brandData;
448
- var _e, _f, _g, _h;
449
- return __generator(this, function (_j) {
450
- switch (_j.label) {
431
+ var _b, settings, brand, _c, brandRes, recipient, _d, data_status, id, brandActivities, terms, isActivitiesNonEditable, isCustomerBaseLocationNonEditable, isCustomerBaseNonEditable, isTermsNonEditable, isSalesRangeNonEditable, activities, customerLocations, expectedCustomer, expectedSale, termAndConditionChecked, refundPolicy, transactionPolicy, isTermsUndefined, isAllTermsAgreed, isTermsAvailable, brandData, removedActivities, payload, requestBody, customerLocation, customerBaseId, salesId, customerBase, brand_3;
432
+ var _e, _f, _g;
433
+ return __generator(this, function (_h) {
434
+ switch (_h.label) {
451
435
  case 0:
452
436
  _b = thunkApi.getState(), settings = _b.settings, brand = _b.brand;
453
- _c = brand.data.verify.responseBody || {}, brandRes = _c.brand, notification = _c.notification;
437
+ _c = brand.data.verify.responseBody || {}, brandRes = _c.brand, recipient = _c.recipient;
454
438
  _d = brandRes || {}, data_status = _d.data_status, id = _d.id, brandActivities = _d.activities, terms = _d.terms;
455
439
  isActivitiesNonEditable = hasNoneEditableValue(data_status, 'activities');
456
440
  isCustomerBaseLocationNonEditable = hasNoneEditableValue(data_status === null || data_status === void 0 ? void 0 : data_status.operations, 'customer_base_location');
@@ -461,9 +445,10 @@ export var updateBrandActivities = createAsyncThunk('brandUpdateBrandActivities'
461
445
  isTermsUndefined = termAndConditionChecked === undefined && refundPolicy === undefined && transactionPolicy === undefined;
462
446
  isAllTermsAgreed = ((_e = terms === null || terms === void 0 ? void 0 : terms.filter(function (t) { return t === null || t === void 0 ? void 0 : t.agree; })) === null || _e === void 0 ? void 0 : _e.length) === 3;
463
447
  isTermsAvailable = !(isTermsNonEditable && isTermsUndefined) && !isAllTermsAgreed;
448
+ brandData = brandRes;
464
449
  removedActivities = (activities === null || activities === void 0 ? void 0 : activities.length) > 0 &&
465
450
  (brandActivities || []).filter(function (brandActivity) { return !(activities || []).some(function (activity) { return activity.id === brandActivity.id; }); });
466
- if (!(!isActivitiesNonEditable && (removedActivities === null || removedActivities === void 0 ? void 0 : removedActivities.length) > 0)) return [3, 2];
451
+ if (!(!isActivitiesNonEditable && (removedActivities === null || removedActivities === void 0 ? void 0 : removedActivities.length) > 0 && isDirty)) return [3, 2];
467
452
  payload = {
468
453
  id: id,
469
454
  activities: removedActivities.map(function (a) { return ({
@@ -472,11 +457,11 @@ export var updateBrandActivities = createAsyncThunk('brandUpdateBrandActivities'
472
457
  };
473
458
  return [4, API.brandService.removeBrandActivity(payload)];
474
459
  case 1:
475
- _j.sent();
476
- _j.label = 2;
460
+ _h.sent();
461
+ _h.label = 2;
477
462
  case 2:
478
463
  requestBody = __assign(__assign({ id: id, activities: isActivitiesNonEditable ? undefined : (activities || []).map(function (a) { return ({ id: a.id }); }) }, (isTermsAvailable && {
479
- term_by: (_f = notification === null || notification === void 0 ? void 0 : notification.recipient) === null || _f === void 0 ? void 0 : _f.id,
464
+ term_by: recipient === null || recipient === void 0 ? void 0 : recipient.id,
480
465
  term: ['general', 'refund', 'chargeback']
481
466
  })), { step_name: BRAND_STEP_NAMES.BRAND_ACTIVITIES });
482
467
  customerLocation = (customerLocations || []).map(function (location) { return ({
@@ -490,80 +475,84 @@ export var updateBrandActivities = createAsyncThunk('brandUpdateBrandActivities'
490
475
  if (salesId && !isSalesRangeNonEditable) {
491
476
  requestBody = __assign(__assign({}, requestBody), { operations: __assign(__assign({}, requestBody.operations), { sales: salesId }) });
492
477
  }
478
+ if (!isDirty) return [3, 4];
493
479
  return [4, API.brandService.updateBrandInfo(requestBody)];
494
480
  case 3:
495
- brandData = (_j.sent()).data;
481
+ brand_3 = (_h.sent()).brand;
482
+ brandData = brand_3;
483
+ _h.label = 4;
484
+ case 4:
496
485
  thunkApi.dispatch(handleNextScreenStep());
497
- (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, id);
486
+ (_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, id);
498
487
  return [2, { data: __assign({}, brandData), formData: originalFormData }];
499
488
  }
500
489
  });
501
490
  });
502
491
  });
503
492
  export var retrieveDataList = createAsyncThunk('brandRetrieveDataList', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
504
- var settings, countryISO2, dataBody, salesDataBody, _a, customerBases, expectedSales, expectedCustomerSales;
505
- return __generator(this, function (_b) {
506
- switch (_b.label) {
493
+ var settings, countryISO2, dataBody, _a, customer_base, sales, expected_customers;
494
+ var _b;
495
+ return __generator(this, function (_c) {
496
+ switch (_c.label) {
507
497
  case 0:
508
498
  settings = thunkApi.getState().settings;
509
499
  countryISO2 = settings.data.businessCountry.iso2;
510
500
  dataBody = {
511
- page: 0
512
- };
513
- salesDataBody = {
514
501
  page: 0,
515
502
  country_code: [countryISO2]
516
503
  };
517
- return [4, Promise.all([
518
- API.dataService.getCustomerBases(dataBody),
519
- API.dataService.getExpectedSales(salesDataBody),
520
- API.dataService.getExpectedCustomerSales(dataBody)
521
- ])];
504
+ return [4, API.dataService.getBrandOperations(dataBody)];
522
505
  case 1:
523
- _a = _b.sent(), customerBases = _a[0].list, expectedSales = _a[1].list, expectedCustomerSales = _a[2].list;
506
+ _a = _c.sent(), customer_base = _a.customer_base, sales = _a.sales, expected_customers = _a.expected_customers;
524
507
  return [2, {
525
- customerBases: customerBases,
526
- expectedSales: (expectedSales === null || expectedSales === void 0 ? void 0 : expectedSales.length) ? expectedSales : EXPECTED_SALES_LIST,
527
- expectedCustomerSales: expectedCustomerSales,
508
+ customerBases: (customer_base === null || customer_base === void 0 ? void 0 : customer_base.list) || [],
509
+ expectedSales: ((_b = sales === null || sales === void 0 ? void 0 : sales.list) === null || _b === void 0 ? void 0 : _b.length) ? sales.list : EXPECTED_SALES_LIST,
510
+ expectedCustomerSales: (expected_customers === null || expected_customers === void 0 ? void 0 : expected_customers.list) || [],
528
511
  countryISO2: countryISO2
529
512
  }];
530
513
  }
531
514
  });
532
515
  }); });
533
516
  export var updateBoardSuccess = createAsyncThunk('updateBoardBrandSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
534
- var _a, settings, brand, _b, id, infoId, _c, showBoard, mode, payload, data, boardInfoData;
535
- var _d, _e, _f, _g, _h, _j, _k, _l;
536
- return __generator(this, function (_m) {
537
- switch (_m.label) {
517
+ var _a, settings, brand, _b, board_id, infoId, _c, showBoard, mode, payload, data, _d, id, type, boardInfoStatusData;
518
+ var _e, _f, _g, _h, _j, _k, _l, _m, _o;
519
+ return __generator(this, function (_p) {
520
+ switch (_p.label) {
538
521
  case 0:
539
522
  _a = thunkApi.getState(), settings = _a.settings, brand = _a.brand;
540
- _b = brand.data.verify.responseBody || {}, id = _b.board_id, infoId = _b.board_info_id;
523
+ _b = brand.data.verify.responseBody || {}, board_id = _b.board_id, infoId = _b.board_info_id;
541
524
  _c = settings.data.appConfig, showBoard = _c.showBoard, mode = _c.mode;
542
- if (!id)
525
+ if (!board_id)
543
526
  return [2];
544
527
  payload = {
545
528
  lang: settings.data.language,
546
- step_name: BRAND_STEP_NAMES.BRAND_SUCCESS,
547
- id: id
529
+ step_name: BRAND_STEP_NAMES.BRAND_SUCCESS
548
530
  };
549
- return [4, API.boardService.updateBoardInfo(__assign({ id: id, infoId: infoId }, payload))];
531
+ return [4, API.boardService.updateBoardInfo(__assign({ id: board_id, infoId: infoId }, payload))];
550
532
  case 1:
551
- data = _m.sent();
533
+ data = _p.sent();
534
+ sendCustomEventToGTM({
535
+ event: 'Send Event',
536
+ event_category: 'Board Flows - Brand',
537
+ event_action: 'Brand Update Success Page',
538
+ event_label: settings.data.businessCountry.iso2
539
+ });
552
540
  if (!showBoard && mode === 'content') {
553
- (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, {});
554
- (_g = (_f = settings.data.appConfig).onFlowCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, { data: data });
555
- return [2, { response: __assign({}, data), formData: params }];
541
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, {});
542
+ (_h = (_g = settings.data.appConfig).onFlowCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, { data: data });
543
+ return [2, { data: data }];
556
544
  }
557
- return [4, API.boardService.retrieveBoardInfoStatus(id)];
545
+ _d = ((_j = data === null || data === void 0 ? void 0 : data.notification) === null || _j === void 0 ? void 0 : _j.recipient) || {}, id = _d.id, type = _d.type;
546
+ return [4, Promise.all([
547
+ API.boardService.retrieveBoardInfoStatus(board_id),
548
+ thunkApi.dispatch(retrieveBoardDetails({ boardId: board_id, individualId: id, individualType: type })).unwrap()
549
+ ])];
558
550
  case 2:
559
- boardInfoData = _m.sent();
560
- return [4, thunkApi.dispatch(retrieveBoardDetails(id)).unwrap()];
561
- case 3:
562
- _m.sent();
563
- (_j = (_h = settings.data.appConfig).onStepCompleted) === null || _j === void 0 ? void 0 : _j.call(_h, settings.data.activeScreen.name, {});
564
- (_l = (_k = settings.data.appConfig).onFlowCompleted) === null || _l === void 0 ? void 0 : _l.call(_k, { data: data });
551
+ boardInfoStatusData = (_p.sent())[0];
552
+ (_l = (_k = settings.data.appConfig).onStepCompleted) === null || _l === void 0 ? void 0 : _l.call(_k, settings.data.activeScreen.name, {});
553
+ (_o = (_m = settings.data.appConfig).onFlowCompleted) === null || _o === void 0 ? void 0 : _o.call(_m, { data: data });
565
554
  thunkApi.dispatch(handleNextScreenStep());
566
- return [2, { response: __assign(__assign({}, data), { flows: (boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) || [] }), formData: params }];
555
+ return [2, { data: data, flows: (boardInfoStatusData === null || boardInfoStatusData === void 0 ? void 0 : boardInfoStatusData.info) || [] }];
567
556
  }
568
557
  });
569
558
  }); });
@@ -644,22 +633,18 @@ export var brandSlice = createSlice({
644
633
  state.customLoading = true;
645
634
  })
646
635
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
647
- var _a, _b;
636
+ var _a, _b, _c;
648
637
  state.error = null;
649
638
  state.customLoading = false;
650
- var _c = action.payload, data = _c.data, token = _c.token, boardResponse = _c.boardResponse, salesChannels = _c.salesChannels, individualData = _c.individualData;
651
- var brand = boardResponse.brand, entity = boardResponse.entity;
639
+ var _d = action.payload, data = _d.data, brand = _d.brandData, token = _d.token, salesChannels = _d.salesChannels, entityInfoId = _d.entityInfoId;
652
640
  state.data.brandData.brandName = (((_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en) || '').trim();
653
- (_b = brand === null || brand === void 0 ? void 0 : brand.terms) === null || _b === void 0 ? void 0 : _b.forEach(function (element) {
654
- if ((element === null || element === void 0 ? void 0 : element.term) === 'general') {
655
- state.data.brandActivities.termAndConditionChecked = element.agree;
656
- state.data.brandActivities.transactionPolicy = element.agree;
657
- state.data.brandActivities.refundPolicy = element.agree;
658
- }
659
- });
641
+ var termFlag = ((_c = (_b = brand === null || brand === void 0 ? void 0 : brand.terms) === null || _b === void 0 ? void 0 : _b.find(function (element) { return (element === null || element === void 0 ? void 0 : element.term) === 'general'; })) === null || _c === void 0 ? void 0 : _c.agree) || false;
642
+ state.data.brandActivities.termAndConditionChecked = termFlag;
643
+ state.data.brandActivities.transactionPolicy = termFlag;
644
+ state.data.brandActivities.refundPolicy = termFlag;
660
645
  var mappedSalesChannels = mapSalesChannel((brand === null || brand === void 0 ? void 0 : brand.channel_services) || []);
661
646
  state.data.brandData.salesChannels = mappedSalesChannels;
662
- 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: mappedSalesChannels, activities: entity === null || entity === void 0 ? void 0 : entity.activities, individualData: individualData });
647
+ state.data.verify.responseBody = __assign(__assign(__assign({}, data), state.data.verify.responseBody), { brand: brand, board_id: data.id, channel_list: (salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.list) || [], salesChannels: mappedSalesChannels, entityInfoId: entityInfoId });
663
648
  state.data.verify.token = token;
664
649
  })
665
650
  .addCase(verifyLeadToken.rejected, function (state, action) {
@@ -682,24 +667,20 @@ export var brandSlice = createSlice({
682
667
  state.error = null;
683
668
  })
684
669
  .addCase(verifyBrandLeadOTP.fulfilled, function (state, action) {
685
- var _a, _b;
670
+ var _a, _b, _c;
686
671
  state.loading = false;
687
672
  state.error = null;
688
- var _c = action.payload, data = _c.data, boardResponse = _c.boardResponse, formData = _c.formData, salesChannels = _c.salesChannels, individualData = _c.individualData;
689
- var brand = boardResponse.brand, entity = boardResponse.entity;
673
+ var _d = action.payload, data = _d.data, brand = _d.brandData, formData = _d.formData, salesChannels = _d.salesChannels, entityInfoId = _d.entityInfoId;
690
674
  state.data.otpData = formData;
691
675
  state.data.otpData.responseBody = data;
692
676
  state.data.brandData.brandName = (((_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en) || '').trim();
693
677
  var mappedSalesChannels = mapSalesChannel((brand === null || brand === void 0 ? void 0 : brand.channel_services) || []);
694
678
  state.data.brandData.salesChannels = mappedSalesChannels;
695
- (_b = brand === null || brand === void 0 ? void 0 : brand.terms) === null || _b === void 0 ? void 0 : _b.forEach(function (element) {
696
- if ((element === null || element === void 0 ? void 0 : element.term) === 'general') {
697
- state.data.brandActivities.termAndConditionChecked = element.agree;
698
- state.data.brandActivities.transactionPolicy = element.agree;
699
- state.data.brandActivities.refundPolicy = element.agree;
700
- }
701
- });
702
- 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: mappedSalesChannels, individualData: individualData });
679
+ var termFlag = ((_c = (_b = brand === null || brand === void 0 ? void 0 : brand.terms) === null || _b === void 0 ? void 0 : _b.find(function (element) { return (element === null || element === void 0 ? void 0 : element.term) === 'general'; })) === null || _c === void 0 ? void 0 : _c.agree) || false;
680
+ state.data.brandActivities.termAndConditionChecked = termFlag;
681
+ state.data.brandActivities.transactionPolicy = termFlag;
682
+ state.data.brandActivities.refundPolicy = termFlag;
683
+ state.data.verify.responseBody = __assign(__assign(__assign({}, data), state.data.verify.responseBody), { brand: brand, board_id: data.id, channel_list: (salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.list) || [], salesChannels: mappedSalesChannels, entityInfoId: entityInfoId });
703
684
  })
704
685
  .addCase(verifyBrandLeadOTP.rejected, function (state, action) {
705
686
  state.loading = false;
@@ -728,27 +709,32 @@ export var brandSlice = createSlice({
728
709
  var _a = action.payload, data = _a.data, formData = _a.formData, segmentLocationList = _a.segmentLocationList, segmentProfitList = _a.segmentProfitList, segmentTechList = _a.segmentTechList, teamSizeList = _a.teamSizeList;
729
710
  var segment = data.segment;
730
711
  state.data.brandData = formData;
731
- var selectedSegmentLocation = segmentLocationList === null || segmentLocationList === void 0 ? void 0 : segmentLocationList.find(function (location) {
712
+ var selectedSegmentLocation = (segmentLocationList === null || segmentLocationList === void 0 ? void 0 : segmentLocationList.find(function (location) {
732
713
  var _a;
733
714
  return location.id === ((_a = segment === null || segment === void 0 ? void 0 : segment.location_type) === null || _a === void 0 ? void 0 : _a.id);
734
- });
735
- var selectedSegmentProfit = segmentProfitList === null || segmentProfitList === void 0 ? void 0 : segmentProfitList.find(function (profit) {
715
+ })) || (segmentLocationList === null || segmentLocationList === void 0 ? void 0 : segmentLocationList[0]);
716
+ var selectedSegmentProfit = (segmentProfitList === null || segmentProfitList === void 0 ? void 0 : segmentProfitList.find(function (profit) {
736
717
  var _a;
737
718
  return profit.id === ((_a = segment === null || segment === void 0 ? void 0 : segment.profit_type) === null || _a === void 0 ? void 0 : _a.id);
738
- });
739
- var selectedSegmentTech = segmentTechList === null || segmentTechList === void 0 ? void 0 : segmentTechList.find(function (tech) {
719
+ })) || (segmentProfitList === null || segmentProfitList === void 0 ? void 0 : segmentProfitList[0]);
720
+ var selectedSegmentTech = (segmentTechList === null || segmentTechList === void 0 ? void 0 : segmentTechList.find(function (tech) {
740
721
  var _a;
741
722
  return tech.id === ((_a = segment === null || segment === void 0 ? void 0 : segment.tech_type) === null || _a === void 0 ? void 0 : _a.id);
742
- });
723
+ })) || (segmentTechList === null || segmentTechList === void 0 ? void 0 : segmentTechList[1]);
743
724
  var selectedTeamSize = teamSizeList === null || teamSizeList === void 0 ? void 0 : teamSizeList.find(function (team) {
744
725
  var _a;
745
726
  return team.id === ((_a = segment === null || segment === void 0 ? void 0 : segment.team) === null || _a === void 0 ? void 0 : _a.id);
746
727
  });
747
- state.data.brandSegmentData.segmentLocation = selectedSegmentLocation || (segmentLocationList === null || segmentLocationList === void 0 ? void 0 : segmentLocationList[0]);
748
- state.data.brandSegmentData.segmentProfit = selectedSegmentProfit || (segmentProfitList === null || segmentProfitList === void 0 ? void 0 : segmentProfitList[0]);
749
- state.data.brandSegmentData.segmentTech = selectedSegmentTech || (segmentTechList === null || segmentTechList === void 0 ? void 0 : segmentTechList[1]);
728
+ state.data.brandSegmentData.segmentLocation = selectedSegmentLocation;
729
+ state.data.brandSegmentData.segmentProfit = selectedSegmentProfit;
730
+ state.data.brandSegmentData.segmentTech = selectedSegmentTech;
750
731
  state.data.brandSegmentData.teamSize = selectedTeamSize;
751
- state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { teamSizeList: teamSizeList, segmentLocationList: segmentLocationList, segmentProfitList: segmentProfitList, segmentTechList: segmentTechList });
732
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { brand: data, teamSizeList: teamSizeList, segmentLocationList: segmentLocationList, segmentProfitList: segmentProfitList, segmentTechList: segmentTechList, segmentDefaultValues: {
733
+ segmentLocation: selectedSegmentLocation,
734
+ segmentProfit: selectedSegmentProfit,
735
+ segmentTech: selectedSegmentTech,
736
+ teamSize: selectedTeamSize
737
+ } });
752
738
  })
753
739
  .addCase(updateBrand.rejected, function (state, action) {
754
740
  state.loading = false;
@@ -759,31 +745,38 @@ export var brandSlice = createSlice({
759
745
  state.error = null;
760
746
  })
761
747
  .addCase(updateSegmentBrand.fulfilled, function (state, action) {
748
+ var _a;
762
749
  state.loading = false;
763
750
  state.error = null;
764
- var _a = action.payload, data = _a.data, formData = _a.formData;
765
- var entity_activities = data.entity_activities, activities = data.activities, operations = data.operations, terms = data.terms;
751
+ var _b = action.payload, data = _b.data, entityData = _b.entityData, formData = _b.formData;
752
+ var activities = data.activities, operations = data.operations, terms = data.terms;
753
+ var entity_activities = (entityData || {}).entity_activities;
766
754
  var selectedActivity = entity_activities === null || entity_activities === void 0 ? void 0 : entity_activities.filter(function (activity) {
767
755
  return activities === null || activities === void 0 ? void 0 : activities.find(function (value) { return activity.id === value.id; });
768
756
  });
769
757
  state.data.brandSegmentData = formData;
770
758
  state.data.brandActivities.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [];
771
- var _b = operations || {}, customer_base = _b.customer_base, sales = _b.sales;
772
- var _c = customer_base || {}, locations = _c.locations, customerBase = __rest(_c, ["locations"]);
759
+ var _c = operations || {}, customer_base = _c.customer_base, sales = _c.sales;
760
+ var _d = customer_base || {}, locations = _d.locations, customerBase = __rest(_d, ["locations"]);
773
761
  if (locations && locations.length)
774
762
  state.data.brandActivities.customerLocations = locations;
775
763
  if (!!sales)
776
764
  state.data.brandActivities.expectedSale = sales;
777
765
  if (!!customerBase)
778
766
  state.data.brandActivities.expectedCustomer = customerBase;
779
- terms === null || terms === void 0 ? void 0 : terms.forEach(function (element) {
780
- if ((element === null || element === void 0 ? void 0 : element.term) === 'general') {
781
- state.data.brandActivities.termAndConditionChecked = element.agree;
782
- state.data.brandActivities.transactionPolicy = element.agree;
783
- state.data.brandActivities.refundPolicy = element.agree;
784
- }
785
- });
786
- state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { activities: entity_activities });
767
+ var termFlag = ((_a = terms === null || terms === void 0 ? void 0 : terms.find(function (element) { return (element === null || element === void 0 ? void 0 : element.term) === 'general'; })) === null || _a === void 0 ? void 0 : _a.agree) || false;
768
+ state.data.brandActivities.termAndConditionChecked = termFlag;
769
+ state.data.brandActivities.transactionPolicy = termFlag;
770
+ state.data.brandActivities.refundPolicy = termFlag;
771
+ state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, state.data.verify.responseBody), { activities: entity_activities }), (entityData && { entity: entityData })), { activitiesDefaultValues: {
772
+ activities: selectedActivity,
773
+ customerLocations: locations,
774
+ expectedSale: sales,
775
+ expectedCustomer: customerBase,
776
+ termAndConditionChecked: termFlag,
777
+ transactionPolicy: termFlag,
778
+ refundPolicy: termFlag
779
+ }, segmentDefaultValues: formData });
787
780
  })
788
781
  .addCase(updateSegmentBrand.rejected, function (state, action) {
789
782
  state.loading = false;
@@ -837,7 +830,7 @@ export var brandSlice = createSlice({
837
830
  .addCase(retrieveBoardDetails.fulfilled, function (state, action) {
838
831
  state.error = null;
839
832
  state.loading = false;
840
- var data = (action.payload || {}).data;
833
+ var data = action.payload || {};
841
834
  state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), data);
842
835
  })
843
836
  .addCase(retrieveBoardDetails.rejected, function (state, action) {
@@ -851,7 +844,7 @@ export var brandSlice = createSlice({
851
844
  .addCase(retrieveBoardStatus.fulfilled, function (state, action) {
852
845
  state.error = null;
853
846
  state.loading = false;
854
- var flows = action.payload.flows;
847
+ var flows = (action.payload || {}).flows;
855
848
  state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows });
856
849
  })
857
850
  .addCase(retrieveBoardStatus.rejected, function (state, action) {
@@ -862,12 +855,8 @@ export var brandSlice = createSlice({
862
855
  var _a;
863
856
  state.loading = false;
864
857
  state.error = null;
865
- var flows = (((_a = action.payload) === null || _a === void 0 ? void 0 : _a.response) || {}).flows;
866
- var _b = state.data.verify.responseBody || {}, individuals = _b.individuals, individualData = _b.individualData;
867
- var data_state = (((individualData === null || individualData === void 0 ? void 0 : individualData.is_authorized) ? individuals : individualData) || {}).data_state;
868
- state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, state.data.verify.responseBody), { flows: flows }), (individualData && { user: individualData })), (data_state && {
869
- individuals: __assign(__assign({}, individuals), { data_state: data_state })
870
- }));
858
+ var _b = action.payload || {}, flows = _b.flows, data = _b.data;
859
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows, recipient: (_a = data === null || data === void 0 ? void 0 : data.notification) === null || _a === void 0 ? void 0 : _a.recipient });
871
860
  })
872
861
  .addCase(updateBoardSuccess.pending, function (state) {
873
862
  state.loading = true;