@tap-payments/auth-jsconnect 1.0.20 → 1.0.23
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 +0 -9
- package/build/@types/form.d.ts +3 -0
- package/build/@types/redux.d.ts +1 -0
- package/build/api/availabilityServices.d.ts +12 -0
- package/build/api/availabilityServices.js +13 -0
- package/build/api/index.d.ts +6 -1
- package/build/api/index.js +3 -1
- package/build/app/settings.d.ts +2 -2
- package/build/app/settings.js +12 -8
- package/build/assets/locales/ar.json +2 -1
- package/build/assets/locales/en.json +2 -1
- package/build/components/Button/Button.js +1 -1
- package/build/constants/api.d.ts +2 -0
- package/build/constants/api.js +5 -1
- package/build/constants/app.js +3 -3
- package/build/features/app/connect/connectStore.d.ts +24 -4
- package/build/features/app/connect/connectStore.js +140 -17
- package/build/features/bank/screens/BankDetails/BankName.js +6 -1
- package/build/features/business/screens/Activities/Activities.js +6 -2
- package/build/features/business/screens/Activities/ActivitiesList.d.ts +1 -1
- package/build/features/business/screens/Customers/CustomerLocations.d.ts +3 -2
- package/build/features/business/screens/Customers/CustomerLocations.js +3 -3
- package/build/features/business/screens/Customers/Customers.js +19 -1
- package/build/features/business/screens/Customers/ExpectedCustomers.d.ts +1 -0
- package/build/features/business/screens/Customers/ExpectedCustomers.js +3 -3
- package/build/features/business/screens/Customers/ExpectedSalesRange.d.ts +1 -0
- package/build/features/business/screens/Customers/ExpectedSalesRange.js +3 -3
- package/build/features/business/screens/VerifyNumber/VerifyNumber.js +1 -1
- package/build/features/connect/screens/Individual/Email.d.ts +2 -1
- package/build/features/connect/screens/Individual/Email.js +29 -3
- package/build/features/connect/screens/Individual/Individual.js +22 -9
- package/build/features/connect/screens/Individual/MobileNumber.d.ts +2 -0
- package/build/features/connect/screens/Individual/MobileNumber.js +8 -4
- package/build/features/connect/screens/Individual/Name.d.ts +2 -1
- package/build/features/connect/screens/Individual/Name.js +3 -1
- package/build/features/connect/screens/Merchant/BrandName.js +9 -0
- package/build/features/connect/screens/Merchant/Merchant.js +8 -2
- package/build/features/connect/screens/Merchant/validation.js +1 -1
- package/build/features/connect/screens/Mobile/Mobile.js +5 -4
- package/build/features/connect/screens/Mobile/MobileNumber.js +6 -6
- package/build/features/connect/screens/NID/DOB.js +12 -2
- package/build/features/connect/screens/NID/NID.js +6 -3
- package/build/features/connect/screens/NID/validation.js +1 -2
- package/build/features/connect/screens/OTP/OTP.js +4 -3
- package/build/features/connect/screens/OTP/OTPInput.js +7 -3
- package/build/features/connect/screens/Password/Password.js +17 -11
- package/build/features/connect/screens/Password/PasswordInput.js +1 -1
- package/build/features/connect/screens/ThankYou/ThankYou.js +6 -1
- package/build/features/shared/Button/Button.js +20 -6
- package/build/utils/string.d.ts +1 -0
- package/build/utils/string.js +5 -4
- package/package.json +3 -1
|
@@ -35,7 +35,7 @@ export declare const NameContainer: import("@emotion/styled").StyledComponent<im
|
|
|
35
35
|
export declare const CheckIconStyled: import("@emotion/styled").StyledComponent<{
|
|
36
36
|
children?: React.ReactNode;
|
|
37
37
|
classes?: Partial<import("@mui/material").SvgIconClasses> | undefined;
|
|
38
|
-
color?: "inherit" | "disabled" | "error" | "
|
|
38
|
+
color?: "inherit" | "disabled" | "error" | "primary" | "secondary" | "action" | "info" | "success" | "warning" | undefined;
|
|
39
39
|
fontSize?: "small" | "inherit" | "medium" | "large" | undefined;
|
|
40
40
|
htmlColor?: string | undefined;
|
|
41
41
|
inheritViewBox?: boolean | undefined;
|
|
@@ -49,7 +49,7 @@ export declare const CheckIconStyled: import("@emotion/styled").StyledComponent<
|
|
|
49
49
|
export declare const RemainingCheck: import("@emotion/styled").StyledComponent<{
|
|
50
50
|
children?: React.ReactNode;
|
|
51
51
|
classes?: Partial<import("@mui/material").SvgIconClasses> | undefined;
|
|
52
|
-
color?: "inherit" | "disabled" | "error" | "
|
|
52
|
+
color?: "inherit" | "disabled" | "error" | "primary" | "secondary" | "action" | "info" | "success" | "warning" | undefined;
|
|
53
53
|
fontSize?: "small" | "inherit" | "medium" | "large" | undefined;
|
|
54
54
|
htmlColor?: string | undefined;
|
|
55
55
|
inheritViewBox?: boolean | undefined;
|
|
@@ -61,6 +61,7 @@ export declare const RemainingCheck: import("@emotion/styled").StyledComponent<{
|
|
|
61
61
|
ref?: ((instance: SVGSVGElement | null) => void) | React.RefObject<SVGSVGElement> | null | undefined;
|
|
62
62
|
}, keyof import("@mui/material/OverridableComponent").CommonProps | "color" | "fontSize" | "shapeRendering" | "children" | "sx" | "htmlColor" | "inheritViewBox" | "titleAccess" | "viewBox"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
63
63
|
interface CustomerLocationsProps {
|
|
64
|
+
show: boolean;
|
|
64
65
|
onListOpen?: () => void;
|
|
65
66
|
onListClose?: () => void;
|
|
66
67
|
}
|
|
@@ -101,8 +101,8 @@ var customerLocations = function (_a) {
|
|
|
101
101
|
};
|
|
102
102
|
var customerLocationsValue = customerLocationsControl.field.value;
|
|
103
103
|
var customerLocationSelected = customerLocationsValue[customerLocationsValue.length - 1];
|
|
104
|
-
return (_jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('select_customer_base') }), _jsx(InputStyled, { readOnly: true, value: isAr ? customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.nameAR : customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: customerLocationsList, placeholder: 'choose_customer_base', onSelectItem: onSelectItem, renderItem: function (item) {
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('select_customer_base') }), _jsx(InputStyled, { readOnly: true, value: isAr ? customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.nameAR : customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: customerLocationsList, placeholder: 'choose_customer_base', onSelectItem: onSelectItem, renderItem: function (item) {
|
|
105
|
+
return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (customerLocationsValue === null || customerLocationsValue === void 0 ? void 0 : customerLocationsValue.id) }, { children: isAr ? item.nameAR : item.name })) })), item.id === (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(CheckIconStyled, {}), checkRemainingCondition(item) && item.id != (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(RemainingCheck, {})] }));
|
|
106
|
+
} }) }))] }) })));
|
|
107
107
|
};
|
|
108
108
|
export default React.memo(customerLocations);
|
|
@@ -29,11 +29,19 @@ import { CUSTOMER_LOCATIONS, EXPECTED_CUSTOMERS, EXPECTED_SALES_RANGE } from '..
|
|
|
29
29
|
import RefundPolicy from './RefundPolicy';
|
|
30
30
|
import TransactionPolicy from './TransactionPolicy';
|
|
31
31
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
32
|
+
import Collapse from '../../../../components/Collapse';
|
|
32
33
|
var FormStyled = styled(Form)(function () { return ({
|
|
33
34
|
display: 'flex',
|
|
34
35
|
flexDirection: 'column'
|
|
35
36
|
}); });
|
|
37
|
+
var ListType;
|
|
38
|
+
(function (ListType) {
|
|
39
|
+
ListType["CustomerLocationsList"] = "CustomerLocationsList";
|
|
40
|
+
ListType["ExpectedCustomersList"] = "ExpectedCustomersList";
|
|
41
|
+
ListType["ExpectedSalesList"] = "ExpectedSalesList";
|
|
42
|
+
})(ListType || (ListType = {}));
|
|
36
43
|
var Customers = function (_a) {
|
|
44
|
+
var _b = React.useState(), listActive = _b[0], setListActive = _b[1];
|
|
37
45
|
var dispatch = useAppDispatch();
|
|
38
46
|
var methods = useForm({
|
|
39
47
|
resolver: yupResolver(CustomerInfoValidation),
|
|
@@ -55,6 +63,16 @@ var Customers = function (_a) {
|
|
|
55
63
|
};
|
|
56
64
|
var t = useTranslation().t;
|
|
57
65
|
var isAr = useLanguage().isAr;
|
|
58
|
-
|
|
66
|
+
var handleMenuClick = function (flag) {
|
|
67
|
+
setListActive(flag);
|
|
68
|
+
};
|
|
69
|
+
var isCustomerLocationsListActive = listActive === ListType.CustomerLocationsList;
|
|
70
|
+
var isExpectedCustomersListActive = listActive === ListType.ExpectedCustomersList;
|
|
71
|
+
var isExpectedSalesListActive = listActive === ListType.ExpectedSalesList;
|
|
72
|
+
var whenNotSelectCustomersLocation = !isExpectedCustomersListActive && !isExpectedSalesListActive;
|
|
73
|
+
var whenNotSelectExpectedCustomers = !isCustomerLocationsListActive && !isExpectedSalesListActive;
|
|
74
|
+
var whenNotSelectExpectedSales = !isCustomerLocationsListActive && !isExpectedCustomersListActive;
|
|
75
|
+
var isAnyListSelected = !isExpectedCustomersListActive && !isCustomerLocationsListActive && !isExpectedSalesListActive;
|
|
76
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(CustomerLocations, { show: whenNotSelectCustomersLocation, onListOpen: function () { return handleMenuClick(ListType.CustomerLocationsList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(ExpectedCustomers, { show: whenNotSelectExpectedCustomers, onListOpen: function () { return handleMenuClick(ListType.ExpectedCustomersList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(ExpectedSales, { show: whenNotSelectExpectedSales, onListOpen: function () { return handleMenuClick(ListType.ExpectedSalesList); }, onListClose: function () { return handleMenuClick(); } }), _jsxs(Collapse, __assign({ in: isAnyListSelected }, { children: [_jsx(RefundPolicy, {}), _jsx(TransactionPolicy, {}), _jsx(Box, __assign({ sx: { mt: 2 } }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: !methods.formState.isValid, isAr: isAr }, { children: t('next') })) }))] }))] })) })) }));
|
|
59
77
|
};
|
|
60
78
|
export default React.memo(Customers);
|
|
@@ -67,8 +67,8 @@ var ExpectedCustomers = function (_a) {
|
|
|
67
67
|
};
|
|
68
68
|
var expectedCustomersValue = expectedCustomersControl.field.value;
|
|
69
69
|
var expectedCustomersSelected = expectedCustomersValue;
|
|
70
|
-
return (_jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_customers_to_serve') }), _jsx(InputStyled, { readOnly: true, value: isAr ? expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.nameAR : expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.name, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: expectedCustomersList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_customers_to_serve') }), _jsx(InputStyled, { readOnly: true, value: isAr ? expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.nameAR : expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.name, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: expectedCustomersList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
71
|
+
return (_jsxs(_Fragment, { children: [_jsx(ListItemContainer, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (expectedCustomersValue === null || expectedCustomersValue === void 0 ? void 0 : expectedCustomersValue.id) }, { children: isAr ? item.nameAR : item.name })) }), item.id === (expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.id) && _jsx(CheckIconStyled, {})] }));
|
|
72
|
+
} }) }))] }) })));
|
|
73
73
|
};
|
|
74
74
|
export default ExpectedCustomers;
|
|
@@ -68,8 +68,8 @@ var ExpectedSalesRange = function (_a) {
|
|
|
68
68
|
};
|
|
69
69
|
var expectedSalesRangeValue = expectedSalesRangeControl.field.value || expectedSalesRangeList;
|
|
70
70
|
var expectedSalesRangeSelected = expectedSalesRangeValue;
|
|
71
|
-
return (_jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_sales_yearly') }), _jsx(InputStyled, { readOnly: true, value: isAr ? expectedSalesRangeSelected === null || expectedSalesRangeSelected === void 0 ? void 0 : expectedSalesRangeSelected.nameAR : expectedSalesRangeSelected === null || expectedSalesRangeSelected === void 0 ? void 0 : expectedSalesRangeSelected.name, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, placeholder: t('choose_expected_sales'), endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: expectedSalesRangeList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_sales_yearly') }), _jsx(InputStyled, { readOnly: true, value: isAr ? expectedSalesRangeSelected === null || expectedSalesRangeSelected === void 0 ? void 0 : expectedSalesRangeSelected.nameAR : expectedSalesRangeSelected === null || expectedSalesRangeSelected === void 0 ? void 0 : expectedSalesRangeSelected.name, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, placeholder: t('choose_expected_sales'), endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: expectedSalesRangeList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
72
|
+
return (_jsxs(_Fragment, { children: [_jsx(ListItemContainer, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.id) }, { children: isAr ? item.nameAR : item.name })) }), item.id === (expectedSalesRangeSelected === null || expectedSalesRangeSelected === void 0 ? void 0 : expectedSalesRangeSelected.id) && _jsx(CheckIconStyled, {})] }));
|
|
73
|
+
} }) }))] }) })));
|
|
74
74
|
};
|
|
75
75
|
export default ExpectedSalesRange;
|
|
@@ -67,7 +67,7 @@ var VerifyNumber = function (_a) {
|
|
|
67
67
|
dispatch(handlePrevScreenStep());
|
|
68
68
|
};
|
|
69
69
|
var loading = false;
|
|
70
|
-
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : t('ide_opt_sent_title'), _jsx("span", __assign({ dir: 'ltr' }, { children: "".concat(
|
|
70
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : t('ide_opt_sent_title'), _jsx("span", __assign({ dir: 'ltr' }, { children: "".concat(maskPhone(phone || '')) }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ disableBack: true, onBackClicked: function () { return onBack(); }, disabled: !methods.formState.isValid, type: 'submit', isAr: isAr, loading: loading }, { children: t('next') }))] })) })) }));
|
|
71
71
|
};
|
|
72
72
|
VerifyNumber.defaultProps = {
|
|
73
73
|
phone: '564656085',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export interface EmailProps {
|
|
3
|
+
show: boolean;
|
|
3
4
|
}
|
|
4
|
-
declare const _default: React.MemoExoticComponent<({}: EmailProps) => JSX.Element>;
|
|
5
|
+
declare const _default: React.MemoExoticComponent<({ show }: EmailProps) => JSX.Element>;
|
|
5
6
|
export default _default;
|
|
@@ -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
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
13
|
import * as React from 'react';
|
|
3
14
|
import { useTranslation } from 'react-i18next';
|
|
@@ -7,20 +18,35 @@ import { keepEmailCharacters } from '../../../../utils';
|
|
|
7
18
|
import { useController, useFormContext } from 'react-hook-form';
|
|
8
19
|
import ClearIcon from '../../../shared/ClearIcon';
|
|
9
20
|
import CheckIcon from '../../../shared/CheckIcon';
|
|
21
|
+
import { checkEmailAvailability } from '../../../app/connect/connectStore';
|
|
22
|
+
import { useAppDispatch } from '../../../../hooks';
|
|
23
|
+
import { debounce } from 'lodash-es';
|
|
24
|
+
import Collapse from '../../../../components/Collapse';
|
|
10
25
|
var Email = function (_a) {
|
|
11
26
|
var _b;
|
|
27
|
+
var show = _a.show;
|
|
28
|
+
var dispatch = useAppDispatch();
|
|
12
29
|
var t = useTranslation().t;
|
|
13
30
|
var control = useFormContext().control;
|
|
14
31
|
var emailControl = useController({ name: 'email', control: control });
|
|
32
|
+
var emailValue = emailControl.field.value;
|
|
33
|
+
var error = (_b = emailControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
34
|
+
var checkEmail = debounce(function (value) {
|
|
35
|
+
dispatch(checkEmailAvailability(value));
|
|
36
|
+
}, 500);
|
|
15
37
|
var handleEmailChange = function (event) {
|
|
16
38
|
var value = keepEmailCharacters(event.target.value);
|
|
17
39
|
emailControl.field.onChange(value);
|
|
18
40
|
};
|
|
19
|
-
|
|
20
|
-
|
|
41
|
+
React.useEffect(function () {
|
|
42
|
+
var isValid = emailValue && !error && emailValue.length > 3;
|
|
43
|
+
if (isValid) {
|
|
44
|
+
checkEmail(emailValue);
|
|
45
|
+
}
|
|
46
|
+
}, [emailValue, error]);
|
|
21
47
|
var clearNumber = function () {
|
|
22
48
|
emailControl.field.onChange('');
|
|
23
49
|
};
|
|
24
|
-
return (_jsx(ScreenContainer, { children: _jsx(Input, { label: t('signup_email_lable'), value: emailValue, onChange: handleEmailChange, type: 'email', placeholder: t('signup_email_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: !error && emailValue ? _jsx(CheckIcon, {}) : emailValue && _jsx(ClearIcon, { onClick: clearNumber }) }) }));
|
|
50
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { label: t('signup_email_lable'), value: emailValue, onChange: handleEmailChange, type: 'email', placeholder: t('signup_email_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: !error && emailValue ? _jsx(CheckIcon, {}) : emailValue && _jsx(ClearIcon, { onClick: clearNumber }) }) }) })));
|
|
25
51
|
};
|
|
26
52
|
export default React.memo(Email);
|
|
@@ -28,16 +28,20 @@ import { clearError, connectSelector, updateLeadIndividual } from '../../../app/
|
|
|
28
28
|
import { useLanguage } from '../../../../hooks';
|
|
29
29
|
import MobileNumber from './MobileNumber';
|
|
30
30
|
import { countriesCode } from '../../../../constants';
|
|
31
|
+
import Collapse from '../../../../components/Collapse';
|
|
31
32
|
var FormStyled = styled(Form)(function () { return ({
|
|
32
33
|
display: 'flex',
|
|
33
34
|
flexDirection: 'column'
|
|
34
35
|
}); });
|
|
35
36
|
var Individual = function (_a) {
|
|
36
|
-
var _b;
|
|
37
|
-
var
|
|
37
|
+
var _b, _c, _d, _e;
|
|
38
|
+
var _f = React.useState(false), listActive = _f[0], setListActive = _f[1];
|
|
39
|
+
var _g = useSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error, searchActive = _g.searchActive;
|
|
40
|
+
var _h = React.useState(((_b = data.individualData.countryCode) === null || _b === void 0 ? void 0 : _b.digits) || 9), mobileLength = _h[0], setMobileLength = _h[1];
|
|
38
41
|
var dispatch = useAppDispatch();
|
|
39
|
-
var
|
|
40
|
-
var
|
|
42
|
+
var t = useTranslation().t;
|
|
43
|
+
var isAr = useLanguage().isAr;
|
|
44
|
+
var isAbsher = (_c = data.otpData) === null || _c === void 0 ? void 0 : _c.isAbsher;
|
|
41
45
|
var methods = useForm({
|
|
42
46
|
resolver: yupResolver(isAbsher ? IndividualMobileValidation(mobileLength) : IndividualValidation()),
|
|
43
47
|
defaultValues: data.individualData,
|
|
@@ -47,15 +51,24 @@ var Individual = function (_a) {
|
|
|
47
51
|
dispatch(updateLeadIndividual(formData));
|
|
48
52
|
};
|
|
49
53
|
var onBack = function () {
|
|
50
|
-
dispatch(handlePrevScreenStep());
|
|
54
|
+
dispatch(handlePrevScreenStep(isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
|
|
51
55
|
};
|
|
52
56
|
React.useEffect(function () {
|
|
53
57
|
if (error)
|
|
54
58
|
dispatch(clearError());
|
|
55
59
|
}, [methods.formState.isValid]);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
React.useEffect(function () {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
if (((_b = (_a = data.individualData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.is_available) === false)
|
|
63
|
+
methods.setError('email', { message: 'tap_js_email_already_exist' });
|
|
64
|
+
if (searchActive)
|
|
65
|
+
methods.setError('email', { message: 'checking...' });
|
|
66
|
+
}, [(_d = data.individualData) === null || _d === void 0 ? void 0 : _d.responseBody, searchActive]);
|
|
67
|
+
var handleMenuListClick = function () {
|
|
68
|
+
listActive ? setListActive(false) : setListActive(true);
|
|
69
|
+
};
|
|
70
|
+
var emailErrChecks = !methods.formState.isValid || !!methods.formState.errors.email || !!error;
|
|
71
|
+
var disabled = emailErrChecks || searchActive || !((_e = data.individualData.responseBody) === null || _e === void 0 ? void 0 : _e.is_available);
|
|
72
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Name, { show: !listActive }), _jsx(MobileNumber, { setMobileLength: setMobileLength, show: isAbsher, onListOpen: function () { return handleMenuListClick(); }, onListClose: function () { return handleMenuListClick(); }, countries: countriesCode }), _jsx(Email, { show: !listActive }), _jsx(Collapse, __assign({ in: !listActive }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
|
|
60
73
|
};
|
|
61
74
|
export default React.memo(Individual);
|
|
@@ -4,6 +4,8 @@ interface MobileNumberProps {
|
|
|
4
4
|
countries: Array<CountryCode>;
|
|
5
5
|
show: boolean;
|
|
6
6
|
setMobileLength?: (length: number) => void;
|
|
7
|
+
onListOpen?: () => void;
|
|
8
|
+
onListClose?: () => void;
|
|
7
9
|
}
|
|
8
10
|
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<MobileNumberProps & React.RefAttributes<unknown>>>;
|
|
9
11
|
export default _default;
|
|
@@ -96,11 +96,15 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
|
96
96
|
var clearMobileNumber = function () {
|
|
97
97
|
phoneControl.field.onChange('');
|
|
98
98
|
};
|
|
99
|
-
var onOpenCountryList = function (event) {
|
|
100
|
-
setAnchorEl(event.currentTarget);
|
|
101
|
-
};
|
|
102
99
|
var onCloseCountryList = function () {
|
|
100
|
+
var _a;
|
|
103
101
|
setAnchorEl(null);
|
|
102
|
+
(_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
103
|
+
};
|
|
104
|
+
var toggleCountryList = function () {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
anchorEl ? setAnchorEl(null) : setAnchorEl(true);
|
|
107
|
+
anchorEl ? (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest) : (_b = rest.onListOpen) === null || _b === void 0 ? void 0 : _b.call(rest);
|
|
104
108
|
};
|
|
105
109
|
var onSelectItem = function (country) {
|
|
106
110
|
var _a;
|
|
@@ -113,7 +117,7 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
|
113
117
|
var mobileValue = phoneControl.field.value || '';
|
|
114
118
|
var countryName = (isAr ? (_b = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.name) === null || _b === void 0 ? void 0 : _b.arabic : (_c = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.name) === null || _c === void 0 ? void 0 : _c.english) || '';
|
|
115
119
|
var error = (_d = phoneControl.fieldState.error) === null || _d === void 0 ? void 0 : _d.message;
|
|
116
|
-
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mb: 3 }, ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(Input, { sx: { direction: 'ltr' }, inputProps: { maxLength: (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits) || 9 }, onChange: onPhoneNumberChange, value: !!anchorEl ? countryName : mobileValue, startAdornment: _jsxs(CountryCodeStyled, __assign({ onClick:
|
|
120
|
+
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mb: 3 }, ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(Input, { sx: { direction: 'ltr' }, inputProps: { maxLength: (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits) || 9 }, onChange: onPhoneNumberChange, value: !!anchorEl ? countryName : mobileValue, startAdornment: _jsxs(CountryCodeStyled, __assign({ onClick: function () { return toggleCountryList(); } }, { children: ["+".concat(countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix), !anchorEl && _jsx(ExpandIconStyled, { anchorEl: !!anchorEl })] })), endAdornment: !!anchorEl ? (_jsx(ExpandIconStyled, { onClick: function () { return toggleCountryList(); }, anchorEl: !!anchorEl })) : !error && mobileValue ? (_jsx(CheckIcon, {})) : (mobileValue && _jsx(ClearIcon, { onClick: clearMobileNumber })), placeholder: "".concat((countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.iso2) === 'SA' ? '5' : '0', "00000000"), warningType: 'alert', warningMessage: error && t(error, { length: countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.english', list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
117
121
|
return (_jsxs(_Fragment, { children: [_jsxs(CountryItemContainer, { children: [_jsxs(CountryCodeText, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.idd_prefix) === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) }, { children: ["+", item.idd_prefix] })), _jsx(CountryNameText, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.idd_prefix) === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) }, { children: isAr ? item.name.arabic : item.name.english }))] }), item.idd_prefix === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) && _jsx(CheckIcon, {})] }));
|
|
118
122
|
} }) }))] })) })));
|
|
119
123
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export interface NameProps {
|
|
3
|
+
show: boolean;
|
|
3
4
|
}
|
|
4
|
-
declare const _default: React.MemoExoticComponent<({}: NameProps) => JSX.Element>;
|
|
5
|
+
declare const _default: React.MemoExoticComponent<({ show }: NameProps) => JSX.Element>;
|
|
5
6
|
export default _default;
|
|
@@ -18,8 +18,10 @@ import { removeAllOtherThanAlphabetAndSpace } from '../../../../utils';
|
|
|
18
18
|
import { useController, useFormContext } from 'react-hook-form';
|
|
19
19
|
import ClearIcon from '../../../shared/ClearIcon';
|
|
20
20
|
import CheckIcon from '../../../shared/CheckIcon';
|
|
21
|
+
import Collapse from '../../../../components/Collapse';
|
|
21
22
|
var Name = function (_a) {
|
|
22
23
|
var _b;
|
|
24
|
+
var show = _a.show;
|
|
23
25
|
var t = useTranslation().t;
|
|
24
26
|
var control = useFormContext().control;
|
|
25
27
|
var nameControl = useController({ name: 'name', control: control });
|
|
@@ -32,6 +34,6 @@ var Name = function (_a) {
|
|
|
32
34
|
var clearNumber = function () {
|
|
33
35
|
nameControl.field.onChange('');
|
|
34
36
|
};
|
|
35
|
-
return (_jsx(ScreenContainer, __assign({ sx: { mb: 3, mt: 2.5 } }, { children: _jsx(Input, { label: t('signup_merchant_name_label'), value: nameValue, onChange: handleNameChange, placeholder: t('signup_merchant_name_label'), warningType: 'alert', warningMessage: error && t(error), endAdornment: !error && nameValue ? _jsx(CheckIcon, {}) : nameValue && _jsx(ClearIcon, { onClick: clearNumber }) }) })));
|
|
37
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, __assign({ sx: { mb: 3, mt: 2.5 } }, { children: _jsx(Input, { label: t('signup_merchant_name_label'), value: nameValue, onChange: handleNameChange, placeholder: t('signup_merchant_name_label'), warningType: 'alert', warningMessage: error && t(error), endAdornment: !error && nameValue ? _jsx(CheckIcon, {}) : nameValue && _jsx(ClearIcon, { onClick: clearNumber }) }) })) })));
|
|
36
38
|
};
|
|
37
39
|
export default React.memo(Name);
|
|
@@ -24,6 +24,9 @@ import ClearIcon from '../../../shared/ClearIcon';
|
|
|
24
24
|
import Tooltip from '../../../../components/Tooltip';
|
|
25
25
|
import { removeAllOtherThanCharsNumbersAndSpace } from '../../../../utils';
|
|
26
26
|
import CheckIcon from '../../../shared/CheckIcon';
|
|
27
|
+
import { checkBrandNameAvailability } from '../../../app/connect/connectStore';
|
|
28
|
+
import { useAppDispatch } from '../../../../hooks';
|
|
29
|
+
import { debounce } from 'lodash-es';
|
|
27
30
|
var LabelContainerStyled = styled(Box)(function (_a) {
|
|
28
31
|
var theme = _a.theme;
|
|
29
32
|
return ({
|
|
@@ -56,14 +59,20 @@ var InfoIconStyled = styled(InfoIcon)(function (_a) {
|
|
|
56
59
|
});
|
|
57
60
|
var BrandName = function (_a) {
|
|
58
61
|
var _b;
|
|
62
|
+
var dispatch = useAppDispatch();
|
|
59
63
|
var _c = React.useState(false), isHovered = _c[0], setIsHovered = _c[1];
|
|
60
64
|
var t = useTranslation().t;
|
|
61
65
|
var control = useFormContext().control;
|
|
62
66
|
var brandControl = useController({ control: control, name: 'brandName' });
|
|
67
|
+
var checkBrand = debounce(function (value) {
|
|
68
|
+
dispatch(checkBrandNameAvailability(value));
|
|
69
|
+
}, 500);
|
|
63
70
|
var handleBrandNameChange = function (_a) {
|
|
64
71
|
var target = _a.target;
|
|
65
72
|
var value = removeAllOtherThanCharsNumbersAndSpace(target.value);
|
|
66
73
|
brandControl.field.onChange(value);
|
|
74
|
+
if (!!value)
|
|
75
|
+
checkBrand(value);
|
|
67
76
|
};
|
|
68
77
|
var clearBrandName = function () {
|
|
69
78
|
brandControl.field.onChange('');
|
|
@@ -27,7 +27,8 @@ import BrandName from './BrandName';
|
|
|
27
27
|
import SocialMedia from './SocialMedia';
|
|
28
28
|
import TAC from './TAC';
|
|
29
29
|
var Merchant = function (_a) {
|
|
30
|
-
var _b
|
|
30
|
+
var _b;
|
|
31
|
+
var _c = useSelector(connectSelector), data = _c.data, loading = _c.loading, error = _c.error, searchActive = _c.searchActive;
|
|
31
32
|
var methods = useForm({
|
|
32
33
|
resolver: yupResolver(MerchantValidationSchema),
|
|
33
34
|
defaultValues: data.brandData,
|
|
@@ -46,7 +47,12 @@ var Merchant = function (_a) {
|
|
|
46
47
|
if (error)
|
|
47
48
|
dispatch(clearError());
|
|
48
49
|
}, [methods.formState.isValid]);
|
|
49
|
-
|
|
50
|
+
React.useEffect(function () {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
if (((_b = (_a = data.brandData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.response_code) == '5')
|
|
53
|
+
methods.setError('brandName', { message: 'Profile Name already exists' });
|
|
54
|
+
}, [(_b = data.brandData) === null || _b === void 0 ? void 0 : _b.responseBody]);
|
|
55
|
+
var disabled = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error || searchActive;
|
|
50
56
|
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandName, {}), _jsx(SocialMedia, {}), _jsx(TAC, {}), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') }))] })) })) }));
|
|
51
57
|
};
|
|
52
58
|
export default React.memo(Merchant);
|
|
@@ -11,7 +11,7 @@ export var MerchantValidationSchema = yup.object().shape({
|
|
|
11
11
|
if (!instagram && !twitter) {
|
|
12
12
|
return yup
|
|
13
13
|
.string()
|
|
14
|
-
.matches(
|
|
14
|
+
.matches(/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,63}(:[0-9]{1,5})?(\/.*)?$/, 'ide_not_valid_url')
|
|
15
15
|
.transform(function (value) { return (!!value ? value : null); })
|
|
16
16
|
.nullable()
|
|
17
17
|
.required('enter_at_least_one');
|
|
@@ -74,10 +74,11 @@ var ListType;
|
|
|
74
74
|
ListType["CountryCodeList"] = "CountryCodeList";
|
|
75
75
|
})(ListType || (ListType = {}));
|
|
76
76
|
var Mobile = function (_a) {
|
|
77
|
-
var _b
|
|
78
|
-
var _c = React.useState(), listType = _c[0], setListType = _c[1];
|
|
79
|
-
var dispatch = useAppDispatch();
|
|
77
|
+
var _b, _c;
|
|
80
78
|
var _d = useSelector(connectSelector), data = _d.data, loading = _d.loading, error = _d.error;
|
|
79
|
+
var _e = React.useState((_c = (_b = data.mobileData) === null || _b === void 0 ? void 0 : _b.countryCode) === null || _c === void 0 ? void 0 : _c.digits), mobileLength = _e[0], setMobileLength = _e[1];
|
|
80
|
+
var _f = React.useState(), listType = _f[0], setListType = _f[1];
|
|
81
|
+
var dispatch = useAppDispatch();
|
|
81
82
|
var methods = useForm({
|
|
82
83
|
resolver: yupResolver(PhoneValidationSchema(mobileLength)),
|
|
83
84
|
defaultValues: data.mobileData,
|
|
@@ -94,7 +95,7 @@ var Mobile = function (_a) {
|
|
|
94
95
|
dispatch(clearError());
|
|
95
96
|
}, [methods.formState.isValid]);
|
|
96
97
|
var onSubmit = function (formData) {
|
|
97
|
-
dispatch(createMobileAuth(formData));
|
|
98
|
+
dispatch(createMobileAuth(__assign(__assign({}, formData), { isResend: false })));
|
|
98
99
|
};
|
|
99
100
|
var onAbsherButtonClicked = function () {
|
|
100
101
|
dispatch(handleCurrentActiveScreen('CONNECT_NID_STEP'));
|
|
@@ -114,16 +114,16 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
|
114
114
|
var clearMobileNumber = function () {
|
|
115
115
|
phoneControl.field.onChange('');
|
|
116
116
|
};
|
|
117
|
-
var onOpenCountryList = function (event) {
|
|
118
|
-
var _a;
|
|
119
|
-
setAnchorEl(event.currentTarget);
|
|
120
|
-
(_a = rest.onListOpen) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
121
|
-
};
|
|
122
117
|
var onCloseCountryList = function () {
|
|
123
118
|
var _a;
|
|
124
119
|
setAnchorEl(null);
|
|
125
120
|
(_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
126
121
|
};
|
|
122
|
+
var toggleCountryList = function () {
|
|
123
|
+
var _a, _b;
|
|
124
|
+
anchorEl ? setAnchorEl(null) : setAnchorEl(true);
|
|
125
|
+
anchorEl ? (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest) : (_b = rest.onListOpen) === null || _b === void 0 ? void 0 : _b.call(rest);
|
|
126
|
+
};
|
|
127
127
|
var onSelectItem = function (country) {
|
|
128
128
|
var _a;
|
|
129
129
|
onCloseCountryList();
|
|
@@ -135,7 +135,7 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
|
135
135
|
var mobileValue = phoneControl.field.value || '';
|
|
136
136
|
var countryName = (isAr ? (_b = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.name) === null || _b === void 0 ? void 0 : _b.arabic : (_c = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.name) === null || _c === void 0 ? void 0 : _c.english) || '';
|
|
137
137
|
var error = (_d = phoneControl.fieldState.error) === null || _d === void 0 ? void 0 : _d.message;
|
|
138
|
-
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(Input, { sx: { direction: 'ltr' }, inputProps: { maxLength: (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits) || 10 }, onChange: onPhoneNumberChange, value: !!anchorEl ? countryName : mobileValue, startAdornment: _jsxs(CountryCodeStyled, __assign({ onClick:
|
|
138
|
+
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(Input, { sx: { direction: 'ltr' }, inputProps: { maxLength: (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits) || 10 }, onChange: onPhoneNumberChange, value: !!anchorEl ? countryName : mobileValue, startAdornment: _jsxs(CountryCodeStyled, __assign({ onClick: function () { return toggleCountryList(); } }, { children: ["+".concat(countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix), !anchorEl && _jsx(ExpandIconStyled, { anchorEl: !!anchorEl })] })), endAdornment: !!anchorEl ? (_jsx(ExpandIconStyled, { onClick: function () { return toggleCountryList(); }, anchorEl: !!anchorEl })) : !error && mobileValue ? (_jsx(CheckIcon, {})) : (mobileValue && _jsx(ClearIcon, { onClick: clearMobileNumber })), placeholder: "".concat((countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.iso2) === 'SA' ? '5' : '0', "00000000"), warningType: 'alert', warningMessage: error && t(error, { length: countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.english', list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
139
139
|
return (_jsxs(_Fragment, { children: [_jsxs(CountryItemContainer, { children: [_jsxs(CountryCodeText, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.idd_prefix) === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) }, { children: ["+", item.idd_prefix] })), _jsx(CountryNameText, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.idd_prefix) === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) }, { children: isAr ? item.name.arabic : item.name.english }))] }), item.idd_prefix === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) && _jsx(CheckIcon, {})] }));
|
|
140
140
|
} }) }))] })) })));
|
|
141
141
|
});
|
|
@@ -10,11 +10,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import {
|
|
14
|
-
import DatePicker from '../../../../components/DatePicker';
|
|
13
|
+
import { useSelector } from 'react-redux';
|
|
15
14
|
import { useTranslation } from 'react-i18next';
|
|
16
15
|
import { useController, useFormContext } from 'react-hook-form';
|
|
16
|
+
import { useAppDispatch } from '../../../../hooks';
|
|
17
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
18
|
+
import DatePicker from '../../../../components/DatePicker';
|
|
17
19
|
import { alpha, styled } from '@mui/material/styles';
|
|
20
|
+
import { clearError, connectSelector } from '../../../app/connect/connectStore';
|
|
18
21
|
import Text from '../../../../components/Text';
|
|
19
22
|
var InputLabelStyled = styled(Text)(function (_a) {
|
|
20
23
|
var theme = _a.theme;
|
|
@@ -25,9 +28,16 @@ var DOB = function (_a) {
|
|
|
25
28
|
var onDateClicked = _a.onDateClicked;
|
|
26
29
|
var t = useTranslation().t;
|
|
27
30
|
var control = useFormContext().control;
|
|
31
|
+
var dispatch = useAppDispatch();
|
|
28
32
|
var dobControl = useController({ control: control, name: 'dob' });
|
|
33
|
+
var error = useSelector(connectSelector).error;
|
|
29
34
|
var handleBirthDateChange = function (data) {
|
|
30
35
|
dobControl.field.onChange(data);
|
|
36
|
+
handleClearError();
|
|
37
|
+
};
|
|
38
|
+
var handleClearError = function () {
|
|
39
|
+
if (error)
|
|
40
|
+
dispatch(clearError());
|
|
31
41
|
};
|
|
32
42
|
var dateValue = (_b = dobControl === null || dobControl === void 0 ? void 0 : dobControl.field) === null || _b === void 0 ? void 0 : _b.value;
|
|
33
43
|
return (_jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, __assign({ sx: { p: function (_a) {
|
|
@@ -43,11 +43,10 @@ var NID = function (_a) {
|
|
|
43
43
|
mode: 'onChange'
|
|
44
44
|
});
|
|
45
45
|
React.useEffect(function () {
|
|
46
|
-
|
|
47
|
-
dispatch(clearError());
|
|
46
|
+
handleClearError();
|
|
48
47
|
}, [methods.formState.isValid]);
|
|
49
48
|
var onSubmit = function (data) {
|
|
50
|
-
dispatch(createNIDAuth(data));
|
|
49
|
+
dispatch(createNIDAuth(__assign(__assign({}, data), { isResend: false })));
|
|
51
50
|
};
|
|
52
51
|
var handleCollapseOpenClose = function (flag) {
|
|
53
52
|
setCollapse(flag);
|
|
@@ -55,6 +54,10 @@ var NID = function (_a) {
|
|
|
55
54
|
var onBack = function () {
|
|
56
55
|
dispatch(handlePrevScreenStep());
|
|
57
56
|
};
|
|
57
|
+
var handleClearError = function () {
|
|
58
|
+
if (error)
|
|
59
|
+
dispatch(clearError());
|
|
60
|
+
};
|
|
58
61
|
var disabled = !methods.formState.isValid || !!error;
|
|
59
62
|
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(IDNumber, { show: !collapse }) })), _jsx(DOB, { onDateClicked: handleCollapseOpenClose }), _jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(Box, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disabled: disabled, loading: loading, error: t(error || '') }, { children: t('next') })) }) }))] })) })) }));
|
|
60
63
|
};
|
|
@@ -4,7 +4,6 @@ export var NIDValidationSchema = yup.object().shape({
|
|
|
4
4
|
nid: yup
|
|
5
5
|
.string()
|
|
6
6
|
.matches(/^(1|2)([0-9]{1,})$/g, 'signup_invalid_national_id_format')
|
|
7
|
-
.min(
|
|
8
|
-
.max(10, 'signup_invalid_national_id_format')
|
|
7
|
+
.min(10, 'signup_invalid_national_id')
|
|
9
8
|
.required('signup_invalid_national_id')
|
|
10
9
|
});
|
|
@@ -25,7 +25,7 @@ import { useLanguage } from '../../../../hooks';
|
|
|
25
25
|
import { useForm, FormProvider } from 'react-hook-form';
|
|
26
26
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
27
27
|
import Form from '../../../../components/Form';
|
|
28
|
-
import { maskPhone } from '../../../../utils';
|
|
28
|
+
import { maskPhone, maskID } from '../../../../utils';
|
|
29
29
|
import { OTPValidation } from './validation';
|
|
30
30
|
import OTPInput from './OTPInput';
|
|
31
31
|
var OTPTitleContainerStyled = styled(Box)(function (_a) {
|
|
@@ -67,11 +67,12 @@ var OTP = function () {
|
|
|
67
67
|
dispatch(verifyAuth(formData));
|
|
68
68
|
};
|
|
69
69
|
var onBack = function () {
|
|
70
|
-
handlePrevScreenStep();
|
|
70
|
+
dispatch(handlePrevScreenStep(isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
|
|
71
71
|
};
|
|
72
72
|
var disabled = !methods.formState.isValid || !!error;
|
|
73
73
|
var phone = ((_a = data.mobileData.countryCode) === null || _a === void 0 ? void 0 : _a.idd_prefix) + (data.mobileData.mobile || '');
|
|
74
|
+
var idNumber = data.nidData.nid;
|
|
74
75
|
var title = isAbsher ? t('opt_nid_sent_title', { provider: 'ABSHER' }) : t('ide_opt_sent_title');
|
|
75
|
-
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : title, _jsx("span", __assign({ dir: 'ltr' }, { children: maskPhone(phone) }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
|
|
76
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : title, !loading && _jsx("span", __assign({ dir: 'ltr' }, { children: isAbsher ? maskID(idNumber) : maskPhone(phone) }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
|
|
76
77
|
};
|
|
77
78
|
export default React.memo(OTP);
|
|
@@ -29,7 +29,7 @@ var BoxStyled = styled(Box)(function (_a) {
|
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
31
|
var OTPInput = function (_a) {
|
|
32
|
-
var
|
|
32
|
+
var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
|
|
33
33
|
var t = useTranslation().t;
|
|
34
34
|
var dispatch = useAppDispatch();
|
|
35
35
|
var otpControl = useController({ name: 'otp', control: control });
|
|
@@ -41,19 +41,23 @@ var OTPInput = function (_a) {
|
|
|
41
41
|
otpControl.field.onChange(otp);
|
|
42
42
|
};
|
|
43
43
|
var handleOnResendOTP = function () {
|
|
44
|
+
if (otpControl.field.value)
|
|
45
|
+
setValue('otp', '', { shouldValidate: true });
|
|
44
46
|
var params = {
|
|
45
47
|
businessCountry: mobileData.businessCountry,
|
|
46
48
|
countryCode: mobileData.countryCode,
|
|
47
49
|
mobile: mobileData.mobile
|
|
48
50
|
};
|
|
49
|
-
dispatch(createMobileAuth(params));
|
|
51
|
+
dispatch(createMobileAuth(__assign(__assign({}, params), { isResend: true })));
|
|
50
52
|
};
|
|
51
53
|
var handleOnResendAbsherOTP = function () {
|
|
54
|
+
if (otpControl.field.value)
|
|
55
|
+
setValue('otp', '', { shouldValidate: true });
|
|
52
56
|
var params = {
|
|
53
57
|
nid: nidData.nid,
|
|
54
58
|
dob: nidData.dob
|
|
55
59
|
};
|
|
56
|
-
dispatch(createNIDAuth(params));
|
|
60
|
+
dispatch(createNIDAuth(__assign(__assign({}, params), { isResend: true })));
|
|
57
61
|
};
|
|
58
62
|
var otpValue = otpControl.field.value;
|
|
59
63
|
return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: isAbsher ? handleOnResendAbsherOTP : handleOnResendOTP, value: otpValue, onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
|