@tap-payments/auth-jsconnect 2.0.76-test → 2.0.77-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.
@@ -254,5 +254,7 @@
254
254
  "enter_civil_id": "Please enter your civil ID",
255
255
  "invalid_civil_id": "Please enter valid civil ID",
256
256
  "authenticate_kuwait_mobile_title": "Authenticate with Kuwait Mobile ID app",
257
- "authenticate_kuwait_mobile_description": "Please go to your Kuwait Mobile ID app and accept the authentication request from Tap."
257
+ "authenticate_kuwait_mobile_description": "Please go to your Kuwait Mobile ID app and accept the authentication request from Tap.",
258
+ "cr_kw_max_length": "May you please verify the entered commercial registration number. (Note - the commercial registration minimum of 3 may contains characters and digits).",
259
+ "fl_kw_max_length": "May you please verify the entered freelancer registration reference. (Note - the freelancer registration may contains characters and digits)."
258
260
  }
@@ -274,5 +274,7 @@
274
274
  "enter_civil_id": "Please enter your civil ID",
275
275
  "invalid_civil_id": "Please enter valid civil ID",
276
276
  "authenticate_kuwait_mobile_title": "Authenticate with Kuwait Mobile ID app",
277
- "authenticate_kuwait_mobile_description": "Please go to your Kuwait Mobile ID app and accept the authentication request from Tap."
277
+ "authenticate_kuwait_mobile_description": "Please go to your Kuwait Mobile ID app and accept the authentication request from Tap.",
278
+ "cr_kw_max_length": "May you please verify the entered commercial registration number. (Note - the commercial registration minimum of 3 may contains characters and digits).",
279
+ "fl_kw_max_length": "May you please verify the entered freelancer registration reference. (Note - the freelancer registration may contains characters and digits)."
278
280
  }
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  export interface RadioLabelProps {
3
3
  label: string;
4
4
  value: string;
5
+ control?: React.ReactElement<any, any>;
5
6
  }
6
- declare const _default: React.MemoExoticComponent<({ label, value }: RadioLabelProps) => JSX.Element>;
7
+ declare const _default: React.MemoExoticComponent<({ label, value, control }: RadioLabelProps) => JSX.Element>;
7
8
  export default _default;
@@ -27,8 +27,8 @@ var RadioLabelStyled = styled(FormControlLabel)(function (_a) {
27
27
  });
28
28
  });
29
29
  var RadioLabel = function (_a) {
30
- var label = _a.label, value = _a.value;
30
+ var label = _a.label, value = _a.value, control = _a.control;
31
31
  var t = useTranslation().t;
32
- return (_jsx(RadioLabelStyled, { value: value, control: _jsx(Radio, { color: 'primary', disableFocusRipple: true, disableRipple: true, disableTouchRipple: true, focusRipple: false }), label: t(label) }));
32
+ return (_jsx(RadioLabelStyled, { value: value, control: control || _jsx(Radio, { color: 'primary', disableFocusRipple: true, disableRipple: true, disableTouchRipple: true, focusRipple: false }), label: t(label) }));
33
33
  };
34
34
  export default React.memo(RadioLabel);
@@ -5,6 +5,8 @@ export declare const VAT_ID_LENGTH = 15;
5
5
  export declare const MAX_IBAN_VALUE = 34;
6
6
  export declare const FL_NUMBER_LENGTH = 8;
7
7
  export declare const CR_NUMBER_LENGTH = 10;
8
+ export declare const KW_MIN_LICENSE_LENGTH = 3;
9
+ export declare const KW_MAX_LICENSE_LENGTH = 50;
8
10
  export declare const SAUDI_NUMBER_LENGTH = 9;
9
11
  export declare const MAX_FILE_SIZE = 5000000;
10
12
  export declare const VALID_FILE_FORMATS: string[];
@@ -5,6 +5,8 @@ export var VAT_ID_LENGTH = 15;
5
5
  export var MAX_IBAN_VALUE = 34;
6
6
  export var FL_NUMBER_LENGTH = 8;
7
7
  export var CR_NUMBER_LENGTH = 10;
8
+ export var KW_MIN_LICENSE_LENGTH = 3;
9
+ export var KW_MAX_LICENSE_LENGTH = 50;
8
10
  export var SAUDI_NUMBER_LENGTH = 9;
9
11
  export var MAX_FILE_SIZE = 5000000;
10
12
  export var VALID_FILE_FORMATS = ['image/jpeg', 'image/png', 'image/jpg', 'application/pdf'];
@@ -60,7 +60,7 @@ import moment from 'moment';
60
60
  import API from '../../../api';
61
61
  import { BusinessType, FlowsTypes } from '../../../@types';
62
62
  import { BUSINESS_FLOW_SUCCESS, BUSINESS_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../constants';
63
- import { convertNumbers2English, getEighteenYearsAgo, hasKey, sleep, isKW } from '../../../utils';
63
+ import { convertNumbers2English, getEighteenYearsAgo, hasKey, sleep, isKW, isSA } from '../../../utils';
64
64
  import { handleNextScreenStep } from '../../../app/settings';
65
65
  export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
66
66
  var payload, data, leadResponse, brandInfo, boardResponse, entity_activities, data_1, countryIso2, board_id, board_info_id, steps, brandID, hasBusinessCompleted, hasBusinessCRInfoCompleted, hasBusinessCRActivitiesCompleted, hasBusinessCustomersCompleted;
@@ -78,7 +78,7 @@ export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', functio
78
78
  leadResponse = undefined;
79
79
  brandInfo = undefined;
80
80
  boardResponse = undefined;
81
- if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 17];
81
+ if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 18];
82
82
  return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
83
83
  case 2:
84
84
  leadResponse = _h.sent();
@@ -105,7 +105,7 @@ export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', functio
105
105
  if (data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH && !isKW(countryIso2)) {
106
106
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
107
107
  }
108
- if (!(data.step_name === 'business_info')) return [3, 17];
108
+ if (!(data.step_name === 'business_info')) return [3, 18];
109
109
  steps = (_d = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _d === void 0 ? void 0 : _d.steps;
110
110
  brandID = (_f = (_e = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _e === void 0 ? void 0 : _e.brand) === null || _f === void 0 ? void 0 : _f.id;
111
111
  hasBusinessCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_SUCCESS);
@@ -117,15 +117,15 @@ export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', functio
117
117
  case 7:
118
118
  _h.sent();
119
119
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
120
- return [3, 17];
120
+ return [3, 18];
121
121
  case 8:
122
122
  if (!(data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH)) return [3, 9];
123
123
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
124
- return [3, 17];
124
+ return [3, 18];
125
125
  case 9:
126
126
  if (!hasBusinessCustomersCompleted) return [3, 10];
127
127
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_SUCCESS_STEP'));
128
- return [3, 17];
128
+ return [3, 18];
129
129
  case 10:
130
130
  if (!hasBusinessCRActivitiesCompleted) return [3, 13];
131
131
  return [4, thunkApi.dispatch(retrieveDataList())];
@@ -135,20 +135,24 @@ export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', functio
135
135
  return [4, API.brandService.retrieveBrand(brandID)];
136
136
  case 12:
137
137
  brandInfo = _h.sent();
138
- return [3, 17];
138
+ return [3, 18];
139
139
  case 13:
140
140
  if (!hasBusinessCRInfoCompleted) return [3, 15];
141
141
  return [4, API.brandService.retrieveBrand(brandID)];
142
142
  case 14:
143
143
  brandInfo = _h.sent();
144
144
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_ACTIVITIES_STEP'));
145
- return [3, 17];
146
- case 15: return [4, thunkApi.dispatch(retrieveEntityList({ leadId: data === null || data === void 0 ? void 0 : data.id }))];
145
+ return [3, 18];
146
+ case 15:
147
+ if (!isSA(countryIso2)) return [3, 17];
148
+ return [4, thunkApi.dispatch(retrieveEntityList({ leadId: data === null || data === void 0 ? void 0 : data.id }))];
147
149
  case 16:
148
150
  _h.sent();
149
- thunkApi.dispatch(handleNextScreenStep('BUSINESS_BUSINESS_TYPE_STEP'));
150
151
  _h.label = 17;
151
- case 17: return [2, {
152
+ case 17:
153
+ thunkApi.dispatch(handleNextScreenStep('BUSINESS_BUSINESS_TYPE_STEP'));
154
+ _h.label = 18;
155
+ case 18: return [2, {
152
156
  data: data,
153
157
  leadData: __assign(__assign({}, leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data), { flows: BUSINESS_FLOW_SUCCESS.concat(boardResponse === null || boardResponse === void 0 ? void 0 : boardResponse.info) }),
154
158
  token: token,
@@ -199,11 +203,14 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
199
203
  case 1:
200
204
  data = (_j.sent()).data;
201
205
  brandInfo = undefined;
202
- if (!!data.errors) return [3, 14];
206
+ if (!!data.errors) return [3, 15];
203
207
  thunkApi.dispatch(updateStepName(stepName));
208
+ if (!isSA(countryIso2)) return [3, 3];
204
209
  return [4, thunkApi.dispatch(retrieveEntityList({ leadId: data === null || data === void 0 ? void 0 : data.id }))];
205
210
  case 2:
206
211
  _j.sent();
212
+ _j.label = 3;
213
+ case 3:
207
214
  (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, { otp: params.otp });
208
215
  steps = responseBody === null || responseBody === void 0 ? void 0 : responseBody.steps;
209
216
  hasBusinessCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_SUCCESS);
@@ -211,49 +218,49 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
211
218
  hasBusinessCRActivitiesCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_CR_ACTIVITIES);
212
219
  hasBusinessCustomersCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_CUSTOMERS);
213
220
  isIdentityAuthStep = data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH;
214
- if (!isNID) return [3, 3];
221
+ if (!isNID) return [3, 4];
215
222
  thunkApi.dispatch(handleNextScreenStep());
216
- return [3, 14];
217
- case 3:
218
- if (!(isIdentityAuthStep && isKW(countryIso2))) return [3, 4];
219
- thunkApi.dispatch(handleNextScreenStep('BUSINESS_CIVIL_ID_STEP'));
220
- return [3, 14];
223
+ return [3, 15];
221
224
  case 4:
222
- if (!hasBusinessCompleted) return [3, 6];
223
- return [4, thunkApi.dispatch(retrieveBoardDetails(verifyResponse === null || verifyResponse === void 0 ? void 0 : verifyResponse.board_id))];
225
+ if (!(isIdentityAuthStep && isKW(countryIso2))) return [3, 5];
226
+ thunkApi.dispatch(handleNextScreenStep('BUSINESS_CIVIL_ID_STEP'));
227
+ return [3, 15];
224
228
  case 5:
229
+ if (!hasBusinessCompleted) return [3, 7];
230
+ return [4, thunkApi.dispatch(retrieveBoardDetails(verifyResponse === null || verifyResponse === void 0 ? void 0 : verifyResponse.board_id))];
231
+ case 6:
225
232
  _j.sent();
226
233
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
227
- return [3, 14];
228
- case 6:
229
- if (!(data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH)) return [3, 7];
230
- thunkApi.dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
231
- return [3, 14];
234
+ return [3, 15];
232
235
  case 7:
233
- if (!hasBusinessCustomersCompleted) return [3, 8];
234
- thunkApi.dispatch(handleNextScreenStep('BUSINESS_SUCCESS_STEP'));
235
- return [3, 14];
236
+ if (!(data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH)) return [3, 8];
237
+ thunkApi.dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
238
+ return [3, 15];
236
239
  case 8:
237
- if (!hasBusinessCRActivitiesCompleted) return [3, 11];
238
- return [4, thunkApi.dispatch(retrieveDataList())];
240
+ if (!hasBusinessCustomersCompleted) return [3, 9];
241
+ thunkApi.dispatch(handleNextScreenStep('BUSINESS_SUCCESS_STEP'));
242
+ return [3, 15];
239
243
  case 9:
244
+ if (!hasBusinessCRActivitiesCompleted) return [3, 12];
245
+ return [4, thunkApi.dispatch(retrieveDataList())];
246
+ case 10:
240
247
  _j.sent();
241
248
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_CUSTOMERS_STEP'));
242
249
  return [4, API.brandService.retrieveBrand(brandID)];
243
- case 10:
244
- brandInfo = _j.sent();
245
- return [3, 14];
246
250
  case 11:
247
- if (!hasBusinessCRInfoCompleted) return [3, 13];
248
- return [4, API.brandService.retrieveBrand(brandID)];
251
+ brandInfo = _j.sent();
252
+ return [3, 15];
249
253
  case 12:
254
+ if (!hasBusinessCRInfoCompleted) return [3, 14];
255
+ return [4, API.brandService.retrieveBrand(brandID)];
256
+ case 13:
250
257
  brandInfo = _j.sent();
251
258
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_ACTIVITIES_STEP'));
252
- return [3, 14];
253
- case 13:
259
+ return [3, 15];
260
+ case 14:
254
261
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_BUSINESS_TYPE_STEP'));
255
- _j.label = 14;
256
- case 14: return [2, { data: data, formData: __assign(__assign({}, params), { isNID: isNID }), brandInfo: brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.brand }];
262
+ _j.label = 15;
263
+ case 15: return [2, { data: data, formData: __assign(__assign({}, params), { isNID: isNID }), brandInfo: brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.brand }];
257
264
  }
258
265
  });
259
266
  }); });
@@ -275,30 +282,27 @@ export var verifyPACI = createAsyncThunk('verifyPACI', function (params, thunkAp
275
282
  count = 1;
276
283
  _f.label = 1;
277
284
  case 1:
278
- if (!(count <= maxCalls)) return [3, 8];
285
+ if (!(count <= maxCalls)) return [3, 7];
279
286
  return [4, API.authService.getTokenVerify(responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token)];
280
287
  case 2:
281
288
  data = _f.sent();
282
289
  response = data;
283
290
  isSuccess = ((_b = data.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
284
- if (!isSuccess) return [3, 5];
285
- return [4, thunkApi.dispatch(retrieveEntityList({ leadId: responseBody === null || responseBody === void 0 ? void 0 : responseBody.id }))];
286
- case 3:
287
- _f.sent();
291
+ if (!isSuccess) return [3, 4];
288
292
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, {});
289
293
  return [4, ((_e = params === null || params === void 0 ? void 0 : params.onSuccess) === null || _e === void 0 ? void 0 : _e.call(params))];
290
- case 4:
294
+ case 3:
291
295
  _f.sent();
292
296
  thunkApi.dispatch(handleNextScreenStep());
293
- return [3, 8];
294
- case 5: return [4, sleep(interval * 1000)];
295
- case 6:
297
+ return [3, 7];
298
+ case 4: return [4, sleep(interval * 1000)];
299
+ case 5:
296
300
  _f.sent();
297
- _f.label = 7;
298
- case 7:
301
+ _f.label = 6;
302
+ case 6:
299
303
  count++;
300
304
  return [3, 1];
301
- case 8: return [2, { response: response }];
305
+ case 7: return [2, { response: response }];
302
306
  }
303
307
  });
304
308
  }); });
@@ -672,7 +676,7 @@ export var businessSlice = createSlice({
672
676
  state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), leadData), state.data.verify.responseBody), { board_id: boardId });
673
677
  state.data.verify.token = token;
674
678
  state.data.otpData.isNID = false;
675
- var _f = state.data.verify.responseBody || {}, entity = _f.entity, entity_activities = _f.entity_activities, business_type = _f.business_type;
679
+ var _f = state.data.verify.responseBody || {}, entity = _f.entity, entity_activities = _f.entity_activities, business_type = _f.business_type, business_name = _f.business_name;
676
680
  var issuingDate = (brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_operation_start_at)
677
681
  ? brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_operation_start_at
678
682
  : (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.issuing_date;
@@ -687,6 +691,7 @@ export var businessSlice = createSlice({
687
691
  });
688
692
  state.data.activitiesData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [activities === null || activities === void 0 ? void 0 : activities[0]];
689
693
  state.data.businessTypeData.responseBody = __assign(__assign({}, state.data.businessTypeData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities });
694
+ state.data.businessTypeData.entityLegalName = (business_name === null || business_name === void 0 ? void 0 : business_name.en) || '';
690
695
  if (!!(entity === null || entity === void 0 ? void 0 : entity.license)) {
691
696
  var licenseNumber_1 = (_c = entity === null || entity === void 0 ? void 0 : entity.license) === null || _c === void 0 ? void 0 : _c.number;
692
697
  var _g = state.data.businessTypeData || {}, responseBody = _g.responseBody, selectedLicense = _g.selectedLicense;
@@ -742,7 +747,7 @@ export var businessSlice = createSlice({
742
747
  }
743
748
  state.data.otpData = formData;
744
749
  state.data.otpData.responseBody = data;
745
- var _f = state.data.verify.responseBody || {}, entity = _f.entity, entity_activities = _f.entity_activities, business_type = _f.business_type;
750
+ var _f = state.data.verify.responseBody || {}, entity = _f.entity, entity_activities = _f.entity_activities, business_type = _f.business_type, business_name = _f.business_name;
746
751
  var issuingDate = (brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_operation_start_at)
747
752
  ? brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_operation_start_at
748
753
  : (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.issuing_date;
@@ -757,6 +762,7 @@ export var businessSlice = createSlice({
757
762
  });
758
763
  state.data.activitiesData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [activities === null || activities === void 0 ? void 0 : activities[0]];
759
764
  state.data.businessTypeData.responseBody = __assign(__assign({}, state.data.businessTypeData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities });
765
+ state.data.businessTypeData.entityLegalName = (business_name === null || business_name === void 0 ? void 0 : business_name.en) || '';
760
766
  if (!!(entity === null || entity === void 0 ? void 0 : entity.license)) {
761
767
  var licenseNumber_2 = (_c = entity === null || entity === void 0 ? void 0 : entity.license) === null || _c === void 0 ? void 0 : _c.number;
762
768
  var _g = state.data.businessTypeData || {}, responseBody = _g.responseBody, selectedLicense = _g.selectedLicense;
@@ -1,5 +1,5 @@
1
1
  import { RootState } from '../../../app/store';
2
- import { ResponseData, MobileFormValues, NIDFormValues, CivilFormValues, OTPFormValues, IndividualFormValues, SharedState, BrandFormValues, FlowsTypes } from '../../../@types';
2
+ import { ResponseData, MobileFormValues, NIDFormValues, CivilFormValues, OTPFormValues, IndividualFormValues, SharedState, BrandFormValues, FlowsTypes, ActionState, CountryCode } from '../../../@types';
3
3
  import { CancelToken } from 'axios';
4
4
  export declare const createMobileAuth: import("@reduxjs/toolkit").AsyncThunk<{
5
5
  response: any;
@@ -24,12 +24,14 @@ export declare const verifyAuth: import("@reduxjs/toolkit").AsyncThunk<{
24
24
  formData: OTPFormValues;
25
25
  leadData: any;
26
26
  selectedChannels: any;
27
+ countries: CountryCode[];
27
28
  }, OTPFormValues, {}>;
28
29
  interface verifyPACIParams {
29
30
  onSuccess?: () => void | Promise<void>;
30
31
  }
31
32
  export declare const verifyPACI: import("@reduxjs/toolkit").AsyncThunk<{
32
33
  response: any;
34
+ countries: CountryCode[];
33
35
  }, verifyPACIParams, {}>;
34
36
  export declare const retrieveLead: import("@reduxjs/toolkit").AsyncThunk<{
35
37
  response: any;
@@ -102,14 +104,15 @@ export interface ConnectState extends SharedState<ConnectData> {
102
104
  export declare const connectSlice: import("@reduxjs/toolkit").Slice<ConnectState, {
103
105
  clearError: (state: ConnectState) => void;
104
106
  stopLoader: (state: ConnectState) => void;
105
- resetMobileScreen: (state: ConnectState) => void;
107
+ resetMobileScreen: (state: ConnectState, action: ActionState<CountryCode>) => void;
106
108
  resetNIDScreen: (state: ConnectState) => void;
107
109
  resetCivilScreen: (state: ConnectState) => void;
108
110
  resetOTPScreen: (state: ConnectState) => void;
109
111
  resetIndividualScreen: (state: ConnectState) => void;
110
112
  resetMerchantScreen: (state: ConnectState) => void;
113
+ setDefaultCountryCode: (state: ConnectState, action: ActionState<CountryCode>) => void;
111
114
  }, "connect/store">;
112
- export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetMobileScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetIndividualScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetMerchantScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetNIDScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetCivilScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
115
+ export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetMobileScreen: import("@reduxjs/toolkit").ActionCreatorWithPayload<CountryCode, string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetIndividualScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetMerchantScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetNIDScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetCivilScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setDefaultCountryCode: import("@reduxjs/toolkit").ActionCreatorWithPayload<CountryCode, string>;
113
116
  declare const _default: import("redux").Reducer<ConnectState, import("redux").AnyAction>;
114
117
  export default _default;
115
118
  export declare const connectSelector: (state: RootState) => ConnectState;
@@ -61,7 +61,7 @@ import { FlowsTypes } from '../../../@types';
61
61
  import API from '../../../api';
62
62
  import { CONNECT_STEP_NAMES, IDENTIFICATION_TYPE, INSTAGRAM_URL, OTHER_BRAND, TWITTER_URL } from '../../../constants';
63
63
  import { defaultCountry } from '../../../constants';
64
- import { getIndividualName, capitalizeTheFirstLetterOfEachWord, getEighteenYearsAgo, sleep } from '../../../utils';
64
+ import { getIndividualName, capitalizeTheFirstLetterOfEachWord, getEighteenYearsAgo, sleep, findCountryByIddPrefix } from '../../../utils';
65
65
  export var createMobileAuth = createAsyncThunk('createMobileAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
66
66
  var settings, requestBody, data;
67
67
  var _a, _b;
@@ -273,7 +273,13 @@ export var verifyAuth = createAsyncThunk('verifyAuth', function (params, thunkAp
273
273
  : thunkApi.dispatch(handleNextScreenStep('CONNECT_MERCHANT_INFO_STEP'));
274
274
  }
275
275
  _g.label = 7;
276
- case 7: return [2, { response: data, formData: params, leadData: individualInfo, selectedChannels: selectedChannels }];
276
+ case 7: return [2, {
277
+ response: data,
278
+ formData: params,
279
+ leadData: individualInfo,
280
+ selectedChannels: selectedChannels,
281
+ countries: settings.data.countries
282
+ }];
277
283
  }
278
284
  });
279
285
  }); });
@@ -334,7 +340,7 @@ export var verifyPACI = createAsyncThunk('verifyPACI', function (params, thunkAp
334
340
  case 7:
335
341
  count++;
336
342
  return [3, 1];
337
- case 8: return [2, { response: response }];
343
+ case 8: return [2, { response: response, countries: settings.data.countries }];
338
344
  }
339
345
  });
340
346
  }); });
@@ -639,8 +645,8 @@ export var connectSlice = createSlice({
639
645
  stopLoader: function (state) {
640
646
  state.loading = false;
641
647
  },
642
- resetMobileScreen: function (state) {
643
- state.data.mobileData = __assign(__assign({}, state.data.mobileData), initialState.data.mobileData);
648
+ resetMobileScreen: function (state, action) {
649
+ state.data.mobileData = __assign(__assign(__assign({}, state.data.mobileData), initialState.data.mobileData), { countryCode: action.payload });
644
650
  },
645
651
  resetNIDScreen: function (state) {
646
652
  state.data.nidData = __assign(__assign({}, state.data.nidData), initialState.data.nidData);
@@ -655,6 +661,10 @@ export var connectSlice = createSlice({
655
661
  state.data.individualData = initialState.data.individualData;
656
662
  },
657
663
  resetMerchantScreen: function (state) {
664
+ },
665
+ setDefaultCountryCode: function (state, action) {
666
+ state.data.mobileData.countryCode = action.payload;
667
+ state.data.individualData.countryCode = action.payload;
658
668
  }
659
669
  },
660
670
  extraReducers: function (builder) {
@@ -727,8 +737,9 @@ export var connectSlice = createSlice({
727
737
  var _a;
728
738
  state.loading = false;
729
739
  state.error = null;
730
- state.data.otpData.responseBody = action.payload.response;
731
- var _b = action.payload.response, name = _b.name, contact = _b.contact, brand = _b.brand;
740
+ var _b = action.payload || {}, response = _b.response, countries = _b.countries;
741
+ state.data.otpData.responseBody = response;
742
+ var name = response.name, contact = response.contact, brand = response.brand;
732
743
  var _c = contact || {}, email = _c.email, phone = _c.phone;
733
744
  var firstName = (name === null || name === void 0 ? void 0 : name.first) + ' ';
734
745
  var middleName = !!(name === null || name === void 0 ? void 0 : name.middle) ? (name === null || name === void 0 ? void 0 : name.middle) + ' ' : '';
@@ -742,6 +753,9 @@ export var connectSlice = createSlice({
742
753
  state.data.individualData.email = email;
743
754
  if (!!(phone === null || phone === void 0 ? void 0 : phone.number))
744
755
  state.data.individualData.mobile = phone === null || phone === void 0 ? void 0 : phone.number;
756
+ var countryCode = state.data.individualData.countryCode;
757
+ if (!!(phone === null || phone === void 0 ? void 0 : phone.country_code))
758
+ state.data.individualData.countryCode = findCountryByIddPrefix(countries, phone === null || phone === void 0 ? void 0 : phone.country_code) || countryCode;
745
759
  state.data.brandData.brandName = (_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en;
746
760
  state.data.brandData.links.website = brand === null || brand === void 0 ? void 0 : brand.website;
747
761
  state.data.otpData.responseBody = action.payload.response;
@@ -796,7 +810,7 @@ export var connectSlice = createSlice({
796
810
  .addCase(verifyAuth.fulfilled, function (state, action) {
797
811
  var _a, _b;
798
812
  state.error = null;
799
- var _c = action.payload, formData = _c.formData, response = _c.response, leadData = _c.leadData, selectedChannels = _c.selectedChannels;
813
+ var _c = action.payload, formData = _c.formData, response = _c.response, leadData = _c.leadData, selectedChannels = _c.selectedChannels, countries = _c.countries;
800
814
  var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
801
815
  if (description) {
802
816
  state.loading = false;
@@ -817,6 +831,9 @@ export var connectSlice = createSlice({
817
831
  state.data.individualData.email = email;
818
832
  if (!!(phone === null || phone === void 0 ? void 0 : phone.number))
819
833
  state.data.individualData.mobile = phone === null || phone === void 0 ? void 0 : phone.number;
834
+ var countryCode = state.data.individualData.countryCode;
835
+ if (!!(phone === null || phone === void 0 ? void 0 : phone.country_code))
836
+ state.data.individualData.countryCode = findCountryByIddPrefix(countries, phone === null || phone === void 0 ? void 0 : phone.country_code) || countryCode;
820
837
  state.data.brandData.brandName = (_b = brand === null || brand === void 0 ? void 0 : brand.name) === null || _b === void 0 ? void 0 : _b.en;
821
838
  state.data.brandData.links.website = brand === null || brand === void 0 ? void 0 : brand.website;
822
839
  state.data.otpData.responseBody = __assign(__assign({}, response), leadData);
@@ -1028,6 +1045,6 @@ export var connectSlice = createSlice({
1028
1045
  });
1029
1046
  }
1030
1047
  });
1031
- export var clearError = (_a = connectSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetMobileScreen = _a.resetMobileScreen, resetOTPScreen = _a.resetOTPScreen, resetIndividualScreen = _a.resetIndividualScreen, resetMerchantScreen = _a.resetMerchantScreen, resetNIDScreen = _a.resetNIDScreen, resetCivilScreen = _a.resetCivilScreen;
1048
+ export var clearError = (_a = connectSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetMobileScreen = _a.resetMobileScreen, resetOTPScreen = _a.resetOTPScreen, resetIndividualScreen = _a.resetIndividualScreen, resetMerchantScreen = _a.resetMerchantScreen, resetNIDScreen = _a.resetNIDScreen, resetCivilScreen = _a.resetCivilScreen, setDefaultCountryCode = _a.setDefaultCountryCode;
1032
1049
  export default connectSlice.reducer;
1033
1050
  export var connectSelector = function (state) { return state.connect; };
@@ -46,6 +46,7 @@ import { ScreenContainer } from '../../../shared/Containers';
46
46
  import { businessSelector } from '../../../app/business/businessStore';
47
47
  import CheckIcon from '@mui/icons-material/Check';
48
48
  import { MandatoryStyled } from './SalesChannels';
49
+ import Search from '../../../../features/shared/Search';
49
50
  export var InputLabelStyled = styled(Text)(function (_a) {
50
51
  var theme = _a.theme;
51
52
  return (__assign({ margin: theme.spacing(2.5, 2.5, 1.5, 2.5), color: alpha(theme.palette.text.primary, 0.4) }, theme.typography.caption));
@@ -59,9 +60,7 @@ export var InputStyled = styled(Input)(function (_a) {
59
60
  }
60
61
  });
61
62
  });
62
- var SimpleListStyled = styled((SimpleList))(function () { return ({
63
- height: 'fit-content'
64
- }); });
63
+ var SimpleListStyled = styled((SimpleList))(function () { return ({}); });
65
64
  export var CheckIconStyled = styled(CheckIcon)(function (_a) {
66
65
  var theme = _a.theme;
67
66
  return ({
@@ -115,18 +114,27 @@ var ActivitiesList = function (_a) {
115
114
  activitiesControl.field.onChange(__spreadArray(__spreadArray([], controlValue, true), [item], false));
116
115
  };
117
116
  var getSelectedActivities = function () {
117
+ var _a, _b;
118
118
  if ((controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) > 1) {
119
119
  return (controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) + ' ' + t('activities_selected');
120
120
  }
121
121
  var item = controlValue[0];
122
- return isAr ? item === null || item === void 0 ? void 0 : item.name.ar : item === null || item === void 0 ? void 0 : item.name.en;
122
+ return isAr ? (_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en;
123
123
  };
124
124
  var getSelectedActivityFlag = function (item) {
125
125
  return controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.id === item.id; });
126
126
  };
127
- return (_jsx(Collapse, __assign({ in: (activitiesMenuList === null || activitiesMenuList === void 0 ? void 0 : activitiesMenuList.length) > 0 }, { children: _jsxs(ScreenContainer, { children: [_jsxs(InputLabelStyled, { children: [t(isCR ? 'activities' : 'category'), " ", _jsx(MandatoryStyled, { children: "*" })] }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, value: getSelectedActivities(), placeholder: isCR ? t('choose_activities') : t('category_name'), onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: activitiesMenuList, onSelectItem: onSelectItem, renderItem: function (item) {
127
+ var handleSearch = function (value) {
128
+ var filteredList = activities === null || activities === void 0 ? void 0 : activities.filter(function (activity) {
129
+ var _a, _b;
130
+ return ((_a = activity === null || activity === void 0 ? void 0 : activity.name) === null || _a === void 0 ? void 0 : _a.en.toLowerCase().startsWith(value.toLowerCase())) ||
131
+ ((_b = activity === null || activity === void 0 ? void 0 : activity.name) === null || _b === void 0 ? void 0 : _b.ar.toLowerCase().startsWith(value.toLowerCase()));
132
+ });
133
+ setActivitiesMenuList(filteredList);
134
+ };
135
+ return (_jsxs(ScreenContainer, { children: [_jsxs(InputLabelStyled, { children: [t(isCR ? 'activities' : 'category'), " ", _jsx(MandatoryStyled, { children: "*" })] }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, value: getSelectedActivities(), placeholder: isCR ? t('choose_activities') : t('category_name'), 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: activitiesMenuList, onSelectItem: onSelectItem, renderItem: function (item) {
128
136
  var _a, _b, _c;
129
137
  return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: item.id === ((_a = getSelectedActivityFlag(item)) === null || _a === void 0 ? void 0 : _a.id) }, { children: isAr ? (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = item === null || item === void 0 ? void 0 : item.name) === null || _c === void 0 ? void 0 : _c.en })) })), getSelectedActivityFlag(item) && _jsx(CheckIconStyled, {})] }));
130
- } }) }))] })] }) })));
138
+ } })] }))] })] }));
131
139
  };
132
140
  export default ActivitiesList;
@@ -15,25 +15,26 @@ import { useForm, FormProvider } from 'react-hook-form';
15
15
  import { useTranslation } from 'react-i18next';
16
16
  import { yupResolver } from '@hookform/resolvers/yup';
17
17
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
18
- import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
18
+ import { handlePrevScreenStep } from '../../../../app/settings';
19
19
  import Form from '../../../../components/Form';
20
20
  import Collapse from '../../../../components/Collapse';
21
21
  import { useLanguage } from '../../../../hooks';
22
22
  import ScreenContainer from '../../../shared/Containers/ScreenContainer';
23
23
  import { businessSelector, clearError, updateLeadBusinessType } from '../../../app/business/businessStore';
24
24
  import Button from '../../../shared/Button';
25
+ import { isSA } from '../../../../utils';
25
26
  import { KWLicenseValidationSchema, LicenseValidationSchema } from './validation';
26
27
  import LicenseList from './LicenseList';
27
- import { isKW } from '../../../../utils';
28
28
  var BusinessType = function (_a) {
29
- var _b = useAppSelector(businessSelector), data = _b.data, loading = _b.loading, error = _b.error;
30
- var settingData = useAppSelector(settingsSelector).data;
29
+ var _b;
30
+ var _c = useAppSelector(businessSelector), data = _c.data, loading = _c.loading, error = _c.error;
31
31
  var t = useTranslation().t;
32
32
  var isAr = useLanguage().isAr;
33
33
  var dispatch = useAppDispatch();
34
- var _c = React.useState(false), listActive = _c[0], setListActive = _c[1];
34
+ var _d = React.useState(false), listActive = _d[0], setListActive = _d[1];
35
+ var isSACountry = React.useMemo(function () { var _a; return isSA((_a = data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.country_code); }, [(_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.country_code]);
35
36
  var methods = useForm({
36
- resolver: yupResolver(isKW(settingData.businessCountry.iso2) ? KWLicenseValidationSchema : LicenseValidationSchema),
37
+ resolver: yupResolver(!isSACountry ? KWLicenseValidationSchema : LicenseValidationSchema),
37
38
  defaultValues: data.businessTypeData,
38
39
  mode: 'onChange'
39
40
  });
@@ -10,15 +10,18 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ import * as React from 'react';
13
14
  import ClearIcon from '../../../shared/ClearIcon';
14
15
  import CheckIcon from '../../../shared/CheckIcon';
15
16
  import Input from '../../../shared/Input';
16
17
  import Collapse from '../../../../components/Collapse';
17
18
  import { useTranslation } from 'react-i18next';
18
19
  import { useController, useFormContext } from 'react-hook-form';
19
- import { removeAllOtherThanCharsNumbersAndSpace } from '../../../../utils';
20
+ import { isSA, removeAllOtherThanCharsNumbersAndSpace } from '../../../../utils';
20
21
  import { styled } from '@mui/material/styles';
21
22
  import Box from '@mui/material/Box';
23
+ import { useAppSelector } from '../../../../hooks';
24
+ import { businessSelector } from '../../../app/business/businessStore';
22
25
  var BoxStyled = styled(Box)(function (_a) {
23
26
  var theme = _a.theme;
24
27
  return ({
@@ -31,13 +34,15 @@ var BoxStyled = styled(Box)(function (_a) {
31
34
  });
32
35
  });
33
36
  var EntityName = function (_a) {
34
- var _b;
37
+ var _b, _c;
35
38
  var show = _a.show;
36
39
  var t = useTranslation().t;
37
40
  var control = useFormContext().control;
38
41
  var entityNameControl = useController({ control: control, name: 'entityLegalName' });
39
42
  var entityNameValue = entityNameControl.field.value;
40
43
  var error = (_b = entityNameControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
44
+ var data = useAppSelector(businessSelector).data;
45
+ var isSACountry = React.useMemo(function () { var _a; return isSA((_a = data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.country_code); }, [(_c = data.verify.responseBody) === null || _c === void 0 ? void 0 : _c.country_code]);
41
46
  var handleChange = function (_a) {
42
47
  var target = _a.target;
43
48
  var value = removeAllOtherThanCharsNumbersAndSpace(target.value);
@@ -46,6 +51,6 @@ var EntityName = function (_a) {
46
51
  var clearEntityName = function () {
47
52
  entityNameControl.field.onChange('');
48
53
  };
49
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(BoxStyled, { children: _jsx(Input, { label: t('entity_legal_name_title'), onChange: handleChange, value: entityNameValue, endAdornment: (entityNameValue === null || entityNameValue === void 0 ? void 0 : entityNameValue.length) >= 3 ? _jsx(CheckIcon, {}) : entityNameValue && _jsx(ClearIcon, { onClick: clearEntityName }), placeholder: t('entity_legal_name_placeholder'), warningType: 'alert', warningMessage: error && t(error) }) }) })));
54
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(BoxStyled, { children: _jsx(Input, { label: t('entity_legal_name_title'), onChange: handleChange, value: entityNameValue, required: !isSACountry, endAdornment: (entityNameValue === null || entityNameValue === void 0 ? void 0 : entityNameValue.length) >= 3 ? _jsx(CheckIcon, {}) : entityNameValue && _jsx(ClearIcon, { onClick: clearEntityName }), placeholder: t('entity_legal_name_placeholder'), warningType: 'alert', warningMessage: error && t(error) }) }) })));
50
55
  };
51
56
  export default EntityName;
@@ -37,9 +37,10 @@ import Text from '../../../../components/Text';
37
37
  import ExpandIcon from '../../../../components/ExpandIcon';
38
38
  import Collapse from '../../../../components/Collapse';
39
39
  import LicenseNumber from './LicenseNumber';
40
- import EntityName from '../../../../features/business/screens/BusinessType/EntityName';
41
- import { isKW } from '../../../../utils';
42
- import { settingsSelector } from '../../../../app/settings';
40
+ import EntityName from '../../../business/screens/BusinessType/EntityName';
41
+ import { isSA } from '../../../../utils';
42
+ import LicenseType from './LicenseType';
43
+ import { OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../../constants';
43
44
  var InputStyled = styled(Input)(function (_a) {
44
45
  var theme = _a.theme;
45
46
  return ({
@@ -60,7 +61,6 @@ var LicenseList = function (_a) {
60
61
  var _b;
61
62
  var rest = __rest(_a, []);
62
63
  var _c = useAppSelector(businessSelector), data = _c.data, error = _c.error;
63
- var settingData = useAppSelector(settingsSelector).data;
64
64
  var businessTypeData = data.businessTypeData;
65
65
  var _d = React.useState(null), anchorEl = _d[0], setAnchorEl = _d[1];
66
66
  var t = useTranslation().t;
@@ -80,18 +80,24 @@ var LicenseList = function (_a) {
80
80
  setAnchorEl(null);
81
81
  (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
82
82
  };
83
+ var isSACountry = React.useMemo(function () { var _a; return isSA((_a = data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.country_code); }, [(_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.country_code]);
83
84
  React.useEffect(function () {
84
- if (licenseList.length > 0)
85
+ if ((licenseList || []).length > 0)
85
86
  setValue('licenseList', licenseList);
86
87
  }, [licenseList]);
87
88
  React.useEffect(function () {
88
- if (licenseList.length > 0) {
89
+ if ((licenseList || []).length > 0) {
89
90
  if (!!selectedLicense) {
90
91
  setValue('selectedLicense', selectedLicense, { shouldValidate: true });
91
92
  setValue('licenseNumber', licenseNumber, { shouldValidate: true });
92
93
  }
93
94
  }
94
95
  }, [licenseList, selectedLicense]);
96
+ React.useEffect(function () {
97
+ var license = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.CR ? OTHER_CR_LICENSE : OTHER_FL_LICENSE;
98
+ if (!isSACountry)
99
+ setValue('selectedLicense', license, { shouldValidate: true });
100
+ }, [isSACountry]);
95
101
  var getLicenseNumber = function (item) {
96
102
  var _a;
97
103
  return ((_a = item === null || item === void 0 ? void 0 : item.license) === null || _a === void 0 ? void 0 : _a.number) || '';
@@ -126,8 +132,8 @@ var LicenseList = function (_a) {
126
132
  var licenseReadonly = !isOtherLicense(selected);
127
133
  var isCR = (selected === null || selected === void 0 ? void 0 : selected.type) === BusinessType.CR;
128
134
  var flValue = isOtherLicense(selected) ? t(getLicenseName(selected)) : getLicenseNumber(selected);
129
- return (_jsxs(ScreenContainer, { children: [_jsx(InputStyled, { label: t('choose_any_license'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_cr'), value: isCR ? t(getLicenseName(selected)) : flValue }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: licenseList || [], onSelectItem: onSelectItem, renderItem: function (item) {
130
- return (_jsxs(_Fragment, { children: [_jsx(LicenseContainer, { children: _jsx(LicenseNameText, __assign({ isSelected: getLicenseNumber(item) === getLicenseNumber(selected) }, { children: isOtherLicense(item) ? t(getLicenseName(item)) : getLicenseFullName(item) })) }), getLicenseNumber(item) === getLicenseNumber(selected) && _jsx(CheckIcon, {})] }));
131
- } }) })), _jsx(EntityName, { show: showLicenseNumber && isKW((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.country_code) }), _jsx(LicenseNumber, { show: showLicenseNumber, readOnly: licenseReadonly })] }));
135
+ return (_jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: isSACountry }, { children: [_jsx(InputStyled, { label: t('choose_any_license'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_cr'), value: isCR ? t(getLicenseName(selected)) : flValue }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: licenseList || [], onSelectItem: onSelectItem, renderItem: function (item) {
136
+ return (_jsxs(_Fragment, { children: [_jsx(LicenseContainer, { children: _jsx(LicenseNameText, __assign({ isSelected: getLicenseNumber(item) === getLicenseNumber(selected) }, { children: isOtherLicense(item) ? t(getLicenseName(item)) : getLicenseFullName(item) })) }), getLicenseNumber(item) === getLicenseNumber(selected) && _jsx(CheckIcon, {})] }));
137
+ } }) }))] })), _jsx(EntityName, { show: showLicenseNumber && !isSACountry }), _jsx(LicenseType, { show: showLicenseNumber && !isSACountry }), _jsx(LicenseNumber, { show: showLicenseNumber, readOnly: licenseReadonly })] }));
132
138
  };
133
139
  export default React.memo(LicenseList);
@@ -13,21 +13,25 @@ import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import * as React from 'react';
14
14
  import { useTranslation } from 'react-i18next';
15
15
  import { useController, useFormContext } from 'react-hook-form';
16
- import { CR_NUMBER_LENGTH, FL_NUMBER_LENGTH } from '../../../../constants';
17
- import { removeAllOtherThanCharsAndNumber } from '../../../../utils';
16
+ import { CR_NUMBER_LENGTH, FL_NUMBER_LENGTH, KW_MAX_LICENSE_LENGTH, KW_MIN_LICENSE_LENGTH } from '../../../../constants';
17
+ import { removeAllOtherThanCharsAndNumber, isSA } from '../../../../utils';
18
18
  import ScreenContainer from '../../../shared/Containers/ScreenContainer';
19
19
  import ClearIcon from '../../../shared/ClearIcon';
20
20
  import CheckIcon from '../../../shared/CheckIcon';
21
21
  import Input from '../../../shared/Input';
22
22
  import Collapse from '../../../../components/Collapse';
23
23
  import { BusinessType } from '../../../../@types';
24
+ import { useAppSelector } from '../../../../hooks';
25
+ import { businessSelector } from '../../../app/business/businessStore';
24
26
  var LicenseNumber = function (_a) {
25
- var _b;
27
+ var _b, _c;
26
28
  var show = _a.show, readOnly = _a.readOnly;
27
29
  var t = useTranslation().t;
28
- var _c = useFormContext(), control = _c.control, getValues = _c.getValues;
30
+ var _d = useFormContext(), control = _d.control, watch = _d.watch, getValues = _d.getValues;
29
31
  var licenseNumberControl = useController({ control: control, name: 'licenseNumber' });
30
- var selectedLicense = getValues('selectedLicense');
32
+ var businessData = useAppSelector(businessSelector).data;
33
+ var isSACountry = React.useMemo(function () { var _a; return isSA((_a = businessData.verify.responseBody) === null || _a === void 0 ? void 0 : _a.country_code); }, [(_b = businessData.verify.responseBody) === null || _b === void 0 ? void 0 : _b.country_code]);
34
+ var selectedLicense = !isSACountry ? watch('selectedLicense') : getValues('selectedLicense');
31
35
  var isCR = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.CR;
32
36
  var handleFLNumberChange = function (_a) {
33
37
  var target = _a.target;
@@ -38,9 +42,11 @@ var LicenseNumber = function (_a) {
38
42
  licenseNumberControl.field.onChange('');
39
43
  };
40
44
  var licenseNumberValue = licenseNumberControl.field.value;
41
- var error = (_b = licenseNumberControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
42
- var length = isCR ? CR_NUMBER_LENGTH : FL_NUMBER_LENGTH;
45
+ var error = (_c = licenseNumberControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message;
46
+ var length = !isSACountry ? KW_MAX_LICENSE_LENGTH : isCR ? CR_NUMBER_LENGTH : FL_NUMBER_LENGTH;
47
+ var minLength = !isSACountry ? KW_MIN_LICENSE_LENGTH : length;
43
48
  var label = isCR ? 'cr_number' : 'fl_number';
44
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { readOnly: readOnly, label: t(label), onChange: handleFLNumberChange, inputProps: { maxLength: length }, value: licenseNumberValue, endAdornment: (licenseNumberValue === null || licenseNumberValue === void 0 ? void 0 : licenseNumberValue.length) === length ? (_jsx(CheckIcon, {})) : (licenseNumberValue && _jsx(ClearIcon, { onClick: clearLicenseNumber })), placeholder: isCR ? t('cr_number_hint') : t('fl_number_hint'), warningType: 'alert', warningMessage: error && t(error, { length: length }) }) }) })));
49
+ var showCheckIcon = !isSACountry ? (licenseNumberValue === null || licenseNumberValue === void 0 ? void 0 : licenseNumberValue.length) >= minLength : (licenseNumberValue === null || licenseNumberValue === void 0 ? void 0 : licenseNumberValue.length) === length;
50
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { readOnly: readOnly, label: t(label), required: !isSACountry, onChange: handleFLNumberChange, inputProps: { maxLength: length }, value: licenseNumberValue, endAdornment: showCheckIcon ? _jsx(CheckIcon, {}) : licenseNumberValue && _jsx(ClearIcon, { onClick: clearLicenseNumber }), placeholder: isCR ? t('cr_number_hint') : t('fl_number_hint'), warningType: 'alert', warningMessage: error && t(error, { length: minLength }) }) }) })));
45
51
  };
46
52
  export default React.memo(LicenseNumber);
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ declare type LicenseTypeProps = {
3
+ show: boolean;
4
+ };
5
+ declare const LicenseType: ({ show }: LicenseTypeProps) => JSX.Element;
6
+ export default LicenseType;
@@ -0,0 +1,67 @@
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 { styled, alpha } from '@mui/material/styles';
14
+ import Collapse from '../../../../components/Collapse';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { useController, useFormContext } from 'react-hook-form';
17
+ import Text from '../../../../components/Text';
18
+ import { ScreenContainer } from '../../../shared/Containers';
19
+ import Mandatory from '../../../shared/Mandatory';
20
+ import RadioLabel from '../../../../components/RadioLabel';
21
+ import { BusinessType } from '../../../../@types';
22
+ import RadioGroup from '../../../../components/RadioGroup';
23
+ import Radio from '../../../../components/Radio';
24
+ import { OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../../constants';
25
+ import { businessSelector, clearError } from '../../../app/business/businessStore';
26
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
27
+ var LabelTextStyled = styled(Text)(function (_a) {
28
+ var theme = _a.theme;
29
+ return (__assign(__assign({}, theme.typography.caption), { color: alpha(theme.palette.text.primary, 0.6), marginBlockEnd: theme.spacing(0.625) }));
30
+ });
31
+ var RadioGroupStyled = styled(RadioGroup)(function (_a) {
32
+ var theme = _a.theme;
33
+ return ({
34
+ marginInlineStart: theme.spacing(0.25)
35
+ });
36
+ });
37
+ var RadioStyled = styled(Radio)(function (_a) {
38
+ var theme = _a.theme;
39
+ return ({
40
+ '& .MuiSvgIcon-root': {
41
+ fontSize: theme.spacing(2.25),
42
+ width: theme.spacing(2.25),
43
+ height: theme.spacing(2.25)
44
+ }
45
+ });
46
+ });
47
+ var LicenseType = function (_a) {
48
+ var show = _a.show;
49
+ var t = useTranslation().t;
50
+ var control = useFormContext().control;
51
+ var error = useAppSelector(businessSelector).error;
52
+ var selectedLicenseControl = useController({ control: control, name: 'selectedLicense' });
53
+ var dispatch = useAppDispatch();
54
+ var handleOnChange = function (_a) {
55
+ var target = _a.target;
56
+ if (error)
57
+ dispatch(clearError());
58
+ selectedLicenseControl.field.onChange(target.value === BusinessType.CR ? OTHER_CR_LICENSE : OTHER_FL_LICENSE);
59
+ };
60
+ var selectedLicenseValue = selectedLicenseControl.field.value;
61
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { pb: 1.5, pl: 2.5, pr: 2.5 } }, { children: [_jsxs(LabelTextStyled, { children: [t('signup_business_type_label'), _jsx(Mandatory, {})] }), _jsxs(RadioGroupStyled, __assign({ value: selectedLicenseValue != null
62
+ ? (selectedLicenseValue === null || selectedLicenseValue === void 0 ? void 0 : selectedLicenseValue.type) === BusinessType.FL
63
+ ? BusinessType.FL
64
+ : BusinessType.CR
65
+ : false, onChange: handleOnChange }, { children: [_jsx(RadioLabel, { value: BusinessType.CR, label: t('commercial_reg'), control: _jsx(RadioStyled, { color: 'primary', disableFocusRipple: true, disableRipple: true, disableTouchRipple: true, focusRipple: false }) }), _jsx(RadioLabel, { value: BusinessType.FL, label: t('freelancer_reg'), control: _jsx(RadioStyled, { color: 'primary', disableFocusRipple: true, disableRipple: true, disableTouchRipple: true, focusRipple: false }) })] }))] })) })));
66
+ };
67
+ export default LicenseType;
@@ -1,5 +1,5 @@
1
1
  import * as yup from 'yup';
2
- import { FL_NUMBER_LENGTH, CR_NUMBER_LENGTH, REGEX_BRAND_NAME } from '../../../../constants';
2
+ import { FL_NUMBER_LENGTH, CR_NUMBER_LENGTH, REGEX_BRAND_NAME, KW_MIN_LICENSE_LENGTH } from '../../../../constants';
3
3
  import { BusinessType } from '../../../../@types';
4
4
  var objectElements = {
5
5
  legal_name: yup.object().shape({
@@ -42,9 +42,9 @@ export var KWLicenseValidationSchema = yup.object().shape({
42
42
  if (length === 0)
43
43
  return true;
44
44
  if (isCR) {
45
- return length === CR_NUMBER_LENGTH ? true : this.createError({ message: 'cr_max_length' });
45
+ return length >= KW_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'cr_kw_max_length' });
46
46
  }
47
- return length === FL_NUMBER_LENGTH ? true : this.createError({ message: 'fl_max_length' });
47
+ return length >= KW_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'fl_kw_max_length' });
48
48
  }
49
49
  })
50
50
  .required(''),
@@ -27,7 +27,7 @@ import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepSta
27
27
  import { handleCurrentActiveScreen, settingsSelector, handleOpen } from '../../app/settings';
28
28
  import AnimationFlow from '../../components/AnimationFlow';
29
29
  import { store } from '../../app/store';
30
- import { connectSelector } from '../app/connect/connectStore';
30
+ import { connectSelector, setDefaultCountryCode } from '../app/connect/connectStore';
31
31
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
32
32
  import Collapse from '../../components/Collapse';
33
33
  import { reactElement, removeElement, isKW } from '../../utils';
@@ -52,6 +52,11 @@ var Connect = memo(function (_a) {
52
52
  dispatch(handleCurrentActiveScreen('CONNECT_CIVIL_ID_STEP'));
53
53
  }
54
54
  }, [settingLoading]);
55
+ React.useEffect(function () {
56
+ var _a;
57
+ if (!!((_a = data.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2))
58
+ dispatch(setDefaultCountryCode(data.businessCountry));
59
+ }, [data.businessCountry]);
55
60
  var handleDialogClose = function () {
56
61
  dispatch(handleOpen(false));
57
62
  };
@@ -71,7 +71,7 @@ var CivilID = function (_a) {
71
71
  }, [methods.formState.isValid]);
72
72
  var onSubmit = function (data) {
73
73
  dispatch(createCivilIdAuth(data));
74
- dispatch(resetMobileScreen());
74
+ dispatch(resetMobileScreen(settingsStore.data.businessCountry));
75
75
  };
76
76
  var handleClearError = function () {
77
77
  if (error)
@@ -73,7 +73,7 @@ var NID = function (_a) {
73
73
  }, [methods.formState.isValid]);
74
74
  var onSubmit = function (data) {
75
75
  dispatch(createNIDAuth(data));
76
- dispatch(resetMobileScreen());
76
+ dispatch(resetMobileScreen(settingsStore.data.businessCountry));
77
77
  };
78
78
  var handleCollapseOpenClose = function (flag) {
79
79
  setCollapse(flag);
@@ -11,3 +11,4 @@ export declare const isExist: (items: Array<any>, id: string) => any;
11
11
  export declare const allAreTruthy: (items: Array<any>, condition: boolean | string, key: string, exclude?: string) => boolean;
12
12
  export declare const sortCountries: (countries: Array<CountryCode>) => CountryCode[];
13
13
  export declare const findCountryByIso2: (countries: Array<CountryCode>, iso2: string) => CountryCode | undefined;
14
+ export declare const findCountryByIddPrefix: (countries: Array<CountryCode>, iddPrefix: string) => CountryCode | undefined;
@@ -63,3 +63,8 @@ export var findCountryByIso2 = function (countries, iso2) {
63
63
  throw new Error('iso2 is required');
64
64
  return countries.find(function (country) { return country.iso2.toLowerCase() === iso2.toLowerCase(); });
65
65
  };
66
+ export var findCountryByIddPrefix = function (countries, iddPrefix) {
67
+ if (!iddPrefix)
68
+ throw new Error('idd_prefix is required');
69
+ return countries.find(function (country) { return country.idd_prefix.toString() === iddPrefix; });
70
+ };
@@ -43,3 +43,4 @@ export declare const getBaseUrl: () => string;
43
43
  export declare const getScreenNameBasedOnFlow: (flow: string) => "CONNECT_NID_STEP" | "" | "BUSINESS_BUSINESS_TYPE_STEP" | "INDIVIDUAL_ADDITIONAL_INDIVIDUAL_INFO_STEP" | "BANK_BANK_DETAILS_STEP" | "TAX_TAX_DETAILS_STEP";
44
44
  export declare const getEighteenYearsAgo: () => string;
45
45
  export declare const isKW: (flag: string) => boolean;
46
+ export declare const isSA: (flag: string) => boolean;
@@ -176,3 +176,6 @@ export var getEighteenYearsAgo = function () {
176
176
  export var isKW = function (flag) {
177
177
  return ['kw', 'kwd'].includes(flag === null || flag === void 0 ? void 0 : flag.toLowerCase());
178
178
  };
179
+ export var isSA = function (flag) {
180
+ return ['sa', 'sau'].includes(flag === null || flag === void 0 ? void 0 : flag.toLowerCase());
181
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.0.76-test",
3
+ "version": "2.0.77-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",