@tap-payments/auth-jsconnect 2.0.68-test → 2.0.70-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.
@@ -22,6 +22,7 @@ export declare type CreateAuthBody = {
22
22
  auth_type?: number;
23
23
  email_url?: string;
24
24
  sign_in?: boolean;
25
+ is_lead?: boolean;
25
26
  step_name?: string;
26
27
  encryption_contract: Array<string>;
27
28
  lang?: LanguageMode;
@@ -33,7 +34,7 @@ export declare type VerifyAuthBody = {
33
34
  device_token: string;
34
35
  step_name: string;
35
36
  service_name: string;
36
- new_user: boolean;
37
+ new_user?: boolean;
37
38
  sign_in: boolean;
38
39
  encryption_contract: Array<string>;
39
40
  remember_me?: boolean;
@@ -22,6 +22,7 @@ export declare const resendOTPNID: import("@reduxjs/toolkit").AsyncThunk<any, vo
22
22
  export declare const verifyAuth: import("@reduxjs/toolkit").AsyncThunk<{
23
23
  response: any;
24
24
  formData: OTPFormValues;
25
+ leadData: any;
25
26
  }, OTPFormValues, {}>;
26
27
  interface verifyPACIParams {
27
28
  onSuccess?: () => void | Promise<void>;
@@ -76,6 +76,7 @@ export var createMobileAuth = createAsyncThunk('createMobileAuth', function (par
76
76
  code: params.countryCode.idd_prefix.toString()
77
77
  },
78
78
  sign_in: false,
79
+ is_lead: true,
79
80
  step_name: CONNECT_STEP_NAMES.CREATE_AUTH_MOBILE,
80
81
  encryption_contract: ['user_credentail.phone', 'user_credentail.code']
81
82
  };
@@ -104,6 +105,7 @@ export var createCivilIdAuth = createAsyncThunk('createCivilIdAuth', function (p
104
105
  country_code: 'KW'
105
106
  },
106
107
  sign_in: false,
108
+ is_lead: true,
107
109
  step_name: CONNECT_STEP_NAMES.CREATE_AUTH_CIVIL_ID,
108
110
  encryption_contract: ['user_credentail.identification_id']
109
111
  };
@@ -132,6 +134,7 @@ export var resendOTPMobile = createAsyncThunk('resendOTPMobile', function (param
132
134
  code: countryCode.idd_prefix.toString()
133
135
  },
134
136
  sign_in: false,
137
+ is_lead: true,
135
138
  step_name: CONNECT_STEP_NAMES.CREATE_AUTH_MOBILE,
136
139
  encryption_contract: ['user_credentail.phone', 'user_credentail.code']
137
140
  };
@@ -159,6 +162,7 @@ export var createNIDAuth = createAsyncThunk('createNIDAuth', function (params, t
159
162
  country_code: settings.data.businessCountry.iso2
160
163
  },
161
164
  sign_in: false,
165
+ is_lead: true,
162
166
  step_name: CONNECT_STEP_NAMES.CREATE_AUTH_NID,
163
167
  encryption_contract: [
164
168
  'user_credentail.country_code',
@@ -194,6 +198,7 @@ export var resendOTPNID = createAsyncThunk('resendOTPNID', function (params, thu
194
198
  country_code: settings.data.businessCountry.iso2
195
199
  },
196
200
  sign_in: false,
201
+ is_lead: true,
197
202
  step_name: CONNECT_STEP_NAMES.CREATE_AUTH_NID,
198
203
  encryption_contract: [
199
204
  'user_credentail.country_code',
@@ -210,7 +215,7 @@ export var resendOTPNID = createAsyncThunk('resendOTPNID', function (params, thu
210
215
  });
211
216
  }); });
212
217
  export var verifyAuth = createAsyncThunk('verifyAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
213
- var _a, connect, settings, isAbsher, _b, mobileData, nidData, responseBody, payload, data, params_1, params_2;
218
+ var _a, connect, settings, isAbsher, _b, mobileData, nidData, responseBody, individualInfo, payload, data, leadData, isNewUser, params_1;
214
219
  var _c, _d;
215
220
  return __generator(this, function (_e) {
216
221
  switch (_e.label) {
@@ -219,13 +224,13 @@ export var verifyAuth = createAsyncThunk('verifyAuth', function (params, thunkAp
219
224
  isAbsher = connect.data.otpData.isAbsher;
220
225
  _b = connect.data, mobileData = _b.mobileData, nidData = _b.nidData;
221
226
  responseBody = (isAbsher ? nidData : mobileData).responseBody;
227
+ individualInfo = undefined;
222
228
  payload = {
223
229
  data: params.otp,
224
230
  auth_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_token,
225
231
  auth_type: responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_type,
226
232
  device_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.device_token,
227
233
  service_name: responseBody === null || responseBody === void 0 ? void 0 : responseBody.service_name,
228
- new_user: responseBody === null || responseBody === void 0 ? void 0 : responseBody.new_user,
229
234
  sign_in: responseBody === null || responseBody === void 0 ? void 0 : responseBody.sign_in,
230
235
  remember_me: responseBody === null || responseBody === void 0 ? void 0 : responseBody.remember_me,
231
236
  scopes: responseBody === null || responseBody === void 0 ? void 0 : responseBody.scopes,
@@ -237,42 +242,43 @@ export var verifyAuth = createAsyncThunk('verifyAuth', function (params, thunkAp
237
242
  data = (_e.sent()).data;
238
243
  if (!!data.errors) return [3, 5];
239
244
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
240
- if (!(responseBody === null || responseBody === void 0 ? void 0 : responseBody.new_user)) return [3, 2];
241
- params_1 = {
242
- leadId: data === null || data === void 0 ? void 0 : data.lead_id,
243
- stepName: 'CONNECT_INDIVIDUAL_STEP'
244
- };
245
- thunkApi.dispatch(retrieveLead(params_1));
246
- return [3, 5];
247
- case 2: return [4, thunkApi.dispatch(retrieveBrandList(data === null || data === void 0 ? void 0 : data.individual_id))];
245
+ return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.lead_id)];
246
+ case 2:
247
+ leadData = (_e.sent()).data;
248
+ individualInfo = leadData;
249
+ isNewUser = leadData === null || leadData === void 0 ? void 0 : leadData.is_new_individual;
250
+ return [4, thunkApi.dispatch(retrieveBrandList(individualInfo === null || individualInfo === void 0 ? void 0 : individualInfo.individual_id))];
248
251
  case 3:
249
252
  _e.sent();
250
253
  return [4, thunkApi.dispatch(retrieveChannels())];
251
254
  case 4:
252
255
  _e.sent();
253
256
  if (!(data === null || data === void 0 ? void 0 : data.lead_id)) {
254
- params_2 = {
257
+ params_1 = {
255
258
  individualId: data === null || data === void 0 ? void 0 : data.individual_id,
256
259
  stepName: 'CONNECT_MERCHANT_INFO_STEP'
257
260
  };
258
- thunkApi.dispatch(createLead(params_2));
261
+ thunkApi.dispatch(createLead(params_1));
259
262
  }
260
263
  else {
261
- thunkApi.dispatch(handleNextScreenStep('CONNECT_MERCHANT_INFO_STEP'));
264
+ isNewUser
265
+ ? thunkApi.dispatch(handleNextScreenStep('CONNECT_INDIVIDUAL_STEP'))
266
+ : thunkApi.dispatch(handleNextScreenStep('CONNECT_MERCHANT_INFO_STEP'));
262
267
  }
263
268
  _e.label = 5;
264
- case 5: return [2, { response: data, formData: params }];
269
+ case 5: return [2, { response: data, formData: params, leadData: individualInfo }];
265
270
  }
266
271
  });
267
272
  }); });
268
273
  export var verifyPACI = createAsyncThunk('verifyPACI', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
269
- var _a, settings, connect, responseBody, expiry, interval, maxCalls, response, count, data, isSuccess, leadBody, leadBody;
274
+ var _a, settings, connect, responseBody, leadBody, expiry, interval, maxCalls, response, count, data, isSuccess, leadBody_1, leadBody_2;
270
275
  var _b, _c, _d, _e;
271
276
  return __generator(this, function (_f) {
272
277
  switch (_f.label) {
273
278
  case 0:
274
279
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
275
280
  responseBody = connect.data.civilIdData.responseBody;
281
+ leadBody = connect.data.otpData.responseBody;
276
282
  expiry = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.expiry) || 120;
277
283
  interval = 3;
278
284
  maxCalls = Math.floor(expiry / interval);
@@ -288,7 +294,7 @@ export var verifyPACI = createAsyncThunk('verifyPACI', function (params, thunkAp
288
294
  case 2:
289
295
  data = _f.sent();
290
296
  response = data;
291
- if (count === 1 && (responseBody === null || responseBody === void 0 ? void 0 : responseBody.new_user) === false) {
297
+ if (count === 1 && (leadBody === null || leadBody === void 0 ? void 0 : leadBody.is_new_individual) === false) {
292
298
  thunkApi.dispatch(retrieveBrandList(data === null || data === void 0 ? void 0 : data.individual_id));
293
299
  thunkApi.dispatch(retrieveChannels());
294
300
  }
@@ -297,19 +303,19 @@ export var verifyPACI = createAsyncThunk('verifyPACI', function (params, thunkAp
297
303
  return [4, ((_c = params === null || params === void 0 ? void 0 : params.onSuccess) === null || _c === void 0 ? void 0 : _c.call(params))];
298
304
  case 3:
299
305
  _f.sent();
300
- if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.new_user) && (data === null || data === void 0 ? void 0 : data.lead_id)) {
301
- leadBody = {
306
+ if ((leadBody === null || leadBody === void 0 ? void 0 : leadBody.is_new_individual) && (data === null || data === void 0 ? void 0 : data.lead_id)) {
307
+ leadBody_1 = {
302
308
  leadId: data === null || data === void 0 ? void 0 : data.lead_id,
303
309
  stepName: 'CONNECT_INDIVIDUAL_STEP'
304
310
  };
305
- thunkApi.dispatch(retrieveLead(leadBody));
311
+ thunkApi.dispatch(retrieveLead(leadBody_1));
306
312
  }
307
313
  else if (!(data === null || data === void 0 ? void 0 : data.lead_id) && (data === null || data === void 0 ? void 0 : data.individual_id)) {
308
- leadBody = {
314
+ leadBody_2 = {
309
315
  individualId: data === null || data === void 0 ? void 0 : data.individual_id,
310
316
  stepName: 'CONNECT_MERCHANT_INFO_STEP'
311
317
  };
312
- thunkApi.dispatch(createLead(leadBody));
318
+ thunkApi.dispatch(createLead(leadBody_2));
313
319
  }
314
320
  else
315
321
  thunkApi.dispatch(handleNextScreenStep('CONNECT_MERCHANT_INFO_STEP'));
@@ -432,7 +438,7 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
432
438
  });
433
439
  }); });
434
440
  export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
435
- var _a, settings, connect, instagram, twitter, _b, mobileData, nidData, otpData, brandData, isAbsher, responseBody, isExistingUser, isOther, brand, payload, data;
441
+ var _a, settings, connect, instagram, twitter, _b, otpData, brandData, isAbsher, responseBody, isExistingUser, isOther, brand, payload, data;
436
442
  var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
437
443
  return __generator(this, function (_q) {
438
444
  switch (_q.label) {
@@ -440,10 +446,10 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
440
446
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
441
447
  instagram = !!((_c = params.links) === null || _c === void 0 ? void 0 : _c.instagram) ? "".concat(INSTAGRAM_URL, "/").concat((_d = params.links) === null || _d === void 0 ? void 0 : _d.instagram) : '';
442
448
  twitter = !!((_e = params.links) === null || _e === void 0 ? void 0 : _e.twitter) ? "".concat(TWITTER_URL, "/").concat((_f = params.links) === null || _f === void 0 ? void 0 : _f.twitter) : '';
443
- _b = connect.data, mobileData = _b.mobileData, nidData = _b.nidData, otpData = _b.otpData, brandData = _b.brandData;
449
+ _b = connect.data, otpData = _b.otpData, brandData = _b.brandData;
444
450
  isAbsher = otpData.isAbsher;
445
- responseBody = (isAbsher ? nidData : mobileData).responseBody;
446
- isExistingUser = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.new_user) === false;
451
+ responseBody = otpData.responseBody;
452
+ isExistingUser = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.is_new_individual) === false;
447
453
  isOther = !!((_g = params.selectedBrandItem) === null || _g === void 0 ? void 0 : _g.id) ? ((_h = params.selectedBrandItem) === null || _h === void 0 ? void 0 : _h.id) === 'other' : true;
448
454
  brand = __assign({ name: {
449
455
  en: params.brandName,
@@ -526,16 +532,15 @@ export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailabi
526
532
  });
527
533
  });
528
534
  export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
529
- var _a, settings, connect, _b, mobileData, nidData, otpData, brandData, isAbsher, responseBody, isExistingUser, leadId, payload, data;
535
+ var _a, settings, connect, _b, otpData, brandData, responseBody, isExistingUser, leadId, payload, data;
530
536
  var _c, _d, _e, _f, _g, _h;
531
537
  return __generator(this, function (_j) {
532
538
  switch (_j.label) {
533
539
  case 0:
534
540
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
535
- _b = connect.data, mobileData = _b.mobileData, nidData = _b.nidData, otpData = _b.otpData, brandData = _b.brandData;
536
- isAbsher = otpData.isAbsher;
537
- responseBody = (isAbsher ? nidData : mobileData).responseBody;
538
- isExistingUser = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.new_user) === false;
541
+ _b = connect.data, otpData = _b.otpData, brandData = _b.brandData;
542
+ responseBody = otpData.responseBody;
543
+ isExistingUser = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.is_new_individual) === false;
539
544
  leadId = isExistingUser ? (_c = brandData.responseBody) === null || _c === void 0 ? void 0 : _c.lead_id : (_d = otpData.responseBody) === null || _d === void 0 ? void 0 : _d.lead_id;
540
545
  payload = {
541
546
  lang: settings.data.language,
@@ -743,16 +748,32 @@ export var connectSlice = createSlice({
743
748
  state.error = action.error.message;
744
749
  })
745
750
  .addCase(verifyAuth.fulfilled, function (state, action) {
746
- var _a;
751
+ var _a, _b;
747
752
  state.error = null;
748
- var _b = action.payload, formData = _b.formData, response = _b.response;
753
+ var _c = action.payload, formData = _c.formData, response = _c.response, leadData = _c.leadData;
749
754
  var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
750
755
  if (description) {
751
756
  state.loading = false;
752
757
  state.error = description;
753
758
  return;
754
759
  }
755
- state.data.otpData.responseBody = response;
760
+ var name = leadData.name, contact = leadData.contact, brand = leadData.brand;
761
+ var _d = contact || {}, email = _d.email, phone = _d.phone;
762
+ var firstName = (name === null || name === void 0 ? void 0 : name.first) + ' ';
763
+ var middleName = !!(name === null || name === void 0 ? void 0 : name.middle) ? (name === null || name === void 0 ? void 0 : name.middle) + ' ' : '';
764
+ var thirdName = !!(name === null || name === void 0 ? void 0 : name.third) ? (name === null || name === void 0 ? void 0 : name.third) + ' ' : '';
765
+ var lastName = !!(name === null || name === void 0 ? void 0 : name.last) ? name === null || name === void 0 ? void 0 : name.last : '';
766
+ if (!!name) {
767
+ var capitalizedName = capitalizeTheFirstLetterOfEachWord(firstName + middleName + thirdName + lastName);
768
+ state.data.individualData.name = capitalizedName;
769
+ }
770
+ if (!!email)
771
+ state.data.individualData.email = email;
772
+ if (!!(phone === null || phone === void 0 ? void 0 : phone.number))
773
+ state.data.individualData.mobile = phone === null || phone === void 0 ? void 0 : phone.number;
774
+ state.data.brandData.brandName = (_b = brand === null || brand === void 0 ? void 0 : brand.name) === null || _b === void 0 ? void 0 : _b.en;
775
+ state.data.brandData.links.website = brand === null || brand === void 0 ? void 0 : brand.website;
776
+ state.data.otpData.responseBody = __assign(__assign({}, response), leadData);
756
777
  state.data.otpData.otp = formData.otp;
757
778
  state.data.brandData.responseBody = __assign(__assign({}, state.data.brandData.responseBody), response);
758
779
  })
@@ -881,7 +902,7 @@ export var connectSlice = createSlice({
881
902
  .addCase(checkEmailAvailability.fulfilled, function (state, action) {
882
903
  var _a;
883
904
  state.error = null;
884
- state.data.individualData.responseBody = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.response;
905
+ state.data.individualData.responseBody = __assign(__assign({}, state.data.individualData.responseBody), (_a = action.payload) === null || _a === void 0 ? void 0 : _a.response);
885
906
  })
886
907
  .addCase(checkEmailAvailability.pending, function (state) {
887
908
  state.error = null;
@@ -939,14 +960,20 @@ export var connectSlice = createSlice({
939
960
  var isHasWebsite = (website === null || website === void 0 ? void 0 : website.length) > 0;
940
961
  var isHasTwitter = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('twitter.com'); });
941
962
  var isHasInstagram = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('instagram.com'); });
942
- var websiteData = channels === null || channels === void 0 ? void 0 : channels.find(function (c) { return c.id.toLocaleLowerCase() === 'website'; });
943
- var socialData = channels === null || channels === void 0 ? void 0 : channels.find(function (c) { var _a; return ((_a = c.name) === null || _a === void 0 ? void 0 : _a.en.toLocaleLowerCase()) === 'social'; });
944
- if (isHasWebsite && (isHasTwitter || isHasInstagram))
945
- selectedChannels = [websiteData, socialData];
946
- else if (isHasTwitter || isHasInstagram)
947
- selectedChannels = [socialData];
948
- else if (isHasWebsite)
949
- selectedChannels = [websiteData];
963
+ var websiteData = channels === null || channels === void 0 ? void 0 : channels.find(function (c) { var _a, _b, _c; return (_c = (_b = (_a = c.name) === null || _a === void 0 ? void 0 : _a.en) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === null || _c === void 0 ? void 0 : _c.includes('website'); });
964
+ var socialData = channels === null || channels === void 0 ? void 0 : channels.find(function (c) { var _a, _b, _c; return (_c = (_b = (_a = c.name) === null || _a === void 0 ? void 0 : _a.en) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === null || _c === void 0 ? void 0 : _c.includes('social'); });
965
+ if (isHasWebsite && (isHasTwitter || isHasInstagram)) {
966
+ if (websiteData)
967
+ selectedChannels.push(websiteData);
968
+ if (socialData)
969
+ selectedChannels.push(socialData);
970
+ }
971
+ else if ((isHasTwitter || isHasInstagram) && socialData) {
972
+ selectedChannels.push(socialData);
973
+ }
974
+ else if (isHasWebsite && websiteData) {
975
+ selectedChannels.push(websiteData);
976
+ }
950
977
  state.data.brandData.salesChannels = selectedChannels;
951
978
  })
952
979
  .addCase(retrieveChannels.rejected, function (state, action) {
@@ -1,13 +1,13 @@
1
1
  import * as yup from 'yup';
2
2
  export declare const LicenseValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
3
  selectedLicense: any;
4
- licenseNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
4
+ licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
5
5
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
6
6
  selectedLicense: any;
7
- licenseNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
7
+ licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
8
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
9
9
  selectedLicense: any;
10
- licenseNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
10
+ licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
11
11
  }>>>;
12
12
  export declare const KWLicenseValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
13
13
  selectedLicense: any;
@@ -13,7 +13,9 @@ var objectElements = {
13
13
  };
14
14
  export var LicenseValidationSchema = yup.object().shape({
15
15
  selectedLicense: yup.object().shape(objectElements).required(''),
16
- licenseNumber: yup.string().test({
16
+ licenseNumber: yup
17
+ .string()
18
+ .test({
17
19
  test: function (value) {
18
20
  var selectedLicense = this.parent.selectedLicense;
19
21
  var isCR = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.CR;
@@ -26,6 +28,7 @@ export var LicenseValidationSchema = yup.object().shape({
26
28
  return length === FL_NUMBER_LENGTH ? true : this.createError({ message: 'fl_max_length' });
27
29
  }
28
30
  })
31
+ .required('')
29
32
  });
30
33
  export var KWLicenseValidationSchema = yup.object().shape({
31
34
  selectedLicense: yup.object().shape(objectElements).required(''),
@@ -54,8 +54,8 @@ import Input from '../../../shared/Input';
54
54
  import { useController, useFormContext } from 'react-hook-form';
55
55
  import ClearIcon from '../../../shared/ClearIcon';
56
56
  import CheckIcon from '../../../shared/CheckIcon';
57
- import { checkEmailAvailability } from '../../../app/connect/connectStore';
58
- import { useAppDispatch } from '../../../../hooks';
57
+ import { checkEmailAvailability, connectSelector } from '../../../app/connect/connectStore';
58
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
59
59
  import { debounce } from 'lodash-es';
60
60
  import Collapse from '../../../../components/Collapse';
61
61
  import { styled } from '@mui/material/styles';
@@ -72,7 +72,9 @@ var cancelToken = null;
72
72
  var Email = function (_a) {
73
73
  var _b;
74
74
  var show = _a.show, fetchingEmail = _a.fetchingEmail, emailChecking = _a.emailChecking;
75
+ var _c = React.useState(''), storedEmail = _c[0], setStoredEmail = _c[1];
75
76
  var dispatch = useAppDispatch();
77
+ var data = useAppSelector(connectSelector).data;
76
78
  var t = useTranslation().t;
77
79
  var control = useFormContext().control;
78
80
  var emailControl = useController({ name: 'email', control: control });
@@ -93,9 +95,15 @@ var Email = function (_a) {
93
95
  var handleEmailChange = function (event) {
94
96
  emailControl.field.onChange(event.target.value);
95
97
  };
98
+ React.useEffect(function () {
99
+ var _a, _b;
100
+ var email = (_b = (_a = data.otpData.responseBody) === null || _a === void 0 ? void 0 : _a.contact) === null || _b === void 0 ? void 0 : _b.email;
101
+ if (!!email)
102
+ setStoredEmail(email);
103
+ }, [data.otpData.responseBody]);
96
104
  React.useEffect(function () {
97
105
  var isValid = emailValue && !error && emailValue.length > 3;
98
- if (isValid) {
106
+ if (isValid && emailValue != storedEmail) {
99
107
  fetchingEmail(true);
100
108
  checkEmail(emailValue);
101
109
  }
@@ -34,11 +34,11 @@ var FormStyled = styled(Form)(function () { return ({
34
34
  flexDirection: 'column'
35
35
  }); });
36
36
  var Individual = function (_a) {
37
- var _b, _c, _d;
38
- var _e = React.useState(false), listActive = _e[0], setListActive = _e[1];
39
- var _f = React.useState(false), emailChecking = _f[0], setEmailChecking = _f[1];
37
+ var _b, _c, _d, _e, _f, _g;
38
+ var _h = React.useState(false), listActive = _h[0], setListActive = _h[1];
39
+ var _j = React.useState(false), emailChecking = _j[0], setEmailChecking = _j[1];
40
40
  var settingsData = useAppSelector(settingsSelector).data;
41
- var _g = useAppSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error;
41
+ var _k = useAppSelector(connectSelector), data = _k.data, loading = _k.loading, error = _k.error;
42
42
  var dispatch = useAppDispatch();
43
43
  var t = useTranslation().t;
44
44
  var isAr = useLanguage().isAr;
@@ -46,7 +46,7 @@ var Individual = function (_a) {
46
46
  var isMobile = data.mobileData.mobile;
47
47
  var individualData = data.individualData;
48
48
  var methods = useForm({
49
- resolver: yupResolver(!isMobile ? IndividualMobileValidation : IndividualValidation),
49
+ resolver: yupResolver(isMobile ? IndividualValidation : IndividualMobileValidation),
50
50
  defaultValues: data.individualData,
51
51
  mode: 'onChange'
52
52
  });
@@ -82,8 +82,12 @@ var Individual = function (_a) {
82
82
  if (((_b = (_a = data.individualData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.is_available) === false)
83
83
  methods.setError('email', { message: 'tap_js_email_already_exist' });
84
84
  }, [(_c = data.individualData) === null || _c === void 0 ? void 0 : _c.responseBody]);
85
+ var isLeadEmailAvailable = ((_e = (_d = data.otpData.responseBody) === null || _d === void 0 ? void 0 : _d.contact) === null || _e === void 0 ? void 0 : _e.email) === methods.watch('email');
86
+ var isEmailValid = ((_f = data.individualData.responseBody) === null || _f === void 0 ? void 0 : _f.is_available) === undefined
87
+ ? isLeadEmailAvailable
88
+ : (_g = data.individualData.responseBody) === null || _g === void 0 ? void 0 : _g.is_available;
85
89
  var emailErrChecks = !methods.formState.isValid || !!methods.formState.errors.email || !!error;
86
- var disabled = emailErrChecks || emailChecking || !((_d = data.individualData.responseBody) === null || _d === void 0 ? void 0 : _d.is_available);
90
+ var disabled = emailErrChecks || emailChecking || !isEmailValid;
87
91
  return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Name, { show: !listActive }), _jsx(MobileNumber, { show: !isMobile, onListOpen: function () { return handleMenuListClick(); }, onListClose: function () { return handleMenuListClick(); }, countries: countriesCode }), _jsx(Email, { show: !listActive, fetchingEmail: function (v) { return setEmailChecking(v); }, emailChecking: emailChecking }), _jsx(Collapse, __assign({ in: !listActive }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
88
92
  };
89
93
  export default React.memo(Individual);
@@ -63,8 +63,8 @@ import Tooltip from '../../../../components/Tooltip';
63
63
  import Collapse from '../../../../components/Collapse';
64
64
  import { removeAllOtherThanCharsNumbersAndSpace } from '../../../../utils';
65
65
  import CheckIcon from '../../../shared/CheckIcon';
66
- import { checkBrandNameAvailability } from '../../../app/connect/connectStore';
67
- import { useAppDispatch } from '../../../../hooks';
66
+ import { checkBrandNameAvailability, connectSelector } from '../../../app/connect/connectStore';
67
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
68
68
  import { debounce } from 'lodash-es';
69
69
  var LabelContainerStyled = styled(Box)(function (_a) {
70
70
  var theme = _a.theme;
@@ -100,9 +100,11 @@ var cancelToken = null;
100
100
  var BrandName = function (_a) {
101
101
  var _b;
102
102
  var show = _a.show, brandNameChecking = _a.brandNameChecking, fetchingBrandName = _a.fetchingBrandName;
103
+ var _c = React.useState(''), storedBrand = _c[0], setStoredBrand = _c[1];
103
104
  var dispatch = useAppDispatch();
104
- var _c = React.useState(false), isHovered = _c[0], setIsHovered = _c[1];
105
+ var _d = React.useState(false), isHovered = _d[0], setIsHovered = _d[1];
105
106
  var t = useTranslation().t;
107
+ var data = useAppSelector(connectSelector).data;
106
108
  var control = useFormContext().control;
107
109
  var brandControl = useController({ control: control, name: 'brandName' });
108
110
  var brandNameValue = brandControl.field.value;
@@ -125,8 +127,10 @@ var BrandName = function (_a) {
125
127
  brandControl.field.onChange(value);
126
128
  };
127
129
  React.useEffect(function () {
130
+ var _a, _b, _c;
128
131
  var isValid = brandNameValue && !error && brandNameValue.length > 2;
129
- if (isValid) {
132
+ var brand = (_c = (_b = (_a = data.otpData.responseBody) === null || _a === void 0 ? void 0 : _a.brand) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.en;
133
+ if (isValid && (brandNameValue === null || brandNameValue === void 0 ? void 0 : brandNameValue.toLowerCase()) != brand) {
130
134
  fetchingBrandName(true);
131
135
  checkBrand(brandNameValue);
132
136
  }
@@ -37,7 +37,7 @@ var Merchant = function (_a) {
37
37
  var _f = React.useState(false), listActive = _f[0], setListActive = _f[1];
38
38
  var _g = useAppSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error;
39
39
  var settingsData = useAppSelector(settingsSelector).data;
40
- var isNewUser = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.new_user;
40
+ var isNewUser = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.is_new_individual;
41
41
  var isAbsher = data.otpData.isAbsher;
42
42
  var _h = data.brandData.responseBody || {}, brands = _h.brands, channelList = _h.channelList;
43
43
  var brandList = brands || [];
package/package.json CHANGED
@@ -1,129 +1,129 @@
1
- {
2
- "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.0.68-test",
4
- "description": "connect library, auth",
5
- "private": false,
6
- "main": "build/index.js",
7
- "module": "build/index.js",
8
- "types": "build/index.d.ts",
9
- "files": [
10
- "build",
11
- "README.md"
12
- ],
13
- "scripts": {
14
- "husky:setup": "npx husky install",
15
- "prettier": "prettier --list-different \"src/**/*.{md,mdx,ts,js,tsx,jsx,json}\" *.json *.js",
16
- "prettier:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md,css,json}\" *.json *.js",
17
- "lint": "eslint src --color --ext .js,.jsx,.ts,.tsx,.json",
18
- "lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
19
- "start": "cross-env NODE_ENV=development webpack serve",
20
- "build": "rm -rf build && cross-env NODE_ENV=production webpack",
21
- "copy:files": "copyfiles -u 1 src/**/*.css build/",
22
- "tsc:alias": "tsc-alias -p tsconfig.json",
23
- "ts:build": "rm -rf build && tsc -p tsconfig.json && tsc-alias -p tsconfig.json && yarn copy:files",
24
- "push": "npm publish --access public"
25
- },
26
- "keywords": [],
27
- "author": {
28
- "name": "Ahmed Elsharkawy",
29
- "email": "a.elsharkawy@tap.company"
30
- },
31
- "license": "ISC",
32
- "devDependencies": {
33
- "@babel/core": "^7.18.6",
34
- "@babel/preset-env": "^7.18.6",
35
- "@babel/preset-react": "^7.18.6",
36
- "@babel/preset-typescript": "^7.18.6",
37
- "@types/lodash-es": "^4.17.6",
38
- "@types/moment-hijri": "^2.1.0",
39
- "@types/react": "^18.0.15",
40
- "@types/react-calendar": "~3.5.1",
41
- "@types/react-dom": "^18.0.6",
42
- "@typescript-eslint/eslint-plugin": "^5.30.5",
43
- "@typescript-eslint/parser": "^5.30.5",
44
- "babel-loader": "^8.2.5",
45
- "copyfiles": "^2.4.1",
46
- "cross-env": "^7.0.3",
47
- "css-loader": "^6.7.1",
48
- "css-minimizer-webpack-plugin": "^4.0.0",
49
- "eslint": "^8.19.0",
50
- "eslint-config-airbnb": "^19.0.4",
51
- "eslint-config-prettier": "^8.5.0",
52
- "eslint-plugin-import": "^2.26.0",
53
- "eslint-plugin-jsx-a11y": "^6.6.0",
54
- "eslint-plugin-node": "^11.1.0",
55
- "eslint-plugin-prettier": "^4.2.1",
56
- "eslint-plugin-react": "^7.30.1",
57
- "eslint-plugin-react-hooks": "^4.6.0",
58
- "file-loader": "^6.2.0",
59
- "fork-ts-checker-webpack-plugin": "^7.2.12",
60
- "html-loader": "^3.1.2",
61
- "html-webpack-plugin": "^5.5.0",
62
- "husky": "^8.0.1",
63
- "lint-staged": "^13.0.3",
64
- "mini-css-extract-plugin": "^2.6.1",
65
- "prettier": "^2.7.1",
66
- "sass": "^1.53.0",
67
- "sass-loader": "^13.0.2",
68
- "style-loader": "^3.3.1",
69
- "terser-webpack-plugin": "^5.3.3",
70
- "tsc-alias": "^1.6.11",
71
- "typescript": "^4.7.4",
72
- "webpack": "^5.73.0",
73
- "webpack-cli": "^4.10.0",
74
- "webpack-dev-server": "^4.9.3",
75
- "webpack-merge": "^5.8.0"
76
- },
77
- "dependencies": {
78
- "@emotion/react": "^11.9.3",
79
- "@emotion/styled": "^11.9.3",
80
- "@fingerprintjs/fingerprintjs": "~3.3.4",
81
- "@hookform/resolvers": "^2.9.6",
82
- "@mui/icons-material": "^5.8.4",
83
- "@mui/material": "^5.8.7",
84
- "@reduxjs/toolkit": "^1.8.3",
85
- "axios": "^0.27.2",
86
- "device-detector-js": "^3.0.3",
87
- "i18next": "^21.8.14",
88
- "i18next-browser-languagedetector": "^6.1.4",
89
- "i18next-http-backend": "^1.4.1",
90
- "jsencrypt": "^2.3.1",
91
- "lodash-es": "^4.17.21",
92
- "lottie-web": "^5.9.6",
93
- "moment-hijri": "~2.1.2",
94
- "react": "^18.2.0",
95
- "react-calendar": "~3.7.0",
96
- "react-device-detect": "^2.2.2",
97
- "react-dom": "^18.2.0",
98
- "react-dropzone": "^14.2.2",
99
- "react-hook-form": "^7.33.1",
100
- "react-i18next": "^11.18.1",
101
- "react-otp-input": "^2.4.0",
102
- "react-redux": "^8.0.2",
103
- "react-spring-bottom-sheet": "^3.4.1",
104
- "yup": "^0.32.11"
105
- },
106
- "peerDependencies": {
107
- "react": "^18.2.0",
108
- "react-dom": "^18.2.0"
109
- },
110
- "lint-staged": {
111
- "src/**/*.{ts,tsx,json,js,jsx}": [
112
- "yarn run prettier:fix",
113
- "yarn run lint",
114
- "git add ."
115
- ]
116
- },
117
- "browserslist": {
118
- "production": [
119
- ">0.2%",
120
- "not dead",
121
- "not op_mini all"
122
- ],
123
- "development": [
124
- "last 1 chrome version",
125
- "last 1 firefox version",
126
- "last 1 safari version"
127
- ]
128
- }
129
- }
1
+ {
2
+ "name": "@tap-payments/auth-jsconnect",
3
+ "version": "2.0.70-test",
4
+ "description": "connect library, auth",
5
+ "private": false,
6
+ "main": "build/index.js",
7
+ "module": "build/index.js",
8
+ "types": "build/index.d.ts",
9
+ "files": [
10
+ "build",
11
+ "README.md"
12
+ ],
13
+ "scripts": {
14
+ "husky:setup": "npx husky install",
15
+ "prettier": "prettier --list-different \"src/**/*.{md,mdx,ts,js,tsx,jsx,json}\" *.json *.js",
16
+ "prettier:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md,css,json}\" *.json *.js",
17
+ "lint": "eslint src --color --ext .js,.jsx,.ts,.tsx,.json",
18
+ "lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
19
+ "start": "cross-env NODE_ENV=development webpack serve",
20
+ "build": "rm -rf build && cross-env NODE_ENV=production webpack",
21
+ "copy:files": "copyfiles -u 1 src/**/*.css build/",
22
+ "tsc:alias": "tsc-alias -p tsconfig.json",
23
+ "ts:build": "rm -rf build && tsc -p tsconfig.json && tsc-alias -p tsconfig.json && yarn copy:files",
24
+ "push": "npm publish --access public"
25
+ },
26
+ "keywords": [],
27
+ "author": {
28
+ "name": "Ahmed Elsharkawy",
29
+ "email": "a.elsharkawy@tap.company"
30
+ },
31
+ "license": "ISC",
32
+ "devDependencies": {
33
+ "@babel/core": "^7.18.6",
34
+ "@babel/preset-env": "^7.18.6",
35
+ "@babel/preset-react": "^7.18.6",
36
+ "@babel/preset-typescript": "^7.18.6",
37
+ "@types/lodash-es": "^4.17.6",
38
+ "@types/moment-hijri": "^2.1.0",
39
+ "@types/react": "^18.0.15",
40
+ "@types/react-calendar": "~3.5.1",
41
+ "@types/react-dom": "^18.0.6",
42
+ "@typescript-eslint/eslint-plugin": "^5.30.5",
43
+ "@typescript-eslint/parser": "^5.30.5",
44
+ "babel-loader": "^8.2.5",
45
+ "copyfiles": "^2.4.1",
46
+ "cross-env": "^7.0.3",
47
+ "css-loader": "^6.7.1",
48
+ "css-minimizer-webpack-plugin": "^4.0.0",
49
+ "eslint": "^8.19.0",
50
+ "eslint-config-airbnb": "^19.0.4",
51
+ "eslint-config-prettier": "^8.5.0",
52
+ "eslint-plugin-import": "^2.26.0",
53
+ "eslint-plugin-jsx-a11y": "^6.6.0",
54
+ "eslint-plugin-node": "^11.1.0",
55
+ "eslint-plugin-prettier": "^4.2.1",
56
+ "eslint-plugin-react": "^7.30.1",
57
+ "eslint-plugin-react-hooks": "^4.6.0",
58
+ "file-loader": "^6.2.0",
59
+ "fork-ts-checker-webpack-plugin": "^7.2.12",
60
+ "html-loader": "^3.1.2",
61
+ "html-webpack-plugin": "^5.5.0",
62
+ "husky": "^8.0.1",
63
+ "lint-staged": "^13.0.3",
64
+ "mini-css-extract-plugin": "^2.6.1",
65
+ "prettier": "^2.7.1",
66
+ "sass": "^1.53.0",
67
+ "sass-loader": "^13.0.2",
68
+ "style-loader": "^3.3.1",
69
+ "terser-webpack-plugin": "^5.3.3",
70
+ "tsc-alias": "^1.6.11",
71
+ "typescript": "^4.7.4",
72
+ "webpack": "^5.73.0",
73
+ "webpack-cli": "^4.10.0",
74
+ "webpack-dev-server": "^4.9.3",
75
+ "webpack-merge": "^5.8.0"
76
+ },
77
+ "dependencies": {
78
+ "@emotion/react": "^11.9.3",
79
+ "@emotion/styled": "^11.9.3",
80
+ "@fingerprintjs/fingerprintjs": "~3.3.4",
81
+ "@hookform/resolvers": "^2.9.6",
82
+ "@mui/icons-material": "^5.8.4",
83
+ "@mui/material": "^5.8.7",
84
+ "@reduxjs/toolkit": "^1.8.3",
85
+ "axios": "^0.27.2",
86
+ "device-detector-js": "^3.0.3",
87
+ "i18next": "^21.8.14",
88
+ "i18next-browser-languagedetector": "^6.1.4",
89
+ "i18next-http-backend": "^1.4.1",
90
+ "jsencrypt": "^2.3.1",
91
+ "lodash-es": "^4.17.21",
92
+ "lottie-web": "^5.9.6",
93
+ "moment-hijri": "~2.1.2",
94
+ "react": "^18.2.0",
95
+ "react-calendar": "~3.7.0",
96
+ "react-device-detect": "^2.2.2",
97
+ "react-dom": "^18.2.0",
98
+ "react-dropzone": "^14.2.2",
99
+ "react-hook-form": "^7.33.1",
100
+ "react-i18next": "^11.18.1",
101
+ "react-otp-input": "^2.4.0",
102
+ "react-redux": "^8.0.2",
103
+ "react-spring-bottom-sheet": "^3.4.1",
104
+ "yup": "^0.32.11"
105
+ },
106
+ "peerDependencies": {
107
+ "react": "^18.2.0",
108
+ "react-dom": "^18.2.0"
109
+ },
110
+ "lint-staged": {
111
+ "src/**/*.{ts,tsx,json,js,jsx}": [
112
+ "yarn run prettier:fix",
113
+ "yarn run lint",
114
+ "git add ."
115
+ ]
116
+ },
117
+ "browserslist": {
118
+ "production": [
119
+ ">0.2%",
120
+ "not dead",
121
+ "not op_mini all"
122
+ ],
123
+ "development": [
124
+ "last 1 chrome version",
125
+ "last 1 firefox version",
126
+ "last 1 safari version"
127
+ ]
128
+ }
129
+ }