@tap-payments/auth-jsconnect 2.6.86-test → 2.6.89-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.
- package/build/@types/app.d.ts +2 -1
- package/build/@types/form.d.ts +2 -0
- package/build/api/entity.d.ts +13 -0
- package/build/api/entity.js +9 -1
- package/build/api/index.d.ts +3 -2
- package/build/constants/app.d.ts +14 -0
- package/build/constants/app.js +14 -0
- package/build/constants/validation.d.ts +3 -0
- package/build/constants/validation.js +3 -0
- package/build/features/app/connectExpress/connectExpressStore.d.ts +6 -1
- package/build/features/app/connectExpress/connectExpressStore.js +56 -5
- package/build/features/connectExpress/screens/AuthenticationList/AuthenticationList.js +22 -5
- package/build/features/connectExpress/screens/AuthenticationList/EntityLegalName.d.ts +3 -0
- package/build/features/connectExpress/screens/AuthenticationList/EntityLegalName.js +48 -0
- package/build/features/connectExpress/screens/AuthenticationList/EntityList.d.ts +3 -3
- package/build/features/connectExpress/screens/AuthenticationList/EntityList.js +49 -10
- package/build/features/connectExpress/screens/AuthenticationList/LicenseNumber.d.ts +3 -0
- package/build/features/connectExpress/screens/AuthenticationList/LicenseNumber.js +36 -0
- package/build/features/connectExpress/screens/AuthenticationList/MerchantList.js +26 -10
- package/build/features/connectExpress/screens/AuthenticationList/validation.d.ts +14 -1
- package/build/features/connectExpress/screens/AuthenticationList/validation.js +32 -7
- package/build/features/shared/Button/Button.js +8 -4
- package/package.json +1 -1
package/build/@types/app.d.ts
CHANGED
|
@@ -117,7 +117,7 @@ export interface EntityLicense extends License {
|
|
|
117
117
|
id: string;
|
|
118
118
|
}
|
|
119
119
|
export interface EntityLicenseAuth extends EntityLicense {
|
|
120
|
-
|
|
120
|
+
business_id: string;
|
|
121
121
|
country: string;
|
|
122
122
|
}
|
|
123
123
|
export interface Activity {
|
|
@@ -296,6 +296,7 @@ export declare type BrandInfo = {
|
|
|
296
296
|
};
|
|
297
297
|
};
|
|
298
298
|
id: string;
|
|
299
|
+
business_id: string;
|
|
299
300
|
name: {
|
|
300
301
|
ar: string;
|
|
301
302
|
en: string;
|
package/build/@types/form.d.ts
CHANGED
package/build/api/entity.d.ts
CHANGED
|
@@ -120,6 +120,18 @@ export declare type MerchantListBody = {
|
|
|
120
120
|
create_if_not_present: boolean;
|
|
121
121
|
platforms?: Array<string>;
|
|
122
122
|
};
|
|
123
|
+
export declare type CreateEntityBody = {
|
|
124
|
+
business_id: string;
|
|
125
|
+
entity: {
|
|
126
|
+
legal_name: {
|
|
127
|
+
en: string;
|
|
128
|
+
ar: string;
|
|
129
|
+
};
|
|
130
|
+
license_number: string;
|
|
131
|
+
country: string;
|
|
132
|
+
is_licensed?: boolean;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
123
135
|
declare const entityService: {
|
|
124
136
|
createEntityInfo: ({ id, ...data }: EntityInfoBody, config?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
125
137
|
updateEntityInfo: ({ id, ...data }: EntityInfoBody, config?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
@@ -138,5 +150,6 @@ declare const entityService: {
|
|
|
138
150
|
getEntityListUsingIndividualId: (individualId: string) => Promise<any>;
|
|
139
151
|
getMerchantListUsingEntityId: (data: MerchantListBody) => Promise<any>;
|
|
140
152
|
getTerminalListUsingMerchantId: (merchantId: string) => Promise<any>;
|
|
153
|
+
createEntity: (data: CreateEntityBody) => Promise<any>;
|
|
141
154
|
};
|
|
142
155
|
export { entityService };
|
package/build/api/entity.js
CHANGED
|
@@ -122,6 +122,13 @@ var getTerminalListUsingMerchantId = function (merchantId) {
|
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
124
|
};
|
|
125
|
+
var createEntity = function (data) {
|
|
126
|
+
return httpClient({
|
|
127
|
+
method: 'post',
|
|
128
|
+
url: "".concat(ENDPOINT_PATHS.ENTITY),
|
|
129
|
+
data: data
|
|
130
|
+
});
|
|
131
|
+
};
|
|
125
132
|
var entityService = {
|
|
126
133
|
createEntityInfo: createEntityInfo,
|
|
127
134
|
updateEntityInfo: updateEntityInfo,
|
|
@@ -139,6 +146,7 @@ var entityService = {
|
|
|
139
146
|
removeEntityActivities: removeEntityActivities,
|
|
140
147
|
getEntityListUsingIndividualId: getEntityListUsingIndividualId,
|
|
141
148
|
getMerchantListUsingEntityId: getMerchantListUsingEntityId,
|
|
142
|
-
getTerminalListUsingMerchantId: getTerminalListUsingMerchantId
|
|
149
|
+
getTerminalListUsingMerchantId: getTerminalListUsingMerchantId,
|
|
150
|
+
createEntity: createEntity
|
|
143
151
|
};
|
|
144
152
|
export { entityService };
|
package/build/api/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ValidateOperatorBody, ConfirmBody } from './operator';
|
|
|
3
3
|
import { CreateAuthBody, VerifyAuthBody, CreatePasswordBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, VerifyAuthExpressOTPBody, ConfigBody } from './auth';
|
|
4
4
|
import { UpdateLeadBody, LeadVerifyBody, CreateLeadBody, LeadOTPVerifyBody, LeadIdentityUpdateBody, ExpressLeadVerifyBody } from './lead';
|
|
5
5
|
import { CheckEmailBody, CheckBrandBody } from './availabilityServices';
|
|
6
|
-
import { EntityInfoBody, EntityBankUpdateBody, BankDocumentInfo, UpdateEntityBody, UpdateEntityActivityBody, UpdateEntityCapitalBody, UpdateEntityAOAFileBody, RemoveEntityActivity, MerchantListBody } from './entity';
|
|
6
|
+
import { EntityInfoBody, EntityBankUpdateBody, BankDocumentInfo, UpdateEntityBody, UpdateEntityActivityBody, UpdateEntityCapitalBody, UpdateEntityAOAFileBody, RemoveEntityActivity, MerchantListBody, CreateEntityBody } from './entity';
|
|
7
7
|
import { CreateAccountBody, ExpressCreateAccountBody } from './account';
|
|
8
8
|
import { DataElementBody } from './data';
|
|
9
9
|
import { BrandListBody, UpdateBrandBody, UpdateIndividualBody, GetIndividualListBody, UpdateIndividualWithTypeBody, UpdateMultipleIndividualBody } from './individual';
|
|
@@ -75,6 +75,7 @@ declare const API: {
|
|
|
75
75
|
getEntityListUsingIndividualId: (individualId: string) => Promise<any>;
|
|
76
76
|
getMerchantListUsingEntityId: (data: MerchantListBody) => Promise<any>;
|
|
77
77
|
getTerminalListUsingMerchantId: (merchantId: string) => Promise<any>;
|
|
78
|
+
createEntity: (data: CreateEntityBody) => Promise<any>;
|
|
78
79
|
};
|
|
79
80
|
availabilityServices: {
|
|
80
81
|
checkEmail: (data: CheckEmailBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
@@ -175,6 +176,6 @@ declare const API: {
|
|
|
175
176
|
getInitialData: (body: InitBody) => Promise<any>;
|
|
176
177
|
};
|
|
177
178
|
};
|
|
178
|
-
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, InitBody, RemoveBrandActivity, RemoveEntityActivity, UpdateIndividualWithTypeBody, UpdateMultipleIndividualBody, ExpressLeadVerifyBody, ConfirmBody, ConfigBody, MerchantListBody };
|
|
179
|
+
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, InitBody, RemoveBrandActivity, RemoveEntityActivity, UpdateIndividualWithTypeBody, UpdateMultipleIndividualBody, ExpressLeadVerifyBody, ConfirmBody, ConfigBody, MerchantListBody, CreateEntityBody };
|
|
179
180
|
export { setAxiosGlobalHeaders, removeAxiosGlobalHeaders, axiosInstance, getAxiosHeaders };
|
|
180
181
|
export default API;
|
package/build/constants/app.d.ts
CHANGED
|
@@ -254,3 +254,17 @@ export declare type FileInfo = {
|
|
|
254
254
|
error: string;
|
|
255
255
|
deleteStatus: DeleteFileStatus;
|
|
256
256
|
};
|
|
257
|
+
export declare const ADD_ENTITY = "add_entity";
|
|
258
|
+
export declare const ADD_NEW_ENTITY: {
|
|
259
|
+
id: string;
|
|
260
|
+
business_id: string;
|
|
261
|
+
country: string;
|
|
262
|
+
legal_name: {
|
|
263
|
+
ar: string;
|
|
264
|
+
en: string;
|
|
265
|
+
};
|
|
266
|
+
license: {
|
|
267
|
+
number: string;
|
|
268
|
+
};
|
|
269
|
+
type: string;
|
|
270
|
+
};
|
package/build/constants/app.js
CHANGED
|
@@ -870,3 +870,17 @@ export var DeleteFileStatus;
|
|
|
870
870
|
DeleteFileStatus["ERROR"] = "error";
|
|
871
871
|
DeleteFileStatus["SUCCESS"] = "success";
|
|
872
872
|
})(DeleteFileStatus || (DeleteFileStatus = {}));
|
|
873
|
+
export var ADD_ENTITY = 'add_entity';
|
|
874
|
+
export var ADD_NEW_ENTITY = {
|
|
875
|
+
id: ADD_ENTITY,
|
|
876
|
+
business_id: '',
|
|
877
|
+
country: '',
|
|
878
|
+
legal_name: {
|
|
879
|
+
ar: ADD_ENTITY,
|
|
880
|
+
en: ADD_ENTITY
|
|
881
|
+
},
|
|
882
|
+
license: {
|
|
883
|
+
number: ''
|
|
884
|
+
},
|
|
885
|
+
type: ''
|
|
886
|
+
};
|
|
@@ -5,6 +5,8 @@ export declare const VAT_ID_LENGTH = 15;
|
|
|
5
5
|
export declare const MAX_IBAN_VALUE = 34;
|
|
6
6
|
export declare const FL_NUMBER_MAX_LENGTH = 20;
|
|
7
7
|
export declare const CR_NUMBER_MAX_LENGTH = 20;
|
|
8
|
+
export declare const LICENSE_NUMBER_MAX_LENGTH = 20;
|
|
9
|
+
export declare const LICENSE_NUMBER_MIN_LENGTH = 5;
|
|
8
10
|
export declare const FL_NUMBER_ENTITY_LENGTH = 50;
|
|
9
11
|
export declare const FL_MIN_LICENSE_LENGTH = 5;
|
|
10
12
|
export declare const CR_MIN_LICENSE_LENGTH = 5;
|
|
@@ -21,6 +23,7 @@ export declare const REGEX_BENEFICIARY_NAME: RegExp;
|
|
|
21
23
|
export declare const REGEX_ALPHANUMERIC: RegExp;
|
|
22
24
|
export declare const REGEX_BRAND_NAME: RegExp;
|
|
23
25
|
export declare const EMAIL_MAX_LENGTH = 50;
|
|
26
|
+
export declare const REGEX_LEGAL_NAME: RegExp;
|
|
24
27
|
export declare const LINKEDIN_URL: RegExp;
|
|
25
28
|
export declare const SOCIAL_USERNAME: RegExp;
|
|
26
29
|
export declare const DIGITS_ONLY: RegExp;
|
|
@@ -5,6 +5,8 @@ export var VAT_ID_LENGTH = 15;
|
|
|
5
5
|
export var MAX_IBAN_VALUE = 34;
|
|
6
6
|
export var FL_NUMBER_MAX_LENGTH = 20;
|
|
7
7
|
export var CR_NUMBER_MAX_LENGTH = 20;
|
|
8
|
+
export var LICENSE_NUMBER_MAX_LENGTH = 20;
|
|
9
|
+
export var LICENSE_NUMBER_MIN_LENGTH = 5;
|
|
8
10
|
export var FL_NUMBER_ENTITY_LENGTH = 50;
|
|
9
11
|
export var FL_MIN_LICENSE_LENGTH = 5;
|
|
10
12
|
export var CR_MIN_LICENSE_LENGTH = 5;
|
|
@@ -21,6 +23,7 @@ export var REGEX_BENEFICIARY_NAME = /^([\u0600-\u065F\u066A-\u06EF\u06FA-\u06FFa
|
|
|
21
23
|
export var REGEX_ALPHANUMERIC = /^[a-zA-Z0-9!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/? ]*$/g;
|
|
22
24
|
export var REGEX_BRAND_NAME = /^(([a-zA-Z0-9])+\s)*[a-zA-Z0-9]+$/;
|
|
23
25
|
export var EMAIL_MAX_LENGTH = 50;
|
|
26
|
+
export var REGEX_LEGAL_NAME = /^([a-zA-Z0-9\s!@#$%^&*()_+-=,.<>?/|\\:;"'~`[\]{}]*)$/;
|
|
24
27
|
export var LINKEDIN_URL = /[a-zA-Z0-9-\/:._]+$/;
|
|
25
28
|
export var SOCIAL_USERNAME = /^[A-Za-z-0-9\d._]{3,}$/;
|
|
26
29
|
export var DIGITS_ONLY = /^\d+$/;
|
|
@@ -92,6 +92,10 @@ export declare const createAccountAsync: import("@reduxjs/toolkit").AsyncThunk<{
|
|
|
92
92
|
boardData: any;
|
|
93
93
|
account: any;
|
|
94
94
|
} | undefined, void, {}>;
|
|
95
|
+
export declare const createEntity: import("@reduxjs/toolkit").AsyncThunk<{
|
|
96
|
+
data: any;
|
|
97
|
+
formData: AuthenticationListFormValues;
|
|
98
|
+
}, AuthenticationListFormValues, {}>;
|
|
95
99
|
interface verifyPACIAsyncParams {
|
|
96
100
|
onSuccess: () => void;
|
|
97
101
|
}
|
|
@@ -141,11 +145,12 @@ export declare const connectSlice: import("@reduxjs/toolkit").Slice<ConnectExpre
|
|
|
141
145
|
resetNIDScreen: (state: ConnectExpressState) => void;
|
|
142
146
|
setDefaultCountryCode: (state: ConnectExpressState, action: ActionState<CountryCode>) => void;
|
|
143
147
|
resetCivilScreen: (state: ConnectExpressState) => void;
|
|
148
|
+
resetAuthenticationScreen: (state: ConnectExpressState) => void;
|
|
144
149
|
resetOTPValue: (state: ConnectExpressState) => void;
|
|
145
150
|
resetStore: (state: ConnectExpressState) => void;
|
|
146
151
|
resetIndividualScreen: (state: ConnectExpressState) => void;
|
|
147
152
|
}, "connectExpress/store">;
|
|
148
|
-
export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setIsLeadIdPassed: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>, resetMobileScreen: import("@reduxjs/toolkit").ActionCreatorWithPayload<CountryCode, string>, resetOTPValue: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetNIDScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetCivilScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetStore: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setError: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, setLeadId: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, setShowBoard: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>, resetIndividualScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setDefaultCountryCode: import("@reduxjs/toolkit").ActionCreatorWithPayload<CountryCode, string>, storeIsStartFromBusinessCountry: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>;
|
|
153
|
+
export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setIsLeadIdPassed: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>, resetMobileScreen: import("@reduxjs/toolkit").ActionCreatorWithPayload<CountryCode, string>, resetOTPValue: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetNIDScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetCivilScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetStore: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setError: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, setLeadId: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, setShowBoard: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>, resetIndividualScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setDefaultCountryCode: import("@reduxjs/toolkit").ActionCreatorWithPayload<CountryCode, string>, storeIsStartFromBusinessCountry: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>, resetAuthenticationScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
149
154
|
declare const _default: import("redux").Reducer<ConnectExpressState, import("redux").AnyAction>;
|
|
150
155
|
export default _default;
|
|
151
156
|
export declare const connectExpressSelector: (state: RootState) => ConnectExpressState;
|
|
@@ -59,7 +59,7 @@ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
|
59
59
|
import { handleNextScreenStep, handleCurrentActiveScreen, handleOpen, handleSetCountryByIso2, onCloseComplete, storeAuthId } from '../../../app/settings';
|
|
60
60
|
import { FlowsTypes, AuthForType, BusinessType, LicenseType } from '../../../@types';
|
|
61
61
|
import API from '../../../api';
|
|
62
|
-
import { CONNECT_EXPRESS_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_FL_LICENSE, SCOPE_AUTH } from '../../../constants';
|
|
62
|
+
import { ADD_NEW_ENTITY, CONNECT_EXPRESS_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_FL_LICENSE, SCOPE_AUTH } from '../../../constants';
|
|
63
63
|
import { defaultCountry } from '../../../constants';
|
|
64
64
|
import { getIndividualName, capitalizeTheFirstLetterOfEachWord, sleep, findCountryByIddPrefix, concatenateObjectValues, isSA, isKW, isOtherThanKWOrSA } from '../../../utils';
|
|
65
65
|
export var updateBusinessCountryAsync = createAsyncThunk('connectExpress/updateBusinessCountryAsync', function (countryCode, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -885,6 +885,33 @@ export var createAccountAsync = createAsyncThunk('connectExpress/createAccountAs
|
|
|
885
885
|
}
|
|
886
886
|
});
|
|
887
887
|
}); });
|
|
888
|
+
export var createEntity = createAsyncThunk('connectExpress/createEntity', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
889
|
+
var settings, brandInfo, legalName, licenseNumber, body, data;
|
|
890
|
+
var _a;
|
|
891
|
+
return __generator(this, function (_b) {
|
|
892
|
+
switch (_b.label) {
|
|
893
|
+
case 0:
|
|
894
|
+
settings = thunkApi.getState().settings;
|
|
895
|
+
brandInfo = params.brandInfo, legalName = params.legalName, licenseNumber = params.licenseNumber;
|
|
896
|
+
body = {
|
|
897
|
+
business_id: (brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_id) || '',
|
|
898
|
+
entity: {
|
|
899
|
+
legal_name: {
|
|
900
|
+
en: legalName || '',
|
|
901
|
+
ar: legalName || ''
|
|
902
|
+
},
|
|
903
|
+
license_number: licenseNumber || '',
|
|
904
|
+
country: (_a = settings.data.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2,
|
|
905
|
+
is_licensed: undefined
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
return [4, API.entityService.createEntity(body)];
|
|
909
|
+
case 1:
|
|
910
|
+
data = _b.sent();
|
|
911
|
+
return [2, { data: data, formData: params }];
|
|
912
|
+
}
|
|
913
|
+
});
|
|
914
|
+
}); });
|
|
888
915
|
export var updateLeadIndividualAsync = createAsyncThunk('connectExpress/updateLeadIndividualAsync', function (_a, thunkApi) {
|
|
889
916
|
var formData = _a.formData, originalFormData = _a.originalFormData;
|
|
890
917
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -1107,6 +1134,9 @@ export var connectSlice = createSlice({
|
|
|
1107
1134
|
resetCivilScreen: function (state) {
|
|
1108
1135
|
state.data.civilIdData = __assign(__assign({}, state.data.civilIdData), initialState.data.civilIdData);
|
|
1109
1136
|
},
|
|
1137
|
+
resetAuthenticationScreen: function (state) {
|
|
1138
|
+
state.data.authenticationData = __assign(__assign({}, state.data.authenticationData), initialState.data.authenticationData);
|
|
1139
|
+
},
|
|
1110
1140
|
resetOTPValue: function (state) {
|
|
1111
1141
|
state.data.otpData.otp = '';
|
|
1112
1142
|
},
|
|
@@ -1412,11 +1442,10 @@ export var connectSlice = createSlice({
|
|
|
1412
1442
|
state.error = null;
|
|
1413
1443
|
state.loading = false;
|
|
1414
1444
|
var _a = action.payload, brandList = _a.brandList, entityList = _a.entityList;
|
|
1445
|
+
var eList = __spreadArray(__spreadArray([], entityList, true), [ADD_NEW_ENTITY], false);
|
|
1415
1446
|
if (brandList === null || brandList === void 0 ? void 0 : brandList.length)
|
|
1416
1447
|
state.data.authenticationData.brandInfo = brandList[0];
|
|
1417
|
-
|
|
1418
|
-
state.data.authenticationData.entityInfo = entityList[0];
|
|
1419
|
-
state.data.responseData = __assign(__assign({}, state.data.responseData), { authenticationData: { brandList: brandList, entityList: entityList } });
|
|
1448
|
+
state.data.responseData = __assign(__assign({}, state.data.responseData), { authenticationData: { brandList: brandList, entityList: eList } });
|
|
1420
1449
|
})
|
|
1421
1450
|
.addCase(retrieveAuthenticationListAsync.pending, function (state) {
|
|
1422
1451
|
state.loading = true;
|
|
@@ -1551,9 +1580,31 @@ export var connectSlice = createSlice({
|
|
|
1551
1580
|
.addCase(updateBusinessCountryAsync.fulfilled, function (state) {
|
|
1552
1581
|
state.loading = false;
|
|
1553
1582
|
state.error = null;
|
|
1583
|
+
})
|
|
1584
|
+
.addCase(createEntity.pending, function (state) {
|
|
1585
|
+
state.loading = true;
|
|
1586
|
+
state.error = null;
|
|
1587
|
+
})
|
|
1588
|
+
.addCase(createEntity.rejected, function (state, action) {
|
|
1589
|
+
state.loading = false;
|
|
1590
|
+
state.error = action.error.message;
|
|
1591
|
+
})
|
|
1592
|
+
.addCase(createEntity.fulfilled, function (state, action) {
|
|
1593
|
+
var _a;
|
|
1594
|
+
state.loading = false;
|
|
1595
|
+
state.error = null;
|
|
1596
|
+
var data = action.payload.data;
|
|
1597
|
+
var authenticationData = ((_a = state.data.responseData) === null || _a === void 0 ? void 0 : _a.authenticationData) || {};
|
|
1598
|
+
var entityList = (authenticationData || {}).entityList;
|
|
1599
|
+
if (data === null || data === void 0 ? void 0 : data.entity) {
|
|
1600
|
+
var entity = __assign(__assign({}, data.entity), { business_id: data === null || data === void 0 ? void 0 : data.business_id });
|
|
1601
|
+
var list = __spreadArray([entity], entityList, true);
|
|
1602
|
+
state.data.authenticationData.entityInfo = list[0];
|
|
1603
|
+
state.data.responseData = __assign(__assign({}, data), { authenticationData: __assign(__assign({}, authenticationData), { entityList: list }) });
|
|
1604
|
+
}
|
|
1554
1605
|
});
|
|
1555
1606
|
}
|
|
1556
1607
|
});
|
|
1557
|
-
export var clearError = (_a = connectSlice.actions, _a.clearError), stopLoader = _a.stopLoader, setIsLeadIdPassed = _a.setIsLeadIdPassed, resetMobileScreen = _a.resetMobileScreen, resetOTPValue = _a.resetOTPValue, resetNIDScreen = _a.resetNIDScreen, resetCivilScreen = _a.resetCivilScreen, resetStore = _a.resetStore, setError = _a.setError, setLeadId = _a.setLeadId, setShowBoard = _a.setShowBoard, resetIndividualScreen = _a.resetIndividualScreen, setDefaultCountryCode = _a.setDefaultCountryCode, storeIsStartFromBusinessCountry = _a.storeIsStartFromBusinessCountry;
|
|
1608
|
+
export var clearError = (_a = connectSlice.actions, _a.clearError), stopLoader = _a.stopLoader, setIsLeadIdPassed = _a.setIsLeadIdPassed, resetMobileScreen = _a.resetMobileScreen, resetOTPValue = _a.resetOTPValue, resetNIDScreen = _a.resetNIDScreen, resetCivilScreen = _a.resetCivilScreen, resetStore = _a.resetStore, setError = _a.setError, setLeadId = _a.setLeadId, setShowBoard = _a.setShowBoard, resetIndividualScreen = _a.resetIndividualScreen, setDefaultCountryCode = _a.setDefaultCountryCode, storeIsStartFromBusinessCountry = _a.storeIsStartFromBusinessCountry, resetAuthenticationScreen = _a.resetAuthenticationScreen;
|
|
1558
1609
|
export default connectSlice.reducer;
|
|
1559
1610
|
export var connectExpressSelector = function (state) { return state.connectExpress; };
|
|
@@ -22,12 +22,14 @@ import { AuthForType } from '../../../../@types';
|
|
|
22
22
|
import Form from '../../../../components/Form';
|
|
23
23
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
24
24
|
import Button from '../../../shared/Button';
|
|
25
|
-
import { clearError, connectExpressSelector, updateOperatorInfoAsync } from '../../../app/connectExpress/connectExpressStore';
|
|
25
|
+
import { clearError, connectExpressSelector, createEntity, resetAuthenticationScreen, updateOperatorInfoAsync } from '../../../app/connectExpress/connectExpressStore';
|
|
26
26
|
import { useLanguage } from '../../../../hooks';
|
|
27
|
-
import { AuthenticationListValidationSchema } from './validation';
|
|
27
|
+
import { AddEntityValidationSchema, AuthenticationListValidationSchema } from './validation';
|
|
28
28
|
import BrandList from './BrandList';
|
|
29
29
|
import EntityList from './EntityList';
|
|
30
30
|
import MerchantList from './MerchantList';
|
|
31
|
+
import LicenseNumber from './LicenseNumber';
|
|
32
|
+
import EntityLegalName from './EntityLegalName';
|
|
31
33
|
var ListType;
|
|
32
34
|
(function (ListType) {
|
|
33
35
|
ListType["BrandList"] = "BrandList";
|
|
@@ -40,7 +42,8 @@ var AuthenticationList = function (_a) {
|
|
|
40
42
|
var _c = useAppSelector(connectExpressSelector), data = _c.data, loading = _c.loading, error = _c.error, merchantLoading = _c.merchantLoading, terminalLoading = _c.terminalLoading;
|
|
41
43
|
var _d = data.authenticationData, brandInfo = _d.brandInfo, entityInfo = _d.entityInfo, merchantInfo = _d.merchantInfo;
|
|
42
44
|
var _e = React.useState(), listActive = _e[0], setListActive = _e[1];
|
|
43
|
-
var _f = ((_b = data.responseData) === null || _b === void 0 ? void 0 : _b.authenticationData) || {}, brandList = _f.brandList,
|
|
45
|
+
var _f = ((_b = data.responseData) === null || _b === void 0 ? void 0 : _b.authenticationData) || {}, brandList = _f.brandList, merchantList = _f.merchantList;
|
|
46
|
+
var _g = React.useState(false), isAddEntity = _g[0], setIsAddEntity = _g[1];
|
|
44
47
|
var otpData = data.otpData;
|
|
45
48
|
var startWithNID = otpData.authFor === AuthForType.NATIONAL_ID;
|
|
46
49
|
React.useEffect(function () {
|
|
@@ -51,7 +54,7 @@ var AuthenticationList = function (_a) {
|
|
|
51
54
|
});
|
|
52
55
|
}, []);
|
|
53
56
|
var methods = useForm({
|
|
54
|
-
resolver: yupResolver(AuthenticationListValidationSchema
|
|
57
|
+
resolver: yupResolver(isAddEntity ? AddEntityValidationSchema : AuthenticationListValidationSchema),
|
|
55
58
|
defaultValues: {
|
|
56
59
|
brandInfo: brandInfo,
|
|
57
60
|
entityInfo: entityInfo,
|
|
@@ -63,12 +66,25 @@ var AuthenticationList = function (_a) {
|
|
|
63
66
|
var isAr = useLanguage().isAr;
|
|
64
67
|
var dispatch = useAppDispatch();
|
|
65
68
|
var onSubmit = function (formData) {
|
|
69
|
+
if (isAddEntity) {
|
|
70
|
+
var data_1 = { licenseNumber: formData.licenseNumber, legalName: formData.legalName, brandInfo: formData.brandInfo };
|
|
71
|
+
dispatch(createEntity(deepCopy(data_1)));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
66
74
|
dispatch(updateOperatorInfoAsync(deepCopy(formData)));
|
|
67
75
|
};
|
|
68
76
|
var onBack = function () {
|
|
69
77
|
var _a;
|
|
78
|
+
if (isAddEntity) {
|
|
79
|
+
setIsAddEntity(false);
|
|
80
|
+
methods.setValue('licenseNumber', '');
|
|
81
|
+
methods.setValue('legalName', '');
|
|
82
|
+
methods.setValue('entityInfo', undefined, { shouldValidate: true });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
70
85
|
var code = (_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2;
|
|
71
86
|
var screen = startWithNID ? (isKW(code) ? 'CONNECT_EXPRESS_CIVIL_ID_STEP' : 'CONNECT_EXPRESS_NID_STEP') : 'CONNECT_EXPRESS_MOBILE_STEP';
|
|
87
|
+
dispatch(resetAuthenticationScreen());
|
|
72
88
|
dispatch(handlePrevScreenStep(screen));
|
|
73
89
|
};
|
|
74
90
|
React.useEffect(function () {
|
|
@@ -88,6 +104,7 @@ var AuthenticationList = function (_a) {
|
|
|
88
104
|
var isBrandList = listActive === ListType.BrandList;
|
|
89
105
|
var isEntityList = listActive === ListType.EntityList;
|
|
90
106
|
var isMerchantList = listActive === ListType.MerchantList;
|
|
91
|
-
|
|
107
|
+
var showLoader = !(merchantList === null || merchantList === void 0 ? void 0 : merchantList.length) ? merchantLoading : merchantList.length === 1 && merchantLoading;
|
|
108
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { list: brandList || [], show: !isAddEntity && !isEntityList && !isMerchantList, onListOpen: function () { return handleMenuClick(ListType.BrandList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(EntityList, { countryList: settingsData.countries || [], show: !isBrandList && !isMerchantList, handleAddEntity: function (flag) { return setIsAddEntity(flag); }, onListOpen: function () { return handleMenuClick(ListType.EntityList); }, onListClose: function () { return handleMenuClick(); } }), _jsxs(Collapse, __assign({ in: isAddEntity && !isBrandList && !isEntityList }, { children: [_jsx(EntityLegalName, {}), _jsx(LicenseNumber, {})] })), _jsx(Collapse, __assign({ in: !isAddEntity }, { children: _jsx(MerchantList, { show: !isBrandList && !isEntityList, onListOpen: function () { return handleMenuClick(ListType.MerchantList); }, onListClose: function () { return handleMenuClick(); } }) })), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading || showLoader }, { children: isAddEntity ? t('create_new_entity') : t('next') })) }))] })) })) }));
|
|
92
109
|
};
|
|
93
110
|
export default React.memo(AuthenticationList);
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { useTranslation } from 'react-i18next';
|
|
14
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
15
|
+
import { styled } from '@mui/material/styles';
|
|
16
|
+
import Box from '@mui/material/Box';
|
|
17
|
+
import { removeAllOtherThanCharsNumbersAndSpace } from '../../../../utils';
|
|
18
|
+
import Input from '../../../shared/Input';
|
|
19
|
+
import { EndAdornment } from '../../../shared/EndAdornment';
|
|
20
|
+
var BoxStyled = styled(Box)(function (_a) {
|
|
21
|
+
var theme = _a.theme;
|
|
22
|
+
return ({
|
|
23
|
+
display: 'flex',
|
|
24
|
+
flexDirection: 'column',
|
|
25
|
+
direction: theme.direction,
|
|
26
|
+
fontFamily: theme.typography.fontFamily,
|
|
27
|
+
overflow: 'hidden',
|
|
28
|
+
paddingBlockEnd: theme.spacing(2.5)
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
var EntityLegalName = function () {
|
|
32
|
+
var _a;
|
|
33
|
+
var t = useTranslation().t;
|
|
34
|
+
var control = useFormContext().control;
|
|
35
|
+
var entityNameControl = useController({ control: control, name: 'legalName' });
|
|
36
|
+
var entityNameValue = entityNameControl.field.value;
|
|
37
|
+
var error = (_a = entityNameControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
|
|
38
|
+
var handleChange = function (_a) {
|
|
39
|
+
var target = _a.target;
|
|
40
|
+
var value = removeAllOtherThanCharsNumbersAndSpace(target.value);
|
|
41
|
+
entityNameControl.field.onChange(value);
|
|
42
|
+
};
|
|
43
|
+
var clearEntityLegalName = function () {
|
|
44
|
+
entityNameControl.field.onChange('');
|
|
45
|
+
};
|
|
46
|
+
return (_jsx(BoxStyled, __assign({ sx: { mt: 2.5 } }, { children: _jsx(Input, { label: t('license_name_label'), onChange: handleChange, required: true, value: entityNameValue || '', endAdornment: _jsx(EndAdornment, { value: entityNameValue, error: error, onClear: clearEntityLegalName }), placeholder: t('license_name_hint'), warningType: 'alert', warningMessage: error && t(error) }) })));
|
|
47
|
+
};
|
|
48
|
+
export default EntityLegalName;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { CountryCode
|
|
2
|
+
import { CountryCode } from '../../../../@types';
|
|
3
3
|
interface EntityListProps {
|
|
4
4
|
show: boolean;
|
|
5
|
-
list: Array<EntityLicenseAuth>;
|
|
6
5
|
countryList: Array<CountryCode>;
|
|
7
6
|
onListOpen?: () => void;
|
|
8
7
|
onListClose?: () => void;
|
|
8
|
+
handleAddEntity?: (flag: boolean) => void;
|
|
9
9
|
}
|
|
10
|
-
declare const _default: React.MemoExoticComponent<({ show,
|
|
10
|
+
declare const _default: React.MemoExoticComponent<({ show, countryList, handleAddEntity, ...rest }: EntityListProps) => JSX.Element>;
|
|
11
11
|
export default _default;
|
|
@@ -20,13 +20,22 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
24
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
25
|
+
if (ar || !(i in from)) {
|
|
26
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
27
|
+
ar[i] = from[i];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
|
+
};
|
|
23
32
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
33
|
import * as React from 'react';
|
|
25
34
|
import { useTranslation } from 'react-i18next';
|
|
26
35
|
import { useFormContext, useController } from 'react-hook-form';
|
|
27
36
|
import Box from '@mui/material/Box';
|
|
28
37
|
import { styled } from '@mui/material/styles';
|
|
29
|
-
import { useLanguage } from '../../../../hooks';
|
|
38
|
+
import { useAppSelector, useLanguage } from '../../../../hooks';
|
|
30
39
|
import ScreenContainer from '../../../shared/Containers/ScreenContainer';
|
|
31
40
|
import InputSelect from '../../../shared/InputSelect';
|
|
32
41
|
import CheckIcon from '../../../shared/CheckIcon';
|
|
@@ -35,6 +44,8 @@ import Text from '../../../../components/Text';
|
|
|
35
44
|
import ExpandIcon from '../../../../components/ExpandIcon';
|
|
36
45
|
import Collapse from '../../../../components/Collapse';
|
|
37
46
|
import Icon from '../../../../components/Icon';
|
|
47
|
+
import { connectExpressSelector } from '../../../../features/app/connectExpress/connectExpressStore';
|
|
48
|
+
import { ADD_ENTITY } from '../../../../constants';
|
|
38
49
|
var EntityContainer = styled(Box)(function () { return ({
|
|
39
50
|
display: 'flex',
|
|
40
51
|
alignItems: 'center'
|
|
@@ -51,13 +62,34 @@ var EntityNameText = styled(Text, { shouldForwardProp: function (prop) { return
|
|
|
51
62
|
return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight }));
|
|
52
63
|
});
|
|
53
64
|
var EntityList = function (_a) {
|
|
54
|
-
var
|
|
55
|
-
var
|
|
65
|
+
var _b, _c;
|
|
66
|
+
var show = _a.show, countryList = _a.countryList, handleAddEntity = _a.handleAddEntity, rest = __rest(_a, ["show", "countryList", "handleAddEntity"]);
|
|
67
|
+
var _d = React.useState([]), list = _d[0], setList = _d[1];
|
|
68
|
+
var _e = React.useState(null), anchorEl = _e[0], setAnchorEl = _e[1];
|
|
56
69
|
var t = useTranslation().t;
|
|
57
70
|
var isAr = useLanguage().isAr;
|
|
58
|
-
var
|
|
71
|
+
var _f = useFormContext(), control = _f.control, watch = _f.watch, setValue = _f.setValue, getValues = _f.getValues;
|
|
72
|
+
var data = useAppSelector(connectExpressSelector).data;
|
|
73
|
+
var brandInfo = watch('brandInfo');
|
|
74
|
+
var entityList = ((_c = (_b = data.responseData) === null || _b === void 0 ? void 0 : _b.authenticationData) === null || _c === void 0 ? void 0 : _c.entityList) || [];
|
|
59
75
|
var selectedEntityControl = useController({ control: control, name: 'entityInfo' });
|
|
60
|
-
|
|
76
|
+
React.useEffect(function () {
|
|
77
|
+
if (entityList.length > 0) {
|
|
78
|
+
var filteredEntityList = entityList.filter(function (entity) { return (brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_id) && entity.business_id === brandInfo.business_id; });
|
|
79
|
+
var list_1 = __spreadArray(__spreadArray([], filteredEntityList, true), [entityList[entityList.length - 1]], false) || [];
|
|
80
|
+
setList(list_1);
|
|
81
|
+
if (filteredEntityList.length) {
|
|
82
|
+
setValue('entityInfo', filteredEntityList[0], { shouldValidate: true });
|
|
83
|
+
setValue('licenseNumber', '');
|
|
84
|
+
setValue('legalName', '');
|
|
85
|
+
handleAddEntity === null || handleAddEntity === void 0 ? void 0 : handleAddEntity(false);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
setValue('merchantInfo', undefined);
|
|
89
|
+
setValue('entityInfo', undefined);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, [entityList, brandInfo]);
|
|
61
93
|
var onOpenEntityList = function (event) {
|
|
62
94
|
var _a;
|
|
63
95
|
setAnchorEl(event.currentTarget);
|
|
@@ -72,7 +104,7 @@ var EntityList = function (_a) {
|
|
|
72
104
|
var _a, _b;
|
|
73
105
|
if (!entity)
|
|
74
106
|
return '';
|
|
75
|
-
return (isAr ? (_a = entity.legal_name) === null || _a === void 0 ? void 0 : _a.ar : (_b = entity.legal_name) === null || _b === void 0 ? void 0 : _b.en) || '';
|
|
107
|
+
return (isAr ? t((_a = entity.legal_name) === null || _a === void 0 ? void 0 : _a.ar) : t((_b = entity.legal_name) === null || _b === void 0 ? void 0 : _b.en)) || '';
|
|
76
108
|
};
|
|
77
109
|
var getEntityId = function (entity) {
|
|
78
110
|
if (!entity)
|
|
@@ -85,12 +117,19 @@ var EntityList = function (_a) {
|
|
|
85
117
|
return '';
|
|
86
118
|
return ((_a = countryList.find(function (country) { return country.iso2.toLocaleLowerCase() === entity.country.toLocaleLowerCase(); })) === null || _a === void 0 ? void 0 : _a.logo) || '';
|
|
87
119
|
};
|
|
88
|
-
var onSelectItem = function (
|
|
89
|
-
selectedEntityControl.field.onChange(
|
|
120
|
+
var onSelectItem = function (entity) {
|
|
121
|
+
selectedEntityControl.field.onChange(entity);
|
|
122
|
+
if (entity.id === ADD_ENTITY) {
|
|
123
|
+
setValue('merchantInfo', undefined);
|
|
124
|
+
handleAddEntity === null || handleAddEntity === void 0 ? void 0 : handleAddEntity(true);
|
|
125
|
+
}
|
|
126
|
+
else
|
|
127
|
+
handleAddEntity === null || handleAddEntity === void 0 ? void 0 : handleAddEntity(false);
|
|
90
128
|
onCloseEntityList();
|
|
91
129
|
};
|
|
92
|
-
|
|
93
|
-
|
|
130
|
+
var selectedEntity = selectedEntityControl.field.value;
|
|
131
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5 } }, { children: [_jsx(InputSelect, { label: t('select_entity_label'), onClick: !!anchorEl ? onCloseEntityList : onOpenEntityList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('select_entity_placeholder'), value: getLegalName(getValues('entityInfo')) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { space: 140, list: list, onSelectItem: onSelectItem, renderItem: function (entity) {
|
|
132
|
+
return (_jsxs(_Fragment, { children: [_jsxs(EntityContainer, { children: [(entity === null || entity === void 0 ? void 0 : entity.country) && _jsx(EntityCountryFlag, { src: getCountryFlag(entity) }), _jsx(EntityNameText, __assign({ isSelected: getEntityId(entity) === getEntityId(selectedEntity) }, { children: t(getLegalName(entity)) }))] }), getEntityId(entity) === getEntityId(selectedEntity) && _jsx(CheckIcon, {})] }));
|
|
94
133
|
} }) }))] })) })));
|
|
95
134
|
};
|
|
96
135
|
export default React.memo(EntityList);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
5
|
+
import { KW_MAX_LICENSE_LENGTH, KW_MIN_LICENSE_LENGTH, LICENSE_NUMBER_MAX_LENGTH, LICENSE_NUMBER_MIN_LENGTH } from '../../../../constants';
|
|
6
|
+
import { removeAllOtherThanCharsAndNumber, isSA } from '../../../../utils';
|
|
7
|
+
import ScreenContainer from '../../../shared/Containers/ScreenContainer';
|
|
8
|
+
import ClearIcon from '../../../shared/ClearIcon';
|
|
9
|
+
import CheckIcon from '../../../shared/CheckIcon';
|
|
10
|
+
import Input from '../../../shared/Input';
|
|
11
|
+
import { useAppSelector } from '../../../../hooks';
|
|
12
|
+
import { settingsSelector } from '../../../../app/settings';
|
|
13
|
+
var LicenseNumber = function () {
|
|
14
|
+
var _a;
|
|
15
|
+
var t = useTranslation().t;
|
|
16
|
+
var control = useFormContext().control;
|
|
17
|
+
var licenseNumberControl = useController({ control: control, name: 'licenseNumber' });
|
|
18
|
+
var settingsData = useAppSelector(settingsSelector).data;
|
|
19
|
+
var isSACountry = React.useMemo(function () { return isSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
20
|
+
var handleFLNumberChange = function (_a) {
|
|
21
|
+
var target = _a.target;
|
|
22
|
+
var value = removeAllOtherThanCharsAndNumber(target.value);
|
|
23
|
+
licenseNumberControl.field.onChange(value);
|
|
24
|
+
};
|
|
25
|
+
var clearLicenseNumber = function () {
|
|
26
|
+
licenseNumberControl.field.onChange('');
|
|
27
|
+
};
|
|
28
|
+
var licenseNumberValue = licenseNumberControl.field.value;
|
|
29
|
+
var error = (_a = licenseNumberControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
|
|
30
|
+
var length = !isSACountry ? KW_MAX_LICENSE_LENGTH : LICENSE_NUMBER_MAX_LENGTH;
|
|
31
|
+
var minLength = !isSACountry ? KW_MIN_LICENSE_LENGTH : LICENSE_NUMBER_MIN_LENGTH;
|
|
32
|
+
var label = 'license_number';
|
|
33
|
+
var showCheckIcon = (licenseNumberValue === null || licenseNumberValue === void 0 ? void 0 : licenseNumberValue.length) >= minLength;
|
|
34
|
+
return (_jsx(ScreenContainer, { children: _jsx(Input, { label: t(label), required: true, onChange: handleFLNumberChange, inputProps: { maxLength: length }, value: licenseNumberValue || '', endAdornment: showCheckIcon ? _jsx(CheckIcon, {}) : licenseNumberValue && _jsx(ClearIcon, { onClick: clearLicenseNumber }), placeholder: t('license_number_hint'), warningType: 'alert', warningMessage: error && t(error, { length: minLength }) }) }));
|
|
35
|
+
};
|
|
36
|
+
export default React.memo(LicenseNumber);
|
|
@@ -34,6 +34,8 @@ import InputSelect from '../../../shared/InputSelect';
|
|
|
34
34
|
import { getMerchantListAsync, connectExpressSelector } from '../../../app/connectExpress/connectExpressStore';
|
|
35
35
|
import { EndAdornmentExpanded } from '../../../shared/EndAdornment';
|
|
36
36
|
import CheckIcon from '../../../shared/CheckIcon';
|
|
37
|
+
import { ADD_ENTITY } from '../../../../constants';
|
|
38
|
+
import { isNetworkError } from '../../../../utils';
|
|
37
39
|
var MerchantContainer = styled(Box)(function () { return ({
|
|
38
40
|
display: 'flex'
|
|
39
41
|
}); });
|
|
@@ -45,15 +47,16 @@ var MerchantList = React.forwardRef(function (_a, ref) {
|
|
|
45
47
|
var _b, _c;
|
|
46
48
|
var show = _a.show, onListOpen = _a.onListOpen, onListClose = _a.onListClose, readOnly = _a.readOnly, isVerified = _a.isVerified;
|
|
47
49
|
var _d = React.useState([]), list = _d[0], setList = _d[1];
|
|
48
|
-
var _e = React.useState(
|
|
50
|
+
var _e = React.useState(0), count = _e[0], setCount = _e[1];
|
|
51
|
+
var _f = React.useState(null), anchorEl = _f[0], setAnchorEl = _f[1];
|
|
49
52
|
var t = useTranslation().t;
|
|
50
53
|
var dispatch = useAppDispatch();
|
|
51
|
-
var
|
|
52
|
-
var
|
|
54
|
+
var _g = useFormContext(), control = _g.control, watch = _g.watch, setValue = _g.setValue, getValues = _g.getValues;
|
|
55
|
+
var _h = useAppSelector(connectExpressSelector), data = _h.data, merchantLoading = _h.merchantLoading, bckError = _h.error;
|
|
53
56
|
var merchantList = (((_b = data.responseData) === null || _b === void 0 ? void 0 : _b.authenticationData) || {}).merchantList;
|
|
54
57
|
var merchantInfoControl = useController({ control: control, name: 'merchantInfo' });
|
|
55
58
|
var entityInfo = watch('entityInfo');
|
|
56
|
-
var brandInfo =
|
|
59
|
+
var brandInfo = getValues('brandInfo');
|
|
57
60
|
var merchantValue = merchantInfoControl.field.value;
|
|
58
61
|
var error = (_c = merchantInfoControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message;
|
|
59
62
|
React.useEffect(function () {
|
|
@@ -63,26 +66,39 @@ var MerchantList = React.forwardRef(function (_a, ref) {
|
|
|
63
66
|
}
|
|
64
67
|
}, [merchantList]);
|
|
65
68
|
React.useEffect(function () {
|
|
66
|
-
|
|
69
|
+
if (!bckError)
|
|
70
|
+
return;
|
|
71
|
+
if (!isNetworkError(bckError) || count > 2)
|
|
72
|
+
return;
|
|
73
|
+
if ((brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.id) && (entityInfo === null || entityInfo === void 0 ? void 0 : entityInfo.id)) {
|
|
74
|
+
setCount(count + 1);
|
|
75
|
+
dispatch(getMerchantListAsync({ entityId: entityInfo.id, brandId: brandInfo.id }));
|
|
76
|
+
}
|
|
77
|
+
}, [bckError]);
|
|
78
|
+
React.useEffect(function () {
|
|
79
|
+
var _a;
|
|
67
80
|
if (!entityInfo)
|
|
68
81
|
return;
|
|
69
82
|
if (merchantLoading)
|
|
70
83
|
return;
|
|
71
84
|
var brandInfoId = brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.id;
|
|
72
85
|
var entityId = (merchantList === null || merchantList === void 0 ? void 0 : merchantList.length) > 0 ? (_a = merchantList[0]) === null || _a === void 0 ? void 0 : _a.business_entity_id : '';
|
|
73
|
-
var brandId = (merchantList === null || merchantList === void 0 ? void 0 : merchantList.length) > 0 ? (_b = merchantList[0]) === null || _b === void 0 ? void 0 : _b.brand_id : '';
|
|
74
86
|
var id = (entityInfo || {}).id;
|
|
75
|
-
if (!id)
|
|
87
|
+
if (!id || id === ADD_ENTITY)
|
|
76
88
|
return;
|
|
77
|
-
if (
|
|
89
|
+
if (entityId && id && entityId !== id) {
|
|
78
90
|
setValue('merchantInfo', undefined);
|
|
79
91
|
dispatch(getMerchantListAsync({ entityId: id, brandId: brandInfoId }));
|
|
80
92
|
return;
|
|
81
93
|
}
|
|
94
|
+
if (entityId && id && entityId === id && (merchantList === null || merchantList === void 0 ? void 0 : merchantList.length)) {
|
|
95
|
+
setValue('merchantInfo', merchantList[0], { shouldValidate: true });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
82
98
|
if (!(merchantList === null || merchantList === void 0 ? void 0 : merchantList.length)) {
|
|
83
99
|
dispatch(getMerchantListAsync({ entityId: id, brandId: brandInfoId }));
|
|
84
100
|
}
|
|
85
|
-
}, [entityInfo, merchantList
|
|
101
|
+
}, [entityInfo, merchantList]);
|
|
86
102
|
var onOpenMerchantSelect = function (event) {
|
|
87
103
|
if (readOnly)
|
|
88
104
|
return;
|
|
@@ -103,7 +119,7 @@ var MerchantList = React.forwardRef(function (_a, ref) {
|
|
|
103
119
|
return '';
|
|
104
120
|
return merchant.display_name;
|
|
105
121
|
};
|
|
106
|
-
return (_jsx(Collapse, __assign({ in: show && (merchantList === null || merchantList === void 0 ? void 0 : merchantList.length) > 1 }, { children: _jsxs(ScreenContainer, __assign({ ref: ref, sx: { mt: 2.5 } }, { children: [_jsx(InputSelect, { label: t('select_merchant_label'), readOnly: readOnly, placeholder: t('select_merchant_placeholder'), value: getName(
|
|
122
|
+
return (_jsx(Collapse, __assign({ in: show && (merchantList === null || merchantList === void 0 ? void 0 : merchantList.length) > 1 }, { children: _jsxs(ScreenContainer, __assign({ ref: ref, sx: { mt: 2.5 } }, { children: [_jsx(InputSelect, { label: t('select_merchant_label'), readOnly: readOnly, placeholder: t('select_merchant_placeholder'), value: getName(getValues('merchantInfo')) || '', warningMessage: error && t(error), onClick: merchantLoading ? undefined : !!anchorEl ? function () { return onCloseMerchantSelect(); } : onOpenMerchantSelect, endAdornment: merchantLoading ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : (_jsx(EndAdornmentExpanded, { anchorEl: anchorEl, isVerified: isVerified })) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { list: list || [], onSelectItem: onSelectItem, renderItem: function (item) {
|
|
107
123
|
return (_jsxs(_Fragment, { children: [_jsx(MerchantContainer, { children: _jsx(MerchantNameText, __assign({ isSelected: item.id === (merchantValue === null || merchantValue === void 0 ? void 0 : merchantValue.id) }, { children: getName(item) })) }), item.id === (merchantValue === null || merchantValue === void 0 ? void 0 : merchantValue.id) && _jsx(CheckIcon, { isVerified: isVerified })] }));
|
|
108
124
|
} }) }))] })) })));
|
|
109
125
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
-
export declare const AuthenticationListValidationSchema:
|
|
2
|
+
export declare const AuthenticationListValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
3
|
brandInfo: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
4
4
|
entityInfo: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
5
5
|
merchantInfo: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
@@ -12,3 +12,16 @@ export declare const AuthenticationListValidationSchema: () => yup.ObjectSchema<
|
|
|
12
12
|
entityInfo: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
13
13
|
merchantInfo: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
14
14
|
}>>>;
|
|
15
|
+
export declare const AddEntityValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
16
|
+
brandInfo: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
17
|
+
licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
18
|
+
legalName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
19
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
20
|
+
brandInfo: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
21
|
+
licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
22
|
+
legalName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
23
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
24
|
+
brandInfo: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
25
|
+
licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
26
|
+
legalName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
27
|
+
}>>>;
|
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { LICENSE_NUMBER_MIN_LENGTH, REGEX_LEGAL_NAME } from '../../../../constants';
|
|
3
|
+
export var AuthenticationListValidationSchema = yup.object().shape({
|
|
4
|
+
brandInfo: yup.object().required('auth_brand_required'),
|
|
5
|
+
entityInfo: yup.object().required('auth_entity_required'),
|
|
6
|
+
merchantInfo: yup.object().required('auth_merchant_required')
|
|
7
|
+
});
|
|
8
|
+
export var AddEntityValidationSchema = yup.object().shape({
|
|
9
|
+
brandInfo: yup.object().required('auth_brand_required'),
|
|
10
|
+
licenseNumber: yup
|
|
11
|
+
.string()
|
|
12
|
+
.test({
|
|
13
|
+
test: function (value) {
|
|
14
|
+
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
15
|
+
if (length === 0)
|
|
16
|
+
return true;
|
|
17
|
+
return length >= LICENSE_NUMBER_MIN_LENGTH ? true : this.createError({ message: 'enter_license_number' });
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
.required(''),
|
|
21
|
+
legalName: yup
|
|
22
|
+
.string()
|
|
23
|
+
.required('')
|
|
24
|
+
.test({
|
|
25
|
+
test: function (value) {
|
|
26
|
+
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
27
|
+
if (length === 0)
|
|
28
|
+
return true;
|
|
29
|
+
return (value === null || value === void 0 ? void 0 : value.match(REGEX_LEGAL_NAME)) && length >= 3 ? true : this.createError({ message: 'enter_valid_legal_name' });
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
.required('')
|
|
33
|
+
});
|
|
@@ -94,10 +94,14 @@ export default function CustomButton(_a) {
|
|
|
94
94
|
setBtnLoading(false);
|
|
95
95
|
}, [loading, error]);
|
|
96
96
|
React.useEffect(function () {
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
if (loading)
|
|
98
|
+
return;
|
|
99
|
+
var timeout = setTimeout(function () {
|
|
100
|
+
setBtnLoading(false);
|
|
101
|
+
}, 1000);
|
|
102
|
+
return function () {
|
|
103
|
+
clearTimeout(timeout);
|
|
104
|
+
};
|
|
101
105
|
}, [loading]);
|
|
102
106
|
React.useEffect(function () {
|
|
103
107
|
setBtnLoading(false);
|