@tap-payments/auth-jsconnect 2.3.46-test → 2.3.47-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.
@@ -52,7 +52,6 @@ export declare type BusinessTypeFormValues = {
52
52
  selectedLicense?: License;
53
53
  certificateId?: Array<string>;
54
54
  articleId?: string;
55
- articleFile?: File;
56
55
  };
57
56
  export declare type ActivitiesFormValues = {
58
57
  activities: Array<Activity> | undefined;
@@ -1,9 +1,16 @@
1
1
  import { BrandListBody, UpdateBrandBody, UpdateSalesChannels } from '../api/individual';
2
+ export declare type RemoveBrandActivity = {
3
+ id: string;
4
+ activities?: Array<{
5
+ id: string;
6
+ }>;
7
+ };
2
8
  declare const brandService: {
3
9
  retrieveBrand: (id: string) => Promise<any>;
4
10
  getBrandList: (data: BrandListBody) => Promise<any>;
5
11
  updateBrandInfo: ({ id, ...data }: UpdateBrandBody) => Promise<any>;
6
12
  updateBrandSales: ({ id, ...data }: UpdateSalesChannels) => void;
7
13
  getBrandListByIndividualId: (id: string) => Promise<any>;
14
+ removeBrandActivity: ({ id, ...data }: RemoveBrandActivity) => Promise<any>;
8
15
  };
9
16
  export { brandService };
@@ -47,11 +47,20 @@ var updateBrandSales = function (_a) {
47
47
  data: data
48
48
  });
49
49
  };
50
+ var removeBrandActivity = function (_a) {
51
+ var id = _a.id, data = __rest(_a, ["id"]);
52
+ return httpClient({
53
+ method: 'put',
54
+ url: "".concat(ENDPOINT_PATHS.BRAND, "/").concat(id, "/activities/remove"),
55
+ data: data
56
+ });
57
+ };
50
58
  var brandService = {
51
59
  retrieveBrand: retrieveBrand,
52
60
  getBrandList: getBrandList,
53
61
  updateBrandInfo: updateBrandInfo,
54
62
  updateBrandSales: updateBrandSales,
55
- getBrandListByIndividualId: getBrandListByIndividualId
63
+ getBrandListByIndividualId: getBrandListByIndividualId,
64
+ removeBrandActivity: removeBrandActivity
56
65
  };
57
66
  export { brandService };
@@ -9,6 +9,7 @@ import { DataElementBody } from './data';
9
9
  import { BrandListBody, UpdateBrandBody, UpdateIndividualBody, GetIndividualListBody } from './individual';
10
10
  import { UpdateBoardBody, RequestEmailBody } from './board';
11
11
  import { GetUserListBody } from './user';
12
+ import { RemoveBrandActivity } from './brand';
12
13
  import { UploadFileBody } from './file';
13
14
  import { DocumentUpdateBody, DocumentInfo, DocumentBody } from './document';
14
15
  declare const API: {
@@ -130,6 +131,7 @@ declare const API: {
130
131
  updateBrandInfo: ({ id, ...data }: UpdateBrandBody) => Promise<any>;
131
132
  updateBrandSales: ({ id, ...data }: import("./individual").UpdateSalesChannels) => void;
132
133
  getBrandListByIndividualId: (id: string) => Promise<any>;
134
+ removeBrandActivity: ({ id, ...data }: RemoveBrandActivity) => Promise<any>;
133
135
  };
134
136
  fileService: {
135
137
  uploadFile: (data: UploadFileBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -142,6 +144,6 @@ declare const API: {
142
144
  removeFilesFromDocument: ({ id, ...data }: DocumentBody) => Promise<import("axios").AxiosResponse<any, any>>;
143
145
  };
144
146
  };
145
- export type { ValidateOperatorBody, CreateAuthBody, ExpressCreateAccountBody, VerifyAuthBody, CreateLeadBody, UpdateLeadBody, LeadVerifyBody, LeadOTPVerifyBody, CheckEmailBody, CheckBrandBody, LeadIdentityUpdateBody, EntityInfoBody, CreateAccountBody, EntityBankUpdateBody, CreatePasswordBody, BrandListBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, UpdateBoardBody, UpdateBrandBody, DataElementBody, UploadFileBody, UpdateEntityBody, DocumentUpdateBody, DocumentInfo, VerifyAuthExpressOTPBody, UpdateIndividualBody, UpdateEntityActivityBody, UpdateEntityCapitalBody, BankDocumentInfo, GetUserListBody, GetIndividualListBody, RequestEmailBody, DocumentBody, UpdateEntityAOAFileBody };
147
+ export type { ValidateOperatorBody, CreateAuthBody, ExpressCreateAccountBody, VerifyAuthBody, CreateLeadBody, UpdateLeadBody, LeadVerifyBody, LeadOTPVerifyBody, CheckEmailBody, CheckBrandBody, LeadIdentityUpdateBody, EntityInfoBody, CreateAccountBody, EntityBankUpdateBody, CreatePasswordBody, BrandListBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, UpdateBoardBody, UpdateBrandBody, DataElementBody, UploadFileBody, UpdateEntityBody, DocumentUpdateBody, DocumentInfo, VerifyAuthExpressOTPBody, UpdateIndividualBody, UpdateEntityActivityBody, UpdateEntityCapitalBody, BankDocumentInfo, GetUserListBody, GetIndividualListBody, RequestEmailBody, DocumentBody, UpdateEntityAOAFileBody, RemoveBrandActivity };
146
148
  export { setAxiosGlobalHeaders, removeAxiosGlobalHeaders, axiosInstance, getAxiosHeaders };
147
149
  export default API;
@@ -332,19 +332,30 @@ export var retrieveEntityList = createAsyncThunk('retrieveEntityList', function
332
332
  });
333
333
  }); });
334
334
  export var updateBrandActivities = createAsyncThunk('brandUpdateBrandActivities', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
335
- var _a, settings, brand, _b, data_status, id, isActivitiesNonEditable, isCustomerBaseLocationNonEditable, isCustomerBaseNonEditable, isTermsNonEditable, isSalesRangeNonEditable, activities, customerLocations, expectedCustomer, expectedSale, requestBody, customerLocation, customerBaseId, salesId, customerBase, brandData;
335
+ var _a, settings, brand, _b, data_status, id, brandActivities, isActivitiesNonEditable, isCustomerBaseLocationNonEditable, isCustomerBaseNonEditable, isTermsNonEditable, isSalesRangeNonEditable, activities, customerLocations, expectedCustomer, expectedSale, removedActivities, payload, requestBody, customerLocation, customerBaseId, salesId, customerBase, brandData;
336
336
  var _c, _d, _e;
337
337
  return __generator(this, function (_f) {
338
338
  switch (_f.label) {
339
339
  case 0:
340
340
  _a = thunkApi.getState(), settings = _a.settings, brand = _a.brand;
341
- _b = ((_c = brand.data.verify.responseBody) === null || _c === void 0 ? void 0 : _c.brand) || {}, data_status = _b.data_status, id = _b.id;
341
+ _b = ((_c = brand.data.verify.responseBody) === null || _c === void 0 ? void 0 : _c.brand) || {}, data_status = _b.data_status, id = _b.id, brandActivities = _b.activities;
342
342
  isActivitiesNonEditable = hasNoneEditableValue(data_status, 'activities');
343
343
  isCustomerBaseLocationNonEditable = hasNoneEditableValue(data_status === null || data_status === void 0 ? void 0 : data_status.operations, 'customer_base_location');
344
344
  isCustomerBaseNonEditable = hasNoneEditableValue(data_status === null || data_status === void 0 ? void 0 : data_status.operations, 'customer_base');
345
345
  isTermsNonEditable = hasNoneEditableValue(data_status, 'terms');
346
346
  isSalesRangeNonEditable = hasNoneEditableValue(data_status === null || data_status === void 0 ? void 0 : data_status.operations, 'sales_range');
347
347
  activities = params.activities, customerLocations = params.customerLocations, expectedCustomer = params.expectedCustomer, expectedSale = params.expectedSale;
348
+ removedActivities = (brandActivities || []).filter(function (brandActivity) { return !(activities || []).some(function (activity) { return activity.id === brandActivity.id; }); });
349
+ if (!(!isActivitiesNonEditable && (removedActivities === null || removedActivities === void 0 ? void 0 : removedActivities.length) > 0)) return [3, 2];
350
+ payload = {
351
+ id: id,
352
+ activities: removedActivities
353
+ };
354
+ return [4, API.brandService.removeBrandActivity(payload)];
355
+ case 1:
356
+ _f.sent();
357
+ _f.label = 2;
358
+ case 2:
348
359
  requestBody = {
349
360
  id: id,
350
361
  activities: isActivitiesNonEditable ? undefined : activities,
@@ -363,7 +374,7 @@ export var updateBrandActivities = createAsyncThunk('brandUpdateBrandActivities'
363
374
  requestBody = __assign(__assign({}, requestBody), { operations: __assign(__assign({}, requestBody.operations), { sales: salesId }) });
364
375
  }
365
376
  return [4, API.brandService.updateBrandInfo(requestBody)];
366
- case 1:
377
+ case 3:
367
378
  brandData = (_f.sent()).data;
368
379
  thunkApi.dispatch(handleNextScreenStep());
369
380
  (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, id);
@@ -60,15 +60,6 @@ export declare const updateLeadBusinessType: import("@reduxjs/toolkit").AsyncThu
60
60
  documentData: any;
61
61
  entityData: any;
62
62
  }, BusinessTypeFormValues, {}>;
63
- interface UploadArticleParams {
64
- file: File;
65
- onProgress?: (value: number) => void;
66
- onSuccess?: (fileId: string) => void;
67
- onFailure?: (error: string) => void;
68
- }
69
- export declare const uploadArticle: import("@reduxjs/toolkit").AsyncThunk<{
70
- data: any;
71
- }, UploadArticleParams, {}>;
72
63
  export declare const updateActivitiesInfo: import("@reduxjs/toolkit").AsyncThunk<{
73
64
  data: any;
74
65
  formData: {
@@ -114,16 +105,16 @@ export interface BusinessState extends SharedState<BusinessData> {
114
105
  customLoading?: boolean;
115
106
  uploading?: boolean;
116
107
  uploadingArticle?: boolean;
117
- uploadingArticleError?: string | null;
118
108
  }
119
109
  export declare const businessSlice: import("@reduxjs/toolkit").Slice<BusinessState, {
120
110
  clearError: (state: BusinessState) => void;
121
111
  stopLoader: (state: BusinessState) => void;
122
112
  resetOTPScreen: (state: BusinessState) => void;
123
- clearArticleId: (state: BusinessState) => void;
124
113
  uploadingStatus: (state: BusinessState, action: ActionState<boolean>) => void;
114
+ uploadingArticleStatus: (state: BusinessState, action: ActionState<boolean>) => void;
115
+ clearAOAFile: (state: BusinessState) => void;
125
116
  }, "business/store">;
126
- export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, clearArticleId: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, uploadingStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>;
117
+ export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, uploadingStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>, uploadingArticleStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>, clearAOAFile: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
127
118
  declare const _default: import("redux").Reducer<BusinessState, import("redux").AnyAction>;
128
119
  export default _default;
129
120
  export declare const businessSelector: (state: RootState) => BusinessState;
@@ -441,36 +441,37 @@ export var retrieveBoardDetails = createAsyncThunk('retrieveBoardDetails', funct
441
441
  });
442
442
  }); });
443
443
  export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
444
- var _a, settings, business, isNonSA, isFL, payload, data, entity_activities, list, accountBody, accountData, documentData, entityData, entityId, articleId, documentBody, payload_1;
445
- var _b, _c, _d, _e, _f, _g;
446
- return __generator(this, function (_h) {
447
- switch (_h.label) {
444
+ var _a, settings, business, isNonSA, selectedLicense, licenseNumber, entityLegalName, certificateId, articleId, isFL, payload, data, entity_activities, list, accountBody, accountData, documentData, entityData, entityId, documentBody, payload_1;
445
+ var _b, _c, _d, _e;
446
+ return __generator(this, function (_f) {
447
+ switch (_f.label) {
448
448
  case 0:
449
449
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
450
450
  isNonSA = !isSA(settings.data.businessCountry.iso2);
451
- isFL = ((_b = params.selectedLicense) === null || _b === void 0 ? void 0 : _b.type) === BusinessType.FL;
451
+ selectedLicense = params.selectedLicense, licenseNumber = params.licenseNumber, entityLegalName = params.entityLegalName, certificateId = params.certificateId, articleId = params.articleId;
452
+ isFL = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.FL;
452
453
  payload = {
453
- id: ((_c = business.data.verify.responseBody) === null || _c === void 0 ? void 0 : _c.lead_id) || '',
454
- license_number: isNonSA && isFL ? '' : params.licenseNumber,
454
+ id: ((_b = business.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.lead_id) || '',
455
+ license_number: isNonSA && isFL ? '' : licenseNumber,
455
456
  license_type: isFL ? 'freelance' : 'commercial_registration',
456
- business_type: (_d = params.selectedLicense) === null || _d === void 0 ? void 0 : _d.type,
457
+ business_type: selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type,
457
458
  step_name: BUSINESS_STEP_NAMES.BUSINESS_CR_INFO,
458
- business: isNonSA && isFL ? undefined : { ar: params.entityLegalName, en: params.entityLegalName },
459
+ business: isNonSA && isFL ? undefined : { ar: entityLegalName, en: entityLegalName },
459
460
  encryption_contract: ['license_number', 'business_type', 'license_type']
460
461
  };
461
462
  return [4, API.leadService.updateLead(payload)];
462
463
  case 1:
463
- data = _h.sent();
464
+ data = _f.sent();
464
465
  entity_activities = data.entity_activities;
465
466
  if (!!entity_activities) return [3, 3];
466
467
  return [4, API.dataService.getActivities()];
467
468
  case 2:
468
- list = (_h.sent()).list;
469
+ list = (_f.sent()).list;
469
470
  data.entity_activities = list;
470
- _h.label = 3;
471
+ _f.label = 3;
471
472
  case 3:
472
473
  accountBody = {
473
- lead_id: (_e = business.data.verify.responseBody) === null || _e === void 0 ? void 0 : _e.lead_id,
474
+ lead_id: (_c = business.data.verify.responseBody) === null || _c === void 0 ? void 0 : _c.lead_id,
474
475
  notify: {
475
476
  email: false,
476
477
  phone: false
@@ -481,24 +482,23 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
481
482
  };
482
483
  return [4, API.accountService.createAccount(accountBody)];
483
484
  case 4:
484
- accountData = _h.sent();
485
+ accountData = _f.sent();
485
486
  entityData = undefined;
486
487
  entityId = accountData === null || accountData === void 0 ? void 0 : accountData.entity_id;
487
- articleId = business.data.businessTypeData.articleId;
488
- if (!((params.certificateId || []).length > 0)) return [3, 6];
488
+ if (!((certificateId || []).length > 0)) return [3, 6];
489
489
  documentBody = {
490
490
  entity_id: entityId || '',
491
491
  documents: [
492
492
  {
493
493
  type: DocumentPurpose.CR,
494
- images: params.certificateId
494
+ images: certificateId
495
495
  }
496
496
  ]
497
497
  };
498
498
  return [4, API.documentService.updateDocumentInfo(documentBody)];
499
499
  case 5:
500
- documentData = _h.sent();
501
- _h.label = 6;
500
+ documentData = _f.sent();
501
+ _f.label = 6;
502
502
  case 6:
503
503
  if (!(articleId && entityId)) return [3, 8];
504
504
  payload_1 = {
@@ -507,44 +507,15 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
507
507
  };
508
508
  return [4, API.entityService.updateEntity(payload_1)];
509
509
  case 7:
510
- entityData = _h.sent();
511
- _h.label = 8;
510
+ entityData = _f.sent();
511
+ _f.label = 8;
512
512
  case 8:
513
513
  thunkApi.dispatch(handleNextScreenStep());
514
- (_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, params);
514
+ (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, params);
515
515
  return [2, { data: data, formData: params, accountData: accountData, documentData: documentData, entityData: entityData }];
516
516
  }
517
517
  });
518
518
  }); });
519
- export var uploadArticle = createAsyncThunk('businessUploadArticle', function (_a) {
520
- var file = _a.file, onProgress = _a.onProgress;
521
- return __awaiter(void 0, void 0, void 0, function () {
522
- var typeArray, type, uploadPayload, onUploadProgress, data;
523
- var _b;
524
- return __generator(this, function (_c) {
525
- switch (_c.label) {
526
- case 0:
527
- typeArray = ((_b = file === null || file === void 0 ? void 0 : file.type) === null || _b === void 0 ? void 0 : _b.split('/')) || [];
528
- type = typeArray[1] || '';
529
- uploadPayload = {
530
- file_link_create: true,
531
- title: file === null || file === void 0 ? void 0 : file.name,
532
- purpose: DocumentPurpose.ARTICLE_ASSOCIATION,
533
- type: type,
534
- file: file
535
- };
536
- onUploadProgress = function (progressEvent) {
537
- var progress = ((progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.loaded) / (progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.total)) * 100;
538
- onProgress === null || onProgress === void 0 ? void 0 : onProgress(Math.floor(progress));
539
- };
540
- return [4, API.fileService.uploadFileInfo(uploadPayload, { onUploadProgress: onUploadProgress })];
541
- case 1:
542
- data = _c.sent();
543
- return [2, { data: data }];
544
- }
545
- });
546
- });
547
- });
548
519
  export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
549
520
  var _a, settings, business, activities, stepName, id, requestBody, data;
550
521
  var _b, _c, _d, _e, _f;
@@ -708,7 +679,6 @@ var initialState = {
708
679
  customLoading: false,
709
680
  uploading: false,
710
681
  uploadingArticle: false,
711
- uploadingArticleError: null,
712
682
  data: {
713
683
  flowName: FlowsTypes.BUSINESS,
714
684
  verify: {
@@ -756,11 +726,15 @@ export var businessSlice = createSlice({
756
726
  resetOTPScreen: function (state) {
757
727
  state.data.otpData.otp = '';
758
728
  },
759
- clearArticleId: function (state) {
760
- state.data.businessTypeData.articleId = '';
761
- },
762
729
  uploadingStatus: function (state, action) {
763
730
  state.uploading = action.payload;
731
+ },
732
+ uploadingArticleStatus: function (state, action) {
733
+ state.uploadingArticle = action.payload;
734
+ },
735
+ clearAOAFile: function (state) {
736
+ var entity = (state.data.verify.responseBody || {}).entity;
737
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { entity: __assign(__assign({}, entity), { AOA_file: undefined, AOA_file_id: undefined }) });
764
738
  }
765
739
  },
766
740
  extraReducers: function (builder) {
@@ -1041,20 +1015,6 @@ export var businessSlice = createSlice({
1041
1015
  .addCase(updateLeadBusinessType.rejected, function (state, action) {
1042
1016
  state.loading = false;
1043
1017
  state.error = action.error.message;
1044
- })
1045
- .addCase(uploadArticle.pending, function (state) {
1046
- state.uploadingArticleError = null;
1047
- state.uploadingArticle = true;
1048
- })
1049
- .addCase(uploadArticle.fulfilled, function (state, action) {
1050
- state.uploadingArticleError = null;
1051
- state.uploadingArticle = false;
1052
- var data = action.payload.data;
1053
- state.data.businessTypeData.articleId = data === null || data === void 0 ? void 0 : data.id;
1054
- })
1055
- .addCase(uploadArticle.rejected, function (state) {
1056
- state.uploadingArticle = false;
1057
- state.uploadingArticleError = 'file_upload_article_error';
1058
1018
  })
1059
1019
  .addCase(updateActivitiesInfo.pending, function (state) {
1060
1020
  state.loading = true;
@@ -1138,6 +1098,6 @@ export var businessSlice = createSlice({
1138
1098
  });
1139
1099
  }
1140
1100
  });
1141
- export var clearError = (_a = businessSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, clearArticleId = _a.clearArticleId, uploadingStatus = _a.uploadingStatus;
1101
+ export var clearError = (_a = businessSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, uploadingStatus = _a.uploadingStatus, uploadingArticleStatus = _a.uploadingArticleStatus, clearAOAFile = _a.clearAOAFile;
1142
1102
  export default businessSlice.reducer;
1143
1103
  export var businessSelector = function (state) { return state.business; };
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
+ import { FileDetails } from '../../../../@types';
2
3
  declare type ArticleProps = {
3
4
  show: boolean;
5
+ defaultFile?: FileDetails;
4
6
  };
5
- declare const Article: ({ show }: ArticleProps) => JSX.Element;
7
+ declare const Article: ({ show, defaultFile }: ArticleProps) => JSX.Element;
6
8
  export default Article;
@@ -10,17 +10,16 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import React from 'react';
14
13
  import { styled } from '@mui/material/styles';
15
14
  import { ScreenContainer } from '../../../shared/Containers';
16
15
  import { useTranslation } from 'react-i18next';
17
16
  import { useController, useFormContext } from 'react-hook-form';
18
17
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
19
- import { businessSelector, clearArticleId, 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';
18
+ import { businessSelector, clearAOAFile, clearError, uploadingArticleStatus } from '../../../app/business/businessStore';
19
+ import { UploadWrapper } from '../../../shared/UploadFile';
20
+ import { FileRemoveType } from '../../../../constants';
23
21
  import Collapse from '../../../../components/Collapse';
22
+ import { DocumentPurpose } from '../../../../@types';
24
23
  var FeatureStyled = styled(ScreenContainer)(function (_a) {
25
24
  var theme = _a.theme;
26
25
  return ({
@@ -28,60 +27,26 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
28
27
  });
29
28
  });
30
29
  var Article = function (_a) {
31
- var show = _a.show;
32
- var _b = React.useState(), error = _b[0], setError = _b[1];
33
- var _c = React.useState(0), progress = _c[0], setProgress = _c[1];
30
+ var _b;
31
+ var show = _a.show, defaultFile = _a.defaultFile;
34
32
  var t = useTranslation().t;
35
- var _d = useFormContext(), control = _d.control, setValue = _d.setValue;
36
- var articleFileControl = useController({ name: 'articleFile', control: control });
33
+ var control = useFormContext().control;
37
34
  var articleIdControl = useController({ name: 'articleId', control: control });
38
- var _e = useAppSelector(businessSelector), loading = _e.loading, uploadingArticle = _e.uploadingArticle, sysError = _e.uploadingArticleError, data = _e.data;
35
+ var _c = useAppSelector(businessSelector), loading = _c.loading, error = _c.error, data = _c.data;
39
36
  var dispatch = useAppDispatch();
40
- var articleValue = articleFileControl.field.value;
41
- var businessTypeData = data.businessTypeData;
42
- var articleFile = businessTypeData.articleFile, articleId = businessTypeData.articleId;
43
- React.useEffect(function () {
44
- if (!articleValue) {
45
- setValue('articleFile', articleFile);
46
- setValue('articleId', articleId);
47
- }
48
- }, [articleFile, articleId]);
49
- var handleArticleChange = function (files) {
50
- setError('');
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('file_not_supported_alert');
56
- return;
57
- }
58
- if ((file === null || file === void 0 ? void 0 : file.size) > MAX_FILE_SIZE) {
59
- setError('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
- }));
37
+ var AOA_file = (((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) || {}).AOA_file;
38
+ var handleArticleChange = function (id) {
39
+ if (error)
40
+ dispatch(clearError());
41
+ articleIdControl.field.onChange(id);
69
42
  };
70
43
  var handleReset = function () {
71
- articleFileControl.field.onChange(undefined);
72
- articleIdControl.field.onChange('');
73
- dispatch(clearArticleId());
74
- setProgress(0);
44
+ if (error)
45
+ dispatch(clearError());
46
+ if (AOA_file)
47
+ dispatch(clearAOAFile());
48
+ articleIdControl.field.onChange(undefined);
75
49
  };
76
- React.useEffect(function () {
77
- if (sysError === 'file_upload_error') {
78
- setError(sysError);
79
- articleFileControl.field.onChange(undefined);
80
- setProgress(0);
81
- }
82
- }, [sysError]);
83
- var fileName = articleValue ? maskFileName(articleValue === null || articleValue === void 0 ? void 0 : articleValue.name) : '';
84
- var errorValue = error || sysError || '';
85
- 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: errorValue && t(errorValue), initialFileName: fileName }) }) })));
50
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadWrapper, { id: 'articleId', fileRemoveType: FileRemoveType.AOA_FILE_ID, control: control, 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, isSubmitting: loading, onDeleteFile: handleReset, defaultFile: defaultFile, purpose: DocumentPurpose.ARTICLE_ASSOCIATION, fileUploadingStatus: function (uploading) { return dispatch(uploadingArticleStatus(uploading)); } }) }) })));
86
51
  };
87
52
  export default Article;
@@ -28,7 +28,7 @@ import LicenseList from './LicenseList';
28
28
  var BusinessType = function (_a) {
29
29
  var _b = useAppSelector(businessSelector), data = _b.data, loading = _b.loading, error = _b.error, uploading = _b.uploading, uploadingArticle = _b.uploadingArticle;
30
30
  var settingsData = useAppSelector(settingsSelector).data;
31
- var _c = data.businessTypeData, selectedLicense = _c.selectedLicense, licenseNumber = _c.licenseNumber, entityLegalName = _c.entityLegalName, certificateId = _c.certificateId, articleId = _c.articleId, articleFile = _c.articleFile;
31
+ var _c = data.businessTypeData, selectedLicense = _c.selectedLicense, licenseNumber = _c.licenseNumber, entityLegalName = _c.entityLegalName, certificateId = _c.certificateId, articleId = _c.articleId;
32
32
  var t = useTranslation().t;
33
33
  var isAr = useLanguage().isAr;
34
34
  var dispatch = useAppDispatch();
@@ -41,8 +41,7 @@ var BusinessType = function (_a) {
41
41
  licenseNumber: licenseNumber,
42
42
  entityLegalName: entityLegalName,
43
43
  certificateId: certificateId,
44
- articleId: articleId,
45
- articleFile: articleFile
44
+ articleId: articleId
46
45
  },
47
46
  mode: 'onChange'
48
47
  });
@@ -56,7 +55,8 @@ var BusinessType = function (_a) {
56
55
  selectedLicense: data.selectedLicense,
57
56
  licenseNumber: data.licenseNumber,
58
57
  entityLegalName: data.entityLegalName,
59
- certificateId: data.certificateId
58
+ certificateId: data.certificateId,
59
+ articleId: data.articleId
60
60
  };
61
61
  dispatch(updateLeadBusinessType(dataValues));
62
62
  };
@@ -32,9 +32,8 @@ var Article = function (_a) {
32
32
  var t = useTranslation().t;
33
33
  var control = useFormContext().control;
34
34
  var articleIdControl = useController({ name: 'articleId', control: control });
35
- var loading = useAppSelector(entitySelector).loading;
36
35
  var dispatch = useAppDispatch();
37
- var _c = useAppSelector(entitySelector), data = _c.data, error = _c.error;
36
+ var _c = useAppSelector(entitySelector), data = _c.data, error = _c.error, loading = _c.loading;
38
37
  var AOA_file = (((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) || {}).AOA_file;
39
38
  var handleArticleChange = function (id) {
40
39
  if (error)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.3.46-test",
3
+ "version": "2.3.47-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",