@tap-payments/auth-jsconnect 2.1.9-test → 2.1.10-test

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/build/@types/form.d.ts +4 -3
  2. package/build/api/entity.d.ts +1 -1
  3. package/build/assets/locales/ar.json +7 -0
  4. package/build/assets/locales/en.json +7 -0
  5. package/build/components/FileInput/DragAndDrop.d.ts +3 -2
  6. package/build/components/FileInput/DragAndDrop.js +4 -4
  7. package/build/components/Lottie/Lottie.d.ts +2924 -127
  8. package/build/components/Lottie/Lottie.js +8 -4
  9. package/build/components/Lottie/files/error.json +692 -0
  10. package/build/components/Lottie/files/start_loading.json +1140 -0
  11. package/build/components/Lottie/files/still_loading.json +1140 -0
  12. package/build/features/app/business/businessStore.d.ts +8 -1
  13. package/build/features/app/business/businessStore.js +74 -15
  14. package/build/features/app/connect/connectStore.d.ts +1 -1
  15. package/build/features/app/connect/connectStore.js +47 -38
  16. package/build/features/bank/screens/BankDetails/BankStatement.js +14 -11
  17. package/build/features/business/screens/BusinessType/Article.d.ts +6 -0
  18. package/build/features/business/screens/BusinessType/Article.js +89 -0
  19. package/build/features/business/screens/BusinessType/BusinessType.js +16 -10
  20. package/build/features/business/screens/BusinessType/EntityName.js +1 -1
  21. package/build/features/business/screens/BusinessType/LicenseCertificate.js +14 -9
  22. package/build/features/business/screens/BusinessType/LicenseList.js +3 -2
  23. package/build/features/business/screens/BusinessType/LicenseType.js +3 -3
  24. package/build/features/business/screens/BusinessType/validation.js +17 -8
  25. package/build/features/business/screens/VerifyPACI/VerifyPACI.d.ts +1 -1
  26. package/build/features/business/screens/VerifyPACI/VerifyPACI.js +9 -134
  27. package/build/features/connect/screens/Merchant/Merchant.js +4 -24
  28. package/build/features/connect/screens/Merchant/SalesChannels.d.ts +2 -5
  29. package/build/features/connect/screens/Merchant/SalesChannels.js +29 -99
  30. package/build/features/connect/screens/VerifyPACI/VerifyPACI.d.ts +1 -1
  31. package/build/features/connect/screens/VerifyPACI/VerifyPACI.js +9 -73
  32. package/build/features/entity/screens/EntityInfoConfirm/Article.js +14 -11
  33. package/build/features/shared/PaciVerification/PaciVerification.d.ts +12 -0
  34. package/build/features/shared/PaciVerification/PaciVerification.js +91 -0
  35. package/build/features/{business/screens/VerifyPACI → shared/PaciVerification}/VerifyPACILoading.d.ts +1 -0
  36. package/build/features/shared/PaciVerification/VerifyPACILoading.js +13 -0
  37. package/build/features/{business/screens/VerifyPACI → shared/PaciVerification}/VerifyPACISuccess.d.ts +0 -0
  38. package/build/features/{business/screens/VerifyPACI → shared/PaciVerification}/VerifyPACISuccess.js +1 -1
  39. package/build/features/shared/PaciVerification/index.d.ts +2 -0
  40. package/build/features/shared/PaciVerification/index.js +2 -0
  41. package/build/features/shared/SalesChannels/SaleChannelIconsInput.d.ts +11 -0
  42. package/build/features/shared/SalesChannels/SaleChannelIconsInput.js +100 -0
  43. package/build/features/shared/SalesChannels/SalesChannel.d.ts +10 -0
  44. package/build/features/shared/SalesChannels/SalesChannel.js +132 -0
  45. package/build/features/shared/SalesChannels/index.d.ts +2 -0
  46. package/build/features/shared/SalesChannels/index.js +2 -0
  47. package/build/features/shared/UploadFile/UploadFile.d.ts +3 -2
  48. package/build/features/shared/UploadFile/UploadFile.js +13 -13
  49. package/build/hooks/index.d.ts +1 -0
  50. package/build/hooks/index.js +1 -0
  51. package/build/hooks/useCountUp.d.ts +9 -0
  52. package/build/hooks/useCountUp.js +17 -0
  53. package/package.json +1 -1
  54. package/build/components/Lottie/files/pulsating_circle_waves.json +0 -236
  55. package/build/features/business/screens/VerifyPACI/VerifyPACILoading.js +0 -23
  56. package/build/features/connect/screens/Merchant/SocialMedia.d.ts +0 -8
  57. package/build/features/connect/screens/Merchant/SocialMedia.js +0 -156
  58. package/build/features/connect/screens/VerifyPACI/VerifyPACILoading.d.ts +0 -6
  59. package/build/features/connect/screens/VerifyPACI/VerifyPACILoading.js +0 -23
  60. package/build/features/connect/screens/VerifyPACI/VerifyPACISuccess.d.ts +0 -5
  61. package/build/features/connect/screens/VerifyPACI/VerifyPACISuccess.js +0 -8
@@ -28,7 +28,7 @@ export declare const verifyLeadOTP: import("@reduxjs/toolkit").AsyncThunk<{
28
28
  leadData: any;
29
29
  }, OTPFormValues, {}>;
30
30
  interface verifyPACIParams {
31
- onSuccess?: () => void | Promise<void>;
31
+ onSuccess?: () => void;
32
32
  }
33
33
  export declare const verifyPACI: import("@reduxjs/toolkit").AsyncThunk<{
34
34
  response: any;
@@ -57,6 +57,7 @@ export declare const updateLeadBusinessType: import("@reduxjs/toolkit").AsyncThu
57
57
  formData: BusinessTypeFormValues;
58
58
  accountData: any;
59
59
  documentData: any;
60
+ entityData: any;
60
61
  }, BusinessTypeFormValues, {}>;
61
62
  interface UploadLicenseCertificateParams {
62
63
  file: File;
@@ -65,6 +66,11 @@ interface UploadLicenseCertificateParams {
65
66
  export declare const uploadLicenseCertificate: import("@reduxjs/toolkit").AsyncThunk<{
66
67
  data: any;
67
68
  }, UploadLicenseCertificateParams, {}>;
69
+ interface UploadArticleParams extends UploadLicenseCertificateParams {
70
+ }
71
+ export declare const uploadArticle: import("@reduxjs/toolkit").AsyncThunk<{
72
+ data: any;
73
+ }, UploadArticleParams, {}>;
68
74
  export declare const updateActivitiesInfo: import("@reduxjs/toolkit").AsyncThunk<{
69
75
  data: any;
70
76
  formData: {
@@ -109,6 +115,7 @@ export interface BusinessData {
109
115
  export interface BusinessState extends SharedState<BusinessData> {
110
116
  customLoading?: boolean;
111
117
  uploading?: boolean;
118
+ uploadingArticle?: boolean;
112
119
  }
113
120
  export declare const businessSlice: import("@reduxjs/toolkit").Slice<BusinessState, {
114
121
  clearError: (state: BusinessState) => void;
@@ -316,7 +316,8 @@ export var verifyPACI = createAsyncThunk('businessVerifyPACI', function (params,
316
316
  isSuccess = ((_b = data.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
317
317
  if (!isSuccess) return [3, 4];
318
318
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, {});
319
- return [4, ((_e = params === null || params === void 0 ? void 0 : params.onSuccess) === null || _e === void 0 ? void 0 : _e.call(params))];
319
+ (_e = params === null || params === void 0 ? void 0 : params.onSuccess) === null || _e === void 0 ? void 0 : _e.call(params);
320
+ return [4, sleep(3000)];
320
321
  case 3:
321
322
  _f.sent();
322
323
  thunkApi.dispatch(handleNextScreenStep());
@@ -453,19 +454,21 @@ export var retrieveBoardDetails = createAsyncThunk('retrieveBoardDetails', funct
453
454
  });
454
455
  }); });
455
456
  export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
456
- var _a, settings, business, payload, data, entity_activities, list, accountBody, accountData, documentData, documentBody;
457
+ var _a, settings, business, isNonSA, isFL, payload, data, entity_activities, list, accountBody, accountData, documentData, entityData, entityId, articleId, documentBody, payload_1;
457
458
  var _b, _c, _d, _e, _f, _g;
458
459
  return __generator(this, function (_h) {
459
460
  switch (_h.label) {
460
461
  case 0:
461
462
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
463
+ isNonSA = !isSA(settings.data.businessCountry.iso2);
464
+ isFL = ((_b = params.selectedLicense) === null || _b === void 0 ? void 0 : _b.type) === BusinessType.FL;
462
465
  payload = {
463
- id: ((_b = business.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.lead_id) || '',
464
- license_number: params.licenseNumber,
465
- license_type: ((_c = params.selectedLicense) === null || _c === void 0 ? void 0 : _c.type) === BusinessType.FL ? 'freelance' : 'commercial_registration',
466
+ id: ((_c = business.data.verify.responseBody) === null || _c === void 0 ? void 0 : _c.lead_id) || '',
467
+ license_number: isNonSA && isFL ? '' : params.licenseNumber,
468
+ license_type: isFL ? 'freelance' : 'commercial_registration',
466
469
  business_type: (_d = params.selectedLicense) === null || _d === void 0 ? void 0 : _d.type,
467
470
  step_name: BUSINESS_STEP_NAMES.BUSINESS_CR_INFO,
468
- business: { ar: params.entityLegalName, en: params.entityLegalName },
471
+ business: isNonSA && isFL ? undefined : { ar: params.entityLegalName, en: params.entityLegalName },
469
472
  encryption_contract: ['license_number', 'business_type', 'license_type']
470
473
  };
471
474
  return [4, API.leadService.updateLead(payload)];
@@ -492,13 +495,15 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
492
495
  return [4, API.accountService.createAccount(accountBody)];
493
496
  case 4:
494
497
  accountData = _h.sent();
495
- documentData = undefined;
496
- if (!!!business.data.businessTypeData.certificateId) return [3, 6];
498
+ entityData = undefined;
499
+ entityId = accountData === null || accountData === void 0 ? void 0 : accountData.entity_id;
500
+ articleId = business.data.businessTypeData.articleId;
501
+ if (!((business.data.businessTypeData.certificateId || []).length > 0)) return [3, 6];
497
502
  documentBody = {
498
- entity_id: (accountData === null || accountData === void 0 ? void 0 : accountData.entity_id) || '',
503
+ entity_id: entityId || '',
499
504
  documents: [
500
505
  {
501
- images: [business.data.businessTypeData.certificateId]
506
+ images: business.data.businessTypeData.certificateId
502
507
  }
503
508
  ]
504
509
  };
@@ -507,9 +512,19 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
507
512
  documentData = _h.sent();
508
513
  _h.label = 6;
509
514
  case 6:
515
+ if (!(articleId && entityId)) return [3, 8];
516
+ payload_1 = {
517
+ id: (accountData === null || accountData === void 0 ? void 0 : accountData.entity_id) || '',
518
+ AOA_file_id: articleId
519
+ };
520
+ return [4, API.entityService.updateEntity(payload_1)];
521
+ case 7:
522
+ entityData = _h.sent();
523
+ _h.label = 8;
524
+ case 8:
510
525
  thunkApi.dispatch(handleNextScreenStep());
511
526
  (_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, params);
512
- return [2, { data: data, formData: params, accountData: accountData, documentData: documentData }];
527
+ return [2, { data: data, formData: params, accountData: accountData, documentData: documentData, entityData: entityData }];
513
528
  }
514
529
  });
515
530
  }); });
@@ -538,6 +553,35 @@ export var uploadLicenseCertificate = createAsyncThunk('uploadLicenseCertificate
538
553
  });
539
554
  });
540
555
  });
556
+ export var uploadArticle = createAsyncThunk('entityUploadArticle', function (_a) {
557
+ var file = _a.file, onProgress = _a.onProgress;
558
+ return __awaiter(void 0, void 0, void 0, function () {
559
+ var typeArray, type, uploadPayload, onUploadProgress, data;
560
+ var _b;
561
+ return __generator(this, function (_c) {
562
+ switch (_c.label) {
563
+ case 0:
564
+ typeArray = ((_b = file === null || file === void 0 ? void 0 : file.type) === null || _b === void 0 ? void 0 : _b.split('/')) || [];
565
+ type = typeArray[1] || '';
566
+ uploadPayload = {
567
+ file_link_create: true,
568
+ title: file === null || file === void 0 ? void 0 : file.name,
569
+ purpose: 'identity_document',
570
+ type: type,
571
+ file: file
572
+ };
573
+ onUploadProgress = function (progressEvent) {
574
+ var progress = ((progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.loaded) / (progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.total)) * 100;
575
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress(Math.floor(progress));
576
+ };
577
+ return [4, API.entityService.uploadFileInfo(uploadPayload, { onUploadProgress: onUploadProgress })];
578
+ case 1:
579
+ data = _c.sent();
580
+ return [2, { data: data }];
581
+ }
582
+ });
583
+ });
584
+ });
541
585
  export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
542
586
  var _a, settings, business, activities, stepName, id, requestBody, data;
543
587
  var _b, _c, _d, _e, _f;
@@ -700,6 +744,7 @@ var initialState = {
700
744
  loading: false,
701
745
  customLoading: false,
702
746
  uploading: false,
747
+ uploadingArticle: false,
703
748
  data: {
704
749
  flowName: FlowsTypes.BUSINESS,
705
750
  verify: {
@@ -719,8 +764,7 @@ var initialState = {
719
764
  },
720
765
  businessTypeData: {
721
766
  licenseNumber: '',
722
- entityLegalName: '',
723
- uploading: false
767
+ entityLegalName: ''
724
768
  },
725
769
  activitiesData: {
726
770
  activities: [],
@@ -870,7 +914,7 @@ export var businessSlice = createSlice({
870
914
  state.loading = false;
871
915
  state.error = action.error.message;
872
916
  })
873
- .addCase(createCivilIdAuth.pending, function (state, action) {
917
+ .addCase(createCivilIdAuth.pending, function (state) {
874
918
  state.loading = true;
875
919
  state.error = null;
876
920
  })
@@ -1035,11 +1079,26 @@ export var businessSlice = createSlice({
1035
1079
  state.error = null;
1036
1080
  state.uploading = false;
1037
1081
  var data = action.payload.data;
1038
- state.data.businessTypeData.certificateId = data === null || data === void 0 ? void 0 : data.id;
1082
+ var ids = state.data.businessTypeData.certificateId || [];
1083
+ state.data.businessTypeData.certificateId = __spreadArray(__spreadArray([], ids, true), [data === null || data === void 0 ? void 0 : data.id], false);
1039
1084
  })
1040
1085
  .addCase(uploadLicenseCertificate.rejected, function (state) {
1041
1086
  state.uploading = false;
1042
1087
  state.error = 'file_upload_error';
1088
+ })
1089
+ .addCase(uploadArticle.pending, function (state) {
1090
+ state.error = null;
1091
+ state.uploadingArticle = true;
1092
+ })
1093
+ .addCase(uploadArticle.fulfilled, function (state, action) {
1094
+ state.error = null;
1095
+ state.uploadingArticle = false;
1096
+ var data = action.payload.data;
1097
+ state.data.businessTypeData.articleId = data === null || data === void 0 ? void 0 : data.id;
1098
+ })
1099
+ .addCase(uploadArticle.rejected, function (state) {
1100
+ state.uploadingArticle = false;
1101
+ state.error = 'file_upload_error';
1043
1102
  })
1044
1103
  .addCase(updateActivitiesInfo.pending, function (state) {
1045
1104
  state.loading = true;
@@ -27,7 +27,7 @@ export declare const verifyAuth: import("@reduxjs/toolkit").AsyncThunk<{
27
27
  userInfoMissed: boolean;
28
28
  }, OTPFormValues, {}>;
29
29
  interface verifyPACIParams {
30
- onSuccess?: () => void | Promise<void>;
30
+ onSuccess?: () => void;
31
31
  }
32
32
  export declare const verifyPACI: import("@reduxjs/toolkit").AsyncThunk<{
33
33
  authResponse: any;
@@ -307,9 +307,9 @@ export var verifyAuth = createAsyncThunk('connect/verifyAuth', function (params,
307
307
  }); });
308
308
  export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
309
309
  var _a, settings, connect, responseBody, expiry, interval, maxCalls, count, authResponse, isSuccess, lead_id, individual_id, leadBody, leadResponse, _b, isNewUser, countryCode, contact, name_1, _c, phone, email, userInfoMissed, channels, brands, err_2;
310
- var _d, _e, _f, _g, _h;
311
- return __generator(this, function (_j) {
312
- switch (_j.label) {
310
+ var _d, _e, _f, _g, _h, _j;
311
+ return __generator(this, function (_k) {
312
+ switch (_k.label) {
313
313
  case 0:
314
314
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
315
315
  responseBody = connect.data.civilIdData.responseBody;
@@ -317,77 +317,86 @@ export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params,
317
317
  interval = 3;
318
318
  maxCalls = Math.floor(expiry / interval);
319
319
  count = 1;
320
- _j.label = 1;
320
+ _k.label = 1;
321
321
  case 1:
322
- if (!(count <= maxCalls)) return [3, 16];
322
+ if (!(count <= maxCalls)) return [3, 19];
323
323
  if (thunkApi.signal.aborted) {
324
- return [3, 16];
324
+ return [3, 19];
325
325
  }
326
326
  return [4, API.authService.getVerifyAuth(responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_token)];
327
327
  case 2:
328
- authResponse = _j.sent();
328
+ authResponse = _k.sent();
329
329
  isSuccess = ((_d = authResponse.status) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === 'success';
330
- if (!isSuccess) return [3, 13];
331
- return [4, ((_e = params === null || params === void 0 ? void 0 : params.onSuccess) === null || _e === void 0 ? void 0 : _e.call(params))];
332
- case 3:
333
- _j.sent();
330
+ if (!isSuccess) return [3, 16];
334
331
  lead_id = authResponse.lead_id, individual_id = authResponse.individual_id;
335
332
  leadBody = {
336
333
  country_code: settings.data.businessCountry.iso2,
337
334
  individual_id: individual_id
338
335
  };
339
- if (!lead_id) return [3, 5];
336
+ if (!lead_id) return [3, 4];
340
337
  return [4, API.leadService.retrieveLead(lead_id)];
341
- case 4:
342
- _b = _j.sent();
343
- return [3, 7];
344
- case 5: return [4, API.leadService.createLead(leadBody)];
338
+ case 3:
339
+ _b = _k.sent();
340
+ return [3, 6];
341
+ case 4: return [4, API.leadService.createLead(leadBody)];
342
+ case 5:
343
+ _b = _k.sent();
344
+ _k.label = 6;
345
345
  case 6:
346
- _b = _j.sent();
347
- _j.label = 7;
348
- case 7:
349
346
  leadResponse = (_b).data;
350
- if ((_f = leadResponse.errors) === null || _f === void 0 ? void 0 : _f.length)
347
+ if ((_e = leadResponse.errors) === null || _e === void 0 ? void 0 : _e.length)
351
348
  throw new Error(leadResponse.errors[0].description);
352
349
  isNewUser = leadResponse.is_new_individual;
353
350
  countryCode = settings.data.businessCountry;
354
351
  contact = leadResponse.contact, name_1 = leadResponse.name;
355
352
  _c = contact || {}, phone = _c.phone, email = _c.email;
356
353
  userInfoMissed = (!phone || !email || !name_1) && !isNewUser;
357
- if (!!isNewUser) return [3, 12];
354
+ if (!!isNewUser) return [3, 13];
358
355
  return [4, API.dataService.getChannelsOfServices({ page: 0 })];
359
- case 8:
360
- channels = (_j.sent()).list;
356
+ case 7:
357
+ channels = (_k.sent()).list;
361
358
  leadResponse.channel_list = channels;
362
- _j.label = 9;
363
- case 9:
364
- _j.trys.push([9, 11, , 12]);
359
+ _k.label = 8;
360
+ case 8:
361
+ _k.trys.push([8, 10, , 11]);
365
362
  return [4, API.brandService.getBrandList({ individual_id: leadResponse.individual_id })];
366
- case 10:
367
- brands = (_j.sent()).brands;
363
+ case 9:
364
+ brands = (_k.sent()).brands;
368
365
  leadResponse.brand_list = fixBrandList(brands, channels);
369
- return [3, 12];
366
+ return [3, 11];
367
+ case 10:
368
+ err_2 = _k.sent();
369
+ return [3, 11];
370
370
  case 11:
371
- err_2 = _j.sent();
372
- return [3, 12];
371
+ (_f = params.onSuccess) === null || _f === void 0 ? void 0 : _f.call(params);
372
+ return [4, sleep(3000)];
373
373
  case 12:
374
+ _k.sent();
375
+ return [3, 15];
376
+ case 13:
377
+ (_g = params.onSuccess) === null || _g === void 0 ? void 0 : _g.call(params);
378
+ return [4, sleep(3000)];
379
+ case 14:
380
+ _k.sent();
381
+ _k.label = 15;
382
+ case 15:
374
383
  if (phone === null || phone === void 0 ? void 0 : phone.country_code)
375
384
  countryCode = findCountryByIddPrefix(settings.data.countries, phone.country_code);
376
- (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, {});
385
+ (_j = (_h = settings.data.appConfig).onStepCompleted) === null || _j === void 0 ? void 0 : _j.call(_h, settings.data.activeScreen.name, {});
377
386
  if (isNewUser || userInfoMissed) {
378
387
  thunkApi.dispatch(handleNextScreenStep('CONNECT_INDIVIDUAL_STEP'));
379
388
  return [2, { authResponse: authResponse, leadResponse: leadResponse, isNewUser: isNewUser, countryCode: countryCode, userInfoMissed: userInfoMissed }];
380
389
  }
381
390
  thunkApi.dispatch(handleNextScreenStep('CONNECT_MERCHANT_INFO_STEP'));
382
391
  return [2, { authResponse: authResponse, leadResponse: leadResponse, isNewUser: isNewUser, countryCode: countryCode, userInfoMissed: userInfoMissed }];
383
- case 13: return [4, sleep(interval * 1000)];
384
- case 14:
385
- _j.sent();
386
- _j.label = 15;
387
- case 15:
392
+ case 16: return [4, sleep(interval * 1000)];
393
+ case 17:
394
+ _k.sent();
395
+ _k.label = 18;
396
+ case 18:
388
397
  count++;
389
398
  return [3, 1];
390
- case 16: throw new Error('paci_verification_failed');
399
+ case 19: throw new Error('paci_verification_failed');
391
400
  }
392
401
  });
393
402
  }); });
@@ -25,22 +25,25 @@ var BankStatement = function () {
25
25
  var dispatch = useAppDispatch();
26
26
  var bankStatementValue = bankStatementFileControl.field.value;
27
27
  var error = ((_a = bankStatementFileControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message) || ((_b = bankStatementIdControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message);
28
- var handleBankStatementChange = function (file) {
28
+ var handleBankStatementChange = function (files) {
29
+ var file = files === null || files === void 0 ? void 0 : files[0];
30
+ if (!file)
31
+ return;
29
32
  if (!VALID_FILE_FORMATS.includes(file === null || file === void 0 ? void 0 : file.type)) {
30
33
  setError('bankStatementFile', { message: 'file_not_supported_alert' });
34
+ return;
31
35
  }
32
- else if ((file === null || file === void 0 ? void 0 : file.size) > MAX_FILE_SIZE) {
36
+ if ((file === null || file === void 0 ? void 0 : file.size) > MAX_FILE_SIZE) {
33
37
  setError('bankStatementFile', { message: 'file_size_alert' });
38
+ return;
34
39
  }
35
- else {
36
- bankStatementFileControl.field.onChange(file);
37
- dispatch(uploadBankStatement({
38
- file: file,
39
- onProgress: function (value) {
40
- setProgress(value);
41
- }
42
- }));
43
- }
40
+ bankStatementFileControl.field.onChange(file);
41
+ dispatch(uploadBankStatement({
42
+ file: file,
43
+ onProgress: function (value) {
44
+ setProgress(value);
45
+ }
46
+ }));
44
47
  };
45
48
  var handleReset = function () {
46
49
  bankStatementFileControl.field.onChange(null);
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ declare type ArticleProps = {
3
+ show: boolean;
4
+ };
5
+ declare const Article: ({ show }: ArticleProps) => JSX.Element;
6
+ export default Article;
@@ -0,0 +1,89 @@
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 } from "react/jsx-runtime";
13
+ import React from 'react';
14
+ import { styled } from '@mui/material/styles';
15
+ import { ScreenContainer } from '../../../shared/Containers';
16
+ import { useTranslation } from 'react-i18next';
17
+ import { useController, useFormContext } from 'react-hook-form';
18
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
19
+ import { businessSelector, uploadArticle } from '../../../app/business/businessStore';
20
+ import UploadFile from '../../../shared/UploadFile';
21
+ import { MAX_FILE_SIZE, VALID_FILE_FORMATS } from '../../../../constants';
22
+ import { maskFileName } from '../../../../utils';
23
+ import Collapse from '../../../../components/Collapse';
24
+ var FeatureStyled = styled(ScreenContainer)(function (_a) {
25
+ var theme = _a.theme;
26
+ return ({
27
+ marginBlockStart: theme.spacing(3)
28
+ });
29
+ });
30
+ var Article = function (_a) {
31
+ var _b, _c;
32
+ var show = _a.show;
33
+ var _d = React.useState(0), progress = _d[0], setProgress = _d[1];
34
+ var t = useTranslation().t;
35
+ var _e = useFormContext(), control = _e.control, setError = _e.setError, clearErrors = _e.clearErrors, setValue = _e.setValue;
36
+ var articleFileControl = useController({ name: 'articleFile', control: control });
37
+ var articleIdControl = useController({ name: 'articleId', control: control });
38
+ var _f = useAppSelector(businessSelector), loading = _f.loading, uploadingArticle = _f.uploadingArticle, sysError = _f.error, data = _f.data;
39
+ var dispatch = useAppDispatch();
40
+ var articleValue = articleFileControl.field.value;
41
+ var error = ((_b = articleFileControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message) || ((_c = articleIdControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message);
42
+ var businessTypeData = data.businessTypeData;
43
+ var articleFile = businessTypeData.articleFile, articleId = businessTypeData.articleId;
44
+ React.useEffect(function () {
45
+ if (!articleValue) {
46
+ setValue('articleFile', articleFile);
47
+ setValue('articleId', articleId);
48
+ }
49
+ }, [articleFile, articleId]);
50
+ var handleArticleChange = function (files) {
51
+ var file = files === null || files === void 0 ? void 0 : files[0];
52
+ if (!file)
53
+ return;
54
+ if (!VALID_FILE_FORMATS.includes(file === null || file === void 0 ? void 0 : file.type)) {
55
+ setError('articleFile', { message: 'file_not_supported_alert' });
56
+ return;
57
+ }
58
+ if ((file === null || file === void 0 ? void 0 : file.size) > MAX_FILE_SIZE) {
59
+ setError('articleFile', { message: 'file_size_alert' });
60
+ return;
61
+ }
62
+ articleFileControl.field.onChange(file);
63
+ dispatch(uploadArticle({
64
+ file: file,
65
+ onProgress: function (value) {
66
+ setProgress(value);
67
+ }
68
+ }));
69
+ };
70
+ var handleReset = function () {
71
+ articleFileControl.field.onChange(null);
72
+ articleIdControl.field.onChange('');
73
+ setProgress(0);
74
+ };
75
+ React.useEffect(function () {
76
+ if (sysError === 'file_upload_error') {
77
+ setError('articleId', { message: sysError });
78
+ articleFileControl.field.onChange(null);
79
+ setProgress(0);
80
+ }
81
+ }, [sysError]);
82
+ React.useEffect(function () {
83
+ if ((articleFileControl.formState.isValid || !!articleValue) && error != 'file_upload_error')
84
+ clearErrors();
85
+ }, [articleFileControl.formState.isValid, articleValue]);
86
+ var fileName = articleValue ? maskFileName(articleValue === null || articleValue === void 0 ? void 0 : articleValue.name) : '';
87
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadFile, { label: t('title_article'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('article_of_association'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleArticleChange, isFileUploaded: !uploadingArticle && !!articleValue, isSubmitting: loading, isUploading: uploadingArticle, progress: progress, onReset: handleReset, error: error && t(error), initialFileName: fileName }) }) })));
88
+ };
89
+ export default Article;
@@ -9,12 +9,23 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
12
23
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
24
  import * as React from 'react';
14
25
  import { useForm, FormProvider } from 'react-hook-form';
15
26
  import { useTranslation } from 'react-i18next';
16
27
  import { yupResolver } from '@hookform/resolvers/yup';
17
- import { useAppDispatch, useAppSelector } from '../../../../hooks';
28
+ import { useAppDispatch, useAppSelector, useSetFromDefaultValues } from '../../../../hooks';
18
29
  import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
19
30
  import Form from '../../../../components/Form';
20
31
  import Collapse from '../../../../components/Collapse';
@@ -28,23 +39,18 @@ import LicenseList from './LicenseList';
28
39
  var BusinessType = function (_a) {
29
40
  var _b = useAppSelector(businessSelector), data = _b.data, loading = _b.loading, error = _b.error, uploading = _b.uploading;
30
41
  var settingsData = useAppSelector(settingsSelector).data;
31
- var businessTypeData = data.businessTypeData;
42
+ var _c = data.businessTypeData, responseBody = _c.responseBody, defaultValues = __rest(_c, ["responseBody"]);
32
43
  var t = useTranslation().t;
33
44
  var isAr = useLanguage().isAr;
34
45
  var dispatch = useAppDispatch();
35
- var _c = React.useState(false), listActive = _c[0], setListActive = _c[1];
46
+ var _d = React.useState(false), listActive = _d[0], setListActive = _d[1];
36
47
  var isSACountry = React.useMemo(function () { return isSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
37
48
  var methods = useForm({
38
49
  resolver: yupResolver(!isSACountry ? KWLicenseValidationSchema : LicenseValidationSchema),
39
- defaultValues: {
40
- selectedLicense: businessTypeData.selectedLicense,
41
- licenseNumber: businessTypeData.licenseNumber,
42
- entityLegalName: businessTypeData.entityLegalName,
43
- certificateId: businessTypeData.certificateId,
44
- certificateFile: businessTypeData.certificateFile
45
- },
50
+ defaultValues: defaultValues,
46
51
  mode: 'onChange'
47
52
  });
53
+ useSetFromDefaultValues(methods, defaultValues);
48
54
  React.useEffect(function () {
49
55
  if (error)
50
56
  dispatch(clearError());
@@ -51,6 +51,6 @@ var EntityName = function (_a) {
51
51
  var clearEntityName = function () {
52
52
  entityNameControl.field.onChange('');
53
53
  };
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) }) }) })));
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: !error && entityNameValue ? _jsx(CheckIcon, {}) : entityNameValue && _jsx(ClearIcon, { onClick: clearEntityName }), placeholder: t('entity_legal_name_placeholder'), warningType: 'alert', warningMessage: error && t(error) }) }) })));
55
55
  };
56
56
  export default EntityName;
@@ -38,14 +38,19 @@ var LicenseCertificate = function (_a) {
38
38
  var dispatch = useAppDispatch();
39
39
  var certificateValue = certificateFileControl.field.value;
40
40
  var error = ((_b = certificateFileControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message) || ((_c = certificateIdControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message);
41
- var handleLicenseCertificateChange = function (file) {
42
- if (!VALID_FILE_FORMATS.includes(file === null || file === void 0 ? void 0 : file.type)) {
43
- setError('certificateFile', { message: 'file_not_supported_alert' });
44
- }
45
- else if ((file === null || file === void 0 ? void 0 : file.size) > MAX_FILE_SIZE) {
46
- setError('certificateFile', { message: 'file_size_alert' });
47
- }
48
- else {
41
+ var handleLicenseCertificateChange = function (files) {
42
+ for (var index = 0; index < files.length; index++) {
43
+ var file = files === null || files === void 0 ? void 0 : files[index];
44
+ if (!file)
45
+ continue;
46
+ if (!VALID_FILE_FORMATS.includes(file === null || file === void 0 ? void 0 : file.type)) {
47
+ setError('certificateFile', { message: 'file_not_supported_alert' });
48
+ continue;
49
+ }
50
+ if ((file === null || file === void 0 ? void 0 : file.size) > MAX_FILE_SIZE) {
51
+ setError('certificateFile', { message: 'file_size_alert' });
52
+ continue;
53
+ }
49
54
  certificateFileControl.field.onChange(file);
50
55
  dispatch(uploadLicenseCertificate({
51
56
  file: file,
@@ -71,6 +76,6 @@ var LicenseCertificate = function (_a) {
71
76
  if ((certificateFileControl.formState.isValid || !!certificateValue) && error != 'file_upload_error')
72
77
  clearErrors();
73
78
  }, [certificateFileControl.formState.isValid, certificateValue]);
74
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadFile, { label: t('title_license_certificate'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_certificate'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleLicenseCertificateChange, isFileUploaded: !uploading && !!certificateValue, isSubmitting: loading, isUploading: uploading, progress: progress, onReset: handleReset, error: error && t(error) }) }) })));
79
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadFile, { label: t('title_license_certificate'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_certificate'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleLicenseCertificateChange, isFileUploaded: !uploading && !!certificateValue, isSubmitting: loading, isUploading: uploading, progress: progress, onReset: handleReset, error: error && t(error), multiple: true }) }) })));
75
80
  };
76
81
  export default LicenseCertificate;
@@ -43,6 +43,7 @@ import LicenseType from './LicenseType';
43
43
  import { OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../../constants';
44
44
  import LicenseCertificate from './LicenseCertificate';
45
45
  import { settingsSelector } from '../../../../app/settings';
46
+ import Article from './Article';
46
47
  var InputStyled = styled(Input)(function (_a) {
47
48
  var theme = _a.theme;
48
49
  return ({
@@ -100,7 +101,7 @@ var LicenseList = function (_a) {
100
101
  if (!!country_code) {
101
102
  var isNonSA = !isSA(country_code);
102
103
  if (isNonSA) {
103
- var license = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.FL ? OTHER_FL_LICENSE : OTHER_CR_LICENSE;
104
+ var license = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.CR ? OTHER_CR_LICENSE : OTHER_FL_LICENSE;
104
105
  setValue('selectedLicense', license, { shouldValidate: true });
105
106
  setValue('entityLegalName', entityLegalName, { shouldValidate: true });
106
107
  }
@@ -142,6 +143,6 @@ var LicenseList = function (_a) {
142
143
  var flValue = isOtherLicense(selected) ? t(getLicenseName(selected)) : getLicenseNumber(selected);
143
144
  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) {
144
145
  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, {})] }));
145
- } }) }))] })), _jsx(EntityName, { show: show && !isSACountry }), _jsx(LicenseType, { show: show && !isSACountry }), _jsx(LicenseNumber, { show: !isSACountry ? isCR : show, readOnly: licenseReadonly }), _jsx(LicenseCertificate, { show: show && !isSACountry && isCR })] }));
146
+ } }) }))] })), _jsx(LicenseType, { show: show && !isSACountry }), _jsx(EntityName, { show: show && !isSACountry && isCR }), _jsx(LicenseNumber, { show: !isSACountry ? isCR : show, readOnly: licenseReadonly }), _jsx(LicenseCertificate, { show: show && !isSACountry && isCR }), _jsx(Article, { show: show && !isSACountry && isCR })] }));
146
147
  };
147
148
  export default React.memo(LicenseList);
@@ -92,16 +92,16 @@ var LicenseType = function (_a) {
92
92
  dispatch(clearError());
93
93
  selectedLicenseControl.field.onChange(target.value === BusinessType.FL ? OTHER_FL_LICENSE : OTHER_CR_LICENSE);
94
94
  if (isKWCountry && target.value === BusinessType.FL) {
95
- setValue('licenseNumber', '', { shouldValidate: true });
96
95
  setValue('certificateFile', undefined, { shouldValidate: true });
97
96
  setValue('certificateId', undefined, { shouldValidate: true });
98
97
  }
99
98
  };
100
99
  var selectedLicenseValue = selectedLicenseControl.field.value;
101
- 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
100
+ var isFL = (selectedLicenseValue === null || selectedLicenseValue === void 0 ? void 0 : selectedLicenseValue.type) === BusinessType.FL;
101
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { pb: isFL ? 9.5 : 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
102
102
  ? (selectedLicenseValue === null || selectedLicenseValue === void 0 ? void 0 : selectedLicenseValue.type) === BusinessType.FL
103
103
  ? BusinessType.FL
104
104
  : BusinessType.CR
105
- : false, onChange: handleOnChange }, { children: [_jsx(RadioLabel, { value: BusinessType.CR, label: _jsxs(LabelStyled, { children: [t('commercial_reg'), _jsx(Tooltip, __assign({ title: t('commercial_reg_hint'), onMouseOver: function () { return setIsCRHovered(true); }, onMouseLeave: function () { return setIsCRHovered(false); }, onTouchStartCapture: function () { return setIsCRHovered(true); } }, { children: isCRHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), control: _jsx(RadioStyled, { color: 'primary', disableFocusRipple: true, disableRipple: true, disableTouchRipple: true, focusRipple: false }) }), _jsx(RadioLabel, { sx: { marginInlineEnd: '0px' }, value: BusinessType.FL, label: _jsxs(LabelStyled, { children: [t('homemaker_reg'), _jsx(Tooltip, __assign({ title: t('homemaker_reg_hint'), onMouseOver: function () { return setIsFLHovered(true); }, onMouseLeave: function () { return setIsFLHovered(false); }, onTouchStartCapture: function () { return setIsFLHovered(true); } }, { children: isFLHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), control: _jsx(RadioStyled, { color: 'primary', disableFocusRipple: true, disableRipple: true, disableTouchRipple: true, focusRipple: false }) })] }))] })) })));
105
+ : false, onChange: handleOnChange }, { children: [_jsx(RadioLabel, { value: BusinessType.FL, label: _jsxs(LabelStyled, { children: [t('homemaker_reg'), _jsx(Tooltip, __assign({ title: t('homemaker_reg_hint'), onMouseOver: function () { return setIsFLHovered(true); }, onMouseLeave: function () { return setIsFLHovered(false); }, onTouchStartCapture: function () { return setIsFLHovered(true); } }, { children: isFLHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), control: _jsx(RadioStyled, { color: 'primary', disableFocusRipple: true, disableRipple: true, disableTouchRipple: true, focusRipple: false }) }), _jsx(RadioLabel, { value: BusinessType.CR, sx: { marginInlineEnd: '0px' }, label: _jsxs(LabelStyled, { children: [t('commercial_reg'), _jsx(Tooltip, __assign({ title: t('commercial_reg_hint'), onMouseOver: function () { return setIsCRHovered(true); }, onMouseLeave: function () { return setIsCRHovered(false); }, onTouchStartCapture: function () { return setIsCRHovered(true); } }, { children: isCRHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), control: _jsx(RadioStyled, { color: 'primary', disableFocusRipple: true, disableRipple: true, disableTouchRipple: true, focusRipple: false }) })] }))] })) })));
106
106
  };
107
107
  export default LicenseType;