@tap-payments/auth-jsconnect 2.6.27-test → 2.6.29-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/api/index.d.ts +1 -1
- package/build/api/lead.d.ts +1 -1
- package/build/api/lead.js +3 -3
- package/build/features/app/board/boardStore.js +9 -9
- package/build/features/board/Board.d.ts +1 -0
- package/build/features/board/Board.js +2 -2
- package/build/features/board/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +5 -2
- package/build/features/connect/screens/BusinessCountry/BusinessCountry.js +33 -11
- package/build/features/connectExpress/screens/BusinessCountry/BusinessCountry.js +35 -11
- package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseList.js +6 -5
- package/build/features/shared/BusinessCountry/BusinessCountry.d.ts +7 -3
- package/build/features/shared/BusinessCountry/BusinessCountry.js +6 -4
- package/package.json +1 -1
package/build/api/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ declare const API: {
|
|
|
53
53
|
retrieveLeadIdentity: (leadId: string) => Promise<any>;
|
|
54
54
|
updateLeadExpress: ({ id, ...data }: UpdateLeadBody) => Promise<any>;
|
|
55
55
|
verifyExpressLeadToken: (data: ExpressLeadVerifyBody) => Promise<any>;
|
|
56
|
-
|
|
56
|
+
createVerifyTokenByBoardId: (boardId: string) => Promise<any>;
|
|
57
57
|
};
|
|
58
58
|
entityService: {
|
|
59
59
|
createEntityInfo: ({ id, ...data }: EntityInfoBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
package/build/api/lead.d.ts
CHANGED
|
@@ -105,6 +105,6 @@ declare const leadService: {
|
|
|
105
105
|
retrieveLeadIdentity: (leadId: string) => Promise<any>;
|
|
106
106
|
updateLeadExpress: ({ id, ...data }: UpdateLeadBody) => Promise<any>;
|
|
107
107
|
verifyExpressLeadToken: (data: ExpressLeadVerifyBody) => Promise<any>;
|
|
108
|
-
|
|
108
|
+
createVerifyTokenByBoardId: (boardId: string) => Promise<any>;
|
|
109
109
|
};
|
|
110
110
|
export { leadService };
|
package/build/api/lead.js
CHANGED
|
@@ -97,14 +97,14 @@ var retrieveLeadIdentity = function (leadId) {
|
|
|
97
97
|
url: "".concat(ENDPOINT_PATHS.LEAD, "/").concat(leadId, "/identity")
|
|
98
98
|
});
|
|
99
99
|
};
|
|
100
|
-
var
|
|
100
|
+
var createVerifyTokenByBoardId = function (boardId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
101
101
|
return __generator(this, function (_a) {
|
|
102
102
|
return [2, httpClient({
|
|
103
103
|
method: 'post',
|
|
104
104
|
url: "".concat(ENDPOINT_PATHS.CREATE_TOKEN_PATH),
|
|
105
105
|
data: {
|
|
106
106
|
service_name: 'tap_email',
|
|
107
|
-
|
|
107
|
+
board_id: boardId
|
|
108
108
|
}
|
|
109
109
|
})];
|
|
110
110
|
});
|
|
@@ -120,6 +120,6 @@ var leadService = {
|
|
|
120
120
|
retrieveLeadIdentity: retrieveLeadIdentity,
|
|
121
121
|
updateLeadExpress: updateLeadExpress,
|
|
122
122
|
verifyExpressLeadToken: verifyExpressLeadToken,
|
|
123
|
-
|
|
123
|
+
createVerifyTokenByBoardId: createVerifyTokenByBoardId
|
|
124
124
|
};
|
|
125
125
|
export { leadService };
|
|
@@ -52,39 +52,39 @@ import { FlowsTypes } from '../../../@types';
|
|
|
52
52
|
import { handleCurrentActiveScreen, handleNextScreenStep } from '../../../app/settings';
|
|
53
53
|
import { BOARD_STEP_STEPS } from '../../../constants';
|
|
54
54
|
import { sleep } from '../../../utils';
|
|
55
|
-
export var createVerifyTokenBy = createAsyncThunk('board/
|
|
55
|
+
export var createVerifyTokenBy = createAsyncThunk('board/createVerifyTokenByBoardId', function (boardId, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
56
|
var settings, data, step_name;
|
|
57
57
|
var _a, _b;
|
|
58
58
|
return __generator(this, function (_c) {
|
|
59
59
|
switch (_c.label) {
|
|
60
60
|
case 0:
|
|
61
61
|
settings = thunkApi.getState().settings;
|
|
62
|
-
return [4, API.leadService.
|
|
62
|
+
return [4, API.leadService.createVerifyTokenByBoardId(boardId)];
|
|
63
63
|
case 1:
|
|
64
64
|
data = _c.sent();
|
|
65
65
|
step_name = data.step_name;
|
|
66
66
|
if (step_name == BOARD_STEP_STEPS.PHONE_AUTH) {
|
|
67
67
|
sleep(0).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('BOARD_VERIFY_STEP')); });
|
|
68
|
-
return [2, __assign(
|
|
68
|
+
return [2, __assign({}, data)];
|
|
69
69
|
}
|
|
70
70
|
return [4, thunkApi.dispatch(retrieveBoardDetails(data.id))];
|
|
71
71
|
case 2:
|
|
72
72
|
_c.sent();
|
|
73
|
-
(_b = (_a = settings.data.appConfig).onFlowCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, { boardId: data.id, boardInfoId: data.board_info_id
|
|
73
|
+
(_b = (_a = settings.data.appConfig).onFlowCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, { boardId: data.id, boardInfoId: data.board_info_id });
|
|
74
74
|
sleep(100).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('BOARD_SUCCESS_FLOWS_BUTTONS_STEP')); });
|
|
75
|
-
return [2, __assign(
|
|
75
|
+
return [2, __assign({}, data)];
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
}); });
|
|
79
79
|
export var resendOTP = createAsyncThunk('board/resendOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
-
var board,
|
|
80
|
+
var board, boardId, data;
|
|
81
81
|
var _a, _b;
|
|
82
82
|
return __generator(this, function (_c) {
|
|
83
83
|
switch (_c.label) {
|
|
84
84
|
case 0:
|
|
85
85
|
board = thunkApi.getState().board;
|
|
86
|
-
|
|
87
|
-
return [4, API.leadService.
|
|
86
|
+
boardId = (_b = (_a = board.data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : '';
|
|
87
|
+
return [4, API.leadService.createVerifyTokenByBoardId(boardId)];
|
|
88
88
|
case 1:
|
|
89
89
|
data = _c.sent();
|
|
90
90
|
return [2, { data: data }];
|
|
@@ -115,7 +115,7 @@ export var verifyBoardLeadOTP = createAsyncThunk('board/verifyBoardLeadOTP', fun
|
|
|
115
115
|
case 2:
|
|
116
116
|
_g.sent();
|
|
117
117
|
(_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
|
|
118
|
-
(_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { boardId: responseBody === null || responseBody === void 0 ? void 0 : responseBody.id, boardInfoId: responseBody === null || responseBody === void 0 ? void 0 : responseBody.board_info_id
|
|
118
|
+
(_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { boardId: responseBody === null || responseBody === void 0 ? void 0 : responseBody.id, boardInfoId: responseBody === null || responseBody === void 0 ? void 0 : responseBody.board_info_id });
|
|
119
119
|
sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('BOARD_SUCCESS_FLOWS_BUTTONS_STEP')); });
|
|
120
120
|
return [2, { data: data, formData: params }];
|
|
121
121
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { LibConfig } from '../../@types';
|
|
3
3
|
export interface BoardLibProps extends LibConfig {
|
|
4
4
|
configToken: string;
|
|
5
|
+
boardId: string;
|
|
5
6
|
}
|
|
6
7
|
export declare function BoardElement(props: BoardLibProps): JSX.Element;
|
|
7
8
|
export declare function renderBoardLib(config: BoardLibProps, elementId: string): {
|
|
@@ -36,7 +36,7 @@ import { boardFeatureScreens } from '../featuresScreens';
|
|
|
36
36
|
import { createVerifyTokenBy, boardSelector } from '../../features/app/board/boardStore';
|
|
37
37
|
import Background from '../shared/Background';
|
|
38
38
|
var Board = memo(function (_a) {
|
|
39
|
-
var configToken = _a.configToken, props = __rest(_a, ["configToken"]);
|
|
39
|
+
var configToken = _a.configToken, boardId = _a.boardId, props = __rest(_a, ["configToken", "boardId"]);
|
|
40
40
|
var theme = useAppTheme().theme;
|
|
41
41
|
var _b = useAppSelector(settingsSelector), data = _b.data, error = _b.error, settingLoading = _b.loading;
|
|
42
42
|
var _c = useAppSelector(boardSelector), customLoading = _c.customLoading, loading = _c.loading, bankError = _c.error;
|
|
@@ -53,7 +53,7 @@ var Board = memo(function (_a) {
|
|
|
53
53
|
React.useEffect(function () {
|
|
54
54
|
if (data.isValidOperator && props.open && !settingLoading) {
|
|
55
55
|
console.log('data', data);
|
|
56
|
-
dispatch(createVerifyTokenBy(
|
|
56
|
+
dispatch(createVerifyTokenBy(boardId));
|
|
57
57
|
}
|
|
58
58
|
}, [data.isValidOperator, settingLoading]);
|
|
59
59
|
var initialLoading = settingLoading || customLoading;
|
|
@@ -24,8 +24,11 @@ var SuccessWithFlowButtons = function () {
|
|
|
24
24
|
var _b = data.verify.responseBody || {}, flows = _b.flows, entity = _b.entity, brand = _b.brand, bank = _b.bank_account, merchant = _b.merchant, user = _b.user, business = _b.business, board_id = _b.board_id, board_info_id = _b.board_info_id, name = _b.name, individuals = _b.individuals;
|
|
25
25
|
var onClose = function () {
|
|
26
26
|
var url = settingsData.appConfig.redirectUrl;
|
|
27
|
-
if (url)
|
|
28
|
-
|
|
27
|
+
if (!url)
|
|
28
|
+
return;
|
|
29
|
+
var newUrl = new URL(url);
|
|
30
|
+
newUrl.searchParams.append('action', 'close');
|
|
31
|
+
window.open("".concat(newUrl), '_self', '_blank');
|
|
29
32
|
};
|
|
30
33
|
return (_jsx(SuccessFlowButtons, { flowName: data.flowName, loading: loading, bank: bank, brand: brand, entity: entity, merchant: merchant, user: __assign({ names: { en: name } }, user), business: business, boardId: board_id, boardInfoId: board_info_id, individuals: individuals, flows: flows || [], onClose: onClose }));
|
|
31
34
|
};
|
|
@@ -1,3 +1,14 @@
|
|
|
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
|
+
};
|
|
1
12
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
13
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,41 +45,50 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
46
|
}
|
|
36
47
|
};
|
|
37
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
48
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
38
49
|
import * as React from 'react';
|
|
39
|
-
import {
|
|
50
|
+
import { useTranslation } from 'react-i18next';
|
|
51
|
+
import { useAppSelector, useAppDispatch, useLanguage } from '../../../../hooks';
|
|
40
52
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
41
53
|
import BusinessCountry from '../../../shared/BusinessCountry';
|
|
54
|
+
import Button from '../../../shared/Button';
|
|
42
55
|
import { findCountryByIso2, isKW, isOtherThanKWOrSA } from '../../../../utils';
|
|
56
|
+
import Collapse from '../../../../components/Collapse';
|
|
43
57
|
import { handleNextScreenStep, handleSetCountryByIso2, settingsSelector } from '../../../../app/settings';
|
|
44
|
-
import { connectSelector, setDefaultCountryCode, updateBusinessCountry, storeIsStartFromBusinessCountry } from '../../../app/connect/connectStore';
|
|
58
|
+
import { connectSelector, setDefaultCountryCode, updateBusinessCountry, storeIsStartFromBusinessCountry, clearError } from '../../../app/connect/connectStore';
|
|
45
59
|
var BusinessCountryScreen = function (_a) {
|
|
46
60
|
var dispatch = useAppDispatch();
|
|
61
|
+
var isAr = useLanguage().isAr;
|
|
62
|
+
var t = useTranslation().t;
|
|
63
|
+
var _b = React.useState(false), isListOpen = _b[0], setListOpen = _b[1];
|
|
47
64
|
var settingsData = useAppSelector(settingsSelector).data;
|
|
48
|
-
var
|
|
65
|
+
var _c = useAppSelector(connectSelector), data = _c.data, loading = _c.loading, error = _c.error;
|
|
49
66
|
React.useEffect(function () {
|
|
67
|
+
dispatch(clearError());
|
|
50
68
|
dispatch(storeIsStartFromBusinessCountry(true));
|
|
51
69
|
}, []);
|
|
52
70
|
var defaultValue = React.useMemo(function () {
|
|
53
71
|
var _a, _b;
|
|
54
|
-
|
|
72
|
+
var value = ((_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2) || ((_b = settingsData.ipCountry) === null || _b === void 0 ? void 0 : _b.iso2);
|
|
73
|
+
setListOpen(!!value);
|
|
74
|
+
return value;
|
|
55
75
|
}, [settingsData.businessCountry, settingsData.ipCountry]);
|
|
56
|
-
var onSelectCountry = function (
|
|
76
|
+
var onSelectCountry = function (iso2) { return __awaiter(void 0, void 0, void 0, function () {
|
|
57
77
|
var countryCode;
|
|
58
78
|
return __generator(this, function (_a) {
|
|
59
79
|
switch (_a.label) {
|
|
60
80
|
case 0:
|
|
61
|
-
countryCode = findCountryByIso2(settingsData.countries,
|
|
62
|
-
dispatch(handleSetCountryByIso2(
|
|
81
|
+
countryCode = findCountryByIso2(settingsData.countries, iso2);
|
|
82
|
+
dispatch(handleSetCountryByIso2(iso2));
|
|
63
83
|
if (!data.leadId) return [3, 2];
|
|
64
|
-
return [4, dispatch(updateBusinessCountry(
|
|
84
|
+
return [4, dispatch(updateBusinessCountry(iso2))];
|
|
65
85
|
case 1:
|
|
66
86
|
_a.sent();
|
|
67
87
|
_a.label = 2;
|
|
68
88
|
case 2:
|
|
69
89
|
if (countryCode)
|
|
70
90
|
dispatch(setDefaultCountryCode(countryCode));
|
|
71
|
-
if (isOtherThanKWOrSA(
|
|
91
|
+
if (isOtherThanKWOrSA(iso2) || isKW(iso2)) {
|
|
72
92
|
dispatch(handleNextScreenStep('CONNECT_MOBILE_STEP'));
|
|
73
93
|
return [2];
|
|
74
94
|
}
|
|
@@ -77,6 +97,8 @@ var BusinessCountryScreen = function (_a) {
|
|
|
77
97
|
}
|
|
78
98
|
});
|
|
79
99
|
}); };
|
|
80
|
-
return (
|
|
100
|
+
return (_jsxs(ScreenContainer, { children: [_jsx(BusinessCountry, { sx: { mb: 2.5 }, countries: settingsData.businessCountries, loading: loading, defaultCountryIso2: defaultValue, onSelectCountry: onSelectCountry, onListOpen: function () { return setListOpen(true); }, onListClose: function () { return setListOpen(false); } }), _jsx(Collapse, __assign({ in: !isListOpen }, { children: _jsx(Button, __assign({ onClick: function () {
|
|
101
|
+
onSelectCountry(defaultValue);
|
|
102
|
+
}, loading: loading, isAr: isAr, disableBack: true, disabled: !defaultValue, error: t(error || '') }, { children: t('next') })) }))] }));
|
|
81
103
|
};
|
|
82
104
|
export default React.memo(BusinessCountryScreen);
|
|
@@ -1,3 +1,14 @@
|
|
|
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
|
+
};
|
|
1
12
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
13
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,41 +45,52 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
46
|
}
|
|
36
47
|
};
|
|
37
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
48
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
38
49
|
import * as React from 'react';
|
|
39
|
-
import {
|
|
50
|
+
import { useTranslation } from 'react-i18next';
|
|
51
|
+
import { useAppSelector, useAppDispatch, useLanguage } from '../../../../hooks';
|
|
40
52
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
41
53
|
import BusinessCountry from '../../../shared/BusinessCountry';
|
|
54
|
+
import Button from '../../../shared/Button';
|
|
55
|
+
import Collapse from '../../../../components/Collapse';
|
|
42
56
|
import { findCountryByIso2, isKW, isOtherThanKWOrSA } from '../../../../utils';
|
|
43
57
|
import { handleNextScreenStep, handleSetCountryByIso2, settingsSelector } from '../../../../app/settings';
|
|
44
|
-
import { connectExpressSelector, setDefaultCountryCode, storeIsStartFromBusinessCountry, updateBusinessCountryAsync } from '../../../app/connectExpress/connectExpressStore';
|
|
58
|
+
import { clearError, connectExpressSelector, setDefaultCountryCode, storeIsStartFromBusinessCountry, updateBusinessCountryAsync } from '../../../app/connectExpress/connectExpressStore';
|
|
45
59
|
var BusinessCountryScreen = function (_a) {
|
|
46
60
|
var dispatch = useAppDispatch();
|
|
61
|
+
var isAr = useLanguage().isAr;
|
|
62
|
+
var t = useTranslation().t;
|
|
63
|
+
var _b = React.useState(false), isListOpen = _b[0], setListOpen = _b[1];
|
|
47
64
|
var settingsData = useAppSelector(settingsSelector).data;
|
|
48
|
-
var
|
|
65
|
+
var _c = useAppSelector(connectExpressSelector), data = _c.data, loading = _c.loading, error = _c.error;
|
|
49
66
|
React.useEffect(function () {
|
|
67
|
+
dispatch(clearError());
|
|
50
68
|
dispatch(storeIsStartFromBusinessCountry(true));
|
|
51
69
|
}, []);
|
|
52
70
|
var defaultValue = React.useMemo(function () {
|
|
53
71
|
var _a, _b;
|
|
54
|
-
|
|
72
|
+
var value = ((_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2) || ((_b = settingsData.ipCountry) === null || _b === void 0 ? void 0 : _b.iso2);
|
|
73
|
+
setListOpen(!!value);
|
|
74
|
+
return value;
|
|
55
75
|
}, [settingsData.businessCountry, settingsData.ipCountry]);
|
|
56
|
-
var onSelectCountry = function (
|
|
76
|
+
var onSelectCountry = function (iso2) { return __awaiter(void 0, void 0, void 0, function () {
|
|
57
77
|
var countryCode;
|
|
58
78
|
return __generator(this, function (_a) {
|
|
59
79
|
switch (_a.label) {
|
|
60
80
|
case 0:
|
|
61
|
-
|
|
62
|
-
|
|
81
|
+
if (!iso2)
|
|
82
|
+
return [2];
|
|
83
|
+
countryCode = findCountryByIso2(settingsData.countries, iso2);
|
|
84
|
+
dispatch(handleSetCountryByIso2(iso2));
|
|
63
85
|
if (!data.leadId) return [3, 2];
|
|
64
|
-
return [4, dispatch(updateBusinessCountryAsync(
|
|
86
|
+
return [4, dispatch(updateBusinessCountryAsync(iso2))];
|
|
65
87
|
case 1:
|
|
66
88
|
_a.sent();
|
|
67
89
|
_a.label = 2;
|
|
68
90
|
case 2:
|
|
69
91
|
if (countryCode)
|
|
70
92
|
dispatch(setDefaultCountryCode(countryCode));
|
|
71
|
-
if (isOtherThanKWOrSA(
|
|
93
|
+
if (isOtherThanKWOrSA(iso2) || isKW(iso2)) {
|
|
72
94
|
dispatch(handleNextScreenStep('CONNECT_EXPRESS_MOBILE_STEP'));
|
|
73
95
|
return [2];
|
|
74
96
|
}
|
|
@@ -77,6 +99,8 @@ var BusinessCountryScreen = function (_a) {
|
|
|
77
99
|
}
|
|
78
100
|
});
|
|
79
101
|
}); };
|
|
80
|
-
return (
|
|
102
|
+
return (_jsxs(ScreenContainer, { children: [_jsx(BusinessCountry, { sx: { mb: 2.5 }, countries: settingsData.businessCountries, loading: loading, defaultCountryIso2: defaultValue, onSelectCountry: onSelectCountry, onListOpen: function () { return setListOpen(true); }, onListClose: function () { return setListOpen(false); } }), _jsx(Collapse, __assign({ in: !isListOpen }, { children: _jsx(Button, __assign({ onClick: function () {
|
|
103
|
+
onSelectCountry(defaultValue);
|
|
104
|
+
}, loading: loading, isAr: isAr, disableBack: true, disabled: !defaultValue, error: t(error || '') }, { children: t('next') })) }))] }));
|
|
81
105
|
};
|
|
82
106
|
export default React.memo(BusinessCountryScreen);
|
|
@@ -28,7 +28,7 @@ import Box from '@mui/material/Box';
|
|
|
28
28
|
import { styled } from '@mui/material/styles';
|
|
29
29
|
import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
|
|
30
30
|
import { BusinessType } from '../../../../@types';
|
|
31
|
-
import { isKW, isOtherLicense, isSA } from '../../../../utils';
|
|
31
|
+
import { isKW, isOtherLicense, isOtherThanKWOrSA, isSA } from '../../../../utils';
|
|
32
32
|
import { settingsSelector } from '../../../../app/settings';
|
|
33
33
|
import { OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../../constants';
|
|
34
34
|
import SimpleList from '../../../../components/SimpleList';
|
|
@@ -80,8 +80,9 @@ var LicenseList = function (_a) {
|
|
|
80
80
|
setAnchorEl(null);
|
|
81
81
|
(_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
82
82
|
};
|
|
83
|
-
var
|
|
83
|
+
var isOtherThanKWOrSACountry = React.useMemo(function () { return isOtherThanKWOrSA(country_code); }, [country_code]);
|
|
84
84
|
var isKWCountry = React.useMemo(function () { return isKW(country_code); }, [country_code]);
|
|
85
|
+
var isSACountry = React.useMemo(function () { return isSA(country_code); }, [country_code]);
|
|
85
86
|
React.useEffect(function () {
|
|
86
87
|
if ((licenseList || []).length > 0)
|
|
87
88
|
setValue('licenseList', licenseList);
|
|
@@ -132,8 +133,8 @@ var LicenseList = function (_a) {
|
|
|
132
133
|
var licenseReadonly = !isOtherLicense(selected);
|
|
133
134
|
var isCR = (selected === null || selected === void 0 ? void 0 : selected.type) === BusinessType.CR;
|
|
134
135
|
var flValue = isOtherLicense(selected) ? t(getLicenseName(selected)) : getLicenseNumber(selected);
|
|
135
|
-
return (_jsxs(ScreenContainer, { children: [_jsx(InputStyled, { label: t('choose_any_license'), readOnly: readOnly, 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) {
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
return (_jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: isSACountry || isOtherThanKWOrSACountry }, { children: [_jsx(InputStyled, { label: t('choose_any_license'), readOnly: readOnly, 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) {
|
|
137
|
+
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, {})] }));
|
|
138
|
+
} }) }))] })), _jsx(LicenseType, { show: show && isKWCountry, readOnly: readOnly }), _jsx(LicenseNumber, { show: isKWCountry ? isCR : show, readOnly: licenseReadonly })] }));
|
|
138
139
|
};
|
|
139
140
|
export default React.memo(LicenseList);
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
import { BusinessCountryInfo } from '../../../@types';
|
|
3
4
|
interface BusinessCountryProps {
|
|
5
|
+
onListOpen?: () => void;
|
|
6
|
+
onListClose?: () => void;
|
|
4
7
|
countries: Array<BusinessCountryInfo>;
|
|
5
8
|
loading: boolean;
|
|
6
9
|
defaultCountryIso2: string;
|
|
7
|
-
onSelectCountry: (
|
|
10
|
+
onSelectCountry: (iso2: string) => void;
|
|
11
|
+
sx?: SxProps<Theme>;
|
|
8
12
|
}
|
|
9
|
-
declare const BusinessCountry: ({ countries, loading, defaultCountryIso2, onSelectCountry }: BusinessCountryProps) => JSX.Element;
|
|
13
|
+
declare const BusinessCountry: ({ sx, onListOpen, onListClose, countries, loading, defaultCountryIso2, onSelectCountry }: BusinessCountryProps) => JSX.Element;
|
|
10
14
|
export default BusinessCountry;
|
|
@@ -96,9 +96,9 @@ var CountryListStyled = styled((SimpleList))(function () { return ({
|
|
|
96
96
|
}); });
|
|
97
97
|
var BusinessCountry = function (_a) {
|
|
98
98
|
var _b, _c;
|
|
99
|
-
var countries = _a.countries, loading = _a.loading, defaultCountryIso2 = _a.defaultCountryIso2, onSelectCountry = _a.onSelectCountry;
|
|
99
|
+
var sx = _a.sx, onListOpen = _a.onListOpen, onListClose = _a.onListClose, countries = _a.countries, loading = _a.loading, defaultCountryIso2 = _a.defaultCountryIso2, onSelectCountry = _a.onSelectCountry;
|
|
100
100
|
var _d = React.useState(countries || []), countryList = _d[0], setCountryList = _d[1];
|
|
101
|
-
var _e = React.useState(
|
|
101
|
+
var _e = React.useState(!!defaultCountryIso2), open = _e[0], setOpen = _e[1];
|
|
102
102
|
var _f = React.useState(''), subIndex = _f[0], setSubIndex = _f[1];
|
|
103
103
|
var _g = React.useState(), selectedCountry = _g[0], setSelectedCountry = _g[1];
|
|
104
104
|
var t = useTranslation().t;
|
|
@@ -107,17 +107,19 @@ var BusinessCountry = function (_a) {
|
|
|
107
107
|
var onSelectItem = function (item) { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
108
|
return __generator(this, function (_a) {
|
|
109
109
|
setSelectedCountry(item);
|
|
110
|
-
onSelectCountry(item);
|
|
110
|
+
onSelectCountry(item.country.iso2);
|
|
111
111
|
return [2];
|
|
112
112
|
});
|
|
113
113
|
}); };
|
|
114
114
|
var handleCloseMainMenu = function () {
|
|
115
115
|
setOpen(false);
|
|
116
116
|
handleSearch('');
|
|
117
|
+
onListClose === null || onListClose === void 0 ? void 0 : onListClose();
|
|
117
118
|
};
|
|
118
119
|
var handleOpenMainMenu = function () {
|
|
119
120
|
setCountryList(countries);
|
|
120
121
|
setOpen(true);
|
|
122
|
+
onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
|
|
121
123
|
};
|
|
122
124
|
var handleOpenSubMenu = function (index) {
|
|
123
125
|
if (subIndex === index)
|
|
@@ -150,7 +152,7 @@ var BusinessCountry = function (_a) {
|
|
|
150
152
|
});
|
|
151
153
|
setCountryList(filteredList);
|
|
152
154
|
};
|
|
153
|
-
return (_jsxs(ScreenContainer, __assign({ sx: { pb: 2.5 } }, { children: [_jsx(InputSelect, { required: true, label: t('country_list_title'), value: (isAr ? (_b = countryValue === null || countryValue === void 0 ? void 0 : countryValue.country) === null || _b === void 0 ? void 0 : _b.name_ar : (_c = countryValue === null || countryValue === void 0 ? void 0 : countryValue.country) === null || _c === void 0 ? void 0 : _c.name_en) || '', onClick: open ? handleCloseMainMenu : handleOpenMainMenu, placeholder: t('choose_any_country'), endAdornment: _jsx(ExpandIcon, { anchorEl: open }) }), _jsxs(Collapse, __assign({ in: open }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { sx: { maxHeight: '350px', paddingTop: 0 }, list: countryList, listItemProps: { sx: { padding: 0 } }, onSelectItem: function (item, e) {
|
|
155
|
+
return (_jsxs(ScreenContainer, __assign({ sx: __assign({ pb: 2.5 }, sx) }, { children: [_jsx(InputSelect, { required: true, label: t('country_list_title'), value: (isAr ? (_b = countryValue === null || countryValue === void 0 ? void 0 : countryValue.country) === null || _b === void 0 ? void 0 : _b.name_ar : (_c = countryValue === null || countryValue === void 0 ? void 0 : countryValue.country) === null || _c === void 0 ? void 0 : _c.name_en) || '', onClick: open ? handleCloseMainMenu : handleOpenMainMenu, placeholder: t('choose_any_country'), endAdornment: _jsx(ExpandIcon, { anchorEl: open }) }), _jsxs(Collapse, __assign({ in: open }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { sx: { maxHeight: '350px', paddingTop: 0 }, list: countryList, listItemProps: { sx: { padding: 0 } }, onSelectItem: function (item, e) {
|
|
154
156
|
e.stopPropagation();
|
|
155
157
|
handleOpenSubMenu(item.id.toString());
|
|
156
158
|
}, renderItem: function (item) {
|