@tap-payments/auth-jsconnect 1.0.22 → 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.
@@ -107,16 +107,7 @@ export interface SourceOfIncome {
107
107
  nameEn: string;
108
108
  }
109
109
  export interface AppInfo {
110
- identifier: string;
111
110
  name: string;
112
- version: string;
113
- requirer?: string;
114
- requirer_version?: string;
115
- app_locale?: string;
116
- sdk_version?: string;
117
- requirer_sim_network_name?: string;
118
- requirer_sim_country_iso?: string;
119
- universal_id?: string;
120
111
  }
121
112
  export interface OSDetails {
122
113
  name: string;
@@ -47,11 +47,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
+ import moment from 'moment-hijri';
50
51
  import { handleNextScreenStep } from '../../../app/settings';
51
52
  import API from '../../../api';
52
53
  import { CONNECT_STEP_NAMES, IDENTIFICATION_TYPE } from '../../../constants';
53
54
  import { defaultCountry } from '../../../constants/dummy';
54
- import { getIndividualName } from '../../../utils';
55
+ import { convertNumbers2English, getIndividualName } from '../../../utils';
55
56
  export var getCountries = createAsyncThunk('getCountries', function () { return __awaiter(void 0, void 0, void 0, function () {
56
57
  var countriesBody, BusinessCountries, list, countries, filterBusinessCountries;
57
58
  return __generator(this, function (_a) {
@@ -100,17 +101,21 @@ export var createMobileAuth = createAsyncThunk('createMobileAuth', function (par
100
101
  });
101
102
  }); });
102
103
  export var createNIDAuth = createAsyncThunk('createNIDAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
103
- var _a, settings, connect, identification_id_type, requestBody, data;
104
+ var _a, settings, connect, identification_id_type, birthDate, requestBody, data;
104
105
  return __generator(this, function (_b) {
105
106
  switch (_b.label) {
106
107
  case 0:
107
108
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
108
109
  identification_id_type = params.nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
110
+ birthDate = params.dob;
111
+ if (identification_id_type === IDENTIFICATION_TYPE.NID) {
112
+ birthDate = convertNumbers2English(moment(birthDate, 'YYYY-MM-DD').format('iYYYY/iMM/iDD')).split('/').join('-');
113
+ }
109
114
  requestBody = {
110
115
  user_credentail: {
111
116
  identification_id: params.nid,
112
117
  identification_id_type: identification_id_type,
113
- date_of_birth: params.dob,
118
+ date_of_birth: birthDate,
114
119
  country_code: connect.data.mobileData.businessCountry.iso2
115
120
  },
116
121
  device_info: settings.data.deviceInfo,
@@ -326,11 +331,6 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
326
331
  return [4, API.leadService.updateLead(payload, { headers: headers })];
327
332
  case 1:
328
333
  data = (_e.sent()).data;
329
- if (!data.errors) {
330
- console.log('success');
331
- alert('Account created successfully, please check your email');
332
- alert("It's a fake message, plz wait us to integrate with the backend. <A.Sharkawy>");
333
- }
334
334
  return [2, { response: data, formData: params }];
335
335
  }
336
336
  });
@@ -12,6 +12,11 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
12
12
  marginBlockEnd: theme.spacing(3)
13
13
  });
14
14
  });
15
+ var InputStyled = styled(Input)(function () { return ({
16
+ '& .MuiInputBase-input': {
17
+ cursor: 'default'
18
+ }
19
+ }); });
15
20
  var BankName = function () {
16
21
  var _a;
17
22
  var t = useTranslation().t;
@@ -22,6 +27,6 @@ var BankName = function () {
22
27
  var clearValue = function () {
23
28
  bankNameControl.field.onChange('');
24
29
  };
25
- return (_jsx(FeatureStyled, { children: _jsx(Input, { label: t('enter_bank_name'), placeholder: t('enter_bank_name_placeholder'), value: bankNameValue, required: true, endAdornment: !hasError && bankNameValue ? _jsx(CheckIcon, {}) : bankNameValue && _jsx(ClearIcon, { onClick: clearValue }) }) }));
30
+ return (_jsx(FeatureStyled, { children: _jsx(InputStyled, { label: t('enter_bank_name'), placeholder: t('enter_bank_name_placeholder'), value: bankNameValue, required: true, readOnly: true, endAdornment: !hasError && bankNameValue ? _jsx(CheckIcon, {}) : bankNameValue && _jsx(ClearIcon, { onClick: clearValue }) }) }));
26
31
  };
27
32
  export default BankName;
@@ -31,7 +31,8 @@ var FormStyled = styled(Form)(function () { return ({
31
31
  flexDirection: 'column'
32
32
  }); });
33
33
  var Activities = function () {
34
- var _a = React.useState(false), collapse = _a[0], setCollapse = _a[1];
34
+ var _a = React.useState(false), anchorEl = _a[0], setAnchorEl = _a[1];
35
+ var _b = React.useState(false), collapse = _b[0], setCollapse = _b[1];
35
36
  var dispatch = useAppDispatch();
36
37
  var isAr = useLanguage().isAr;
37
38
  var t = useTranslation().t;
@@ -55,6 +56,9 @@ var Activities = function () {
55
56
  var onBack = function () {
56
57
  dispatch(handlePrevScreenStep());
57
58
  };
58
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(Collapse, __assign({ in: !collapse }, { children: [!!ACTIVITIES && _jsx(ActivitiesList, {}), _jsx(SalesChannels, {})] })), _jsx(OperationStartDate, { onDateClicked: handleCollapseOpenClose }), _jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disabled: !methods.formState.isValid }, { children: t('next') })) }))] })) })) }));
59
+ var handleMenuClick = function () {
60
+ anchorEl ? setAnchorEl(false) : setAnchorEl(true);
61
+ };
62
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(Collapse, __assign({ in: !collapse }, { children: [!!ACTIVITIES && (_jsx(ActivitiesList, { onListOpen: function () { return handleMenuClick(); }, onListClose: function () { return handleMenuClick(); } })), _jsx(Collapse, __assign({ in: !anchorEl }, { children: _jsx(SalesChannels, {}) }))] })), _jsx(Collapse, __assign({ in: !anchorEl }, { children: _jsx(OperationStartDate, { onDateClicked: handleCollapseOpenClose }) })), _jsx(Collapse, __assign({ in: !collapse && !anchorEl }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disabled: !methods.formState.isValid }, { children: t('next') })) }))] })) })) }));
59
63
  };
60
64
  export default Activities;
@@ -20,7 +20,7 @@ export declare const InputStyled: import("@emotion/styled").StyledComponent<Pick
20
20
  export declare const CheckIconStyled: import("@emotion/styled").StyledComponent<{
21
21
  children?: React.ReactNode;
22
22
  classes?: Partial<import("@mui/material").SvgIconClasses> | undefined;
23
- color?: "inherit" | "disabled" | "error" | "success" | "primary" | "secondary" | "action" | "info" | "warning" | undefined;
23
+ color?: "inherit" | "disabled" | "error" | "primary" | "secondary" | "action" | "info" | "success" | "warning" | undefined;
24
24
  fontSize?: "small" | "inherit" | "medium" | "large" | undefined;
25
25
  htmlColor?: string | undefined;
26
26
  inheritViewBox?: boolean | undefined;
@@ -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" | "success" | "primary" | "secondary" | "action" | "info" | "warning" | undefined;
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" | "success" | "primary" | "secondary" | "action" | "info" | "warning" | undefined;
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
- 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
- } }) }))] }));
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
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(CustomerLocations, {}), _jsx(ExpectedCustomers, {}), _jsx(ExpectedSales, {}), _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') })) }))] })) })) }));
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);
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  interface ExpectedCustomersProps {
3
+ show: boolean;
3
4
  onListOpen?: () => void;
4
5
  onListClose?: () => void;
5
6
  }
@@ -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
- 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
- } }) }))] }));
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;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  interface ExpectedSalesRangeProps {
3
+ show: boolean;
3
4
  onListOpen?: () => void;
4
5
  onListClose?: () => void;
5
6
  }
@@ -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
- 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
- } }) }))] }));
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(code, " ").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') }))] })) })) }));
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',
@@ -29,17 +29,21 @@ var Email = function (_a) {
29
29
  var t = useTranslation().t;
30
30
  var control = useFormContext().control;
31
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;
32
34
  var checkEmail = debounce(function (value) {
33
35
  dispatch(checkEmailAvailability(value));
34
36
  }, 500);
35
37
  var handleEmailChange = function (event) {
36
38
  var value = keepEmailCharacters(event.target.value);
37
39
  emailControl.field.onChange(value);
38
- if (!!value)
39
- checkEmail(value);
40
40
  };
41
- var emailValue = emailControl.field.value;
42
- var error = (_b = emailControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
41
+ React.useEffect(function () {
42
+ var isValid = emailValue && !error && emailValue.length > 3;
43
+ if (isValid) {
44
+ checkEmail(emailValue);
45
+ }
46
+ }, [emailValue, error]);
43
47
  var clearNumber = function () {
44
48
  emailControl.field.onChange('');
45
49
  };
@@ -34,11 +34,13 @@ var FormStyled = styled(Form)(function () { return ({
34
34
  flexDirection: 'column'
35
35
  }); });
36
36
  var Individual = function (_a) {
37
- var _b, _c, _d;
38
- var _e = React.useState(false), listActive = _e[0], setListActive = _e[1];
39
- var _f = useSelector(connectSelector), data = _f.data, loading = _f.loading, error = _f.error, searchActive = _f.searchActive;
40
- var _g = React.useState(((_b = data.individualData.countryCode) === null || _b === void 0 ? void 0 : _b.digits) || 9), mobileLength = _g[0], setMobileLength = _g[1];
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];
41
41
  var dispatch = useAppDispatch();
42
+ var t = useTranslation().t;
43
+ var isAr = useLanguage().isAr;
42
44
  var isAbsher = (_c = data.otpData) === null || _c === void 0 ? void 0 : _c.isAbsher;
43
45
  var methods = useForm({
44
46
  resolver: yupResolver(isAbsher ? IndividualMobileValidation(mobileLength) : IndividualValidation()),
@@ -57,15 +59,16 @@ var Individual = function (_a) {
57
59
  }, [methods.formState.isValid]);
58
60
  React.useEffect(function () {
59
61
  var _a, _b;
60
- if (((_b = (_a = data.individualData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.is_available) == false)
62
+ if (((_b = (_a = data.individualData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.is_available) === false)
61
63
  methods.setError('email', { message: 'tap_js_email_already_exist' });
62
- }, [(_d = data.individualData) === null || _d === void 0 ? void 0 : _d.responseBody]);
63
- var t = useTranslation().t;
64
- var isAr = useLanguage().isAr;
65
- var disabled = !methods.formState.isValid || !!methods.formState.errors.email || !!error || searchActive;
64
+ if (searchActive)
65
+ methods.setError('email', { message: 'checking...' });
66
+ }, [(_d = data.individualData) === null || _d === void 0 ? void 0 : _d.responseBody, searchActive]);
66
67
  var handleMenuListClick = function () {
67
68
  listActive ? setListActive(false) : setListActive(true);
68
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);
69
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') })) }))] })) })) }));
70
73
  };
71
74
  export default React.memo(Individual);
@@ -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 { ScreenContainer } from '../../../shared/Containers';
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,8 +43,7 @@ var NID = function (_a) {
43
43
  mode: 'onChange'
44
44
  });
45
45
  React.useEffect(function () {
46
- if (error)
47
- dispatch(clearError());
46
+ handleClearError();
48
47
  }, [methods.formState.isValid]);
49
48
  var onSubmit = function (data) {
50
49
  dispatch(createNIDAuth(__assign(__assign({}, data), { isResend: false })));
@@ -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, 'signup_invalid_national_id_format')
8
- .max(10, 'signup_invalid_national_id_format')
7
+ .min(10, 'signup_invalid_national_id')
9
8
  .required('signup_invalid_national_id')
10
9
  });
@@ -7,8 +7,13 @@ import { updateLeadSuccess } from '../../../app/connect/connectStore';
7
7
  var ThankYou = function (_a) {
8
8
  var t = useTranslation().t;
9
9
  var dispatch = useAppDispatch();
10
- var onSuccess = function () {
10
+ React.useEffect(function () {
11
11
  dispatch(updateLeadSuccess());
12
+ }, []);
13
+ var onSuccess = function () {
14
+ console.log('success');
15
+ alert('Account created successfully, please check your email');
16
+ alert("It's a fake message, plz wait us to integrate with the backend. <A.Sharkawy>");
12
17
  };
13
18
  return _jsx(SuccessScreen, { title: t('ide_successfully_verified_message'), onSuccess: onSuccess });
14
19
  };
@@ -6,3 +6,4 @@ export declare const getIndividualName: (name: string) => {
6
6
  middle: string;
7
7
  last: string;
8
8
  } | undefined;
9
+ export declare const convertNumbers2English: (str: string) => string;
@@ -37,3 +37,6 @@ export var getIndividualName = function (name) {
37
37
  }
38
38
  return { first: first, middle: middle, last: last };
39
39
  };
40
+ export var convertNumbers2English = function (str) {
41
+ return str.replace(/[٠-٩]/g, function (d) { return '٠١٢٣٤٥٦٧٨٩'.indexOf(d); });
42
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",
@@ -58,6 +58,7 @@
58
58
  "fork-ts-checker-webpack-plugin": "^7.2.12",
59
59
  "html-loader": "^3.1.2",
60
60
  "html-webpack-plugin": "^5.5.0",
61
+ "@types/moment-hijri": "^2.1.0",
61
62
  "husky": "^8.0.1",
62
63
  "lint-staged": "^13.0.3",
63
64
  "mini-css-extract-plugin": "^2.6.1",
@@ -87,6 +88,7 @@
87
88
  "i18next-browser-languagedetector": "^6.1.4",
88
89
  "i18next-http-backend": "^1.4.1",
89
90
  "lodash-es": "^4.17.21",
91
+ "moment-hijri": "~2.1.2",
90
92
  "react": "^18.2.0",
91
93
  "react-calendar": "~3.7.0",
92
94
  "react-dom": "^18.2.0",