@tap-payments/auth-jsconnect 2.0.45 → 2.0.46

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 (203) hide show
  1. package/build/@types/app.d.ts +47 -2
  2. package/build/@types/app.js +22 -0
  3. package/build/@types/form.d.ts +19 -1
  4. package/build/@types/index.d.ts +1 -0
  5. package/build/@types/index.js +1 -0
  6. package/build/@types/user.d.ts +141 -0
  7. package/build/@types/user.js +1 -0
  8. package/build/api/board.d.ts +16 -0
  9. package/build/api/board.js +10 -1
  10. package/build/api/country.d.ts +4 -0
  11. package/build/api/country.js +9 -1
  12. package/build/api/entity.d.ts +3 -3
  13. package/build/api/index.d.ts +8 -3
  14. package/build/api/individual.d.ts +54 -4
  15. package/build/api/individual.js +9 -1
  16. package/build/api/user.d.ts +6 -0
  17. package/build/api/user.js +9 -1
  18. package/build/app/settings.js +11 -8
  19. package/build/assets/locales/ar.json +28 -2
  20. package/build/assets/locales/en.json +28 -1
  21. package/build/components/SimpleList/SimpleList.d.ts +2 -0
  22. package/build/constants/api.d.ts +1 -0
  23. package/build/constants/api.js +3 -1
  24. package/build/constants/app.d.ts +1 -0
  25. package/build/constants/app.js +20 -7
  26. package/build/constants/assets.d.ts +4 -0
  27. package/build/constants/assets.js +4 -0
  28. package/build/features/app/bank/bankStore.d.ts +1 -0
  29. package/build/features/app/bank/bankStore.js +19 -13
  30. package/build/features/app/brand/brandStore.d.ts +2 -0
  31. package/build/features/app/brand/brandStore.js +69 -49
  32. package/build/features/app/business/businessStore.js +3 -3
  33. package/build/features/app/connect/connectStore.js +6 -6
  34. package/build/features/app/connectExpress/connectExpressStore.js +15 -9
  35. package/build/features/app/entity/entityStore.d.ts +2 -0
  36. package/build/features/app/entity/entityStore.js +5 -3
  37. package/build/features/app/individual/individualStore.d.ts +93 -4
  38. package/build/features/app/individual/individualStore.js +613 -129
  39. package/build/features/app/password/passwordStore.js +2 -2
  40. package/build/features/app/tax/taxStore.js +30 -29
  41. package/build/features/bank/Bank.js +2 -2
  42. package/build/features/bank/screens/BankDetails/BankDetails.js +8 -7
  43. package/build/features/bank/screens/BankDetails/BankName.js +13 -10
  44. package/build/features/bank/screens/BankDetails/BankStatement.js +8 -2
  45. package/build/features/bank/screens/BankDetails/Beneficiary.js +12 -13
  46. package/build/features/bank/screens/BankDetails/IBAN.js +14 -10
  47. package/build/features/bank/screens/BankDetails/validation.d.ts +14 -14
  48. package/build/features/bank/screens/BankDetails/validation.js +34 -15
  49. package/build/features/bank/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  50. package/build/features/brand/Brand.js +2 -2
  51. package/build/features/brand/screens/BrandActivities/ActivitiesList.d.ts +3 -3
  52. package/build/features/brand/screens/BrandActivities/ActivitiesList.js +8 -6
  53. package/build/features/brand/screens/BrandActivities/BrandActivities.js +12 -2
  54. package/build/features/brand/screens/BrandActivities/CustomerBase.d.ts +2 -2
  55. package/build/features/brand/screens/BrandActivities/CustomerBase.js +9 -6
  56. package/build/features/brand/screens/BrandActivities/ExpectedSalesRange.js +10 -7
  57. package/build/features/brand/screens/BrandActivities/validation.d.ts +7 -7
  58. package/build/features/brand/screens/BrandActivities/validation.js +26 -15
  59. package/build/features/brand/screens/BrandInfo/BrandInfo.js +11 -4
  60. package/build/features/brand/screens/BrandInfo/BrandName.js +13 -12
  61. package/build/features/brand/screens/BrandInfo/SalesChannels.js +21 -9
  62. package/build/features/brand/screens/BrandInfo/validation.d.ts +7 -7
  63. package/build/features/brand/screens/BrandInfo/validation.js +46 -36
  64. package/build/features/brand/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  65. package/build/features/business/Business.js +2 -2
  66. package/build/features/business/screens/Activities/ActivitiesList.d.ts +3 -3
  67. package/build/features/business/screens/BusinessType/LicenseCertificate.js +2 -1
  68. package/build/features/business/screens/BusinessType/LicenseType.d.ts +2 -2
  69. package/build/features/business/screens/Customers/CustomerLocations.d.ts +2 -2
  70. package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  71. package/build/features/connect/Connect.js +2 -2
  72. package/build/features/connect/screens/Merchant/BrandList.js +4 -4
  73. package/build/features/connect/screens/Merchant/BrandName.js +6 -5
  74. package/build/features/connect/screens/Merchant/validation.js +2 -2
  75. package/build/features/connectExpress/ConnectExpress.js +2 -2
  76. package/build/features/connectExpress/screens/CollectBusinessInfo/BrandName.js +1 -3
  77. package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseType.d.ts +2 -2
  78. package/build/features/connectExpress/screens/CollectBusinessInfo/validation.js +5 -5
  79. package/build/features/connectExpress/screens/CreateAccountLoader/CreateAccountLoader.js +23 -3
  80. package/build/features/connectExpress/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +3 -3
  81. package/build/features/entity/Entity.js +2 -2
  82. package/build/features/entity/screens/EntityCapital/ActivityList.d.ts +3 -3
  83. package/build/features/entity/screens/EntityName/EntityTypeList.d.ts +3 -3
  84. package/build/features/entity/screens/EntityName/LicenseCertificate.js +9 -3
  85. package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  86. package/build/features/featuresScreens.js +10 -0
  87. package/build/features/individual/Individual.js +2 -2
  88. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.d.ts +13 -0
  89. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +48 -25
  90. package/build/features/individual/screens/AdditionalIndividualInfo/CivilIDFile.js +6 -1
  91. package/build/features/individual/screens/AdditionalIndividualInfo/InfluencerSwitch.js +9 -2
  92. package/build/features/individual/screens/AdditionalIndividualInfo/MonthlyIncome.js +11 -17
  93. package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +12 -16
  94. package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.d.ts +2 -2
  95. package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.js +9 -2
  96. package/build/features/individual/screens/AdditionalIndividualInfo/ShareCount.d.ts +6 -0
  97. package/build/features/individual/screens/AdditionalIndividualInfo/ShareCount.js +35 -0
  98. package/build/features/individual/screens/AdditionalIndividualInfo/ShareValue.d.ts +6 -0
  99. package/build/features/individual/screens/AdditionalIndividualInfo/ShareValue.js +41 -0
  100. package/build/features/individual/screens/AdditionalIndividualInfo/SignatureFile.js +8 -2
  101. package/build/features/individual/screens/AdditionalIndividualInfo/SourceOfIncome.js +9 -6
  102. package/build/features/individual/screens/AdditionalIndividualInfo/validation.d.ts +25 -23
  103. package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +19 -25
  104. package/build/features/individual/screens/IndividualList/CollectPhoneEmail.d.ts +10 -0
  105. package/build/features/individual/screens/IndividualList/CollectPhoneEmail.js +31 -0
  106. package/build/features/individual/screens/IndividualList/Email.d.ts +6 -0
  107. package/build/features/individual/screens/IndividualList/Email.js +48 -0
  108. package/build/features/individual/screens/IndividualList/IndividualList.d.ts +31 -0
  109. package/build/features/individual/screens/IndividualList/IndividualList.js +58 -0
  110. package/build/features/individual/screens/IndividualList/MobileNumber.d.ts +12 -0
  111. package/build/features/individual/screens/IndividualList/MobileNumber.js +143 -0
  112. package/build/features/individual/screens/IndividualList/UserList.d.ts +5 -0
  113. package/build/features/individual/screens/IndividualList/UserList.js +186 -0
  114. package/build/features/individual/screens/IndividualList/index.d.ts +3 -0
  115. package/build/features/individual/screens/IndividualList/index.js +2 -0
  116. package/build/features/individual/screens/IndividualList/validation.d.ts +12 -0
  117. package/build/features/individual/screens/IndividualList/validation.js +39 -0
  118. package/build/features/individual/screens/IndividualPersonalInfo/BirthCity.d.ts +8 -0
  119. package/build/features/individual/screens/IndividualPersonalInfo/BirthCity.js +109 -0
  120. package/build/features/individual/screens/{AdditionalIndividualInfo/EmployerLocation.d.ts → IndividualPersonalInfo/BirthCountry.d.ts} +2 -2
  121. package/build/features/individual/screens/{AdditionalIndividualInfo/EmployerLocation.js → IndividualPersonalInfo/BirthCountry.js} +14 -24
  122. package/build/features/individual/screens/IndividualPersonalInfo/DOB.d.ts +7 -0
  123. package/build/features/individual/screens/IndividualPersonalInfo/DOB.js +46 -0
  124. package/build/features/individual/screens/IndividualPersonalInfo/Email.d.ts +6 -0
  125. package/build/features/individual/screens/IndividualPersonalInfo/Email.js +50 -0
  126. package/build/features/individual/screens/IndividualPersonalInfo/ExpiryDate.d.ts +7 -0
  127. package/build/features/individual/screens/IndividualPersonalInfo/ExpiryDate.js +50 -0
  128. package/build/features/individual/screens/IndividualPersonalInfo/Gender.d.ts +34 -0
  129. package/build/features/individual/screens/IndividualPersonalInfo/Gender.js +81 -0
  130. package/build/features/individual/screens/IndividualPersonalInfo/ID.d.ts +6 -0
  131. package/build/features/individual/screens/IndividualPersonalInfo/ID.js +48 -0
  132. package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.d.ts +21 -0
  133. package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.js +139 -0
  134. package/build/features/individual/screens/IndividualPersonalInfo/IssuedCountry.d.ts +10 -0
  135. package/build/features/individual/screens/IndividualPersonalInfo/IssuedCountry.js +88 -0
  136. package/build/features/individual/screens/IndividualPersonalInfo/MobileNumber.d.ts +10 -0
  137. package/build/features/individual/screens/IndividualPersonalInfo/MobileNumber.js +145 -0
  138. package/build/features/individual/screens/IndividualPersonalInfo/Name.d.ts +6 -0
  139. package/build/features/individual/screens/IndividualPersonalInfo/Name.js +52 -0
  140. package/build/features/individual/screens/IndividualPersonalInfo/Nationality.d.ts +10 -0
  141. package/build/features/individual/screens/IndividualPersonalInfo/Nationality.js +88 -0
  142. package/build/features/individual/screens/IndividualPersonalInfo/index.d.ts +3 -0
  143. package/build/features/individual/screens/IndividualPersonalInfo/index.js +2 -0
  144. package/build/features/individual/screens/IndividualPersonalInfo/validation.d.ts +38 -0
  145. package/build/features/individual/screens/IndividualPersonalInfo/validation.js +68 -0
  146. package/build/features/individual/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  147. package/build/features/individual/screens/Verify/Verify.js +10 -17
  148. package/build/features/password/Password.js +2 -2
  149. package/build/features/password/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  150. package/build/features/shared/Address/Address.d.ts +6 -1
  151. package/build/features/shared/Address/Address.js +40 -30
  152. package/build/features/shared/Address/CountryList.d.ts +1 -1
  153. package/build/features/shared/Address/InputSelect.d.ts +1 -1
  154. package/build/features/shared/Address/InputText.d.ts +2 -1
  155. package/build/features/shared/Address/InputText.js +2 -2
  156. package/build/features/shared/Button/Button.js +11 -0
  157. package/build/features/shared/Button/FlowsButtons.d.ts +1 -0
  158. package/build/features/shared/Button/FlowsButtons.js +5 -5
  159. package/build/features/shared/Button/ListButton.d.ts +18 -0
  160. package/build/features/shared/Button/ListButton.js +125 -0
  161. package/build/features/shared/Button/index.d.ts +2 -1
  162. package/build/features/shared/Button/index.js +2 -1
  163. package/build/features/shared/CreateAccountLoading/CreateAccountLoading.d.ts +2 -1
  164. package/build/features/shared/CreateAccountLoading/CreateAccountLoading.js +2 -2
  165. package/build/features/shared/SalesChannels/SalesChannel.d.ts +2 -1
  166. package/build/features/shared/SalesChannels/SalesChannel.js +2 -2
  167. package/build/features/shared/SuccessFlowButtons/SuccessFlowButtons.d.ts +2 -1
  168. package/build/features/shared/SuccessFlowButtons/SuccessFlowButtons.js +8 -6
  169. package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +6 -1
  170. package/build/features/shared/UploadMultipleFile/UploadMultipleFile.js +33 -11
  171. package/build/features/signIn/SignIn.js +2 -2
  172. package/build/features/tax/Tax.js +2 -2
  173. package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  174. package/build/features/tax/screens/TaxDetails/TaxDetails.js +2 -1
  175. package/build/features/tax/screens/TaxDetails/TaxDocument.js +8 -2
  176. package/build/features/tax/screens/TaxDetails/VATId.js +8 -3
  177. package/build/features/tax/screens/TaxDetails/validation.d.ts +4 -4
  178. package/build/features/tax/screens/TaxDetails/validation.js +10 -5
  179. package/build/utils/array.d.ts +1 -0
  180. package/build/utils/array.js +10 -2
  181. package/build/utils/common.d.ts +1 -0
  182. package/build/utils/common.js +6 -0
  183. package/build/utils/date.d.ts +1 -0
  184. package/build/utils/date.js +7 -1
  185. package/build/utils/error.d.ts +1 -0
  186. package/build/utils/error.js +3 -0
  187. package/build/utils/html.d.ts +1 -1
  188. package/build/utils/html.js +4 -1
  189. package/build/utils/index.d.ts +1 -0
  190. package/build/utils/index.js +1 -0
  191. package/build/utils/string.d.ts +15 -2
  192. package/build/utils/string.js +37 -3
  193. package/build/utils/validation.d.ts +1 -0
  194. package/build/utils/validation.js +3 -0
  195. package/package.json +129 -129
  196. package/build/features/individual/screens/AdditionalIndividualInfo/EmployerName.d.ts +0 -6
  197. package/build/features/individual/screens/AdditionalIndividualInfo/EmployerName.js +0 -46
  198. package/build/features/individual/screens/ShowIndividualInfo/ShowOwnerInfo.d.ts +0 -19
  199. package/build/features/individual/screens/ShowIndividualInfo/ShowOwnerInfo.js +0 -52
  200. package/build/features/individual/screens/ShowIndividualInfo/index.d.ts +0 -3
  201. package/build/features/individual/screens/ShowIndividualInfo/index.js +0 -2
  202. package/build/features/individual/screens/ShowIndividualInfo/info.d.ts +0 -7
  203. package/build/features/individual/screens/ShowIndividualInfo/info.js +0 -28
@@ -45,19 +45,40 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
47
  };
48
+ var __rest = (this && this.__rest) || function (s, e) {
49
+ var t = {};
50
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
+ t[p] = s[p];
52
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
+ t[p[i]] = s[p[i]];
56
+ }
57
+ return t;
58
+ };
59
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
60
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
61
+ if (ar || !(i in from)) {
62
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
63
+ ar[i] = from[i];
64
+ }
65
+ }
66
+ return to.concat(ar || Array.prototype.slice.call(from));
67
+ };
48
68
  var _a;
49
69
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
70
  import API from '../../../api';
51
- import { FlowsTypes } from '../../../@types';
71
+ import { FlowsTypes, IndividualGender, IndividualType, FieldType } from '../../../@types';
52
72
  import { handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
53
- import { INDIVIDUAl_STEP_NAMES } from '../../../constants';
73
+ import { defaultCountry, IDENTIFICATION_TYPE, INDIVIDUAl_STEP_NAMES } from '../../../constants';
74
+ import { convertNumbers2English, dateFormat, findCountryByIddPrefix, findCountryByIso2, getEighteenYearsAgo, getUserNameObject, getUserName, sleep, isValidEmail } from '../../../utils';
54
75
  export var verifyLeadToken = createAsyncThunk('individualVerifyLeadToken', function (_a, thunkApi) {
55
76
  var token = _a.token, isInternally = _a.isInternally;
56
77
  return __awaiter(void 0, void 0, void 0, function () {
57
- var payload, settings, data, boardData, individualData, countryCode, boardInfoData, boardInfoStatus, countries, board_id, board_info_id, notification, _b, id, type, info, hasIndividualCompleted;
58
- var _c, _d, _e, _f;
59
- return __generator(this, function (_g) {
60
- switch (_g.label) {
78
+ var payload, settings, data, boardData, individualData, countryCode, boardInfoData, boardInfoStatus, countries, board_id, board_info_id, notification, _b, id, type, payload_1, info, hasIndividualCompleted, birthCountry;
79
+ var _c, _d, _e, _f, _g, _h, _j, _k;
80
+ return __generator(this, function (_l) {
81
+ switch (_l.label) {
61
82
  case 0:
62
83
  payload = {
63
84
  service_name: 'tap_email',
@@ -66,70 +87,83 @@ export var verifyLeadToken = createAsyncThunk('individualVerifyLeadToken', funct
66
87
  settings = thunkApi.getState().settings;
67
88
  return [4, API.leadService.verifyLeadToken(payload)];
68
89
  case 1:
69
- data = (_g.sent()).data;
90
+ data = (_l.sent()).data;
70
91
  boardInfoStatus = undefined;
71
92
  countries = settings.data.countries;
72
- if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 11];
93
+ if (((_c = data.errors) === null || _c === void 0 ? void 0 : _c.length) || (data === null || data === void 0 ? void 0 : data.mw_error))
94
+ throw new Error(data.errors[0].description || (data === null || data === void 0 ? void 0 : data.mw_error));
73
95
  if (isInternally)
74
96
  data.step_name = INDIVIDUAl_STEP_NAMES.INDIVIDUAl_INFO;
75
97
  if (data === null || data === void 0 ? void 0 : data.country_code) {
76
98
  countryCode = data === null || data === void 0 ? void 0 : data.country_code;
77
99
  thunkApi.dispatch(handleSetCountryByIso2(countryCode));
78
100
  }
79
- if (!(data.step_name !== INDIVIDUAl_STEP_NAMES.PHONE_AUTH)) return [3, 11];
101
+ if (!(data.step_name !== INDIVIDUAl_STEP_NAMES.PHONE_AUTH)) return [3, 14];
80
102
  board_id = data === null || data === void 0 ? void 0 : data.id;
81
103
  board_info_id = data === null || data === void 0 ? void 0 : data.board_info_id;
82
104
  if (!(board_id && board_info_id)) return [3, 4];
83
105
  return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
84
106
  case 2:
85
- boardInfoData = _g.sent();
107
+ boardInfoData = _l.sent();
86
108
  notification = (boardInfoData || {}).notification;
87
109
  _b = (notification === null || notification === void 0 ? void 0 : notification.recipient) || {}, id = _b.id, type = _b.type;
88
110
  if (!(id && type)) return [3, 4];
89
- return [4, API.individualService.retrieveIndividual(id, type)];
111
+ return [4, thunkApi.dispatch(retrieveIndividualInfo({ id: id, type: type, countryCode: countryCode }))];
90
112
  case 3:
91
- individualData = _g.sent();
92
- _g.label = 4;
113
+ payload_1 = (_l.sent()).payload;
114
+ individualData = payload_1.data || {};
115
+ _l.label = 4;
93
116
  case 4:
94
117
  if (!board_id) return [3, 7];
95
118
  return [4, API.boardService.retrieveBoardDetails(board_id)];
96
119
  case 5:
97
- boardData = _g.sent();
120
+ boardData = _l.sent();
98
121
  return [4, API.boardService.retrieveBoardInfoStatus(board_id)];
99
122
  case 6:
100
- boardInfoStatus = _g.sent();
101
- _g.label = 7;
123
+ boardInfoStatus = _l.sent();
124
+ _l.label = 7;
102
125
  case 7:
103
126
  if (!countryCode) {
104
- countryCode = (_c = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _c === void 0 ? void 0 : _c.country;
127
+ countryCode = (_d = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _d === void 0 ? void 0 : _d.country;
105
128
  if (countryCode)
106
129
  thunkApi.dispatch(handleSetCountryByIso2(countryCode));
107
130
  }
108
131
  info = (boardInfoStatus || {}).info;
109
- hasIndividualCompleted = ((_d = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'individual'; })) === null || _d === void 0 ? void 0 : _d.status) === 'completed';
132
+ hasIndividualCompleted = ((_e = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'individual'; })) === null || _e === void 0 ? void 0 : _e.status) === 'completed';
110
133
  if (!hasIndividualCompleted) return [3, 8];
111
134
  thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
112
- return [3, 11];
135
+ return [3, 14];
113
136
  case 8:
114
- if (!countryCode) return [3, 10];
115
- return [4, thunkApi.dispatch(retrieveDataList(countryCode))];
137
+ if (!(individualData === null || individualData === void 0 ? void 0 : individualData.is_authorized)) return [3, 11];
138
+ if (!((_f = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _f === void 0 ? void 0 : _f.id)) return [3, 10];
139
+ return [4, thunkApi.dispatch(getIndividualList((_g = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _g === void 0 ? void 0 : _g.id))];
116
140
  case 9:
117
- _g.sent();
118
- _g.label = 10;
141
+ _l.sent();
142
+ _l.label = 10;
119
143
  case 10:
120
- thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_ADDITIONAL_INDIVIDUAL_INFO_STEP'));
121
- _g.label = 11;
122
- case 11: return [2, {
144
+ thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_LIST_STEP'));
145
+ return [3, 14];
146
+ case 11:
147
+ birthCountry = ((_h = individualData === null || individualData === void 0 ? void 0 : individualData.birth) === null || _h === void 0 ? void 0 : _h.country) || countryCode;
148
+ if (!birthCountry) return [3, 13];
149
+ return [4, thunkApi.dispatch(getCityList(birthCountry))];
150
+ case 12:
151
+ _l.sent();
152
+ _l.label = 13;
153
+ case 13:
154
+ thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_PERSONAL_INDIVIDUAL_INFO_STEP'));
155
+ _l.label = 14;
156
+ case 14: return [2, {
123
157
  data: data,
124
158
  boardResponse: {
125
- user: individualData === null || individualData === void 0 ? void 0 : individualData.user,
126
159
  brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand,
127
160
  bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account,
128
161
  entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity,
129
162
  merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
130
163
  merchant_id: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.merchant_id,
131
- name: (_e = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _e === void 0 ? void 0 : _e.names,
132
- contact: (_f = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _f === void 0 ? void 0 : _f.contact,
164
+ name: (_j = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _j === void 0 ? void 0 : _j.names,
165
+ contact: (_k = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _k === void 0 ? void 0 : _k.contact,
166
+ individuals: boardData === null || boardData === void 0 ? void 0 : boardData.individuals,
133
167
  countries: countries,
134
168
  countryCode: countryCode,
135
169
  notification: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification,
@@ -158,6 +192,154 @@ export var resendOTP = createAsyncThunk('resendOTPIndividual', function (params,
158
192
  }
159
193
  });
160
194
  }); });
195
+ export var addDetailsAsync = createAsyncThunk('individual/addDetailsAsync', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
196
+ var settings, user, userList, id, type, birth, countryCode;
197
+ return __generator(this, function (_a) {
198
+ switch (_a.label) {
199
+ case 0:
200
+ settings = thunkApi.getState().settings;
201
+ user = params.user, userList = params.userList;
202
+ id = user.id, type = user.type, birth = user.birth;
203
+ countryCode = (birth === null || birth === void 0 ? void 0 : birth.country) || settings.data.businessCountry.iso2;
204
+ if (!countryCode) return [3, 2];
205
+ return [4, thunkApi.dispatch(getCityList(countryCode))];
206
+ case 1:
207
+ _a.sent();
208
+ _a.label = 2;
209
+ case 2: return [4, thunkApi.dispatch(retrieveIndividualInfo({ id: id, type: type }))];
210
+ case 3:
211
+ _a.sent();
212
+ sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_PERSONAL_INDIVIDUAL_INFO_STEP')); });
213
+ return [2, { userList: userList }];
214
+ }
215
+ });
216
+ }); });
217
+ export var requestDetailsByEmail = createAsyncThunk('individual/requestDetailsByEmail', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
218
+ var individual, _a, merchant_id, board_id, user, collectInfo, id, type, _b, resEmail, resPhone, isPhoneAndEmailAvailable, email, mobile, countryCode, hasContact, individualData, hasPhone, requestBody, data_1, payload, data;
219
+ var _c;
220
+ return __generator(this, function (_d) {
221
+ switch (_d.label) {
222
+ case 0:
223
+ individual = thunkApi.getState().individual;
224
+ _a = individual.data.verify.responseBody || {}, merchant_id = _a.merchant_id, board_id = _a.board_id;
225
+ user = params.user, collectInfo = params.collectInfo;
226
+ id = user.id, type = user.type;
227
+ _b = (user === null || user === void 0 ? void 0 : user.contact) || {}, resEmail = _b.email, resPhone = _b.phone;
228
+ isPhoneAndEmailAvailable = isValidEmail(resEmail) && (resPhone === null || resPhone === void 0 ? void 0 : resPhone.country_code) && (resPhone === null || resPhone === void 0 ? void 0 : resPhone.number);
229
+ email = collectInfo.email, mobile = collectInfo.mobile, countryCode = collectInfo.countryCode;
230
+ hasContact = !!email || !!mobile;
231
+ individualData = undefined;
232
+ if (!(!isPhoneAndEmailAvailable && hasContact)) return [3, 2];
233
+ hasPhone = mobile && (countryCode === null || countryCode === void 0 ? void 0 : countryCode.idd_prefix);
234
+ requestBody = {
235
+ id: id,
236
+ type: type,
237
+ contact: {
238
+ email: email,
239
+ phone: hasPhone
240
+ ? {
241
+ country_code: (_c = countryCode === null || countryCode === void 0 ? void 0 : countryCode.idd_prefix) === null || _c === void 0 ? void 0 : _c.toString(),
242
+ number: mobile
243
+ }
244
+ : undefined
245
+ }
246
+ };
247
+ return [4, API.individualService.updateIndividual(requestBody)];
248
+ case 1:
249
+ data_1 = _d.sent();
250
+ individualData = data_1 === null || data_1 === void 0 ? void 0 : data_1.user;
251
+ if (type === IndividualType.SHARE_HOLDER)
252
+ individualData = data_1 === null || data_1 === void 0 ? void 0 : data_1.shareholder;
253
+ else if (type === IndividualType.BOARD_MEMBER)
254
+ individualData = data_1 === null || data_1 === void 0 ? void 0 : data_1.board_member;
255
+ else if (type === IndividualType.BUYER)
256
+ individualData = data_1 === null || data_1 === void 0 ? void 0 : data_1.buyer;
257
+ else if (type === IndividualType.CUSTOMER)
258
+ individualData = data_1 === null || data_1 === void 0 ? void 0 : data_1.customer;
259
+ _d.label = 2;
260
+ case 2:
261
+ payload = {
262
+ id: board_id,
263
+ merchant_id: merchant_id,
264
+ info: [
265
+ {
266
+ name: 'individual'
267
+ }
268
+ ],
269
+ notification: {
270
+ recipient: {
271
+ id: id,
272
+ type: type
273
+ },
274
+ channel: ['email']
275
+ }
276
+ };
277
+ return [4, API.boardService.requestDetailsByEmail(payload)];
278
+ case 3:
279
+ data = _d.sent();
280
+ return [2, { data: data, userData: __assign(__assign({}, individualData), { type: type }) }];
281
+ }
282
+ });
283
+ }); });
284
+ export var getIndividualList = createAsyncThunk('individual/getIndividualList', function (businessId) { return __awaiter(void 0, void 0, void 0, function () {
285
+ var payload, _a, users, shareholders, board_members, userList, shareHolderList, boardMemberList, individualList;
286
+ return __generator(this, function (_b) {
287
+ switch (_b.label) {
288
+ case 0:
289
+ payload = {
290
+ page: 1,
291
+ limit: 10,
292
+ business_id: businessId
293
+ };
294
+ return [4, API.individualService.getIndividualList(payload)];
295
+ case 1:
296
+ _a = _b.sent(), users = _a.users, shareholders = _a.shareholders, board_members = _a.board_members;
297
+ userList = (users || []).map(function (user) { return (__assign(__assign({}, user), { type: IndividualType.USER })); });
298
+ shareHolderList = (shareholders || []).map(function (shareholder) { return (__assign(__assign({}, shareholder), { type: IndividualType.SHARE_HOLDER })); });
299
+ boardMemberList = (board_members || []).map(function (board_member) { return (__assign(__assign({}, board_member), { type: IndividualType.BOARD_MEMBER })); });
300
+ individualList = __spreadArray(__spreadArray(__spreadArray([], userList, true), shareHolderList, true), boardMemberList, true);
301
+ return [2, individualList];
302
+ }
303
+ });
304
+ }); });
305
+ export var getCityList = createAsyncThunk('individual/getCityList', function (countryCode) { return __awaiter(void 0, void 0, void 0, function () {
306
+ var cityBody, list;
307
+ return __generator(this, function (_a) {
308
+ switch (_a.label) {
309
+ case 0:
310
+ cityBody = {
311
+ country: [countryCode]
312
+ };
313
+ return [4, API.countryService.getCities(cityBody)];
314
+ case 1:
315
+ list = (_a.sent()).list;
316
+ return [2, list || []];
317
+ }
318
+ });
319
+ }); });
320
+ export var retrieveIndividualInfo = createAsyncThunk('individual/retrieveIndividualInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
321
+ var id, type, countryCode, settings, data, individualData;
322
+ return __generator(this, function (_a) {
323
+ switch (_a.label) {
324
+ case 0:
325
+ id = params.id, type = params.type, countryCode = params.countryCode;
326
+ settings = thunkApi.getState().settings;
327
+ return [4, API.individualService.retrieveIndividual(id, type)];
328
+ case 1:
329
+ data = _a.sent();
330
+ individualData = data === null || data === void 0 ? void 0 : data.user;
331
+ if (type === IndividualType.SHARE_HOLDER)
332
+ individualData = data === null || data === void 0 ? void 0 : data.shareholder;
333
+ else if (type === IndividualType.BOARD_MEMBER)
334
+ individualData = data === null || data === void 0 ? void 0 : data.board_member;
335
+ else if (type === IndividualType.BUYER)
336
+ individualData = data === null || data === void 0 ? void 0 : data.buyer;
337
+ else if (type === IndividualType.CUSTOMER)
338
+ individualData = data === null || data === void 0 ? void 0 : data.customer;
339
+ return [2, { data: __assign(__assign({}, (individualData || {})), { type: type }), countryCode: countryCode, countries: settings.data.countries }];
340
+ }
341
+ });
342
+ }); });
161
343
  export var retrieveDataList = createAsyncThunk('individualRetrieveDataList', function (countryCode) { return __awaiter(void 0, void 0, void 0, function () {
162
344
  var monthlyIncomeBody, dataBody, _a, sourceIncome, monthlyIncome, occupation;
163
345
  return __generator(this, function (_b) {
@@ -186,24 +368,24 @@ export var retrieveDataList = createAsyncThunk('individualRetrieveDataList', fun
186
368
  });
187
369
  }); });
188
370
  export var retrieveBoardDetails = createAsyncThunk('retrieveIndividualBoardDetails', function (boardId) { return __awaiter(void 0, void 0, void 0, function () {
189
- var data;
190
- var _a, _b;
191
- return __generator(this, function (_c) {
192
- switch (_c.label) {
371
+ var _a, user, data;
372
+ var _b, _c;
373
+ return __generator(this, function (_d) {
374
+ switch (_d.label) {
193
375
  case 0: return [4, API.boardService.retrieveBoardDetails(boardId)];
194
376
  case 1:
195
- data = _c.sent();
377
+ _a = _d.sent(), user = _a.user, data = __rest(_a, ["user"]);
196
378
  return [2, {
197
- 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 })
379
+ data: __assign(__assign({}, data), { 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: (_b = data === null || data === void 0 ? void 0 : data.user) === null || _b === void 0 ? void 0 : _b.names, individuals: data === null || data === void 0 ? void 0 : data.individuals, contact: (_c = data === null || data === void 0 ? void 0 : data.user) === null || _c === void 0 ? void 0 : _c.contact })
198
380
  }];
199
381
  }
200
382
  });
201
383
  }); });
202
384
  export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
203
- var _a, individual, settings, responseBody, _b, board_id, board_info_id, countries, payload, data, boardInfoData, individualData, boardData, countryCode, boardInfoStatus, notification, _c, id, type, info, hasIndividualCompleted;
204
- var _d, _e, _f, _g, _h, _j, _k;
205
- return __generator(this, function (_l) {
206
- switch (_l.label) {
385
+ var _a, individual, settings, responseBody, _b, board_id, board_info_id, countries, payload, data, boardInfoData, individualData, boardData, countryCode, boardInfoStatus, notification, _c, id, type, payload_2, info, hasIndividualCompleted, birthCountry;
386
+ var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
387
+ return __generator(this, function (_p) {
388
+ switch (_p.label) {
207
389
  case 0:
208
390
  _a = thunkApi.getState(), individual = _a.individual, settings = _a.settings;
209
391
  responseBody = individual.data.verify.responseBody;
@@ -218,57 +400,69 @@ export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function
218
400
  };
219
401
  return [4, API.leadService.verifyLeadOTP(payload)];
220
402
  case 1:
221
- data = (_l.sent()).data;
403
+ data = (_p.sent()).data;
222
404
  boardInfoStatus = undefined;
223
- if (!!(data === null || data === void 0 ? void 0 : data.errors)) return [3, 11];
224
- if (!(board_id && board_info_id)) return [3, 4];
225
- return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
405
+ if (!!(data === null || data === void 0 ? void 0 : data.errors)) return [3, 14];
406
+ if (!board_id) return [3, 4];
407
+ return [4, API.boardService.retrieveBoardInfoStatus(board_id)];
226
408
  case 2:
227
- boardInfoData = _l.sent();
228
- notification = (boardInfoData || {}).notification;
229
- _c = (notification === null || notification === void 0 ? void 0 : notification.recipient) || {}, id = _c.id, type = _c.type;
230
- if (!(id && type)) return [3, 4];
231
- return [4, API.individualService.retrieveIndividual(id, type)];
409
+ boardInfoStatus = _p.sent();
410
+ return [4, API.boardService.retrieveBoardDetails(board_id)];
232
411
  case 3:
233
- individualData = _l.sent();
234
- _l.label = 4;
412
+ boardData = _p.sent();
413
+ _p.label = 4;
235
414
  case 4:
236
- if (!board_id) return [3, 7];
237
- return [4, API.boardService.retrieveBoardInfoStatus(board_id)];
415
+ countryCode = (_e = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _e === void 0 ? void 0 : _e.country;
416
+ if (!(board_id && board_info_id)) return [3, 7];
417
+ return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
238
418
  case 5:
239
- boardInfoStatus = _l.sent();
240
- return [4, API.boardService.retrieveBoardDetails(board_id)];
419
+ boardInfoData = _p.sent();
420
+ notification = (boardInfoData || {}).notification;
421
+ _c = (notification === null || notification === void 0 ? void 0 : notification.recipient) || {}, id = _c.id, type = _c.type;
422
+ if (!(id && type)) return [3, 7];
423
+ return [4, thunkApi.dispatch(retrieveIndividualInfo({ id: id, type: type, countryCode: countryCode }))];
241
424
  case 6:
242
- boardData = _l.sent();
243
- _l.label = 7;
425
+ payload_2 = (_p.sent()).payload;
426
+ individualData = payload_2.data || {};
427
+ _p.label = 7;
244
428
  case 7:
245
- countryCode = (_e = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _e === void 0 ? void 0 : _e.country;
246
429
  info = (boardInfoStatus || {}).info;
247
430
  hasIndividualCompleted = ((_f = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'individual'; })) === null || _f === void 0 ? void 0 : _f.status) === 'completed';
248
431
  (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, { otp: params.otp });
249
432
  if (!hasIndividualCompleted) return [3, 8];
250
433
  thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
251
- return [3, 11];
434
+ return [3, 14];
252
435
  case 8:
253
- if (!countryCode) return [3, 10];
254
- return [4, thunkApi.dispatch(retrieveDataList(countryCode))];
436
+ if (!(individualData === null || individualData === void 0 ? void 0 : individualData.is_authorized)) return [3, 11];
437
+ if (!((_j = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _j === void 0 ? void 0 : _j.id)) return [3, 10];
438
+ return [4, thunkApi.dispatch(getIndividualList((_k = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _k === void 0 ? void 0 : _k.id))];
255
439
  case 9:
256
- _l.sent();
257
- _l.label = 10;
440
+ _p.sent();
441
+ _p.label = 10;
258
442
  case 10:
259
- thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_ADDITIONAL_INDIVIDUAL_INFO_STEP'));
260
- _l.label = 11;
261
- case 11: return [2, {
443
+ thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_LIST_STEP'));
444
+ return [3, 14];
445
+ case 11:
446
+ birthCountry = ((_l = individualData === null || individualData === void 0 ? void 0 : individualData.birth) === null || _l === void 0 ? void 0 : _l.country) || countryCode;
447
+ if (!birthCountry) return [3, 13];
448
+ return [4, thunkApi.dispatch(getCityList(birthCountry))];
449
+ case 12:
450
+ _p.sent();
451
+ _p.label = 13;
452
+ case 13:
453
+ thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_PERSONAL_INDIVIDUAL_INFO_STEP'));
454
+ _p.label = 14;
455
+ case 14: return [2, {
262
456
  data: data,
263
457
  boardResponse: {
264
- user: individualData === null || individualData === void 0 ? void 0 : individualData.user,
265
458
  brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand,
266
459
  bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account,
267
460
  entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity,
268
461
  merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
269
462
  merchant_id: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.merchant_id,
270
- name: (_j = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _j === void 0 ? void 0 : _j.names,
271
- contact: (_k = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _k === void 0 ? void 0 : _k.contact,
463
+ name: (_m = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _m === void 0 ? void 0 : _m.names,
464
+ contact: (_o = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _o === void 0 ? void 0 : _o.contact,
465
+ individuals: boardData === null || boardData === void 0 ? void 0 : boardData.individuals,
272
466
  countries: countries,
273
467
  countryCode: countryCode,
274
468
  notification: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification,
@@ -279,34 +473,118 @@ export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function
279
473
  }
280
474
  });
281
475
  }); });
476
+ export var updateIndividualPersonalInfo = createAsyncThunk('individual/updateIndividualPersonalInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
477
+ var _a, settings, individual, _b, notification, user, entity, _c, id, type, name, email, mobile, countryCode, gender, nid, issuedCountry, expiryDate, dob, placeOfBirthCountry, placeOfBirthCity, nationality, code, data_status, userName, identification_id_type, isNameEditable, isEmailEditable, isMobileNumberEditable, isMobileCountryEditable, isNidEditable, isIssuedCountryEditable, isExpiryEditable, isIdTypeEditable, isNationalityEditable, hasContact, hasPhone, hasIdentification, hasBirth, names, contact, requestBody, data;
478
+ var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
479
+ return __generator(this, function (_s) {
480
+ switch (_s.label) {
481
+ case 0:
482
+ _a = thunkApi.getState(), settings = _a.settings, individual = _a.individual;
483
+ _b = individual.data.verify.responseBody || {}, notification = _b.notification, user = _b.user, entity = _b.entity;
484
+ _c = ((user === null || user === void 0 ? void 0 : user.is_authorized) ? user : notification === null || notification === void 0 ? void 0 : notification.recipient) || {}, id = _c.id, type = _c.type;
485
+ name = params.name, email = params.email, mobile = params.mobile, countryCode = params.countryCode, gender = params.gender, nid = params.nid, issuedCountry = params.issuedCountry, expiryDate = params.expiryDate, dob = params.dob, placeOfBirthCountry = params.placeOfBirthCountry, placeOfBirthCity = params.placeOfBirthCity, nationality = params.nationality;
486
+ code = entity === null || entity === void 0 ? void 0 : entity.country;
487
+ data_status = (user || {}).data_status;
488
+ userName = getUserNameObject(name);
489
+ identification_id_type = nid && (nid === null || nid === void 0 ? void 0 : nid.startsWith('1')) ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
490
+ isNameEditable = (data_status === null || data_status === void 0 ? void 0 : data_status.name) === FieldType.EDITABLE && userName.first;
491
+ isEmailEditable = ((_d = data_status === null || data_status === void 0 ? void 0 : data_status.contact) === null || _d === void 0 ? void 0 : _d.email) === FieldType.EDITABLE;
492
+ isMobileNumberEditable = ((_f = (_e = data_status === null || data_status === void 0 ? void 0 : data_status.contact) === null || _e === void 0 ? void 0 : _e.phone) === null || _f === void 0 ? void 0 : _f.number) === FieldType.EDITABLE && mobile;
493
+ isMobileCountryEditable = ((_h = (_g = data_status === null || data_status === void 0 ? void 0 : data_status.contact) === null || _g === void 0 ? void 0 : _g.phone) === null || _h === void 0 ? void 0 : _h.country_code) === FieldType.EDITABLE;
494
+ isNidEditable = ((_j = data_status === null || data_status === void 0 ? void 0 : data_status.identification) === null || _j === void 0 ? void 0 : _j.id) === FieldType.EDITABLE && nid;
495
+ isIssuedCountryEditable = ((_k = data_status === null || data_status === void 0 ? void 0 : data_status.identification) === null || _k === void 0 ? void 0 : _k.issuer_country) === FieldType.EDITABLE;
496
+ isExpiryEditable = ((_l = data_status === null || data_status === void 0 ? void 0 : data_status.identification) === null || _l === void 0 ? void 0 : _l.expiry) === FieldType.EDITABLE && expiryDate;
497
+ isIdTypeEditable = ((_m = data_status === null || data_status === void 0 ? void 0 : data_status.identification) === null || _m === void 0 ? void 0 : _m.type) === FieldType.EDITABLE && identification_id_type;
498
+ isNationalityEditable = (data_status === null || data_status === void 0 ? void 0 : data_status.nationality) === FieldType.EDITABLE;
499
+ hasContact = email || mobile || countryCode;
500
+ hasPhone = mobile && (countryCode === null || countryCode === void 0 ? void 0 : countryCode.idd_prefix);
501
+ hasIdentification = nid || issuedCountry || identification_id_type || expiryDate;
502
+ hasBirth = placeOfBirthCity || placeOfBirthCountry;
503
+ names = isNameEditable
504
+ ? {
505
+ en: userName,
506
+ ar: userName
507
+ }
508
+ : undefined;
509
+ contact = hasContact
510
+ ? {
511
+ email: isEmailEditable ? email : undefined,
512
+ phone: hasPhone
513
+ ? {
514
+ country_code: isMobileCountryEditable ? (_o = countryCode === null || countryCode === void 0 ? void 0 : countryCode.idd_prefix) === null || _o === void 0 ? void 0 : _o.toString() : undefined,
515
+ number: isMobileNumberEditable ? mobile : undefined
516
+ }
517
+ : undefined
518
+ }
519
+ : undefined;
520
+ requestBody = {
521
+ id: id,
522
+ type: type,
523
+ names: names,
524
+ gender: gender || undefined,
525
+ contact: contact,
526
+ identification: hasIdentification
527
+ ? {
528
+ id: isNidEditable ? nid : undefined,
529
+ issued_country_code: isIssuedCountryEditable ? issuedCountry === null || issuedCountry === void 0 ? void 0 : issuedCountry.iso2 : undefined,
530
+ expiry: isExpiryEditable ? new Date(expiryDate).getTime() : undefined,
531
+ type: isIdTypeEditable ? identification_id_type : undefined
532
+ }
533
+ : undefined,
534
+ date_of_birth: dob,
535
+ birth: hasBirth && {
536
+ city: (_p = placeOfBirthCity === null || placeOfBirthCity === void 0 ? void 0 : placeOfBirthCity.name) === null || _p === void 0 ? void 0 : _p.en,
537
+ country: placeOfBirthCountry === null || placeOfBirthCountry === void 0 ? void 0 : placeOfBirthCountry.iso2
538
+ },
539
+ nationality: isNationalityEditable ? nationality === null || nationality === void 0 ? void 0 : nationality.iso2 : undefined,
540
+ encryption_contract: [
541
+ 'gender',
542
+ 'contact.email',
543
+ 'contact.phone.country_code',
544
+ 'contact.phone.number',
545
+ 'identification.id',
546
+ 'identification.issued_country_code',
547
+ 'identification.expiry',
548
+ 'identification.type',
549
+ 'birth.city',
550
+ 'birth.country',
551
+ 'date_of_birth',
552
+ 'nationality'
553
+ ],
554
+ step_name: INDIVIDUAl_STEP_NAMES.INDIVIDUAl_PERSONAL_INFO
555
+ };
556
+ return [4, API.individualService.updateIndividual(requestBody)];
557
+ case 1:
558
+ data = (_s.sent()).data;
559
+ if (!(type === IndividualType.USER || type === IndividualType.BUYER)) return [3, 3];
560
+ return [4, thunkApi.dispatch(retrieveDataList(code))];
561
+ case 2:
562
+ _s.sent();
563
+ _s.label = 3;
564
+ case 3:
565
+ thunkApi.dispatch(handleNextScreenStep());
566
+ (_r = (_q = settings.data.appConfig).onStepCompleted) === null || _r === void 0 ? void 0 : _r.call(_q, settings.data.activeScreen.name, requestBody);
567
+ return [2, { data: data, formData: params }];
568
+ }
569
+ });
570
+ }); });
282
571
  export var updateIndividualInfo = createAsyncThunk('updateIndividualInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
283
- var _a, settings, individual, _b, id, type, civilID, signatureFileId, businessCountry, documentsList, requestBody, documentBody, data;
284
- var _c, _d, _e, _f, _g, _h, _j, _k;
285
- return __generator(this, function (_l) {
286
- switch (_l.label) {
572
+ var _a, settings, individual, _b, notification, user, _c, id, type, civilID, signatureFileId, businessCountry, documentsList, isSendSignatureFile, documentBody, occupation, sourceIncome, monthlyIncome, isPEP, isInfluencer, shareCount, shareValue, isOccupationEditable, isSourceIncomeEditable, isPEPEditable, isInfluencerEditable, isSharesAvailable, pepInfo, influencerInfo, occupationInfo, sourceIncomeInfo, monthlyIncomeInfo, userPayload, shareHolderPayload, boardMemberPayload, buyerMemberPayload, payload, requestBody, data;
573
+ var _d, _e, _f, _g, _h, _j;
574
+ return __generator(this, function (_k) {
575
+ switch (_k.label) {
287
576
  case 0:
288
577
  _a = thunkApi.getState(), settings = _a.settings, individual = _a.individual;
289
- _b = ((_d = (_c = individual.data.verify.responseBody) === null || _c === void 0 ? void 0 : _c.notification) === null || _d === void 0 ? void 0 : _d.recipient) || {}, id = _b.id, type = _b.type;
578
+ _b = individual.data.verify.responseBody || {}, notification = _b.notification, user = _b.user;
579
+ _c = ((user === null || user === void 0 ? void 0 : user.is_authorized) ? user : notification === null || notification === void 0 ? void 0 : notification.recipient) || {}, id = _c.id, type = _c.type;
290
580
  civilID = params.civilID, signatureFileId = params.signatureFileId;
291
581
  businessCountry = settings.data.businessCountry;
292
582
  documentsList = [];
583
+ isSendSignatureFile = (user === null || user === void 0 ? void 0 : user.is_authorized) && (type === IndividualType.USER || type === IndividualType.BUYER);
293
584
  if ((civilID || []).length > 0)
294
585
  documentsList.push({ type: 'Civil ID File', images: civilID });
295
- if ((signatureFileId || []).length > 0)
586
+ if (isSendSignatureFile && (signatureFileId || []).length > 0)
296
587
  documentsList.push({ type: 'Signature File', images: signatureFileId });
297
- requestBody = {
298
- id: id,
299
- type: type,
300
- occupation: { id: (_e = params.occupation) === null || _e === void 0 ? void 0 : _e.id },
301
- employer_name: params.employerName,
302
- employer_country: (_f = params.employerLocation) === null || _f === void 0 ? void 0 : _f.iso2,
303
- source_income: [{ id: (_g = params.sourceIncome) === null || _g === void 0 ? void 0 : _g.id }],
304
- monthly_income: { id: (_h = params.monthlyIncome) === null || _h === void 0 ? void 0 : _h.id },
305
- is_relative_PEP: params.isPEP,
306
- is_influencer: params.isInfluencer,
307
- encryption_contract: ['employer_name', 'employer_country'],
308
- step_name: INDIVIDUAl_STEP_NAMES.INDIVIDUAl_INFO
309
- };
310
588
  documentBody = {
311
589
  individual_type_id: id || '',
312
590
  country: businessCountry.iso2,
@@ -315,13 +593,59 @@ export var updateIndividualInfo = createAsyncThunk('updateIndividualInfo', funct
315
593
  if (!(documentsList.length > 0)) return [3, 2];
316
594
  return [4, API.entityService.updateDocumentInfo(documentBody)];
317
595
  case 1:
318
- _l.sent();
319
- _l.label = 2;
320
- case 2: return [4, API.individualService.updateIndividual(requestBody)];
596
+ _k.sent();
597
+ _k.label = 2;
598
+ case 2:
599
+ occupation = params.occupation, sourceIncome = params.sourceIncome, monthlyIncome = params.monthlyIncome, isPEP = params.isPEP, isInfluencer = params.isInfluencer, shareCount = params.shareCount, shareValue = params.shareValue;
600
+ isOccupationEditable = ((_d = user === null || user === void 0 ? void 0 : user.data_status) === null || _d === void 0 ? void 0 : _d.occupation) === FieldType.EDITABLE && (occupation === null || occupation === void 0 ? void 0 : occupation.id);
601
+ isSourceIncomeEditable = ((_e = user === null || user === void 0 ? void 0 : user.data_status) === null || _e === void 0 ? void 0 : _e.source_of_income) === FieldType.EDITABLE && (sourceIncome === null || sourceIncome === void 0 ? void 0 : sourceIncome.id);
602
+ isPEPEditable = ((_f = user === null || user === void 0 ? void 0 : user.data_status) === null || _f === void 0 ? void 0 : _f.is_relative_PEP) === FieldType.EDITABLE;
603
+ isInfluencerEditable = ((_g = user === null || user === void 0 ? void 0 : user.data_status) === null || _g === void 0 ? void 0 : _g.is_influencer) === FieldType.EDITABLE;
604
+ isSharesAvailable = shareCount || shareValue;
605
+ pepInfo = isPEPEditable ? isPEP : undefined;
606
+ influencerInfo = isInfluencerEditable ? isInfluencer : undefined;
607
+ occupationInfo = isOccupationEditable ? { id: occupation.id } : undefined;
608
+ sourceIncomeInfo = isSourceIncomeEditable ? [{ id: sourceIncome.id }] : undefined;
609
+ monthlyIncomeInfo = (monthlyIncome === null || monthlyIncome === void 0 ? void 0 : monthlyIncome.id) && { id: monthlyIncome.id };
610
+ userPayload = {
611
+ occupation: occupationInfo,
612
+ source_income: sourceIncomeInfo,
613
+ monthly_income: monthlyIncomeInfo,
614
+ is_relative_PEP: pepInfo,
615
+ is_influencer: influencerInfo
616
+ };
617
+ shareHolderPayload = {
618
+ shares: isSharesAvailable
619
+ ? {
620
+ count: shareCount && Number(shareCount),
621
+ value: shareValue && Number(shareValue)
622
+ }
623
+ : undefined
624
+ };
625
+ boardMemberPayload = {
626
+ is_relative_PEP: pepInfo,
627
+ is_influencer: influencerInfo
628
+ };
629
+ buyerMemberPayload = {
630
+ occupation: occupationInfo,
631
+ source_income: sourceIncomeInfo,
632
+ monthly_income: monthlyIncomeInfo
633
+ };
634
+ payload = userPayload;
635
+ if (type === IndividualType.SHARE_HOLDER)
636
+ payload = shareHolderPayload;
637
+ if (type === IndividualType.BOARD_MEMBER)
638
+ payload = boardMemberPayload;
639
+ if (type === IndividualType.BUYER)
640
+ payload = buyerMemberPayload;
641
+ if (type === IndividualType.CUSTOMER)
642
+ payload = {};
643
+ requestBody = __assign(__assign({ id: id, type: type }, payload), { encryption_contract: [], step_name: INDIVIDUAl_STEP_NAMES.INDIVIDUAl_INFO });
644
+ return [4, API.individualService.updateIndividual(requestBody)];
321
645
  case 3:
322
- data = (_l.sent()).data;
646
+ data = (_k.sent()).data;
323
647
  thunkApi.dispatch(handleNextScreenStep());
324
- (_k = (_j = settings.data.appConfig).onStepCompleted) === null || _k === void 0 ? void 0 : _k.call(_j, settings.data.activeScreen.name, requestBody);
648
+ (_j = (_h = settings.data.appConfig).onStepCompleted) === null || _j === void 0 ? void 0 : _j.call(_h, settings.data.activeScreen.name, requestBody);
325
649
  return [2, { data: data, formData: params }];
326
650
  }
327
651
  });
@@ -360,6 +684,7 @@ export var updateBoardSuccess = createAsyncThunk('individualUpdateBoardSuccess',
360
684
  var initialState = {
361
685
  error: null,
362
686
  loading: false,
687
+ cityLoading: false,
363
688
  data: {
364
689
  flowName: FlowsTypes.INDIVIDUAL,
365
690
  verify: {
@@ -368,6 +693,25 @@ var initialState = {
368
693
  otpData: {
369
694
  otp: ''
370
695
  },
696
+ individualCollectData: {
697
+ email: '',
698
+ mobile: '',
699
+ countryCode: defaultCountry
700
+ },
701
+ individualPersonalData: {
702
+ name: '',
703
+ email: '',
704
+ mobile: '',
705
+ countryCode: defaultCountry,
706
+ gender: IndividualGender.MALE,
707
+ nid: '',
708
+ issuedCountry: undefined,
709
+ expiryDate: '',
710
+ dob: getEighteenYearsAgo(),
711
+ placeOfBirthCountry: undefined,
712
+ placeOfBirthCity: undefined,
713
+ nationality: undefined
714
+ },
371
715
  individualData: {
372
716
  occupation: undefined,
373
717
  sourceIncome: undefined,
@@ -375,7 +719,9 @@ var initialState = {
375
719
  employerName: '',
376
720
  employerLocation: undefined,
377
721
  isPEP: null,
378
- isInfluencer: null
722
+ isInfluencer: null,
723
+ shareCount: '',
724
+ shareValue: ''
379
725
  }
380
726
  }
381
727
  };
@@ -392,6 +738,10 @@ export var individualSlice = createSlice({
392
738
  resetOTPScreen: function (state) {
393
739
  state.data.otpData.otp = '';
394
740
  },
741
+ resetIndividualData: function (state) {
742
+ state.data.individualPersonalData = __assign(__assign({}, state.data.individualPersonalData), initialState.data.individualPersonalData);
743
+ state.data.individualData = __assign(__assign({}, state.data.individualData), initialState.data.individualData);
744
+ },
395
745
  civilIDUploadingStatus: function (state, action) {
396
746
  state.data.individualData.civilIDUploading = action.payload;
397
747
  },
@@ -406,38 +756,11 @@ export var individualSlice = createSlice({
406
756
  state.customLoading = true;
407
757
  })
408
758
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
409
- var _a;
410
759
  state.error = null;
411
760
  state.customLoading = false;
412
- var _b = action.payload, data = _b.data, token = _b.token, boardResponse = _b.boardResponse;
413
- var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
414
- if (description) {
415
- state.error = description;
416
- return;
417
- }
761
+ var _a = action.payload, data = _a.data, token = _a.token, boardResponse = _a.boardResponse;
418
762
  state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), state.data.verify.responseBody), boardResponse), { board_id: data.id });
419
763
  state.data.verify.token = token;
420
- var _c = boardResponse || {}, countries = _c.countries, user = _c.user, countryCode = _c.countryCode;
421
- var _d = user || {}, source_income = _d.source_income, monthly_income = _d.monthly_income, occupation = _d.occupation, is_relative_PEP = _d.is_relative_PEP, is_influencer = _d.is_influencer;
422
- var _e = state.data.individualData.responseBody || {}, sourceIncomeList = _e.sourceIncomeList, monthlyIncomeList = _e.monthlyIncomeList, occupationList = _e.occupationList;
423
- var selectedSourceIncome = (sourceIncomeList === null || sourceIncomeList === void 0 ? void 0 : sourceIncomeList.find(function (source) { var _a; return (source === null || source === void 0 ? void 0 : source.id) === ((_a = source_income === null || source_income === void 0 ? void 0 : source_income[0]) === null || _a === void 0 ? void 0 : _a.id); })) || (sourceIncomeList === null || sourceIncomeList === void 0 ? void 0 : sourceIncomeList[0]);
424
- if (!!selectedSourceIncome)
425
- state.data.individualData.sourceIncome = selectedSourceIncome;
426
- var code = (user === null || user === void 0 ? void 0 : user.employer_country) || countryCode;
427
- if (!!code) {
428
- var employerLocation = (countries || []).find(function (country) { return country.iso2 === code; });
429
- state.data.individualData.employerLocation = employerLocation;
430
- }
431
- var selectedMonthlyIncome = monthlyIncomeList === null || monthlyIncomeList === void 0 ? void 0 : monthlyIncomeList.find(function (income) {
432
- return income.id === (monthly_income === null || monthly_income === void 0 ? void 0 : monthly_income.id);
433
- });
434
- var selectedOccupation = occupationList === null || occupationList === void 0 ? void 0 : occupationList.find(function (occup) {
435
- return occup.id === (occupation === null || occupation === void 0 ? void 0 : occupation.id);
436
- });
437
- state.data.individualData.monthlyIncome = selectedMonthlyIncome;
438
- state.data.individualData.occupation = selectedOccupation;
439
- state.data.individualData.isPEP = is_relative_PEP;
440
- state.data.individualData.isInfluencer = is_influencer;
441
764
  })
442
765
  .addCase(verifyLeadToken.rejected, function (state, action) {
443
766
  state.error = action.error.message;
@@ -477,13 +800,106 @@ export var individualSlice = createSlice({
477
800
  state.data.otpData = formData;
478
801
  state.data.otpData.responseBody = data;
479
802
  state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), boardResponse);
480
- var _c = boardResponse || {}, countries = _c.countries, user = _c.user, countryCode = _c.countryCode;
481
- var _d = user || {}, source_income = _d.source_income, monthly_income = _d.monthly_income, occupation = _d.occupation, is_relative_PEP = _d.is_relative_PEP, is_influencer = _d.is_influencer;
482
- var _e = state.data.individualData.responseBody || {}, sourceIncomeList = _e.sourceIncomeList, monthlyIncomeList = _e.monthlyIncomeList, occupationList = _e.occupationList;
803
+ })
804
+ .addCase(verifyLeadOTP.rejected, function (state, action) {
805
+ state.loading = false;
806
+ state.error = action.error.message;
807
+ })
808
+ .addCase(addDetailsAsync.pending, function (state) {
809
+ state.loading = true;
810
+ state.error = null;
811
+ })
812
+ .addCase(addDetailsAsync.fulfilled, function (state, action) {
813
+ state.loading = false;
814
+ state.error = null;
815
+ var userList = action.payload.userList;
816
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { userList: userList });
817
+ })
818
+ .addCase(addDetailsAsync.rejected, function (state, action) {
819
+ state.loading = false;
820
+ state.error = action.error.message;
821
+ })
822
+ .addCase(requestDetailsByEmail.pending, function (state) {
823
+ state.loading = true;
824
+ state.error = null;
825
+ })
826
+ .addCase(requestDetailsByEmail.fulfilled, function (state, action) {
827
+ state.loading = false;
828
+ state.error = null;
829
+ var _a = action.payload, data = _a.data, userData = _a.userData;
830
+ var userList = (state.data.verify.responseBody || {}).userList;
831
+ var list = userList || [];
832
+ list = list.map(function (user) {
833
+ var _a, _b;
834
+ var userInfo = user.id === (userData === null || userData === void 0 ? void 0 : userData.id) ? userData : user;
835
+ return user.id === ((_b = (_a = data === null || data === void 0 ? void 0 : data.notification) === null || _a === void 0 ? void 0 : _a.recipient) === null || _b === void 0 ? void 0 : _b.id) ? __assign(__assign({}, userInfo), { isRequestedEmail: true }) : userInfo;
836
+ });
837
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { requestEmailData: data, userList: list });
838
+ })
839
+ .addCase(requestDetailsByEmail.rejected, function (state, action) {
840
+ state.loading = false;
841
+ state.error = action.error.message;
842
+ })
843
+ .addCase(retrieveIndividualInfo.pending, function (state) {
844
+ state.loading = true;
845
+ state.error = null;
846
+ })
847
+ .addCase(retrieveIndividualInfo.fulfilled, function (state, action) {
848
+ var _a, _b, _c, _d;
849
+ state.loading = false;
850
+ state.error = null;
851
+ var _e = action.payload, data = _e.data, countries = _e.countries, countryCode = _e.countryCode;
852
+ var user = (state.data.verify.responseBody || {}).user;
853
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { user: __assign(__assign({}, data), { is_authorized: data.is_authorized !== undefined ? data.is_authorized : user === null || user === void 0 ? void 0 : user.is_authorized }) });
854
+ var _f = data || {}, source_income = _f.source_income, monthly_income = _f.monthly_income, occupation = _f.occupation, is_relative_PEP = _f.is_relative_PEP, is_influencer = _f.is_influencer, birth = _f.birth, contact = _f.contact, identification = _f.identification, nationality = _f.nationality, gender = _f.gender, employer_country = _f.employer_country, shares = _f.shares;
855
+ var _g = state.data.individualData.responseBody || {}, sourceIncomeList = _g.sourceIncomeList, monthlyIncomeList = _g.monthlyIncomeList, occupationList = _g.occupationList;
856
+ var cityList = (state.data.verify.responseBody || {}).cityList;
857
+ if (data)
858
+ state.data.individualPersonalData.name = getUserName(data, false);
859
+ if (contact === null || contact === void 0 ? void 0 : contact.email)
860
+ state.data.individualPersonalData.email = contact === null || contact === void 0 ? void 0 : contact.email;
861
+ if ((_a = contact === null || contact === void 0 ? void 0 : contact.phone) === null || _a === void 0 ? void 0 : _a.number)
862
+ state.data.individualPersonalData.mobile = (_b = contact === null || contact === void 0 ? void 0 : contact.phone) === null || _b === void 0 ? void 0 : _b.number;
863
+ if ((_c = contact === null || contact === void 0 ? void 0 : contact.phone) === null || _c === void 0 ? void 0 : _c.country_code) {
864
+ state.data.individualPersonalData.countryCode = findCountryByIddPrefix(countries, (_d = contact === null || contact === void 0 ? void 0 : contact.phone) === null || _d === void 0 ? void 0 : _d.country_code) || defaultCountry;
865
+ }
866
+ if (gender)
867
+ state.data.individualPersonalData.gender = gender.toLowerCase();
868
+ if (identification === null || identification === void 0 ? void 0 : identification.id)
869
+ state.data.individualPersonalData.nid = identification === null || identification === void 0 ? void 0 : identification.id;
870
+ state.data.individualPersonalData.issuedCountry = identification === null || identification === void 0 ? void 0 : identification.issued_country_code;
871
+ if (identification === null || identification === void 0 ? void 0 : identification.issued_country_code) {
872
+ state.data.individualPersonalData.issuedCountry = findCountryByIso2(countries, identification === null || identification === void 0 ? void 0 : identification.issued_country_code);
873
+ }
874
+ var expiryDate = (identification === null || identification === void 0 ? void 0 : identification.expiry) || new Date().getTime();
875
+ state.data.individualPersonalData.expiryDate = convertNumbers2English(dateFormat(expiryDate));
876
+ if (birth === null || birth === void 0 ? void 0 : birth.date)
877
+ state.data.individualPersonalData.dob = convertNumbers2English(dateFormat(birth === null || birth === void 0 ? void 0 : birth.date));
878
+ if (birth === null || birth === void 0 ? void 0 : birth.country) {
879
+ state.data.individualPersonalData.placeOfBirthCountry = findCountryByIso2(countries, birth === null || birth === void 0 ? void 0 : birth.country);
880
+ }
881
+ if (birth === null || birth === void 0 ? void 0 : birth.city) {
882
+ var selectedCity = cityList === null || cityList === void 0 ? void 0 : cityList.find(function (city) {
883
+ return city.name.en === (birth === null || birth === void 0 ? void 0 : birth.city);
884
+ });
885
+ state.data.individualPersonalData.placeOfBirthCity = selectedCity;
886
+ }
887
+ if (nationality) {
888
+ state.data.individualPersonalData.nationality = findCountryByIso2(countries, nationality);
889
+ }
890
+ var _h = shares || {}, count = _h.count, value = _h.value;
891
+ var shareCount = count === null || count === void 0 ? void 0 : count.toString();
892
+ var shareValue = value === null || value === void 0 ? void 0 : value.toString();
893
+ if (shareCount) {
894
+ state.data.individualData.shareCount = shareCount;
895
+ }
896
+ if (shareValue) {
897
+ state.data.individualData.shareValue = shareValue;
898
+ }
483
899
  var selectedSourceIncome = (sourceIncomeList === null || sourceIncomeList === void 0 ? void 0 : sourceIncomeList.find(function (source) { var _a; return (source === null || source === void 0 ? void 0 : source.id) === ((_a = source_income === null || source_income === void 0 ? void 0 : source_income[0]) === null || _a === void 0 ? void 0 : _a.id); })) || (sourceIncomeList === null || sourceIncomeList === void 0 ? void 0 : sourceIncomeList[0]);
484
900
  if (!!selectedSourceIncome)
485
901
  state.data.individualData.sourceIncome = selectedSourceIncome;
486
- var code = (user === null || user === void 0 ? void 0 : user.employer_country) || countryCode;
902
+ var code = employer_country || countryCode;
487
903
  if (!!code) {
488
904
  var employerLocation = (countries || []).find(function (country) { return country.iso2 === code; });
489
905
  state.data.individualData.employerLocation = employerLocation;
@@ -499,7 +915,20 @@ export var individualSlice = createSlice({
499
915
  state.data.individualData.isPEP = is_relative_PEP;
500
916
  state.data.individualData.isInfluencer = is_influencer;
501
917
  })
502
- .addCase(verifyLeadOTP.rejected, function (state, action) {
918
+ .addCase(retrieveIndividualInfo.rejected, function (state, action) {
919
+ state.loading = false;
920
+ state.error = action.error.message;
921
+ })
922
+ .addCase(getIndividualList.pending, function (state) {
923
+ state.loading = true;
924
+ state.error = null;
925
+ })
926
+ .addCase(getIndividualList.fulfilled, function (state, action) {
927
+ state.loading = false;
928
+ state.error = null;
929
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { userList: action.payload });
930
+ })
931
+ .addCase(getIndividualList.rejected, function (state, action) {
503
932
  state.loading = false;
504
933
  state.error = action.error.message;
505
934
  })
@@ -508,15 +937,70 @@ export var individualSlice = createSlice({
508
937
  state.error = null;
509
938
  })
510
939
  .addCase(retrieveDataList.fulfilled, function (state, action) {
940
+ var _a;
511
941
  state.loading = false;
512
942
  state.error = null;
513
- var _a = action.payload, sourceIncome = _a.sourceIncome, monthlyIncome = _a.monthlyIncome, occupation = _a.occupation;
943
+ var _b = action.payload, sourceIncome = _b.sourceIncome, monthlyIncome = _b.monthlyIncome, occupationData = _b.occupation;
514
944
  var data = state.data.individualData.responseBody;
515
- state.data.individualData.responseBody = __assign(__assign({}, data), { sourceIncomeList: (sourceIncome === null || sourceIncome === void 0 ? void 0 : sourceIncome.list) || [], monthlyIncomeList: (monthlyIncome === null || monthlyIncome === void 0 ? void 0 : monthlyIncome.list) || [], occupationList: (occupation === null || occupation === void 0 ? void 0 : occupation.list) || [] });
945
+ var sourceIncomeList = (sourceIncome === null || sourceIncome === void 0 ? void 0 : sourceIncome.list) || [];
946
+ var monthlyIncomeList = (monthlyIncome === null || monthlyIncome === void 0 ? void 0 : monthlyIncome.list) || [];
947
+ var occupationList = (occupationData === null || occupationData === void 0 ? void 0 : occupationData.list) || [];
948
+ state.data.individualData.responseBody = __assign(__assign({}, data), { sourceIncomeList: sourceIncomeList, monthlyIncomeList: monthlyIncomeList, occupationList: occupationList });
949
+ var _c = ((_a = state.data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.user) || {}, source_income = _c.source_income, monthly_income = _c.monthly_income, occupation = _c.occupation;
950
+ var selectedSourceIncome = (sourceIncomeList === null || sourceIncomeList === void 0 ? void 0 : sourceIncomeList.find(function (source) { var _a; return (source === null || source === void 0 ? void 0 : source.id) === ((_a = source_income === null || source_income === void 0 ? void 0 : source_income[0]) === null || _a === void 0 ? void 0 : _a.id); })) || (sourceIncomeList === null || sourceIncomeList === void 0 ? void 0 : sourceIncomeList[0]);
951
+ if (!!selectedSourceIncome)
952
+ state.data.individualData.sourceIncome = selectedSourceIncome;
953
+ var selectedMonthlyIncome = monthlyIncomeList === null || monthlyIncomeList === void 0 ? void 0 : monthlyIncomeList.find(function (income) {
954
+ return income.id === (monthly_income === null || monthly_income === void 0 ? void 0 : monthly_income.id);
955
+ });
956
+ var selectedOccupation = occupationList === null || occupationList === void 0 ? void 0 : occupationList.find(function (occup) {
957
+ return occup.id === (occupation === null || occupation === void 0 ? void 0 : occupation.id);
958
+ });
959
+ state.data.individualData.monthlyIncome = selectedMonthlyIncome;
960
+ state.data.individualData.occupation = selectedOccupation;
516
961
  })
517
962
  .addCase(retrieveDataList.rejected, function (state, action) {
518
963
  state.loading = false;
519
964
  state.error = action.error.message;
965
+ })
966
+ .addCase(getCityList.pending, function (state) {
967
+ state.cityLoading = true;
968
+ state.error = null;
969
+ })
970
+ .addCase(getCityList.fulfilled, function (state, action) {
971
+ var _a;
972
+ state.cityLoading = false;
973
+ state.error = null;
974
+ var data = state.data.verify.responseBody;
975
+ var cityList = action.payload;
976
+ state.data.verify.responseBody = __assign(__assign({}, data), { cityList: cityList });
977
+ var birth = (((_a = state.data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.user) || {}).birth;
978
+ var city = (birth || {}).city;
979
+ if (city) {
980
+ var selectedCity = cityList === null || cityList === void 0 ? void 0 : cityList.find(function (c) {
981
+ return c.name.en === city;
982
+ });
983
+ state.data.individualPersonalData.placeOfBirthCity = selectedCity;
984
+ }
985
+ })
986
+ .addCase(getCityList.rejected, function (state, action) {
987
+ state.cityLoading = false;
988
+ state.error = action.error.message;
989
+ })
990
+ .addCase(updateIndividualPersonalInfo.pending, function (state) {
991
+ state.loading = true;
992
+ state.error = null;
993
+ })
994
+ .addCase(updateIndividualPersonalInfo.fulfilled, function (state, action) {
995
+ state.loading = false;
996
+ state.error = null;
997
+ var _a = action.payload, data = _a.data, formData = _a.formData;
998
+ state.data.individualPersonalData = formData;
999
+ state.data.individualPersonalData.responseBody = data;
1000
+ })
1001
+ .addCase(updateIndividualPersonalInfo.rejected, function (state, action) {
1002
+ state.loading = false;
1003
+ state.error = action.error.message;
520
1004
  })
521
1005
  .addCase(updateIndividualInfo.pending, function (state) {
522
1006
  state.loading = true;
@@ -571,6 +1055,6 @@ export var individualSlice = createSlice({
571
1055
  });
572
1056
  }
573
1057
  });
574
- export var clearError = (_a = individualSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, civilIDUploadingStatus = _a.civilIDUploadingStatus, signatureFileUploadingStatus = _a.signatureFileUploadingStatus;
1058
+ export var clearError = (_a = individualSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, civilIDUploadingStatus = _a.civilIDUploadingStatus, signatureFileUploadingStatus = _a.signatureFileUploadingStatus, resetIndividualData = _a.resetIndividualData;
575
1059
  export default individualSlice.reducer;
576
1060
  export var individualSelector = function (state) { return state.individual; };