@tap-payments/auth-jsconnect 2.0.54-test → 2.0.56-test

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/build/@types/app.d.ts +39 -14
  2. package/build/@types/app.js +9 -0
  3. package/build/@types/form.d.ts +11 -0
  4. package/build/api/auth.d.ts +14 -1
  5. package/build/api/auth.js +24 -1
  6. package/build/api/axios.js +2 -2
  7. package/build/api/data.d.ts +33 -7
  8. package/build/api/data.js +41 -16
  9. package/build/api/entity.d.ts +2 -0
  10. package/build/api/index.d.ts +11 -8
  11. package/build/api/individual.d.ts +1 -1
  12. package/build/app/rootReducer.d.ts +3 -0
  13. package/build/app/rootReducer.js +7 -1
  14. package/build/app/settings.js +8 -2
  15. package/build/app/store.d.ts +7 -1
  16. package/build/assets/locales/ar.json +14 -4
  17. package/build/assets/locales/en.json +14 -4
  18. package/build/components/AnimationFlow/AnimationFlow.d.ts +4 -1
  19. package/build/components/AnimationFlow/AnimationFlow.js +5 -7
  20. package/build/components/AnimationFlow/BottomSheet.js +2 -1
  21. package/build/components/AnimationFlow/Dialog.d.ts +4 -1
  22. package/build/components/AnimationFlow/Dialog.js +9 -4
  23. package/build/components/FileInput/DragAndDrop.d.ts +9 -1
  24. package/build/components/FileInput/DragAndDrop.js +113 -8
  25. package/build/components/Lottie/Lottie.d.ts +878 -0
  26. package/build/components/Lottie/Lottie.js +58 -0
  27. package/build/components/Lottie/files/pulsating_circle_waves.json +236 -0
  28. package/build/components/Lottie/files/success.json +425 -0
  29. package/build/components/Lottie/index.d.ts +3 -0
  30. package/build/components/Lottie/index.js +3 -0
  31. package/build/components/ProgressBar/CircularProgressBar.d.ts +14 -0
  32. package/build/components/ProgressBar/CircularProgressBar.js +48 -0
  33. package/build/components/ProgressBar/index.d.ts +2 -0
  34. package/build/components/ProgressBar/index.js +2 -0
  35. package/build/components/SocialMediaGroup/SocialMediaGroup.d.ts +2 -1
  36. package/build/components/SocialMediaGroup/SocialMediaGroup.js +27 -34
  37. package/build/constants/api.d.ts +1 -0
  38. package/build/constants/api.js +10 -7
  39. package/build/constants/app.d.ts +15 -0
  40. package/build/constants/app.js +75 -3
  41. package/build/constants/assets.d.ts +17 -1
  42. package/build/constants/assets.js +22 -6
  43. package/build/constants/validation.d.ts +1 -0
  44. package/build/constants/validation.js +1 -0
  45. package/build/features/app/auth/authStore.d.ts +35 -0
  46. package/build/features/app/auth/authStore.js +148 -0
  47. package/build/features/app/bank/bankStore.d.ts +4 -0
  48. package/build/features/app/bank/bankStore.js +42 -22
  49. package/build/features/app/business/businessStore.js +53 -43
  50. package/build/features/app/connect/connectStore.d.ts +13 -1
  51. package/build/features/app/connect/connectStore.js +164 -4
  52. package/build/features/app/entity/entityStore.d.ts +53 -0
  53. package/build/features/app/entity/entityStore.js +461 -0
  54. package/build/features/app/individual/individualStore.js +19 -11
  55. package/build/features/app/otp/otpStore.d.ts +28 -0
  56. package/build/features/app/otp/otpStore.js +153 -0
  57. package/build/features/app/signIn/signInStore.js +2 -2
  58. package/build/features/auth/Auth.d.ts +10 -0
  59. package/build/features/auth/Auth.js +87 -0
  60. package/build/features/auth/index.d.ts +1 -0
  61. package/build/features/auth/index.js +1 -0
  62. package/build/features/auth/screens/OTP/OTP.d.ts +5 -0
  63. package/build/features/auth/screens/OTP/OTP.js +72 -0
  64. package/build/features/auth/screens/OTP/OTPInput.d.ts +5 -0
  65. package/build/features/auth/screens/OTP/OTPInput.js +44 -0
  66. package/build/features/auth/screens/OTP/index.d.ts +3 -0
  67. package/build/features/auth/screens/OTP/index.js +2 -0
  68. package/build/features/auth/screens/OTP/validation.d.ts +8 -0
  69. package/build/features/auth/screens/OTP/validation.js +4 -0
  70. package/build/features/bank/Bank.js +10 -4
  71. package/build/features/bank/screens/BankDetails/BankDetails.js +2 -2
  72. package/build/features/bank/screens/BankDetails/BankStatement.js +33 -8
  73. package/build/features/business/Business.d.ts +1 -1
  74. package/build/features/business/Business.js +12 -5
  75. package/build/features/business/screens/Activities/ActivitiesList.d.ts +1 -1
  76. package/build/features/business/screens/Activities/SalesChannels.js +1 -1
  77. package/build/features/business/screens/Customers/CustomerLocations.d.ts +2 -2
  78. package/build/features/business/screens/Customers/CustomerLocations.js +25 -7
  79. package/build/features/business/screens/Customers/ExpectedCustomers.js +16 -4
  80. package/build/features/business/screens/Customers/ExpectedSalesRange.js +32 -14
  81. package/build/features/connect/Connect.d.ts +2 -1
  82. package/build/features/connect/Connect.js +40 -10
  83. package/build/features/connect/screens/CivilID/CivilID.d.ts +5 -0
  84. package/build/features/connect/screens/CivilID/CivilID.js +85 -0
  85. package/build/features/connect/screens/CivilID/IDNumber.d.ts +7 -0
  86. package/build/features/connect/screens/CivilID/IDNumber.js +59 -0
  87. package/build/features/connect/screens/CivilID/index.d.ts +3 -0
  88. package/build/features/connect/screens/CivilID/index.js +2 -0
  89. package/build/features/connect/screens/CivilID/validation.d.ts +8 -0
  90. package/build/features/connect/screens/CivilID/validation.js +4 -0
  91. package/build/features/connect/screens/Individual/Individual.js +6 -2
  92. package/build/features/connect/screens/Merchant/Merchant.js +35 -11
  93. package/build/features/connect/screens/Merchant/SalesChannels.d.ts +5 -0
  94. package/build/features/connect/screens/Merchant/SalesChannels.js +114 -0
  95. package/build/features/connect/screens/Merchant/SocialMedia.js +56 -11
  96. package/build/features/connect/screens/Merchant/validation.d.ts +87 -0
  97. package/build/features/connect/screens/Merchant/validation.js +68 -2
  98. package/build/features/connect/screens/Mobile/Mobile.js +7 -4
  99. package/build/features/connect/screens/VerifyPACI/VerifyPACI.d.ts +5 -0
  100. package/build/features/connect/screens/VerifyPACI/VerifyPACI.js +169 -0
  101. package/build/features/connect/screens/VerifyPACI/VerifyPACILoading.d.ts +5 -0
  102. package/build/features/connect/screens/VerifyPACI/VerifyPACILoading.js +22 -0
  103. package/build/features/connect/screens/VerifyPACI/VerifyPACISuccess.d.ts +5 -0
  104. package/build/features/connect/screens/VerifyPACI/VerifyPACISuccess.js +8 -0
  105. package/build/features/connect/screens/VerifyPACI/index.d.ts +3 -0
  106. package/build/features/connect/screens/VerifyPACI/index.js +2 -0
  107. package/build/features/entity/Entity.d.ts +7 -0
  108. package/build/features/entity/Entity.js +70 -0
  109. package/build/features/entity/index.d.ts +1 -0
  110. package/build/features/entity/index.js +1 -0
  111. package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.d.ts +54 -0
  112. package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.js +139 -0
  113. package/build/features/entity/screens/EntityInfoConfirm/EntityInfo.d.ts +5 -0
  114. package/build/features/entity/screens/EntityInfoConfirm/EntityInfo.js +56 -0
  115. package/build/features/entity/screens/EntityInfoConfirm/LicenseName.d.ts +5 -0
  116. package/build/features/entity/screens/EntityInfoConfirm/LicenseName.js +17 -0
  117. package/build/features/entity/screens/EntityInfoConfirm/LicenseNumber.d.ts +5 -0
  118. package/build/features/entity/screens/EntityInfoConfirm/LicenseNumber.js +28 -0
  119. package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.d.ts +6 -0
  120. package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.js +38 -0
  121. package/build/features/entity/screens/EntityInfoConfirm/SalesChannels.d.ts +5 -0
  122. package/build/features/entity/screens/EntityInfoConfirm/SalesChannels.js +112 -0
  123. package/build/features/entity/screens/EntityInfoConfirm/index.d.ts +2 -0
  124. package/build/features/entity/screens/EntityInfoConfirm/index.js +2 -0
  125. package/build/features/entity/screens/EntityInfoConfirm/validation.d.ts +107 -0
  126. package/build/features/entity/screens/EntityInfoConfirm/validation.js +17 -0
  127. package/build/features/entity/screens/ResetPasswordSuccess/ResetPasswordSuccess.d.ts +5 -0
  128. package/build/features/entity/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +9 -0
  129. package/build/features/entity/screens/ResetPasswordSuccess/index.d.ts +3 -0
  130. package/build/features/entity/screens/ResetPasswordSuccess/index.js +2 -0
  131. package/build/features/entity/screens/Success/Success.d.ts +5 -0
  132. package/build/features/entity/screens/Success/Success.js +16 -0
  133. package/build/features/entity/screens/Success/index.d.ts +3 -0
  134. package/build/features/entity/screens/Success/index.js +2 -0
  135. package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.d.ts +3 -0
  136. package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +109 -0
  137. package/build/features/entity/screens/SuccessWithFlowButtons/index.d.ts +2 -0
  138. package/build/features/entity/screens/SuccessWithFlowButtons/index.js +2 -0
  139. package/build/features/entity/screens/Verify/OTPInput.d.ts +7 -0
  140. package/build/features/entity/screens/Verify/OTPInput.js +47 -0
  141. package/build/features/entity/screens/Verify/Verify.d.ts +5 -0
  142. package/build/features/entity/screens/Verify/Verify.js +78 -0
  143. package/build/features/entity/screens/Verify/index.d.ts +2 -0
  144. package/build/features/entity/screens/Verify/index.js +2 -0
  145. package/build/features/entity/screens/Verify/validation.d.ts +8 -0
  146. package/build/features/entity/screens/Verify/validation.js +4 -0
  147. package/build/features/featuresScreens.d.ts +3 -0
  148. package/build/features/featuresScreens.js +48 -0
  149. package/build/features/individual/Individual.d.ts +1 -1
  150. package/build/features/individual/Individual.js +12 -5
  151. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +1 -1
  152. package/build/features/individual/screens/AdditionalIndividualInfo/MonthlyIncome.js +14 -3
  153. package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +11 -3
  154. package/build/features/individual/screens/AdditionalIndividualInfo/SourceOfIncome.js +2 -2
  155. package/build/features/otp/OTP.d.ts +7 -0
  156. package/build/features/otp/OTP.js +58 -0
  157. package/build/features/otp/index.d.ts +0 -0
  158. package/build/features/otp/index.js +1 -0
  159. package/build/features/otp/screens/OTPVerify/OTPInput.d.ts +6 -0
  160. package/build/features/otp/screens/OTPVerify/OTPInput.js +47 -0
  161. package/build/features/otp/screens/OTPVerify/Verify.d.ts +5 -0
  162. package/build/features/otp/screens/OTPVerify/Verify.js +49 -0
  163. package/build/features/otp/screens/OTPVerify/index.d.ts +2 -0
  164. package/build/features/otp/screens/OTPVerify/index.js +2 -0
  165. package/build/features/otp/screens/OTPVerify/validation.d.ts +8 -0
  166. package/build/features/otp/screens/OTPVerify/validation.js +4 -0
  167. package/build/features/password/Password.d.ts +1 -1
  168. package/build/features/password/Password.js +12 -5
  169. package/build/features/shared/Background/Background.d.ts +7 -5
  170. package/build/features/shared/Background/Background.js +16 -5
  171. package/build/features/shared/Dialog/CloseDialog.d.ts +11 -0
  172. package/build/features/shared/Dialog/CloseDialog.js +62 -0
  173. package/build/features/shared/Dialog/DialogContainer.d.ts +8 -0
  174. package/build/features/shared/Dialog/DialogContainer.js +56 -0
  175. package/build/features/shared/Dialog/index.d.ts +4 -0
  176. package/build/features/shared/Dialog/index.js +4 -0
  177. package/build/features/shared/Input/Input.d.ts +1 -1
  178. package/build/features/shared/Input/Input.js +2 -2
  179. package/build/features/shared/UploadFile/UploadFile.d.ts +8 -3
  180. package/build/features/shared/UploadFile/UploadFile.js +23 -8
  181. package/build/features/signIn/SignIn.d.ts +1 -1
  182. package/build/features/signIn/SignIn.js +12 -4
  183. package/build/features/tax/Tax.d.ts +1 -1
  184. package/build/features/tax/Tax.js +12 -4
  185. package/build/hooks/index.d.ts +1 -0
  186. package/build/hooks/index.js +1 -0
  187. package/build/hooks/useAppConfig.js +2 -0
  188. package/build/hooks/useAppDispatch.d.ts +3 -0
  189. package/build/hooks/useErrorListener.js +3 -2
  190. package/build/hooks/useScreen.d.ts +3 -0
  191. package/build/hooks/useScreen.js +14 -0
  192. package/build/index.d.ts +5 -2
  193. package/build/index.js +11 -2
  194. package/build/utils/device.d.ts +1 -0
  195. package/build/utils/device.js +13 -0
  196. package/build/utils/html.d.ts +1 -0
  197. package/build/utils/html.js +6 -0
  198. package/build/utils/locale.js +1 -1
  199. package/build/utils/rsa.d.ts +2 -2
  200. package/build/utils/rsa.js +1 -1
  201. package/build/utils/string.d.ts +22 -20
  202. package/build/utils/string.js +9 -0
  203. package/package.json +1 -1
@@ -35,6 +35,7 @@ import SimpleList from '../../../../components/SimpleList';
35
35
  import { ScreenContainer } from '../../../shared/Containers';
36
36
  import { useLanguage, useAppSelector, useAppDispatch } from '../../../../hooks';
37
37
  import { businessSelector, clearError } from '../../../app/business/businessStore';
38
+ import Search from '../../../../features/shared/Search';
38
39
  export var InputLabelStyled = styled(Text)(function (_a) {
39
40
  var theme = _a.theme;
40
41
  return (__assign({ margin: theme.spacing(2.5, 2.5, 1.5, 2.5), color: alpha(theme.palette.text.primary, 0.4) }, theme.typography.caption));
@@ -89,9 +90,12 @@ var customerLocations = function (_a) {
89
90
  (_a = rest.onListOpen) === null || _a === void 0 ? void 0 : _a.call(rest);
90
91
  };
91
92
  var onCloseList = function () {
92
- var _a;
93
+ var _a, _b;
93
94
  setAnchorEl(null);
94
95
  (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
96
+ if (((_b = response === null || response === void 0 ? void 0 : response.customerBases) === null || _b === void 0 ? void 0 : _b.length) > 0) {
97
+ setCustomerLocationsList(response === null || response === void 0 ? void 0 : response.customerBases);
98
+ }
95
99
  };
96
100
  React.useEffect(function () {
97
101
  var _a;
@@ -106,15 +110,29 @@ var customerLocations = function (_a) {
106
110
  };
107
111
  var onSelectItem = function (customerLocations) {
108
112
  onCloseList();
109
- var remaining = customerLocationsList.filter(function (location) { return location.id <= customerLocations.id; });
113
+ var checked = customerLocationsList.filter(function (location) { return location.id === customerLocations.id; });
114
+ if (customerLocations.id === 'cba_zHyD6221116meEv257b93818')
115
+ customerLocationsControl.field.onChange(checked.concat(customerLocationsList.filter(function (location) { return location.id === 'cba_PKZd19221115ub9D25H493833'; })));
116
+ else if (customerLocations.id === 'cba_NnUL20221116g2QG25Na9n129')
117
+ customerLocationsControl.field.onChange(checked.concat(customerLocationsList.filter(function (location) { return location.id != customerLocations.id; })));
118
+ else if (customerLocations.id === 'cba_PKZd19221115ub9D25H493833')
119
+ customerLocationsControl.field.onChange(checked);
110
120
  if (error)
111
121
  dispatch(clearError());
112
- customerLocationsControl.field.onChange(remaining);
122
+ };
123
+ var handleSearch = function (value) {
124
+ var _a;
125
+ var filteredList = (_a = response === null || response === void 0 ? void 0 : response.customerBases) === null || _a === void 0 ? void 0 : _a.filter(function (location) {
126
+ return location.name.en.toLowerCase().startsWith(value.toLowerCase()) ||
127
+ location.name.ar.toLowerCase().startsWith(value.toLowerCase());
128
+ });
129
+ setCustomerLocationsList(filteredList);
113
130
  };
114
131
  var customerLocationsValue = customerLocationsControl.field.value;
115
- var customerLocationSelected = customerLocationsValue[customerLocationsValue.length - 1];
116
- return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('select_customer_base') }), _jsx(InputStyled, { readOnly: true, value: isAr ? customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name_ar : customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name_en, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: customerLocationsList, placeholder: 'choose_customer_base', onSelectItem: onSelectItem, renderItem: function (item) {
117
- return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (customerLocationsValue === null || customerLocationsValue === void 0 ? void 0 : customerLocationsValue.id) }, { children: isAr ? item.name_ar : item.name_en })) })), item.id === (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(CheckIconStyled, {}), checkRemainingCondition(item) && item.id != (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(RemainingCheck, {})] }));
118
- } }) }))] }) })));
132
+ var customerLocationSelected = customerLocationsValue === null || customerLocationsValue === void 0 ? void 0 : customerLocationsValue[0];
133
+ console.log(customerLocationSelected, 'sele');
134
+ return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('select_customer_base') }), _jsx(InputStyled, { readOnly: true, value: isAr ? customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name.ar : customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name.en, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { searchKeyPath: 'name.en', list: customerLocationsList, placeholder: 'choose_customer_base', onSelectItem: onSelectItem, renderItem: function (item) {
135
+ return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (customerLocationsValue === null || customerLocationsValue === void 0 ? void 0 : customerLocationsValue.id) }, { children: isAr ? item.name.ar : item.name.en })) })), item.id === (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(CheckIconStyled, {}), checkRemainingCondition(item) && item.id != (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(RemainingCheck, {})] }));
136
+ } })] }))] }) })));
119
137
  };
120
138
  export default React.memo(customerLocations);
@@ -33,6 +33,7 @@ import ExpandIcon from '../../../../components/ExpandIcon';
33
33
  import { ScreenContainer } from '../../../shared/Containers';
34
34
  import { CheckIconStyled, InputLabelStyled, InputStyled, NameContainer } from './CustomerLocations';
35
35
  import { businessSelector, clearError } from '../../../app/business/businessStore';
36
+ import Search from '../../../../features/shared/Search';
36
37
  var ListItemContainer = styled(Box)(function (_a) {
37
38
  var theme = _a.theme;
38
39
  return ({
@@ -61,9 +62,12 @@ var ExpectedCustomers = function (_a) {
61
62
  (_a = rest.onListOpen) === null || _a === void 0 ? void 0 : _a.call(rest);
62
63
  };
63
64
  var onCloseList = function () {
64
- var _a;
65
+ var _a, _b;
65
66
  setAnchorEl(null);
66
67
  (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
68
+ if (((_b = response === null || response === void 0 ? void 0 : response.expectedCustomerSales) === null || _b === void 0 ? void 0 : _b.length) > 0) {
69
+ setExpectedCustomersList(response === null || response === void 0 ? void 0 : response.expectedCustomerSales);
70
+ }
67
71
  };
68
72
  React.useEffect(function () {
69
73
  var _a;
@@ -77,10 +81,18 @@ var ExpectedCustomers = function (_a) {
77
81
  dispatch(clearError());
78
82
  onCloseList();
79
83
  };
84
+ var handleSearch = function (value) {
85
+ var _a;
86
+ var filteredList = (_a = response === null || response === void 0 ? void 0 : response.expectedCustomerSales) === null || _a === void 0 ? void 0 : _a.filter(function (customer) {
87
+ return customer.name.en.toLowerCase().startsWith(value.toLowerCase()) ||
88
+ customer.name.ar.toLowerCase().startsWith(value.toLowerCase());
89
+ });
90
+ setExpectedCustomersList(filteredList);
91
+ };
80
92
  var expectedCustomersValue = expectedCustomerControl.field.value;
81
93
  var expectedCustomersSelected = expectedCustomersValue;
82
- return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_customers_to_serve') }), _jsx(InputStyled, { readOnly: true, value: isAr ? expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.name_ar : expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.name_en, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: expectedCustomersList, onSelectItem: onSelectItem, renderItem: function (item) {
83
- return (_jsxs(_Fragment, { children: [_jsx(ListItemContainer, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (expectedCustomersValue === null || expectedCustomersValue === void 0 ? void 0 : expectedCustomersValue.id) }, { children: isAr ? item.name_ar : item.name_en })) }), item.id === (expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.id) && _jsx(CheckIconStyled, {})] }));
84
- } }) }))] }) })));
94
+ return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_customers_to_serve') }), _jsx(InputStyled, { readOnly: true, value: isAr ? expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.name.ar : expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.name.en, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { searchKeyPath: 'name', list: expectedCustomersList, onSelectItem: onSelectItem, renderItem: function (item) {
95
+ return (_jsxs(_Fragment, { children: [_jsx(ListItemContainer, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (expectedCustomersValue === null || expectedCustomersValue === void 0 ? void 0 : expectedCustomersValue.id) }, { children: isAr ? item.name.ar : item.name.en })) }), item.id === (expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.id) && _jsx(CheckIconStyled, {})] }));
96
+ } })] }))] }) })));
85
97
  };
86
98
  export default ExpectedCustomers;
@@ -23,6 +23,7 @@ import { businessSelector, clearError } from '../../../app/business/businessStor
23
23
  import { isExist } from '../../../../utils';
24
24
  import { ScreenContainer } from '../../../shared/Containers';
25
25
  import { InputLabelStyled, CheckIconStyled, InputStyled, NameContainer } from './CustomerLocations';
26
+ import Search from '../../../../features/shared/Search';
26
27
  var ListItem = styled(Box)(function (_a) {
27
28
  var theme = _a.theme;
28
29
  return ({
@@ -65,6 +66,9 @@ var ExpectedSalesRange = function (_a) {
65
66
  setAnchorEl(null);
66
67
  onListClose === null || onListClose === void 0 ? void 0 : onListClose();
67
68
  handleCloseSubMenu();
69
+ if ((expectedSales === null || expectedSales === void 0 ? void 0 : expectedSales.length) > 0) {
70
+ setExpectedSalesRangeList(expectedSales);
71
+ }
68
72
  };
69
73
  var handleOpenSubMenu = function (index) {
70
74
  if (subIndex === index)
@@ -86,24 +90,38 @@ var ExpectedSalesRange = function (_a) {
86
90
  dispatch(clearError());
87
91
  expectedSaleControl.field.onChange(expectedSalesRange);
88
92
  };
93
+ var handleSearch = function (value) {
94
+ var filteredSubList = expectedSales === null || expectedSales === void 0 ? void 0 : expectedSales.filter(function (salesRange) {
95
+ var _a;
96
+ return (_a = salesRange.sub) === null || _a === void 0 ? void 0 : _a.find(function (obj) { return obj.name.en.toLowerCase().startsWith(value.toLowerCase()); });
97
+ });
98
+ var filteredList = expectedSales === null || expectedSales === void 0 ? void 0 : expectedSales.filter(function (salesRange) {
99
+ var _a, _b;
100
+ return salesRange.name.en.toLowerCase().includes(value.toLowerCase()) ||
101
+ salesRange.name.ar.toLowerCase().includes(value.toLowerCase()) ||
102
+ ((_a = salesRange.sub) === null || _a === void 0 ? void 0 : _a.find(function (obj) { return obj.name.en.toLowerCase().includes(value.toLowerCase()); })) ||
103
+ ((_b = salesRange.sub) === null || _b === void 0 ? void 0 : _b.find(function (obj) { return obj.name.ar.toLowerCase().includes(value.toLowerCase()); }));
104
+ });
105
+ setExpectedSalesRangeList(filteredList);
106
+ };
89
107
  React.useEffect(function () {
90
108
  var item = isExist(expectedSales || [], expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.id);
91
109
  if (item)
92
110
  setSubIndex(item.id);
93
111
  }, [anchorEl, expectedSalesRangeValue]);
94
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_sales_yearly') }), _jsx(InputStyled, { readOnly: true, value: (isAr ? expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.name_ar : expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.name_en) || '', onClick: !!anchorEl ? handleCloseMainMenu : handleOpenMainMenu, placeholder: t('choose_expected_sales'), endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleListStyled, { sx: { maxHeight: '350px', paddingTop: 0 }, list: expectedSalesRangeList, listItemProps: { sx: { padding: 0 } }, onSelectItem: function (item) {
95
- var isOnlyOneItem = !item.sub || item.sub.length === 1;
96
- if (isOnlyOneItem)
97
- onSelectItem(item);
98
- else
99
- handleOpenSubMenu(item.id);
100
- }, renderItem: function (item) {
101
- var _a;
102
- var isOnlyOneItem = !item.sub || ((_a = item.sub) === null || _a === void 0 ? void 0 : _a.length) === 1;
103
- var showCheck = item.id === (expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.id) && isOnlyOneItem;
104
- return (_jsxs(ListItemContainer, { children: [_jsxs(ListItem, __assign({ sx: __assign({ bgcolor: 'rgb(196 184 184 / 8%)', borderBottom: '1px solid rgba(227, 232, 238, 0.8)' }, (isOnlyOneItem && { bgcolor: 'inherit', borderBottom: 'none' })) }, { children: [_jsx(NameContainer, __assign({ isSelected: item.id === (expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.id), sx: __assign({}, (isOnlyOneItem && { paddingInlineStart: '5px' })) }, { children: isAr ? item.name_ar : item.name_en })), showCheck ? _jsx(CheckIconStyled, {}) : !isOnlyOneItem && _jsx(ExpandIcon, { anchorEl: subIndex === item.id })] })), _jsx(Collapse, __assign({ in: item.id === subIndex && !isOnlyOneItem }, { children: _jsx(SimpleListStyled, { sx: { pt: 0, pb: 0 }, list: (!isOnlyOneItem && item.sub) || [], onSelectItem: onSelectItem, listItemProps: { sx: { padding: 0, '&:last-child': { paddingBottom: 0 } } }, renderItem: function (item, idx) {
105
- return (_jsxs(ListItem, __assign({ sx: { mt: idx === 0 ? 1 : 0 } }, { children: [_jsx(NameContainer, __assign({ isSelected: item.id === (expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.id) }, { children: isAr ? item.name_ar : item.name_en })), item.id === (expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.id) && _jsx(CheckIconStyled, {})] })));
106
- } }) }))] }));
107
- } }) }))] }) })));
112
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_sales_yearly') }), _jsx(InputStyled, { readOnly: true, value: (isAr ? expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.name.ar : expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.name.en) || '', onClick: !!anchorEl ? handleCloseMainMenu : handleOpenMainMenu, placeholder: t('choose_expected_sales'), endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { sx: { maxHeight: '350px', paddingTop: 0 }, list: expectedSalesRangeList, listItemProps: { sx: { padding: 0 } }, onSelectItem: function (item) {
113
+ var isOnlyOneItem = !item.sub || item.sub.length === 1;
114
+ if (isOnlyOneItem)
115
+ onSelectItem(item);
116
+ else
117
+ handleOpenSubMenu(item.id);
118
+ }, renderItem: function (item) {
119
+ var _a;
120
+ var isOnlyOneItem = !item.sub || ((_a = item.sub) === null || _a === void 0 ? void 0 : _a.length) === 1;
121
+ var showCheck = item.id === (expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.id) && isOnlyOneItem;
122
+ return (_jsxs(ListItemContainer, { children: [_jsxs(ListItem, __assign({ sx: __assign({ bgcolor: 'rgb(196 184 184 / 8%)', borderBottom: '1px solid rgba(227, 232, 238, 0.8)' }, (isOnlyOneItem && { bgcolor: 'inherit', borderBottom: 'none' })) }, { children: [_jsx(NameContainer, __assign({ isSelected: item.id === (expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.id), sx: __assign({}, (isOnlyOneItem && { paddingInlineStart: '5px' })) }, { children: isAr ? item.name.ar : item.name.en })), showCheck ? _jsx(CheckIconStyled, {}) : !isOnlyOneItem && _jsx(ExpandIcon, { anchorEl: subIndex === item.id })] })), _jsx(Collapse, __assign({ in: item.id === subIndex && !isOnlyOneItem }, { children: _jsx(SimpleListStyled, { sx: { pt: 0, pb: 0 }, list: (!isOnlyOneItem && item.sub) || [], onSelectItem: onSelectItem, listItemProps: { sx: { padding: 0, '&:last-child': { paddingBottom: 0 } } }, renderItem: function (item, idx) {
123
+ return (_jsxs(ListItem, __assign({ sx: { mt: idx === 0 ? 1 : 0 } }, { children: [_jsx(NameContainer, __assign({ isSelected: item.id === (expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.id) }, { children: isAr ? item.name.ar : item.name.en })), item.id === (expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.id) && _jsx(CheckIconStyled, {})] })));
124
+ } }) }))] }));
125
+ } })] }))] }) })));
108
126
  };
109
127
  export default ExpectedSalesRange;
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { LibConfig } from '../../@types';
3
3
  export interface ConnectLibProps extends LibConfig {
4
+ onClose?: () => void;
4
5
  }
5
6
  export declare function ConnectLib(props: ConnectLibProps): JSX.Element;
6
7
  export declare function renderConnectLib(config: ConnectLibProps, elementId: string): void;
7
- export declare function unmountConnectLib(elementId: string): void;
8
+ export declare function unmountConnectLib(elementId: string, unmountTimeout?: number): void;
@@ -9,30 +9,53 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
12
23
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { memo } from 'react';
24
+ import React, { memo } from 'react';
14
25
  import { FeatureContainer } from '../shared/Containers';
15
- import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener } from '../../hooks';
16
- import { settingsSelector } from '../../app/settings';
26
+ import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener, useAppDispatch } from '../../hooks';
27
+ import { handleCurrentActiveScreen, settingsSelector, handleOpen } from '../../app/settings';
17
28
  import AnimationFlow from '../../components/AnimationFlow';
18
29
  import { store } from '../../app/store';
19
30
  import { connectSelector } from '../app/connect/connectStore';
20
31
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
21
32
  import Collapse from '../../components/Collapse';
22
- import { reactElement } from '../../utils';
23
- import { CONNECT_SCREENS_NAVIGATION } from '../../constants';
33
+ import { reactElement, removeElement, isKW } from '../../utils';
34
+ import { CONNECT_SCREENS_NAVIGATION, DIALOG_ID } from '../../constants';
24
35
  import { connectFeatureScreens } from '../featuresScreens';
25
36
  import CustomFooter from '../shared/Footer';
26
37
  import Background from '../shared/Background';
27
- var Connect = memo(function (props) {
38
+ var Connect = memo(function (_a) {
39
+ var onClose = _a.onClose, props = __rest(_a, ["onClose"]);
28
40
  var theme = useAppTheme().theme;
29
- var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, settingLoading = _a.loading;
41
+ var dispatch = useAppDispatch();
42
+ var _b = useAppSelector(settingsSelector), data = _b.data, error = _b.error, settingLoading = _b.loading;
30
43
  var connectError = useAppSelector(connectSelector).error;
31
44
  useAppConfig(__assign({ navigation: CONNECT_SCREENS_NAVIGATION }, props));
32
45
  useErrorListener(connectError || error);
33
46
  useStepStartedListener();
34
47
  var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open;
35
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading, error: error, open: open, footer: _jsx(CustomFooter, {}), screenId: activeScreen.name }, { children: _jsx(FeatureContainer, { children: connectFeatureScreens.map(function (_a, index) {
48
+ React.useEffect(function () {
49
+ var _a;
50
+ if (!settingLoading) {
51
+ if (isKW((_a = data.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2))
52
+ dispatch(handleCurrentActiveScreen('CONNECT_CIVIL_ID_STEP'));
53
+ }
54
+ }, [settingLoading]);
55
+ var handleDialogClose = function () {
56
+ dispatch(handleOpen(false));
57
+ };
58
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ open: open, isTapOrigin: isTapOrigin, loading: settingLoading }, { children: _jsx(AnimationFlow, __assign({ onClose: onClose, onConfirm: handleDialogClose, isTapOrigin: isTapOrigin, loading: settingLoading, error: error, open: open, footer: _jsx(CustomFooter, {}), screenId: activeScreen.name }, { children: _jsx(FeatureContainer, { children: connectFeatureScreens.map(function (_a, index) {
36
59
  var Element = _a.element, name = _a.name;
37
60
  var isActive = activeScreen.name === name;
38
61
  return (_jsx(Collapse, __assign({ in: isActive, timeout: { enter: 1000, exit: 800 } }, { children: _jsx(Element, {}) }), index));
@@ -44,6 +67,13 @@ export function ConnectLib(props) {
44
67
  export function renderConnectLib(config, elementId) {
45
68
  reactElement(elementId).render(_jsx(ConnectLib, __assign({}, config)));
46
69
  }
47
- export function unmountConnectLib(elementId) {
48
- reactElement(elementId).unmount();
70
+ export function unmountConnectLib(elementId, unmountTimeout) {
71
+ if (unmountTimeout === void 0) { unmountTimeout = 1000; }
72
+ var element = document.getElementById(elementId);
73
+ setTimeout(function () {
74
+ var _a;
75
+ ((_a = element === null || element === void 0 ? void 0 : element.children) === null || _a === void 0 ? void 0 : _a.length) && element.removeChild(element.children[0]);
76
+ removeElement(DIALOG_ID);
77
+ reactElement(elementId).unmount();
78
+ }, unmountTimeout);
49
79
  }
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface CivilIDProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: CivilIDProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,85 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import { useTranslation } from 'react-i18next';
15
+ import { alpha, styled } from '@mui/material/styles';
16
+ import { useForm, FormProvider } from 'react-hook-form';
17
+ import { yupResolver } from '@hookform/resolvers/yup';
18
+ import { civilIDValidationSchema } from './validation';
19
+ import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
20
+ import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
21
+ import { clearError, connectSelector, createCivilIdAuth } from '../../../app/connect/connectStore';
22
+ import Form from '../../../../components/Form';
23
+ import Button, { MobileButton } from '../../../shared/Button';
24
+ import { ScreenContainer } from '../../../shared/Containers';
25
+ import Collapse from '../../../../components/Collapse';
26
+ import Box from '@mui/material/Box';
27
+ import Divider from '@mui/material/Divider';
28
+ import Text from '../../../../components/Text';
29
+ import IDNumber from './IDNumber';
30
+ var FormStyled = styled(Form)(function () { return ({
31
+ display: 'flex',
32
+ flexDirection: 'column'
33
+ }); });
34
+ var TextStyled = styled(Text)(function (_a) {
35
+ var theme = _a.theme;
36
+ return ({
37
+ color: alpha(theme.palette.primary.dark, 0.4)
38
+ });
39
+ });
40
+ var DividerStyled = styled(Divider)(function (_a) {
41
+ var theme = _a.theme;
42
+ return ({
43
+ width: '45%',
44
+ borderColor: alpha(theme.palette.primary.dark, 0.4),
45
+ marginBlockEnd: theme.spacing(0.62)
46
+ });
47
+ });
48
+ var OrBoxStyled = styled(Box)(function (_a) {
49
+ var theme = _a.theme;
50
+ return ({
51
+ display: 'flex',
52
+ justifyContent: 'space-between',
53
+ marginBlockEnd: theme.spacing(1.62),
54
+ marginBlockStart: theme.spacing(-1.25),
55
+ marginInline: theme.spacing(2.5)
56
+ });
57
+ });
58
+ var CivilID = function (_a) {
59
+ var isAr = useLanguage().isAr;
60
+ var dispatch = useAppDispatch();
61
+ var t = useTranslation().t;
62
+ var _b = useAppSelector(connectSelector), data = _b.data, loading = _b.loading, error = _b.error;
63
+ var settingsStore = useAppSelector(settingsSelector);
64
+ var methods = useForm({
65
+ resolver: yupResolver(civilIDValidationSchema),
66
+ defaultValues: data.civilIdData,
67
+ mode: 'onChange'
68
+ });
69
+ React.useEffect(function () {
70
+ handleClearError();
71
+ }, [methods.formState.isValid]);
72
+ var onSubmit = function (data) {
73
+ dispatch(createCivilIdAuth(data));
74
+ };
75
+ var handleClearError = function () {
76
+ if (error)
77
+ dispatch(clearError());
78
+ };
79
+ var onBack = function () {
80
+ dispatch(handlePrevScreenStep('CONNECT_MOBILE_STEP'));
81
+ };
82
+ var disabled = !methods.formState.isValid || !!error;
83
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(IDNumber, { sx: { mb: methods.formState.isValid ? 7.5 : 0, transition: 'mb 0.3s' } }), _jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') })), _jsxs(Collapse, __assign({ in: !methods.formState.isValid }, { children: [_jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(MobileButton, __assign({ onClick: function () { return onBack(); }, disabled: loading || settingsStore.loading }, { children: t('mobile_button_label') }))] }))] })) })) }));
84
+ };
85
+ export default React.memo(CivilID);
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { SxProps, Theme } from '@mui/material/styles';
3
+ interface IDNumberProps {
4
+ sx: SxProps<Theme> | undefined;
5
+ }
6
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<IDNumberProps & React.RefAttributes<unknown>>>;
7
+ export default _default;
@@ -0,0 +1,59 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import Box from '@mui/material/Box';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { useController, useFormContext } from 'react-hook-form';
17
+ import { styled, alpha } from '@mui/material/styles';
18
+ import Text from '../../../../components/Text';
19
+ import Input from '../../../shared/Input';
20
+ import ClearIcon from '../../../shared/ClearIcon';
21
+ import CheckIcon from '../../../shared/CheckIcon';
22
+ import ScreenContainer from '../../../shared/Containers/ScreenContainer';
23
+ import { removeAllOtherThanCharsAndNumber } from '../../../../utils';
24
+ import { CIVIL_ID_NUMBER_LENGTH } from '../../../../constants';
25
+ var LabelContainerStyled = styled(Box)(function (_a) {
26
+ var theme = _a.theme;
27
+ return ({
28
+ display: 'flex',
29
+ justifyContent: 'space-between',
30
+ padding: theme.spacing(0, 2.5, 1.25, 2.5)
31
+ });
32
+ });
33
+ var InputLabelStyled = styled(Text)(function (_a) {
34
+ var theme = _a.theme;
35
+ return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
36
+ });
37
+ var IDNumber = React.forwardRef(function (_a, ref) {
38
+ var _b;
39
+ var sx = _a.sx;
40
+ var t = useTranslation().t;
41
+ var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
42
+ var civilIdControl = useController({ control: control, name: 'civilId' });
43
+ React.useEffect(function () {
44
+ if (civilIdControl.field.value)
45
+ setValue('civilId', civilIdControl.field.value, { shouldValidate: true });
46
+ }, []);
47
+ var handleIdChange = function (_a) {
48
+ var target = _a.target;
49
+ var value = removeAllOtherThanCharsAndNumber(target.value);
50
+ civilIdControl.field.onChange(value);
51
+ };
52
+ var clearIdNumber = function () {
53
+ civilIdControl.field.onChange('');
54
+ };
55
+ var idValue = civilIdControl.field.value;
56
+ var error = (_b = civilIdControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
57
+ return (_jsxs(ScreenContainer, __assign({ ref: ref, sx: sx }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('enter_civil_id') }) }), _jsx(Input, { dir: 'ltr', type: 'text', inputProps: { maxLength: CIVIL_ID_NUMBER_LENGTH }, onChange: handleIdChange, value: idValue, endAdornment: !error && idValue ? _jsx(CheckIcon, {}) : idValue && _jsx(ClearIcon, { onClick: clearIdNumber }), placeholder: t('civil_id_placeholder'), warningType: 'alert', warningMessage: error && t(error), required: true })] })));
58
+ });
59
+ export default React.memo(IDNumber);
@@ -0,0 +1,3 @@
1
+ import CivilID, { CivilIDProps } from './CivilID';
2
+ export type { CivilIDProps };
3
+ export default CivilID;
@@ -0,0 +1,2 @@
1
+ import CivilID from './CivilID';
2
+ export default CivilID;
@@ -0,0 +1,8 @@
1
+ import * as yup from 'yup';
2
+ export declare const civilIDValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ civilId: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
5
+ civilId: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
6
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
+ civilId: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ }>>>;
@@ -0,0 +1,4 @@
1
+ import * as yup from 'yup';
2
+ export var civilIDValidationSchema = yup.object().shape({
3
+ civilId: yup.string().min(10, 'invalid_civil_id').max(20, 'invalid_civil_id').required('invalid_civil_id')
4
+ });
@@ -18,7 +18,7 @@ import { useTranslation } from 'react-i18next';
18
18
  import { useForm, FormProvider } from 'react-hook-form';
19
19
  import { yupResolver } from '@hookform/resolvers/yup';
20
20
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
21
- import { handlePrevScreenStep } from '../../../../app/settings';
21
+ import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
22
22
  import { IndividualValidation, IndividualMobileValidation } from './validation';
23
23
  import Form from '../../../../components/Form';
24
24
  import Button from '../../../shared/Button';
@@ -28,6 +28,7 @@ import { useLanguage } from '../../../../hooks';
28
28
  import MobileNumber from './MobileNumber';
29
29
  import { countriesCode } from '../../../../constants';
30
30
  import Collapse from '../../../../components/Collapse';
31
+ import { isKW } from '../../../../utils';
31
32
  var FormStyled = styled(Form)(function () { return ({
32
33
  display: 'flex',
33
34
  flexDirection: 'column'
@@ -36,6 +37,7 @@ var Individual = function (_a) {
36
37
  var _b, _c, _d;
37
38
  var _e = React.useState(false), listActive = _e[0], setListActive = _e[1];
38
39
  var _f = React.useState(false), emailChecking = _f[0], setEmailChecking = _f[1];
40
+ var settingsData = useAppSelector(settingsSelector).data;
39
41
  var _g = useAppSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error;
40
42
  var dispatch = useAppDispatch();
41
43
  var t = useTranslation().t;
@@ -51,8 +53,10 @@ var Individual = function (_a) {
51
53
  dispatch(updateLeadIndividual(formData));
52
54
  };
53
55
  var onBack = function () {
56
+ var _a;
54
57
  dispatch(resetIndividualScreen());
55
- dispatch(handlePrevScreenStep(isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
58
+ var code = (_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2;
59
+ dispatch(handlePrevScreenStep(isKW(code) ? 'CONNECT_CIVIL_ID_STEP' : isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
56
60
  };
57
61
  React.useEffect(function () {
58
62
  if (error)
@@ -16,28 +16,32 @@ import { useTranslation } from 'react-i18next';
16
16
  import Collapse from '@mui/material/Collapse';
17
17
  import { yupResolver } from '@hookform/resolvers/yup';
18
18
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
19
- import { handlePrevScreenStep } from '../../../../app/settings';
19
+ import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
20
20
  import Form from '../../../../components/Form';
21
21
  import { INSTAGRAM_URL, TWITTER_URL } from '../../../../constants';
22
22
  import { ScreenContainer } from '../../../shared/Containers';
23
23
  import Button from '../../../shared/Button';
24
24
  import { clearError, connectSelector, updateLeadBrand } from '../../../app/connect/connectStore';
25
25
  import { useLanguage } from '../../../../hooks';
26
+ import { isKW } from '../../../../utils';
26
27
  import { MerchantValidationSchema, ValidationOptions } from './validation';
27
28
  import BrandName from './BrandName';
28
29
  import SocialMedia from './SocialMedia';
29
30
  import TAC from './TAC';
30
31
  import BrandList from './BrandList';
32
+ import SalesChannels from './SalesChannels';
31
33
  var Merchant = function (_a) {
32
- var _b, _c, _d;
33
- var _e = React.useState(false), brandNameChecking = _e[0], setBrandNameChecking = _e[1];
34
- var _f = React.useState(ValidationOptions.NEW_USER), userType = _f[0], setUserType = _f[1];
35
- var _g = React.useState(false), listActive = _g[0], setListActive = _g[1];
36
- var _h = useAppSelector(connectSelector), data = _h.data, loading = _h.loading, error = _h.error;
34
+ var _b, _c;
35
+ var _d = React.useState(false), brandNameChecking = _d[0], setBrandNameChecking = _d[1];
36
+ var _e = React.useState(ValidationOptions.NEW_USER), userType = _e[0], setUserType = _e[1];
37
+ var _f = React.useState(false), listActive = _f[0], setListActive = _f[1];
38
+ var _g = useAppSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error;
39
+ var settingsData = useAppSelector(settingsSelector).data;
37
40
  var isNewUser = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.new_user;
38
41
  var isAbsher = data.otpData.isAbsher;
39
- var brandList = ((_c = data.brandData.responseBody) === null || _c === void 0 ? void 0 : _c.brands) || [];
40
- var _j = data.brandData, brandName = _j.brandName, links = _j.links, selectedBrandItem = _j.selectedBrandItem, termAndConditionChecked = _j.termAndConditionChecked, responseBody = _j.responseBody;
42
+ var _h = data.brandData.responseBody || {}, brands = _h.brands, channelList = _h.channelList;
43
+ var brandList = brands || [];
44
+ var _j = data.brandData, brandName = _j.brandName, links = _j.links, selectedBrandItem = _j.selectedBrandItem, termAndConditionChecked = _j.termAndConditionChecked, responseBody = _j.responseBody, salesChannels = _j.salesChannels;
41
45
  var methods = useForm({
42
46
  resolver: yupResolver(MerchantValidationSchema(userType)),
43
47
  defaultValues: {
@@ -56,11 +60,13 @@ var Merchant = function (_a) {
56
60
  dispatch(updateLeadBrand(formData));
57
61
  };
58
62
  var onBack = function () {
63
+ var _a;
59
64
  if (isNewUser) {
60
65
  dispatch(handlePrevScreenStep('CONNECT_INDIVIDUAL_STEP'));
61
66
  return;
62
67
  }
63
- dispatch(handlePrevScreenStep(isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
68
+ var code = (_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2;
69
+ dispatch(handlePrevScreenStep(isKW(code) ? 'CONNECT_CIVIL_ID_STEP' : isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
64
70
  };
65
71
  React.useEffect(function () {
66
72
  if (error)
@@ -82,6 +88,7 @@ var Merchant = function (_a) {
82
88
  var sites = { website: '', twitter: '', instagram: '' };
83
89
  methods.setValue('brandName', '', { shouldValidate: true });
84
90
  methods.setValue('links', sites);
91
+ methods.setValue('salesChannels', []);
85
92
  }, 100);
86
93
  }
87
94
  if (isNewUser === false && (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0 && (formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) !== 'other') {
@@ -92,18 +99,35 @@ var Merchant = function (_a) {
92
99
  var website = (_e = formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.website) === null || _e === void 0 ? void 0 : _e.replaceAll(/(https|http):\/\//g, '');
93
100
  var sites_1 = __assign(__assign({}, links), { website: website, twitter: twitter, instagram: instagram });
94
101
  setTimeout(function () { return methods.setValue('links', sites_1, { shouldValidate: true }); }, 100);
102
+ var selectedChannels = (!!(channelList === null || channelList === void 0 ? void 0 : channelList[0]) && [channelList === null || channelList === void 0 ? void 0 : channelList[0]]) || [];
103
+ var _f = formDataSelectedBrand || {}, websiteUrl = _f.website, social = _f.social;
104
+ var isHasWebsite = (websiteUrl === null || websiteUrl === void 0 ? void 0 : websiteUrl.length) > 0;
105
+ var isHasTwitter = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('twitter.com'); });
106
+ var isHasInstagram = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('instagram.com'); });
107
+ var websiteData = channelList === null || channelList === void 0 ? void 0 : channelList.find(function (c) { return c.name.en.toLocaleLowerCase() === 'website'; });
108
+ var socialData = channelList === null || channelList === void 0 ? void 0 : channelList.find(function (c) { return c.name.en === 'social media'; });
109
+ if (isHasWebsite && (isHasTwitter || isHasInstagram))
110
+ selectedChannels = [websiteData, socialData];
111
+ else if (isHasTwitter || isHasInstagram)
112
+ selectedChannels = [socialData];
113
+ else if (isHasWebsite)
114
+ selectedChannels = [websiteData];
115
+ methods.setValue('salesChannels', selectedChannels);
95
116
  }
96
117
  }, [formDataSelectedBrand, isNewUser]);
97
118
  React.useEffect(function () {
98
119
  if (!(formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) && (selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.id))
99
120
  methods.setValue('selectedBrandItem', selectedBrandItem, { shouldValidate: true });
100
121
  }, [selectedBrandItem]);
122
+ React.useEffect(function () {
123
+ methods.setValue('salesChannels', salesChannels);
124
+ }, [salesChannels]);
101
125
  var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
102
- var disabled = brandErrChecks || brandNameChecking || ((_d = data.brandData.responseBody) === null || _d === void 0 ? void 0 : _d.response_code) === '5';
126
+ var disabled = brandErrChecks || brandNameChecking || ((_c = data.brandData.responseBody) === null || _c === void 0 ? void 0 : _c.response_code) === '5';
103
127
  var isBrandListAvailable = userType !== ValidationOptions.NEW_USER && brandList.length > 0;
104
128
  var askingForBrandInfo = userType === ValidationOptions.NEW_USER ||
105
129
  brandList.length === 0 ||
106
130
  userType === ValidationOptions.EXISTING_USER_WITH_OTHER_BRAND;
107
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: isBrandListAvailable, list: brandList, onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); } }), _jsx(BrandName, { show: !listActive && askingForBrandInfo, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(SocialMedia, { show: !listActive, isNewUser: isNewUser }), _jsx(TAC, { show: !listActive && askingForBrandInfo }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
131
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: isBrandListAvailable, list: brandList, onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); } }), _jsx(BrandName, { show: !listActive && askingForBrandInfo, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(Collapse, __assign({ in: !listActive }, { children: _jsx(SalesChannels, {}) })), _jsx(SocialMedia, { show: !listActive, isNewUser: isNewUser }), _jsx(TAC, { show: !listActive && askingForBrandInfo }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
108
132
  };
109
133
  export default React.memo(Merchant);
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export declare const MandatoryStyled: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
3
+ export declare const CollapseStyled: import("@emotion/styled").StyledComponent<import("../../../../components/Collapse").CollapseProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
4
+ declare const SalesChannels: () => JSX.Element;
5
+ export default SalesChannels;