@tap-payments/auth-jsconnect 1.0.20 → 1.0.21

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.
@@ -110,13 +110,13 @@ export interface AppInfo {
110
110
  identifier: string;
111
111
  name: string;
112
112
  version: string;
113
- requirer: string;
114
- requirer_version: string;
115
- app_locale: string;
116
- sdk_version: string;
117
- requirer_sim_network_name: string;
118
- requirer_sim_country_iso: string;
119
- universal_id: string;
113
+ requirer?: string;
114
+ requirer_version?: string;
115
+ app_locale?: string;
116
+ sdk_version?: string;
117
+ requirer_sim_network_name?: string;
118
+ requirer_sim_country_iso?: string;
119
+ universal_id?: string;
120
120
  }
121
121
  export interface OSDetails {
122
122
  name: string;
@@ -7,6 +7,9 @@ export declare type MobileFormValues = {
7
7
  export declare type OTPFormValues = {
8
8
  otp: string;
9
9
  };
10
+ export declare type PasswordFormValues = {
11
+ password: string;
12
+ };
10
13
  export declare type NIDFormValues = {
11
14
  nid: string;
12
15
  dob: string;
@@ -2,6 +2,7 @@ export interface SharedState<T> {
2
2
  error: string | null;
3
3
  loading: boolean;
4
4
  data: T;
5
+ searchActive?: boolean;
5
6
  }
6
7
  export interface ActionState<T> {
7
8
  type: string;
@@ -0,0 +1,12 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ export declare type CheckEmailBody = {
3
+ email: string | null;
4
+ };
5
+ export declare type CheckBrandBody = {
6
+ profile_name: string;
7
+ };
8
+ declare const availabilityServices: {
9
+ checkEmail: (data: CheckEmailBody, config?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
10
+ checkBrand: (data: CheckBrandBody, config?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
11
+ };
12
+ export default availabilityServices;
@@ -0,0 +1,13 @@
1
+ import instance from './axios';
2
+ import { ENDPOINT_PATHS } from '../constants';
3
+ var checkEmail = function (data, config) {
4
+ return instance.post("".concat(ENDPOINT_PATHS.CHECK_EMAIL), data, config);
5
+ };
6
+ var checkBrand = function (data, config) {
7
+ return instance.post("".concat(ENDPOINT_PATHS.CHECK_BRAND), data, config);
8
+ };
9
+ var availabilityServices = {
10
+ checkEmail: checkEmail,
11
+ checkBrand: checkBrand
12
+ };
13
+ export default availabilityServices;
@@ -1,6 +1,7 @@
1
1
  import { ValidateOperatorBody } from './operator';
2
2
  import { CreateAuthBody, VerifyAuthBody } from './auth';
3
3
  import { UpdateLeadBody } from './lead';
4
+ import { CheckEmailBody, CheckBrandBody } from './availabilityServices';
4
5
  declare const API: {
5
6
  ipService: {
6
7
  getIP: () => Promise<import("axios").AxiosResponse<any, any>>;
@@ -19,6 +20,10 @@ declare const API: {
19
20
  leadService: {
20
21
  updateLead: (data: UpdateLeadBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
21
22
  };
23
+ availabilityServices: {
24
+ checkEmail: (data: CheckEmailBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
25
+ checkBrand: (data: CheckBrandBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
26
+ };
22
27
  };
23
- export type { ValidateOperatorBody, CreateAuthBody, VerifyAuthBody, UpdateLeadBody };
28
+ export type { ValidateOperatorBody, CreateAuthBody, VerifyAuthBody, UpdateLeadBody, CheckEmailBody, CheckBrandBody };
24
29
  export default API;
@@ -3,11 +3,13 @@ import { operatorService } from './operator';
3
3
  import { countryService } from './country';
4
4
  import { authService } from './auth';
5
5
  import { leadService } from './lead';
6
+ import availabilityServices from './availabilityServices';
6
7
  var API = {
7
8
  ipService: ipService,
8
9
  operatorService: operatorService,
9
10
  countryService: countryService,
10
11
  authService: authService,
11
- leadService: leadService
12
+ leadService: leadService,
13
+ availabilityServices: availabilityServices
12
14
  };
13
15
  export default API;
@@ -24,10 +24,10 @@ export declare const settingsSlice: import("@reduxjs/toolkit").Slice<SettingsSta
24
24
  handleLanguage: (state: SettingsState, action: ActionState<LanguageMode>) => void;
25
25
  handleNextScreenStep: (state: SettingsState, action: ActionState<string | undefined>) => void;
26
26
  handleCurrentActiveScreen: (state: SettingsState, action: ActionState<string>) => void;
27
- handlePrevScreenStep: (state: SettingsState) => void;
27
+ handlePrevScreenStep: (state: SettingsState, action: ActionState<string | undefined>) => void;
28
28
  handleActiveFlowScreens: (state: SettingsState, action: ActionState<Array<ScreenStepNavigation>>) => void;
29
29
  }, "settings">;
30
- export declare const handleSkin: import("@reduxjs/toolkit").ActionCreatorWithPayload<ThemeMode, string>, handleLanguage: import("@reduxjs/toolkit").ActionCreatorWithPayload<LanguageMode, string>, handleActiveFlowScreens: import("@reduxjs/toolkit").ActionCreatorWithPayload<ScreenStepNavigation[], string>, handleNextScreenStep: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, string>, handlePrevScreenStep: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, handleCurrentActiveScreen: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
30
+ export declare const handleSkin: import("@reduxjs/toolkit").ActionCreatorWithPayload<ThemeMode, string>, handleLanguage: import("@reduxjs/toolkit").ActionCreatorWithPayload<LanguageMode, string>, handleActiveFlowScreens: import("@reduxjs/toolkit").ActionCreatorWithPayload<ScreenStepNavigation[], string>, handleNextScreenStep: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, string>, handlePrevScreenStep: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, string>, handleCurrentActiveScreen: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
31
31
  declare const _default: import("redux").Reducer<SettingsState, import("redux").AnyAction>;
32
32
  export default _default;
33
33
  export declare const settingsSelector: (state: RootState) => SettingsState;
@@ -122,11 +122,21 @@ export var settingsSlice = createSlice({
122
122
  return alert('Active screen not found');
123
123
  state.data.activeScreen = activeScreen;
124
124
  },
125
- handlePrevScreenStep: function (state) {
125
+ handlePrevScreenStep: function (state, action) {
126
126
  var prev = state.data.activeScreen.prev;
127
+ if (isArray(prev)) {
128
+ if (!action.payload)
129
+ return alert('Previous screen is an array, but no payload was provided');
130
+ var prevName_1 = findItem(prev, action.payload);
131
+ var prevScreen_1 = state.data.featureScreensNavigation.find(function (item) { return item.name === prevName_1; });
132
+ if (!prevScreen_1)
133
+ return alert('Previous screen step not found');
134
+ state.data.activeScreen = prevScreen_1;
135
+ return;
136
+ }
127
137
  var prevScreen = state.data.featureScreensNavigation.find(function (item) { return item.name === prev; });
128
138
  if (!prevScreen)
129
- return alert('Prev screen step not found');
139
+ return alert('Previous screen step not found');
130
140
  state.data.activeScreen = prevScreen;
131
141
  },
132
142
  handleActiveFlowScreens: function (state, action) {
@@ -6,4 +6,6 @@ export declare const ENDPOINT_PATHS: {
6
6
  OPERATOR: string;
7
7
  AUTH: string;
8
8
  LEAD: string;
9
+ CHECK_EMAIL: string;
10
+ CHECK_BRAND: string;
9
11
  };
@@ -5,6 +5,8 @@ var IP_PATH = '/ip';
5
5
  var OPERATOR_PATH = '/operator';
6
6
  var AUTH_PATH = '/auth';
7
7
  var LEAD_PATH = '/lead';
8
+ var CHECK_EMAIL = '/lead/identity/emailcheck';
9
+ var CHECK_BRAND = 'lead/profile/profile_name';
8
10
  export var ENDPOINT_PATHS = {
9
11
  BASE_URL: API_BASE_URL,
10
12
  BUSINESS_COUNTRIES: API_BUSINESS_COUNTRIES,
@@ -12,5 +14,7 @@ export var ENDPOINT_PATHS = {
12
14
  IP: IP_PATH,
13
15
  OPERATOR: OPERATOR_PATH,
14
16
  AUTH: AUTH_PATH,
15
- LEAD: LEAD_PATH
17
+ LEAD: LEAD_PATH,
18
+ CHECK_EMAIL: CHECK_EMAIL,
19
+ CHECK_BRAND: CHECK_BRAND
16
20
  };
@@ -26,7 +26,7 @@ export var CONNECT_SCREENS_NAVIGATION = [
26
26
  {
27
27
  name: 'CONNECT_OTP_STEP',
28
28
  next: ['CONNECT_INDIVIDUAL_STEP', 'CONNECT_PASSWORD_STEP'],
29
- prev: 'CONNECT_MOBILE_STEP',
29
+ prev: ['CONNECT_MOBILE_STEP', 'CONNECT_NID_STEP'],
30
30
  order: 2
31
31
  },
32
32
  {
@@ -1,25 +1,36 @@
1
1
  import { RootState } from '../../../app/store';
2
- import { ResponseData, CountryCode, MobileFormValues, NIDFormValues, OTPFormValues, IndividualFormValues, SharedState, BrandFormValues } from '../../../@types';
2
+ import { ResponseData, CountryCode, MobileFormValues, NIDFormValues, OTPFormValues, IndividualFormValues, SharedState, BrandFormValues, PasswordFormValues } from '../../../@types';
3
3
  export declare const getCountries: import("@reduxjs/toolkit").AsyncThunk<{
4
4
  businessCountries: any;
5
5
  countries: any;
6
6
  }, void, {}>;
7
7
  export declare const createMobileAuth: import("@reduxjs/toolkit").AsyncThunk<{
8
8
  response: any;
9
- formData: MobileFormValues;
10
- }, MobileFormValues, {}>;
9
+ formData: MobileFormValues & {
10
+ isResend: boolean;
11
+ };
12
+ }, MobileFormValues & {
13
+ isResend: boolean;
14
+ }, {}>;
11
15
  export declare const createNIDAuth: import("@reduxjs/toolkit").AsyncThunk<{
12
16
  response: any;
13
17
  formData: {
14
18
  type: string;
15
19
  nid: string;
16
20
  dob: string;
21
+ isResend: boolean;
17
22
  };
18
- }, NIDFormValues, {}>;
23
+ }, NIDFormValues & {
24
+ isResend: boolean;
25
+ }, {}>;
19
26
  export declare const verifyAuth: import("@reduxjs/toolkit").AsyncThunk<{
20
27
  response: any;
21
28
  formData: OTPFormValues;
22
29
  }, OTPFormValues, {}>;
30
+ export declare const verifyAuthPassword: import("@reduxjs/toolkit").AsyncThunk<{
31
+ response: any;
32
+ formData: PasswordFormValues;
33
+ }, PasswordFormValues, {}>;
23
34
  export declare const updateLeadIndividual: import("@reduxjs/toolkit").AsyncThunk<{
24
35
  response: any;
25
36
  formData: IndividualFormValues;
@@ -28,6 +39,14 @@ export declare const updateLeadBrand: import("@reduxjs/toolkit").AsyncThunk<{
28
39
  response: any;
29
40
  formData: BrandFormValues;
30
41
  }, BrandFormValues, {}>;
42
+ export declare const checkEmailAvailability: import("@reduxjs/toolkit").AsyncThunk<{
43
+ response: any;
44
+ formData: string;
45
+ } | undefined, string, {}>;
46
+ export declare const checkBrandNameAvailability: import("@reduxjs/toolkit").AsyncThunk<{
47
+ response: any;
48
+ formData: string;
49
+ } | undefined, string, {}>;
31
50
  export declare const updateLeadSuccess: import("@reduxjs/toolkit").AsyncThunk<{
32
51
  response: any;
33
52
  formData: void;
@@ -42,6 +61,7 @@ export interface ConnectData {
42
61
  otpData: OTPFormValues & ResponseData & {
43
62
  isAbsher: boolean;
44
63
  };
64
+ passwordData: PasswordFormValues & ResponseData;
45
65
  individualData: IndividualFormValues & ResponseData;
46
66
  brandData: BrandFormValues & ResponseData;
47
67
  }
@@ -93,7 +93,7 @@ export var createMobileAuth = createAsyncThunk('createMobileAuth', function (par
93
93
  return [4, API.authService.createAuth(requestBody)];
94
94
  case 1:
95
95
  data = (_a.sent()).data;
96
- if (!data.errors)
96
+ if (!data.errors && !params.isResend)
97
97
  thunkApi.dispatch(handleNextScreenStep());
98
98
  return [2, { response: data, formData: params }];
99
99
  }
@@ -121,7 +121,7 @@ export var createNIDAuth = createAsyncThunk('createNIDAuth', function (params, t
121
121
  return [4, API.authService.createAuth(requestBody)];
122
122
  case 1:
123
123
  data = (_b.sent()).data;
124
- if (!data.errors)
124
+ if (!data.errors && !params.isResend)
125
125
  thunkApi.dispatch(handleNextScreenStep());
126
126
  return [2, { response: data, formData: __assign(__assign({}, params), { type: identification_id_type }) }];
127
127
  }
@@ -156,16 +156,43 @@ export var verifyAuth = createAsyncThunk('verifyAuth', function (params, thunkAp
156
156
  thunkApi.dispatch(handleNextScreenStep('CONNECT_INDIVIDUAL_STEP'));
157
157
  }
158
158
  else {
159
- if (responseBody === null || responseBody === void 0 ? void 0 : responseBody.sign_in)
160
- thunkApi.dispatch(handleNextScreenStep('CONNECT_PASSWORD_STEP'));
161
- else
162
- alert('Need to implement this flow');
159
+ thunkApi.dispatch(handleNextScreenStep('CONNECT_PASSWORD_STEP'));
163
160
  }
164
161
  }
165
162
  return [2, { response: data, formData: params }];
166
163
  }
167
164
  });
168
165
  }); });
166
+ export var verifyAuthPassword = createAsyncThunk('verifyAuthPassword', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
167
+ var connect, isAbsher, responseBody, payload, data;
168
+ return __generator(this, function (_a) {
169
+ switch (_a.label) {
170
+ case 0:
171
+ connect = thunkApi.getState().connect;
172
+ isAbsher = connect.data.otpData.isAbsher;
173
+ responseBody = (isAbsher ? connect.data.nidData : connect.data.mobileData).responseBody;
174
+ payload = {
175
+ data: params.password,
176
+ auth_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_token,
177
+ auth_type: responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_type,
178
+ device_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.device_token,
179
+ service_name: responseBody === null || responseBody === void 0 ? void 0 : responseBody.service_name,
180
+ new_user: responseBody === null || responseBody === void 0 ? void 0 : responseBody.new_user,
181
+ sign_in: true,
182
+ remember_me: responseBody === null || responseBody === void 0 ? void 0 : responseBody.remember_me,
183
+ scopes: responseBody === null || responseBody === void 0 ? void 0 : responseBody.scopes,
184
+ step_name: CONNECT_STEP_NAMES.VERIFY_AUTH_PASSWORD,
185
+ encryption_contract: []
186
+ };
187
+ return [4, API.authService.verifyAuth(payload)];
188
+ case 1:
189
+ data = (_a.sent()).data;
190
+ if (!data.errors)
191
+ thunkApi.dispatch(handleNextScreenStep());
192
+ return [2, { response: data, formData: params }];
193
+ }
194
+ });
195
+ }); });
169
196
  export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
170
197
  var _a, settings, connect, isAbsher, headers, payload, data;
171
198
  var _b, _c, _d;
@@ -235,6 +262,52 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
235
262
  }
236
263
  });
237
264
  }); });
265
+ export var checkEmailAvailability = createAsyncThunk('checkEmailAvailability', function (email, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
266
+ var _a, settings, connect, headers, requestBody, data;
267
+ var _b, _c, _d;
268
+ return __generator(this, function (_e) {
269
+ switch (_e.label) {
270
+ case 0:
271
+ _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
272
+ headers = {
273
+ lead_id: (_b = connect.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.lead_id,
274
+ device_identifier: (_d = (_c = settings.data.deviceInfo) === null || _c === void 0 ? void 0 : _c.browser) === null || _d === void 0 ? void 0 : _d.browser_id
275
+ };
276
+ requestBody = {
277
+ email: email
278
+ };
279
+ return [4, API.availabilityServices.checkEmail(requestBody, { headers: headers })];
280
+ case 1:
281
+ data = (_e.sent()).data;
282
+ if (!data.errors)
283
+ return [2, { response: data, formData: email }];
284
+ return [2];
285
+ }
286
+ });
287
+ }); });
288
+ export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailability', function (brandName, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
289
+ var _a, settings, connect, headers, requestBody, data;
290
+ var _b, _c, _d;
291
+ return __generator(this, function (_e) {
292
+ switch (_e.label) {
293
+ case 0:
294
+ _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
295
+ headers = {
296
+ lead_id: ((_b = connect.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.lead_id) || '',
297
+ device_identifier: (_d = (_c = settings.data.deviceInfo) === null || _c === void 0 ? void 0 : _c.browser) === null || _d === void 0 ? void 0 : _d.browser_id
298
+ };
299
+ requestBody = {
300
+ profile_name: brandName
301
+ };
302
+ return [4, API.availabilityServices.checkBrand(requestBody, { headers: headers })];
303
+ case 1:
304
+ data = (_e.sent()).data;
305
+ if (!data.errors)
306
+ return [2, { response: data, formData: brandName }];
307
+ return [2];
308
+ }
309
+ });
310
+ }); });
238
311
  export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
239
312
  var _a, settings, connect, headers, payload, data;
240
313
  var _b, _c, _d;
@@ -265,6 +338,7 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
265
338
  var initialState = {
266
339
  error: null,
267
340
  loading: false,
341
+ searchActive: false,
268
342
  data: {
269
343
  countries: [],
270
344
  businessCountries: [],
@@ -282,6 +356,9 @@ var initialState = {
282
356
  otp: '',
283
357
  isAbsher: false
284
358
  },
359
+ passwordData: {
360
+ password: ''
361
+ },
285
362
  individualData: {
286
363
  name: '',
287
364
  email: '',
@@ -391,6 +468,27 @@ export var connectSlice = createSlice({
391
468
  .addCase(verifyAuth.rejected, function (state, action) {
392
469
  state.loading = false;
393
470
  state.error = action.error.message;
471
+ })
472
+ .addCase(verifyAuthPassword.fulfilled, function (state, action) {
473
+ var _a;
474
+ state.loading = false;
475
+ state.error = null;
476
+ var _b = action.payload, formData = _b.formData, response = _b.response;
477
+ var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || []).description;
478
+ if (description) {
479
+ state.error = description;
480
+ return;
481
+ }
482
+ state.data.passwordData.password = formData.password;
483
+ state.data.passwordData.responseBody = response;
484
+ })
485
+ .addCase(verifyAuthPassword.pending, function (state) {
486
+ state.loading = true;
487
+ state.error = null;
488
+ })
489
+ .addCase(verifyAuthPassword.rejected, function (state, action) {
490
+ state.loading = false;
491
+ state.error = action.error.message;
394
492
  })
395
493
  .addCase(updateLeadIndividual.fulfilled, function (state, action) {
396
494
  var _a;
@@ -433,6 +531,34 @@ export var connectSlice = createSlice({
433
531
  .addCase(updateLeadBrand.rejected, function (state, action) {
434
532
  state.loading = false;
435
533
  state.error = action.error.message;
534
+ })
535
+ .addCase(checkEmailAvailability.fulfilled, function (state, action) {
536
+ var _a;
537
+ state.searchActive = false;
538
+ state.error = null;
539
+ state.data.individualData.responseBody = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.response;
540
+ })
541
+ .addCase(checkEmailAvailability.pending, function (state) {
542
+ state.searchActive = true;
543
+ state.error = null;
544
+ })
545
+ .addCase(checkEmailAvailability.rejected, function (state, action) {
546
+ state.searchActive = false;
547
+ state.error = action.error.message;
548
+ })
549
+ .addCase(checkBrandNameAvailability.fulfilled, function (state, action) {
550
+ var _a;
551
+ state.searchActive = false;
552
+ state.error = null;
553
+ state.data.brandData.responseBody = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.response;
554
+ })
555
+ .addCase(checkBrandNameAvailability.pending, function (state) {
556
+ state.searchActive = true;
557
+ state.error = null;
558
+ })
559
+ .addCase(checkBrandNameAvailability.rejected, function (state, action) {
560
+ state.searchActive = false;
561
+ state.error = action.error.message;
436
562
  })
437
563
  .addCase(updateLeadSuccess.fulfilled, function (state, action) {
438
564
  var _a;
@@ -7,14 +7,23 @@ import { keepEmailCharacters } from '../../../../utils';
7
7
  import { useController, useFormContext } from 'react-hook-form';
8
8
  import ClearIcon from '../../../shared/ClearIcon';
9
9
  import CheckIcon from '../../../shared/CheckIcon';
10
+ import { checkEmailAvailability } from '../../../app/connect/connectStore';
11
+ import { useAppDispatch } from '../../../../hooks';
12
+ import { debounce } from 'lodash-es';
10
13
  var Email = function (_a) {
11
14
  var _b;
15
+ var dispatch = useAppDispatch();
12
16
  var t = useTranslation().t;
13
17
  var control = useFormContext().control;
14
18
  var emailControl = useController({ name: 'email', control: control });
19
+ var checkEmail = debounce(function (value) {
20
+ dispatch(checkEmailAvailability(value));
21
+ }, 500);
15
22
  var handleEmailChange = function (event) {
16
23
  var value = keepEmailCharacters(event.target.value);
17
24
  emailControl.field.onChange(value);
25
+ if (!!value)
26
+ checkEmail(value);
18
27
  };
19
28
  var emailValue = emailControl.field.value;
20
29
  var error = (_b = emailControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
@@ -33,10 +33,10 @@ var FormStyled = styled(Form)(function () { return ({
33
33
  flexDirection: 'column'
34
34
  }); });
35
35
  var Individual = function (_a) {
36
- var _b;
37
- var _c = React.useState(9), mobileLength = _c[0], setMobileLength = _c[1];
36
+ var _b, _c;
37
+ var _d = React.useState(9), mobileLength = _d[0], setMobileLength = _d[1];
38
38
  var dispatch = useAppDispatch();
39
- var _d = useSelector(connectSelector), data = _d.data, loading = _d.loading, error = _d.error;
39
+ var _e = useSelector(connectSelector), data = _e.data, loading = _e.loading, error = _e.error, searchActive = _e.searchActive;
40
40
  var isAbsher = (_b = data.otpData) === null || _b === void 0 ? void 0 : _b.isAbsher;
41
41
  var methods = useForm({
42
42
  resolver: yupResolver(isAbsher ? IndividualMobileValidation(mobileLength) : IndividualValidation()),
@@ -53,9 +53,14 @@ var Individual = function (_a) {
53
53
  if (error)
54
54
  dispatch(clearError());
55
55
  }, [methods.formState.isValid]);
56
+ React.useEffect(function () {
57
+ var _a, _b;
58
+ if (((_b = (_a = data.individualData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.is_available) == false)
59
+ methods.setError('email', { message: 'tap_js_email_already_exist' });
60
+ }, [(_c = data.individualData) === null || _c === void 0 ? void 0 : _c.responseBody]);
56
61
  var t = useTranslation().t;
57
62
  var isAr = useLanguage().isAr;
58
- var disabled = !methods.formState.isValid || !!error;
63
+ var disabled = !methods.formState.isValid || !!methods.formState.errors.email || !!error || searchActive;
59
64
  return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Name, {}), _jsx(MobileNumber, { setMobileLength: setMobileLength, show: isAbsher, countries: countriesCode }), _jsx(Email, {}), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
60
65
  };
61
66
  export default React.memo(Individual);
@@ -24,6 +24,9 @@ import ClearIcon from '../../../shared/ClearIcon';
24
24
  import Tooltip from '../../../../components/Tooltip';
25
25
  import { removeAllOtherThanCharsNumbersAndSpace } from '../../../../utils';
26
26
  import CheckIcon from '../../../shared/CheckIcon';
27
+ import { checkBrandNameAvailability } from '../../../app/connect/connectStore';
28
+ import { useAppDispatch } from '../../../../hooks';
29
+ import { debounce } from 'lodash-es';
27
30
  var LabelContainerStyled = styled(Box)(function (_a) {
28
31
  var theme = _a.theme;
29
32
  return ({
@@ -56,14 +59,20 @@ var InfoIconStyled = styled(InfoIcon)(function (_a) {
56
59
  });
57
60
  var BrandName = function (_a) {
58
61
  var _b;
62
+ var dispatch = useAppDispatch();
59
63
  var _c = React.useState(false), isHovered = _c[0], setIsHovered = _c[1];
60
64
  var t = useTranslation().t;
61
65
  var control = useFormContext().control;
62
66
  var brandControl = useController({ control: control, name: 'brandName' });
67
+ var checkBrand = debounce(function (value) {
68
+ dispatch(checkBrandNameAvailability(value));
69
+ }, 500);
63
70
  var handleBrandNameChange = function (_a) {
64
71
  var target = _a.target;
65
72
  var value = removeAllOtherThanCharsNumbersAndSpace(target.value);
66
73
  brandControl.field.onChange(value);
74
+ if (!!value)
75
+ checkBrand(value);
67
76
  };
68
77
  var clearBrandName = function () {
69
78
  brandControl.field.onChange('');
@@ -27,7 +27,8 @@ import BrandName from './BrandName';
27
27
  import SocialMedia from './SocialMedia';
28
28
  import TAC from './TAC';
29
29
  var Merchant = function (_a) {
30
- var _b = useSelector(connectSelector), data = _b.data, loading = _b.loading, error = _b.error;
30
+ var _b;
31
+ var _c = useSelector(connectSelector), data = _c.data, loading = _c.loading, error = _c.error, searchActive = _c.searchActive;
31
32
  var methods = useForm({
32
33
  resolver: yupResolver(MerchantValidationSchema),
33
34
  defaultValues: data.brandData,
@@ -46,7 +47,12 @@ var Merchant = function (_a) {
46
47
  if (error)
47
48
  dispatch(clearError());
48
49
  }, [methods.formState.isValid]);
49
- var disabled = !methods.formState.isValid || !!error;
50
+ React.useEffect(function () {
51
+ var _a, _b;
52
+ if (((_b = (_a = data.brandData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.response_code) == '5')
53
+ methods.setError('brandName', { message: 'Profile Name already exists' });
54
+ }, [(_b = data.brandData) === null || _b === void 0 ? void 0 : _b.responseBody]);
55
+ var disabled = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error || searchActive;
50
56
  return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandName, {}), _jsx(SocialMedia, {}), _jsx(TAC, {}), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') }))] })) })) }));
51
57
  };
52
58
  export default React.memo(Merchant);
@@ -74,10 +74,11 @@ var ListType;
74
74
  ListType["CountryCodeList"] = "CountryCodeList";
75
75
  })(ListType || (ListType = {}));
76
76
  var Mobile = function (_a) {
77
- var _b = React.useState(10), mobileLength = _b[0], setMobileLength = _b[1];
78
- var _c = React.useState(), listType = _c[0], setListType = _c[1];
79
- var dispatch = useAppDispatch();
77
+ var _b, _c;
80
78
  var _d = useSelector(connectSelector), data = _d.data, loading = _d.loading, error = _d.error;
79
+ var _e = React.useState((_c = (_b = data.mobileData) === null || _b === void 0 ? void 0 : _b.countryCode) === null || _c === void 0 ? void 0 : _c.digits), mobileLength = _e[0], setMobileLength = _e[1];
80
+ var _f = React.useState(), listType = _f[0], setListType = _f[1];
81
+ var dispatch = useAppDispatch();
81
82
  var methods = useForm({
82
83
  resolver: yupResolver(PhoneValidationSchema(mobileLength)),
83
84
  defaultValues: data.mobileData,
@@ -94,7 +95,7 @@ var Mobile = function (_a) {
94
95
  dispatch(clearError());
95
96
  }, [methods.formState.isValid]);
96
97
  var onSubmit = function (formData) {
97
- dispatch(createMobileAuth(formData));
98
+ dispatch(createMobileAuth(__assign(__assign({}, formData), { isResend: false })));
98
99
  };
99
100
  var onAbsherButtonClicked = function () {
100
101
  dispatch(handleCurrentActiveScreen('CONNECT_NID_STEP'));
@@ -47,7 +47,7 @@ var NID = function (_a) {
47
47
  dispatch(clearError());
48
48
  }, [methods.formState.isValid]);
49
49
  var onSubmit = function (data) {
50
- dispatch(createNIDAuth(data));
50
+ dispatch(createNIDAuth(__assign(__assign({}, data), { isResend: false })));
51
51
  };
52
52
  var handleCollapseOpenClose = function (flag) {
53
53
  setCollapse(flag);
@@ -25,7 +25,7 @@ import { useLanguage } from '../../../../hooks';
25
25
  import { useForm, FormProvider } from 'react-hook-form';
26
26
  import { yupResolver } from '@hookform/resolvers/yup';
27
27
  import Form from '../../../../components/Form';
28
- import { maskPhone } from '../../../../utils';
28
+ import { maskPhone, maskID } from '../../../../utils';
29
29
  import { OTPValidation } from './validation';
30
30
  import OTPInput from './OTPInput';
31
31
  var OTPTitleContainerStyled = styled(Box)(function (_a) {
@@ -67,11 +67,12 @@ var OTP = function () {
67
67
  dispatch(verifyAuth(formData));
68
68
  };
69
69
  var onBack = function () {
70
- handlePrevScreenStep();
70
+ dispatch(handlePrevScreenStep(isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
71
71
  };
72
72
  var disabled = !methods.formState.isValid || !!error;
73
73
  var phone = ((_a = data.mobileData.countryCode) === null || _a === void 0 ? void 0 : _a.idd_prefix) + (data.mobileData.mobile || '');
74
+ var idNumber = data.nidData.nid;
74
75
  var title = isAbsher ? t('opt_nid_sent_title', { provider: 'ABSHER' }) : t('ide_opt_sent_title');
75
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : title, _jsx("span", __assign({ dir: 'ltr' }, { children: maskPhone(phone) }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
76
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : title, !loading && _jsx("span", __assign({ dir: 'ltr' }, { children: isAbsher ? maskID(idNumber) : maskPhone(phone) }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
76
77
  };
77
78
  export default React.memo(OTP);
@@ -29,7 +29,7 @@ var BoxStyled = styled(Box)(function (_a) {
29
29
  });
30
30
  });
31
31
  var OTPInput = function (_a) {
32
- var control = useFormContext().control;
32
+ var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
33
33
  var t = useTranslation().t;
34
34
  var dispatch = useAppDispatch();
35
35
  var otpControl = useController({ name: 'otp', control: control });
@@ -41,19 +41,23 @@ var OTPInput = function (_a) {
41
41
  otpControl.field.onChange(otp);
42
42
  };
43
43
  var handleOnResendOTP = function () {
44
+ if (otpControl.field.value)
45
+ setValue('otp', '', { shouldValidate: true });
44
46
  var params = {
45
47
  businessCountry: mobileData.businessCountry,
46
48
  countryCode: mobileData.countryCode,
47
49
  mobile: mobileData.mobile
48
50
  };
49
- dispatch(createMobileAuth(params));
51
+ dispatch(createMobileAuth(__assign(__assign({}, params), { isResend: true })));
50
52
  };
51
53
  var handleOnResendAbsherOTP = function () {
54
+ if (otpControl.field.value)
55
+ setValue('otp', '', { shouldValidate: true });
52
56
  var params = {
53
57
  nid: nidData.nid,
54
58
  dob: nidData.dob
55
59
  };
56
- dispatch(createNIDAuth(params));
60
+ dispatch(createNIDAuth(__assign(__assign({}, params), { isResend: true })));
57
61
  };
58
62
  var otpValue = otpControl.field.value;
59
63
  return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: isAbsher ? handleOnResendAbsherOTP : handleOnResendOTP, value: otpValue, onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
@@ -11,12 +11,14 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import * as React from 'react';
14
+ import { useSelector } from 'react-redux';
15
+ import { useAppDispatch } from '../../../../hooks';
14
16
  import { useForm, FormProvider } from 'react-hook-form';
15
17
  import { useTranslation } from 'react-i18next';
16
18
  import { yupResolver } from '@hookform/resolvers/yup';
17
- import { useAppDispatch } from '../../../../hooks';
18
19
  import { styled } from '@mui/material/styles';
19
- import { handleNextScreenStep, handlePrevScreenStep } from '../../../../app/settings';
20
+ import { handlePrevScreenStep } from '../../../../app/settings';
21
+ import { clearError, connectSelector, verifyAuthPassword } from '../../../app/connect/connectStore';
20
22
  import Form from '../../../../components/Form';
21
23
  import Button from '../../../shared/Button';
22
24
  import { ScreenContainer } from '../../../shared/Containers';
@@ -30,23 +32,27 @@ var FormStyled = styled(Form)(function () { return ({
30
32
  height: '100%'
31
33
  }); });
32
34
  var Password = function (_a) {
35
+ var dispatch = useAppDispatch();
36
+ var _b = useSelector(connectSelector), data = _b.data, loading = _b.loading, error = _b.error;
33
37
  var methods = useForm({
34
38
  resolver: yupResolver(PasswordValidationSchema),
35
- defaultValues: {
36
- password: ''
37
- },
39
+ defaultValues: data.passwordData,
38
40
  mode: 'onChange'
39
41
  });
40
42
  var t = useTranslation().t;
41
43
  var isAr = useLanguage().isAr;
42
- var dispatch = useAppDispatch();
43
- var onSubmit = function (data) {
44
- console.log('data', data);
45
- dispatch(handleNextScreenStep());
44
+ var isAbsher = data.otpData.isAbsher;
45
+ React.useEffect(function () {
46
+ if (error)
47
+ dispatch(clearError());
48
+ }, [methods.formState.isValid]);
49
+ var onSubmit = function (formData) {
50
+ dispatch(verifyAuthPassword(formData));
46
51
  };
47
52
  var onBack = function () {
48
- dispatch(handlePrevScreenStep());
53
+ dispatch(handlePrevScreenStep(isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
49
54
  };
50
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(PasswordInput, {}), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: !methods.formState.isValid, isAr: isAr, loading: false }, { children: t('next') }))] })) })) }));
55
+ var disabled = !methods.formState.isValid || !!error;
56
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(PasswordInput, {}), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
51
57
  };
52
58
  export default React.memo(Password);
@@ -34,6 +34,6 @@ var PasswordInput = function (_a) {
34
34
  };
35
35
  var passwordValue = passwordControl.field.value;
36
36
  var error = (_b = passwordControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
37
- return (_jsx(ScreenContainer, __assign({ sx: { mt: 2.5 } }, { children: _jsx(Input, { label: t('tap_js_password_description'), inputProps: { autoComplete: 'off' }, onChange: handlePasswordChange, value: passwordValue, endAdornment: _jsx(PasswordIcon, { show: showPassword, onShow: handleShowPassword, onHide: handleHidePassword }), placeholder: t('tap_js_password_placeholder'), type: showPassword ? 'text' : 'password', warningType: 'alert', warningMessage: error && t(error, { length: 8 }) }) })));
37
+ return (_jsx(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 5 } }, { children: _jsx(Input, { label: t('tap_js_password_description'), inputProps: { autoComplete: 'off' }, onChange: handlePasswordChange, value: passwordValue, endAdornment: _jsx(PasswordIcon, { show: showPassword, onShow: handleShowPassword, onHide: handleHidePassword }), placeholder: t('tap_js_password_placeholder'), type: showPassword ? 'text' : 'password', warningType: 'alert', warningMessage: error && t(error, { length: 8 }) }) })));
38
38
  };
39
39
  export default React.memo(PasswordInput);
@@ -1,14 +1,12 @@
1
1
  export var string = '';
2
2
  export var maskPhone = function (str) {
3
3
  if (str === void 0) { str = ''; }
4
- var first = str.substring(0, 1);
5
4
  var lastTwo = str.substring(str.length - 2, str.length);
6
- return first + '••••' + lastTwo;
5
+ return ' ••••' + lastTwo;
7
6
  };
8
7
  export var maskID = function (str) {
9
- var first = str.substring(0, 1);
10
8
  var lastTwo = str.substring(str.length - 2, str.length);
11
- return first + '••••••' + lastTwo;
9
+ return ' ••••' + lastTwo;
12
10
  };
13
11
  export var getIndividualName = function (name) {
14
12
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",