@tap-payments/auth-jsconnect 1.0.48 → 1.0.51

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.
Files changed (30) hide show
  1. package/build/constants/assets.d.ts +1 -0
  2. package/build/constants/assets.js +2 -1
  3. package/build/constants/validation.d.ts +0 -1
  4. package/build/constants/validation.js +0 -1
  5. package/build/features/app/business/businessStore.d.ts +1 -1
  6. package/build/features/app/business/businessStore.js +12 -22
  7. package/build/features/app/connect/connectStore.d.ts +1 -1
  8. package/build/features/app/connect/connectStore.js +4 -11
  9. package/build/features/connect/screens/Individual/Email.js +2 -1
  10. package/build/features/connect/screens/Individual/Individual.js +5 -11
  11. package/build/features/connect/screens/Individual/MobileNumber.d.ts +0 -1
  12. package/build/features/connect/screens/Individual/MobileNumber.js +3 -3
  13. package/build/features/connect/screens/Individual/validation.d.ts +2 -2
  14. package/build/features/connect/screens/Individual/validation.js +40 -24
  15. package/build/features/connect/screens/Merchant/BrandList.js +0 -5
  16. package/build/features/connect/screens/Merchant/BrandName.js +2 -1
  17. package/build/features/connect/screens/Merchant/Merchant.js +11 -3
  18. package/build/features/connect/screens/Merchant/SocialMedia.js +1 -1
  19. package/build/features/connect/screens/Merchant/validation.d.ts +4 -4
  20. package/build/features/connect/screens/Merchant/validation.js +9 -9
  21. package/build/features/connect/screens/Mobile/Mobile.js +3 -9
  22. package/build/features/connect/screens/Mobile/MobileNumber.js +3 -3
  23. package/build/features/connect/screens/Mobile/validation.d.ts +1 -1
  24. package/build/features/connect/screens/Mobile/validation.js +27 -10
  25. package/build/features/connect/screens/NID/NID.js +2 -2
  26. package/build/features/shared/Button/MobileButton.d.ts +9 -0
  27. package/build/features/shared/Button/MobileButton.js +67 -0
  28. package/build/features/shared/Button/index.d.ts +2 -1
  29. package/build/features/shared/Button/index.js +2 -1
  30. package/package.json +1 -1
@@ -33,4 +33,5 @@ export declare const ICONS_NAMES: {
33
33
  SUCCESS: string;
34
34
  ABSHER_LOGO: string;
35
35
  EMAIL_ICON: string;
36
+ MOBILE_ICON: string;
36
37
  };
@@ -32,5 +32,6 @@ export var ICONS_NAMES = {
32
32
  WHITE_ARROW: 'https://tap-connecet.b-cdn.net/imgs/whiteArrow.svg',
33
33
  SUCCESS: 'https://tap-connecet.b-cdn.net/imgs/success.svg',
34
34
  ABSHER_LOGO: 'https://dash.b-cdn.net/icons/menu/Absher.svg',
35
- EMAIL_ICON: 'https://dash.b-cdn.net/icons/menu/email.png'
35
+ EMAIL_ICON: 'https://dash.b-cdn.net/icons/menu/email.png',
36
+ MOBILE_ICON: 'https://dash.b-cdn.net/icons/menu/mobile.svg'
36
37
  };
@@ -7,4 +7,3 @@ export declare const CR_NUMBER_LENGTH = 10;
7
7
  export declare const SAUDI_NUMBER_LENGTH = 9;
8
8
  export declare const REGEX_FULL_NAME: RegExp;
9
9
  export declare const REGEX_WEBSITE: RegExp;
10
- export declare const REGEX_SAUDI_NUMBER: RegExp;
@@ -7,4 +7,3 @@ export var CR_NUMBER_LENGTH = 10;
7
7
  export var SAUDI_NUMBER_LENGTH = 9;
8
8
  export var REGEX_FULL_NAME = /^([a-zA-Z]{2,}\s{1}[a-zA-Z]{1,}|[a-zA-Z]+\s{1}[a-zA-Z.-]{1,}\s{1}[a-zA-Z.-]{1,}\s{1}[a-zA-Z]{1,}|[a-zA-Z]+\s{1}[a-zA-Z.-]{1,}\s{1}[a-zA-Z]{1,})$/g;
9
9
  export var REGEX_WEBSITE = /^[a-zA-Z0-9]+([\-\.]{1}[a-zA-Z0-9]+)*\.[a-zA-Z]{2,63}(:[0-9]{1,5})?(\/.*)?$/;
10
- export var REGEX_SAUDI_NUMBER = /^(05|5)([0-9]{1,})$/g;
@@ -1,7 +1,7 @@
1
1
  import { RootState } from '../../../app/store';
2
2
  import { ActivitiesFormValues, BusinessInfoFormValues, CustomersFormValues, BusinessTypeFormValues, CountryCode, License, NIDFormValues, OTPFormValues, ResponseData, SharedState } from '../../../@types';
3
3
  export declare const getCountries: import("@reduxjs/toolkit").AsyncThunk<{
4
- businessCountry: undefined;
4
+ businessCountry: any;
5
5
  countries: any;
6
6
  }, void, {}>;
7
7
  export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
@@ -55,7 +55,7 @@ import i18n from '../../../i18n';
55
55
  import { convertNumbers2English, removeRequestHeaders } from '../../../utils';
56
56
  import { handleCurrentActiveScreen, handleNextScreenStep } from '../../../app/settings';
57
57
  export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
58
- var settings, countriesBody, businessCountry, list;
58
+ var settings, countriesBody, businessCountry;
59
59
  return __generator(this, function (_a) {
60
60
  switch (_a.label) {
61
61
  case 0:
@@ -63,17 +63,10 @@ export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi
63
63
  return [4, API.countryService.getAllCountries()];
64
64
  case 1:
65
65
  countriesBody = (_a.sent()).data;
66
- businessCountry = undefined;
67
- list = (countriesBody.list || []).map(function (country) {
68
- if ([country.iso2, country.iso3].includes(settings.data.appConfig.businessCountryCode.toUpperCase())) {
69
- businessCountry = country;
70
- }
71
- if (country.iso2 === 'SA') {
72
- country.digits = 9;
73
- }
74
- return country;
66
+ businessCountry = (countriesBody.list || []).find(function (country) {
67
+ return [country.iso2, country.iso3].includes(settings.data.appConfig.businessCountryCode.toUpperCase());
75
68
  });
76
- return [2, { businessCountry: businessCountry, countries: list }];
69
+ return [2, { businessCountry: businessCountry, countries: (countriesBody === null || countriesBody === void 0 ? void 0 : countriesBody.list) || [] }];
77
70
  }
78
71
  });
79
72
  }); });
@@ -490,12 +483,10 @@ export var businessSlice = createSlice({
490
483
  state.error = action.error.message;
491
484
  })
492
485
  .addCase(retrieveEntityList.pending, function (state) {
493
- state.loading = true;
494
486
  state.error = null;
495
487
  })
496
488
  .addCase(retrieveEntityList.fulfilled, function (state, action) {
497
489
  var _a;
498
- state.loading = false;
499
490
  state.error = null;
500
491
  var data = action.payload.data;
501
492
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
@@ -513,7 +504,6 @@ export var businessSlice = createSlice({
513
504
  }
514
505
  })
515
506
  .addCase(retrieveEntityList.rejected, function (state, action) {
516
- state.loading = false;
517
507
  state.error = action.error.message;
518
508
  })
519
509
  .addCase(updateLeadBusinessType.pending, function (state) {
@@ -521,10 +511,10 @@ export var businessSlice = createSlice({
521
511
  state.error = null;
522
512
  })
523
513
  .addCase(updateLeadBusinessType.fulfilled, function (state, action) {
524
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
514
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
525
515
  state.loading = false;
526
516
  state.error = null;
527
- var _v = action.payload, data = _v.data, formData = _v.formData;
517
+ var _t = action.payload, data = _t.data, formData = _t.formData;
528
518
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
529
519
  if (description) {
530
520
  state.error = description;
@@ -533,20 +523,20 @@ export var businessSlice = createSlice({
533
523
  state.data.businessTypeData = formData;
534
524
  var isAr = i18n.dir() === 'rtl';
535
525
  state.data.businessInfo.brandName = isAr ? (_c = (_b = data === null || data === void 0 ? void 0 : data.brand) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.ar : (_e = (_d = data === null || data === void 0 ? void 0 : data.brand) === null || _d === void 0 ? void 0 : _d.name) === null || _e === void 0 ? void 0 : _e.en;
536
- state.data.businessInfo.licenseNumber = (_g = (_f = data === null || data === void 0 ? void 0 : data.entity) === null || _f === void 0 ? void 0 : _f.license) === null || _g === void 0 ? void 0 : _g.number;
537
- state.data.businessInfo.legalName = isAr ? (_j = (_h = data === null || data === void 0 ? void 0 : data.entity) === null || _h === void 0 ? void 0 : _h.legal_name) === null || _j === void 0 ? void 0 : _j.ar : (_l = (_k = data === null || data === void 0 ? void 0 : data.entity) === null || _k === void 0 ? void 0 : _k.legal_name) === null || _l === void 0 ? void 0 : _l.en;
538
- if (!!((_o = (_m = data === null || data === void 0 ? void 0 : data.entity) === null || _m === void 0 ? void 0 : _m.license) === null || _o === void 0 ? void 0 : _o.issuing_date)) {
539
- state.data.activitiesData.operationStartDate = convertNumbers2English(moment((_q = (_p = data === null || data === void 0 ? void 0 : data.entity) === null || _p === void 0 ? void 0 : _p.license) === null || _q === void 0 ? void 0 : _q.issuing_date).format('YYYY-MM-DD'));
526
+ state.data.businessInfo.licenseNumber = (data === null || data === void 0 ? void 0 : data.license_number) || '';
527
+ state.data.businessInfo.legalName = isAr ? (_g = (_f = data === null || data === void 0 ? void 0 : data.entity) === null || _f === void 0 ? void 0 : _f.legal_name) === null || _g === void 0 ? void 0 : _g.ar : (_j = (_h = data === null || data === void 0 ? void 0 : data.entity) === null || _h === void 0 ? void 0 : _h.legal_name) === null || _j === void 0 ? void 0 : _j.en;
528
+ if (!!((_l = (_k = data === null || data === void 0 ? void 0 : data.entity) === null || _k === void 0 ? void 0 : _k.license) === null || _l === void 0 ? void 0 : _l.issuing_date)) {
529
+ state.data.activitiesData.operationStartDate = convertNumbers2English(moment((_o = (_m = data === null || data === void 0 ? void 0 : data.entity) === null || _m === void 0 ? void 0 : _m.license) === null || _o === void 0 ? void 0 : _o.issuing_date).format('YYYY-MM-DD'));
540
530
  }
541
531
  if (formData.businessType === BusinessType.CR) {
542
- var activities = ((_s = (_r = data === null || data === void 0 ? void 0 : data.license) === null || _r === void 0 ? void 0 : _r.activities) === null || _s === void 0 ? void 0 : _s.isic) || [];
532
+ var activities = ((_q = (_p = data === null || data === void 0 ? void 0 : data.license) === null || _p === void 0 ? void 0 : _p.activities) === null || _q === void 0 ? void 0 : _q.isic) || [];
543
533
  var selectedActivity = activities === null || activities === void 0 ? void 0 : activities[0];
544
534
  if (!!selectedActivity)
545
535
  state.data.activitiesData.activities = [selectedActivity];
546
536
  state.data.businessTypeData.responseBody = __assign(__assign({}, data), { activities: activities });
547
537
  return;
548
538
  }
549
- var category = (_u = (_t = data === null || data === void 0 ? void 0 : data.license) === null || _t === void 0 ? void 0 : _t.License) === null || _u === void 0 ? void 0 : _u.Category;
539
+ var category = (_s = (_r = data === null || data === void 0 ? void 0 : data.license) === null || _r === void 0 ? void 0 : _r.License) === null || _s === void 0 ? void 0 : _s.Category;
550
540
  if (!!category)
551
541
  state.data.activitiesData.activities = [category];
552
542
  state.data.businessTypeData.responseBody = __assign(__assign({}, data), { activities: !!category ? [category] : [] });
@@ -2,7 +2,7 @@ import { RootState } from '../../../app/store';
2
2
  import { ResponseData, CountryCode, MobileFormValues, NIDFormValues, OTPFormValues, IndividualFormValues, SharedState, BrandFormValues } from '../../../@types';
3
3
  import { CancelToken } from 'axios';
4
4
  export declare const getCountries: import("@reduxjs/toolkit").AsyncThunk<{
5
- businessCountry: undefined;
5
+ businessCountry: any;
6
6
  countries: any;
7
7
  }, void, {}>;
8
8
  export declare const createMobileAuth: import("@reduxjs/toolkit").AsyncThunk<{
@@ -53,7 +53,7 @@ import { BRAND_LIST, CONNECT_STEP_NAMES, IDENTIFICATION_TYPE, INSTAGRAM_URL, TWI
53
53
  import { defaultCountry } from '../../../constants';
54
54
  import { getIndividualName, getClientEmailUrl, capitalizeTheFirstLetterOfEachWord, removeRequestHeaders } from '../../../utils';
55
55
  export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
56
- var settings, countriesBody, businessCountry, list;
56
+ var settings, countriesBody, businessCountry;
57
57
  return __generator(this, function (_a) {
58
58
  switch (_a.label) {
59
59
  case 0:
@@ -61,17 +61,10 @@ export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi
61
61
  return [4, API.countryService.getAllCountries()];
62
62
  case 1:
63
63
  countriesBody = (_a.sent()).data;
64
- businessCountry = undefined;
65
- list = (countriesBody.list || []).map(function (country) {
66
- if ([country.iso2, country.iso3].includes(settings.data.appConfig.businessCountryCode.toUpperCase())) {
67
- businessCountry = country;
68
- }
69
- if (country.iso2 === 'SA') {
70
- country.digits = 9;
71
- }
72
- return country;
64
+ businessCountry = (countriesBody.list || []).find(function (country) {
65
+ return [country.iso2, country.iso3].includes(settings.data.appConfig.businessCountryCode.toUpperCase());
73
66
  });
74
- return [2, { businessCountry: businessCountry, countries: list }];
67
+ return [2, { businessCountry: businessCountry, countries: countriesBody.list }];
75
68
  }
76
69
  });
77
70
  }); });
@@ -59,6 +59,7 @@ import { useAppDispatch } from '../../../../hooks';
59
59
  import { debounce } from 'lodash-es';
60
60
  import Collapse from '../../../../components/Collapse';
61
61
  import { styled } from '@mui/material/styles';
62
+ import CircularProgress from '@mui/material/CircularProgress';
62
63
  var InputStyled = styled(Input)(function (_a) {
63
64
  var theme = _a.theme;
64
65
  return ({
@@ -102,6 +103,6 @@ var Email = function (_a) {
102
103
  var clearNumber = function () {
103
104
  emailControl.field.onChange('');
104
105
  };
105
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(InputStyled, { label: t('signup_email_lable'), value: emailValue, onEnterPressed: function (e) { return e.preventDefault(); }, onChange: handleEmailChange, type: 'email', placeholder: t('signup_email_placeholder'), warningType: 'alert', warningMessage: emailChecking ? t('checking...') : error && t(error), endAdornment: !error && emailValue ? _jsx(CheckIcon, {}) : emailValue && _jsx(ClearIcon, { onClick: clearNumber }) }) }) })));
106
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(InputStyled, { label: t('signup_email_lable'), value: emailValue, onEnterPressed: function (e) { return e.preventDefault(); }, onChange: handleEmailChange, type: 'email', placeholder: t('signup_email_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: emailChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && emailValue ? (_jsx(CheckIcon, {})) : (emailValue && _jsx(ClearIcon, { onClick: clearNumber })) }) }) })));
106
107
  };
107
108
  export default React.memo(Email);
@@ -35,22 +35,19 @@ var FormStyled = styled(Form)(function () { return ({
35
35
  }); });
36
36
  var Individual = function (_a) {
37
37
  var _b, _c, _d;
38
- var _e = React.useState(false), isSA = _e[0], setIsSA = _e[1];
39
- var _f = React.useState(false), listActive = _f[0], setListActive = _f[1];
40
- var _g = React.useState(false), emailChecking = _g[0], setEmailChecking = _g[1];
41
- var _h = useSelector(connectSelector), data = _h.data, loading = _h.loading, error = _h.error;
42
- var _j = React.useState(data.individualData.countryCode.digits), mobileLength = _j[0], setMobileLength = _j[1];
38
+ var _e = React.useState(false), listActive = _e[0], setListActive = _e[1];
39
+ var _f = React.useState(false), emailChecking = _f[0], setEmailChecking = _f[1];
40
+ var _g = useSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error;
43
41
  var dispatch = useAppDispatch();
44
42
  var t = useTranslation().t;
45
43
  var isAr = useLanguage().isAr;
46
44
  var isAbsher = (_b = data.otpData) === null || _b === void 0 ? void 0 : _b.isAbsher;
47
45
  var individualData = data.individualData;
48
46
  var methods = useForm({
49
- resolver: yupResolver(isAbsher ? IndividualMobileValidation(mobileLength, isSA) : IndividualValidation()),
47
+ resolver: yupResolver(isAbsher ? IndividualMobileValidation : IndividualValidation),
50
48
  defaultValues: data.individualData,
51
49
  mode: 'onChange'
52
50
  });
53
- var countryCodeSA = methods.getValues('countryCode').iso2 === 'SA';
54
51
  var onSubmit = function (formData) {
55
52
  dispatch(updateLeadIndividual(formData));
56
53
  };
@@ -81,11 +78,8 @@ var Individual = function (_a) {
81
78
  if (((_b = (_a = data.individualData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.is_available) === false)
82
79
  methods.setError('email', { message: 'tap_js_email_already_exist' });
83
80
  }, [(_c = data.individualData) === null || _c === void 0 ? void 0 : _c.responseBody]);
84
- React.useEffect(function () {
85
- setIsSA(countryCodeSA);
86
- }, [countryCodeSA]);
87
81
  var emailErrChecks = !methods.formState.isValid || !!methods.formState.errors.email || !!error;
88
82
  var disabled = emailErrChecks || emailChecking || !((_d = data.individualData.responseBody) === null || _d === void 0 ? void 0 : _d.is_available);
89
- 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, fetchingEmail: function (v) { return setEmailChecking(v); }, emailChecking: emailChecking }), _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') })) }))] })) })) }));
83
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Name, { show: !listActive }), _jsx(MobileNumber, { show: isAbsher, onListOpen: function () { return handleMenuListClick(); }, onListClose: function () { return handleMenuListClick(); }, countries: countriesCode }), _jsx(Email, { show: !listActive, fetchingEmail: function (v) { return setEmailChecking(v); }, emailChecking: emailChecking }), _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') })) }))] })) })) }));
90
84
  };
91
85
  export default React.memo(Individual);
@@ -3,7 +3,6 @@ import { CountryCode } from '../../../../@types';
3
3
  interface MobileNumberProps {
4
4
  countries: Array<CountryCode>;
5
5
  show: boolean;
6
- setMobileLength?: (length: number) => void;
7
6
  onListOpen?: () => void;
8
7
  onListClose?: () => void;
9
8
  }
@@ -87,6 +87,8 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
87
87
  var error = (_d = phoneControl.fieldState.error) === null || _d === void 0 ? void 0 : _d.message;
88
88
  var isSA = countryCodeValue.iso2 === 'SA';
89
89
  var mobileLen = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits;
90
+ var isStartsWith5 = mobileValue.startsWith('5');
91
+ var requiredLen = isSA && isStartsWith5 ? mobileLen - 1 : mobileLen;
90
92
  React.useEffect(function () {
91
93
  if (mobileValue)
92
94
  setValue('mobile', mobileValue, { shouldValidate: true });
@@ -110,13 +112,11 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
110
112
  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);
111
113
  };
112
114
  var onSelectItem = function (country) {
113
- var _a;
114
115
  onCloseCountryList();
115
116
  setValue('mobile', '');
116
117
  countryCodeControl.field.onChange(country);
117
- (_a = rest.setMobileLength) === null || _a === void 0 ? void 0 : _a.call(rest, country.digits);
118
118
  };
119
- 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' }, type: 'tel', inputProps: { maxLength: mobileLen }, 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(isSA ? '5' : '0', "00000000"), warningType: 'alert', warningMessage: error && t(error, { length: mobileLen }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.english', list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
119
+ return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref, sx: { mb: 3 } }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(Input, { sx: { direction: 'ltr' }, inputProps: { maxLength: requiredLen }, type: 'tel', 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(isSA ? '5' : '0', "00000000"), warningType: 'alert', warningMessage: error && t(error, { length: requiredLen, number: '05|5' }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.english', list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
120
120
  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, {})] }));
121
121
  } }) }))] })) })));
122
122
  });
@@ -1,5 +1,5 @@
1
1
  import * as yup from 'yup';
2
- export declare const IndividualValidation: () => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
2
+ export declare const IndividualValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
3
  name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
4
  email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
5
5
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
@@ -9,7 +9,7 @@ export declare const IndividualValidation: () => yup.ObjectSchema<import("yup/li
9
9
  name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
10
10
  email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
11
11
  }>>>;
12
- export declare const IndividualMobileValidation: (length: number, isSA: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
12
+ export declare const IndividualMobileValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
13
13
  name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
14
14
  email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
15
15
  mobile: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
@@ -1,25 +1,41 @@
1
- import { REGEX_FULL_NAME, REGEX_SAUDI_NUMBER } from '../../../../constants';
1
+ import { REGEX_FULL_NAME } from '../../../../constants';
2
2
  import * as yup from 'yup';
3
- export var IndividualValidation = function () {
4
- return yup.object().shape({
5
- name: yup
6
- .string()
7
- .matches(REGEX_FULL_NAME, 'please write your first and last name')
8
- .required('please write your first and last name'),
9
- email: yup.string().email('email_not_valid').required('email_not_valid')
10
- });
11
- };
12
- export var IndividualMobileValidation = function (length, isSA) {
13
- return yup.object().shape({
14
- name: yup
15
- .string()
16
- .matches(REGEX_FULL_NAME, 'please write your first and last name')
17
- .required('please write your first and last name'),
18
- email: yup.string().email('email_not_valid').required('email_not_valid'),
19
- mobile: yup
20
- .string()
21
- .length(length, 'enter_valid_mobile_number')
22
- .matches(isSA ? REGEX_SAUDI_NUMBER : /^[0-9]/g, 'start_with_number')
23
- .required('mobile_number_error')
24
- });
25
- };
3
+ export var IndividualValidation = yup.object().shape({
4
+ name: yup
5
+ .string()
6
+ .matches(REGEX_FULL_NAME, 'please write your first and last name')
7
+ .required('please write your first and last name'),
8
+ email: yup.string().email('email_not_valid').required('email_not_valid')
9
+ });
10
+ export var IndividualMobileValidation = yup.object().shape({
11
+ name: yup
12
+ .string()
13
+ .matches(REGEX_FULL_NAME, 'please write your first and last name')
14
+ .required('please write your first and last name'),
15
+ email: yup.string().email('email_not_valid').required('email_not_valid'),
16
+ mobile: yup
17
+ .string()
18
+ .test({
19
+ test: function (value) {
20
+ var countryCode = this.parent.countryCode;
21
+ var isSA = countryCode.iso2 === 'SA';
22
+ var digits = countryCode.digits;
23
+ var mobileValue = value || '';
24
+ var valueLen = mobileValue.length;
25
+ var isNumber = mobileValue.match(/^[0-9]/g);
26
+ if (!isNumber)
27
+ return this.createError({ message: 'enter_valid_mobile_number' });
28
+ var isStartWithZero = mobileValue.startsWith('05');
29
+ var isStartWith5 = mobileValue.startsWith('5');
30
+ var isSaudiNumber = isStartWith5 || isStartWithZero;
31
+ if (isSA) {
32
+ if (!isSaudiNumber)
33
+ return this.createError({ message: 'start_with_number' });
34
+ var requiredLen = isStartWith5 ? digits - 1 : digits;
35
+ return valueLen === requiredLen ? true : this.createError({ message: 'enter_valid_mobile_number' });
36
+ }
37
+ return valueLen === digits ? true : this.createError({ message: 'enter_valid_mobile_number' });
38
+ }
39
+ })
40
+ .required('mobile_number_error')
41
+ });
@@ -32,7 +32,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
32
32
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
33
33
  import * as React from 'react';
34
34
  import { useTranslation } from 'react-i18next';
35
- import { useFormContext } from 'react-hook-form';
36
35
  import Box from '@mui/material/Box';
37
36
  import { styled } from '@mui/material/styles';
38
37
  import { useLanguage } from '../../../../hooks';
@@ -63,7 +62,6 @@ var BrandList = function (_a) {
63
62
  var _d = React.useState(null), anchorEl = _d[0], setAnchorEl = _d[1];
64
63
  var t = useTranslation().t;
65
64
  var isAr = useLanguage().isAr;
66
- var setValue = useFormContext().setValue;
67
65
  var onOpenBrandList = function (event) {
68
66
  var _a;
69
67
  setAnchorEl(event.currentTarget);
@@ -81,7 +79,6 @@ var BrandList = function (_a) {
81
79
  var first = array[0];
82
80
  if (first) {
83
81
  setSelectedBrand(first);
84
- setValue('brandName', getBrandName(first), { shouldValidate: true });
85
82
  if (!hasOther)
86
83
  array = __spreadArray(__spreadArray([], array, true), [OTHER_BRAND], false);
87
84
  setBrandList(array);
@@ -103,11 +100,9 @@ var BrandList = function (_a) {
103
100
  setSelectedBrand(brand);
104
101
  onCloseBrandList();
105
102
  if (isOtherLicense(brand)) {
106
- setValue('brandName', '', { shouldValidate: true });
107
103
  (_a = rest.showTerms) === null || _a === void 0 ? void 0 : _a.call(rest);
108
104
  return;
109
105
  }
110
- setValue('brandName', getBrandName(brand), { shouldValidate: true });
111
106
  (_b = rest.hideTerms) === null || _b === void 0 ? void 0 : _b.call(rest);
112
107
  };
113
108
  var hasList = (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0;
@@ -56,6 +56,7 @@ import { styled, alpha } from '@mui/material/styles';
56
56
  import InfoIcon from '@mui/icons-material/Info';
57
57
  import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
58
58
  import { ScreenContainer } from '../../../shared/Containers';
59
+ import CircularProgress from '@mui/material/CircularProgress';
59
60
  import Text from '../../../../components/Text';
60
61
  import Input from '../../../shared/Input';
61
62
  import ClearIcon from '../../../shared/ClearIcon';
@@ -137,6 +138,6 @@ var BrandName = function (_a) {
137
138
  var clearBrandName = function () {
138
139
  brandControl.field.onChange('');
139
140
  };
140
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 3 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('signup_brand_name_label') }), _jsx(Tooltip, __assign({ title: t('brand_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { onChange: handleBrandNameChange, value: brandNameValue, placeholder: t('signup_brand_name_placeholder'), warningType: 'alert', warningMessage: brandNameChecking ? t('checking...') : error && t(error), endAdornment: !error && brandNameValue ? _jsx(CheckIcon, {}) : brandNameValue && _jsx(ClearIcon, { onClick: clearBrandName }) })] })) })));
141
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('signup_brand_name_label') }), _jsx(Tooltip, __assign({ title: t('brand_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { onChange: handleBrandNameChange, value: brandNameValue, placeholder: t('signup_brand_name_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: brandNameChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && brandNameValue ? (_jsx(CheckIcon, {})) : (brandNameValue && _jsx(ClearIcon, { onClick: clearBrandName })) })] })) })));
141
142
  };
142
143
  export default React.memo(BrandName);
@@ -33,9 +33,9 @@ var Merchant = function (_a) {
33
33
  var _j = React.useState(false), brandNameChecking = _j[0], setBrandNameChecking = _j[1];
34
34
  var _k = useSelector(connectSelector), data = _k.data, loading = _k.loading, error = _k.error;
35
35
  var isNewUser = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.new_user;
36
- var _l = React.useState(isNewUser), showTermsCheck = _l[0], setShowTermsCheck = _l[1];
36
+ var _l = React.useState(isNewUser), isOther = _l[0], setIsOther = _l[1];
37
37
  var methods = useForm({
38
- resolver: yupResolver(MerchantValidationSchema(showTermsCheck)),
38
+ resolver: yupResolver(MerchantValidationSchema(isOther)),
39
39
  defaultValues: data.brandData,
40
40
  mode: 'onChange'
41
41
  });
@@ -54,6 +54,14 @@ var Merchant = function (_a) {
54
54
  }
55
55
  dispatch(handlePrevScreenStep(isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
56
56
  };
57
+ React.useEffect(function () {
58
+ if (!isNewUser) {
59
+ methods.setValue('brandName', '', { shouldValidate: true });
60
+ methods.setValue('termAndConditionChecked', false, {
61
+ shouldValidate: true
62
+ });
63
+ }
64
+ }, [isOther]);
57
65
  React.useEffect(function () {
58
66
  if (error)
59
67
  dispatch(clearError());
@@ -66,6 +74,6 @@ var Merchant = function (_a) {
66
74
  var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
67
75
  var disabled = brandErrChecks || brandNameChecking || ((_e = (_d = data.brandData) === null || _d === void 0 ? void 0 : _d.responseBody) === null || _e === void 0 ? void 0 : _e.response_code) === '5';
68
76
  var showBrandList = ((_g = (((_f = data.brandData) === null || _f === void 0 ? void 0 : _f.brandList) || [])) === null || _g === void 0 ? void 0 : _g.length) > 0 && !isNewUser;
69
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: showBrandList, list: ((_h = data.brandData) === null || _h === void 0 ? void 0 : _h.brandList) || [], onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); }, showTerms: function () { return setShowTermsCheck(true); }, hideTerms: function () { return setShowTermsCheck(false); } }), _jsx(BrandName, { show: !listActive, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(SocialMedia, { show: !listActive, sx: !showTermsCheck ? { mb: 0 } : {} }), _jsx(TAC, { show: !listActive && showTermsCheck }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
77
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: showBrandList, list: ((_h = data.brandData) === null || _h === void 0 ? void 0 : _h.brandList) || [], onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); }, showTerms: function () { return setIsOther(true); }, hideTerms: function () { return setIsOther(false); } }), _jsx(BrandName, { show: !listActive && isOther, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(SocialMedia, { show: !listActive, sx: !isOther ? { mb: 0 } : {} }), _jsx(TAC, { show: !listActive && isOther }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
70
78
  };
71
79
  export default React.memo(Merchant);
@@ -79,7 +79,7 @@ var SocialMedia = function (_a) {
79
79
  var websiteError = (_b = errors === null || errors === void 0 ? void 0 : errors.website) === null || _b === void 0 ? void 0 : _b.message;
80
80
  var twitterError = (_c = errors === null || errors === void 0 ? void 0 : errors.twitter) === null || _c === void 0 ? void 0 : _c.message;
81
81
  var instagramError = (_d = errors === null || errors === void 0 ? void 0 : errors.instagram) === null || _d === void 0 ? void 0 : _d.message;
82
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: __assign({ mb: 3, direction: 'ltr' }, sx) }, { children: [_jsx(SocialMediaGroupStyled, { defaultValue: socialMediaType, exclusive: true, onChange: function (e, value) {
82
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: __assign({ mt: 3, mb: 3, direction: 'ltr' }, sx) }, { children: [_jsx(SocialMediaGroupStyled, { defaultValue: socialMediaType, exclusive: true, onChange: function (e, value) {
83
83
  setSocialMediaType(value);
84
84
  } }), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.WEB, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: websiteValue, startAdornment: _jsx(TextStyled, { children: "https://" }), placeholder: t('signup_website_placeholder'), warningType: 'alert', warningMessage: websiteError && t(websiteError), endAdornment: !websiteError && websiteValue ? _jsx(CheckIcon, {}) : websiteValue && _jsx(ClearIconStyled, { onClick: handleClear }) }) })), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.TWITTER, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: twitterValue, startAdornment: _jsx(TextStyled, { children: "@" }), placeholder: t('signup_twitter_placeholder'), warningType: 'alert', warningMessage: twitterError && t(twitterError), endAdornment: !twitterError && twitterValue ? _jsx(CheckIcon, {}) : twitterValue && _jsx(ClearIconStyled, { onClick: handleClear }) }) })), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.INSTAGRAM, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: instagramValue, startAdornment: _jsx(TextStyled, { children: "@" }), placeholder: t('signup_instagram_placeholder'), warningType: 'alert', warningMessage: instagramError && t(instagramError), endAdornment: !instagramError && instagramValue ? (_jsx(CheckIcon, {})) : (instagramValue && _jsx(ClearIconStyled, { onClick: handleClear })) }) }))] })) })));
85
85
  };
@@ -1,6 +1,6 @@
1
1
  import * as yup from 'yup';
2
- export declare const MerchantValidationSchema: (termsIsRequired: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
- brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
2
+ export declare const MerchantValidationSchema: (isOther: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
4
4
  termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, boolean | undefined>;
5
5
  links: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
6
6
  website: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
@@ -16,7 +16,7 @@ export declare const MerchantValidationSchema: (termsIsRequired: boolean) => yup
16
16
  twitter: yup.StringSchema<string | null | undefined, import("yup/lib/types").AnyObject, string | null | undefined>;
17
17
  }>>>;
18
18
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
19
- brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
19
+ brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
20
20
  termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, boolean | undefined>;
21
21
  links: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
22
22
  website: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
@@ -32,7 +32,7 @@ export declare const MerchantValidationSchema: (termsIsRequired: boolean) => yup
32
32
  twitter: yup.StringSchema<string | null | undefined, import("yup/lib/types").AnyObject, string | null | undefined>;
33
33
  }>>>;
34
34
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
35
- brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
35
+ brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
36
36
  termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, boolean | undefined>;
37
37
  links: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
38
38
  website: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
@@ -1,15 +1,15 @@
1
1
  import { REGEX_WEBSITE } from '../../../../constants';
2
2
  import * as yup from 'yup';
3
- export var MerchantValidationSchema = function (termsIsRequired) {
3
+ export var MerchantValidationSchema = function (isOther) {
4
4
  return yup.object().shape({
5
- brandName: yup
6
- .string()
7
- .min(3, 'enter_brand_name_english_chars_numbers_space')
8
- .max(250, 'enter_brand_name_english_chars_numbers_space')
9
- .required('enter_valid_brand_name'),
10
- termAndConditionChecked: termsIsRequired
11
- ? yup.boolean().required().isTrue('check_terms_cond')
12
- : yup.boolean().optional(),
5
+ brandName: isOther
6
+ ? yup
7
+ .string()
8
+ .min(3, 'enter_brand_name_english_chars_numbers_space')
9
+ .max(250, 'enter_brand_name_english_chars_numbers_space')
10
+ .required('enter_valid_brand_name')
11
+ : yup.string().optional(),
12
+ termAndConditionChecked: isOther ? yup.boolean().required().isTrue('check_terms_cond') : yup.boolean().optional(),
13
13
  links: yup.object().shape({
14
14
  website: yup.string().when(['instagram', 'twitter'], function (instagram, twitter) {
15
15
  if (!instagram && !twitter) {
@@ -75,18 +75,15 @@ var ListType;
75
75
  var Mobile = function (_a) {
76
76
  var settingsStore = useSelector(settingsSelector);
77
77
  var _b = useSelector(connectSelector), data = _b.data, loading = _b.loading, error = _b.error;
78
- var _c = React.useState(data.mobileData.countryCode.digits), mobileLength = _c[0], setMobileLength = _c[1];
79
- var _d = React.useState(), listType = _d[0], setListType = _d[1];
80
- var _e = React.useState(false), isSA = _e[0], setIsSA = _e[1];
78
+ var _c = React.useState(), listType = _c[0], setListType = _c[1];
81
79
  var dispatch = useAppDispatch();
82
80
  var methods = useForm({
83
- resolver: yupResolver(PhoneValidationSchema(mobileLength, isSA)),
81
+ resolver: yupResolver(PhoneValidationSchema),
84
82
  defaultValues: data.mobileData,
85
83
  mode: 'onChange'
86
84
  });
87
85
  var t = useTranslation().t;
88
86
  var isAr = useLanguage().isAr;
89
- var countryCodeSA = methods.getValues('countryCode').iso2 === 'SA';
90
87
  var handleMenuListClick = function (flag) {
91
88
  setListType(flag);
92
89
  };
@@ -95,9 +92,6 @@ var Mobile = function (_a) {
95
92
  methods.setValue('countryCode', data.mobileData.countryCode);
96
93
  }
97
94
  }, [data.mobileData]);
98
- React.useEffect(function () {
99
- setIsSA(countryCodeSA);
100
- }, [countryCodeSA]);
101
95
  React.useEffect(function () {
102
96
  if (error)
103
97
  dispatch(clearError());
@@ -112,6 +106,6 @@ var Mobile = function (_a) {
112
106
  var isCountryListActive = listType === ListType.CountryCodeList;
113
107
  var listActive = isBusinessListActive || isCountryListActive;
114
108
  var disabled = !methods.formState.isValid || !!error;
115
- return (_jsxs(ScreenContainer, { children: [_jsx(MIDTitle, { show: !listActive, title: t('join_our_community'), description: t('ide_terms_and_conditions_description') }), _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(InputsContainerStyled, { children: _jsx(MobileNumber, { show: !isBusinessListActive, setMobileLength: setMobileLength, countries: data.countries, onListOpen: function () { return handleMenuListClick(ListType.CountryCodeList); }, onListClose: function () { return handleMenuListClick(); } }) }), _jsxs(Collapse, __assign({ in: !listActive }, { children: [_jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, loading: loading, error: t(error || '') }, { children: t('next') })), _jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(AbsherButton, __assign({ disabled: settingsStore.loading || loading, onClick: function () { return onBack(); }, isAr: isAr }, { children: t('absher_button_label') }))] }))] })) }))] }));
109
+ return (_jsxs(ScreenContainer, { children: [_jsx(MIDTitle, { show: !listActive, title: t('join_our_community'), description: t('ide_terms_and_conditions_description') }), _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(InputsContainerStyled, { children: _jsx(MobileNumber, { show: !isBusinessListActive, countries: data.countries, onListOpen: function () { return handleMenuListClick(ListType.CountryCodeList); }, onListClose: function () { return handleMenuListClick(); } }) }), _jsxs(Collapse, __assign({ in: !listActive }, { children: [_jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, loading: loading, error: t(error || '') }, { children: t('next') })), _jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(AbsherButton, __assign({ disabled: settingsStore.loading || loading, onClick: function () { return onBack(); }, isAr: isAr }, { children: t('absher_button_label') }))] }))] })) }))] }));
116
110
  };
117
111
  export default React.memo(Mobile);
@@ -87,6 +87,8 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
87
87
  var error = (_d = phoneControl.fieldState.error) === null || _d === void 0 ? void 0 : _d.message;
88
88
  var isSA = countryCodeValue.iso2 === 'SA';
89
89
  var mobileLen = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits;
90
+ var isStartsWith5 = mobileValue.startsWith('5');
91
+ var requiredLen = isSA && isStartsWith5 ? mobileLen - 1 : mobileLen;
90
92
  React.useEffect(function () {
91
93
  if (mobileValue)
92
94
  setValue('mobile', mobileValue, { shouldValidate: true });
@@ -110,13 +112,11 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
110
112
  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);
111
113
  };
112
114
  var onSelectItem = function (country) {
113
- var _a;
114
115
  onCloseCountryList();
115
116
  setValue('mobile', '');
116
117
  countryCodeControl.field.onChange(country);
117
- (_a = rest.setMobileLength) === null || _a === void 0 ? void 0 : _a.call(rest, country.digits);
118
118
  };
119
- 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: mobileLen }, type: 'tel', 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(isSA ? '5' : '0', "00000000"), warningType: 'alert', warningMessage: error && t(error, { length: mobileLen }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.english', list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
119
+ 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: requiredLen }, type: 'tel', 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(isSA ? '5' : '0', "00000000"), warningType: 'alert', warningMessage: error && t(error, { length: requiredLen, number: '05|5' }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.english', list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
120
120
  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, {})] }));
121
121
  } }) }))] })) })));
122
122
  });
@@ -1,5 +1,5 @@
1
1
  import * as yup from 'yup';
2
- export declare const PhoneValidationSchema: (length: number, isSA: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
2
+ export declare const PhoneValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
3
  mobile: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
4
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
5
5
  mobile: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
@@ -1,11 +1,28 @@
1
- import { REGEX_SAUDI_NUMBER } from '../../../../constants';
2
1
  import * as yup from 'yup';
3
- export var PhoneValidationSchema = function (length, isSA) {
4
- return yup.object().shape({
5
- mobile: yup
6
- .string()
7
- .matches(isSA ? REGEX_SAUDI_NUMBER : /^[0-9]/g, 'start_with_number')
8
- .length(length, 'enter_valid_mobile_number')
9
- .required('mobile_number_error')
10
- });
11
- };
2
+ export var PhoneValidationSchema = yup.object().shape({
3
+ mobile: yup
4
+ .string()
5
+ .test({
6
+ test: function (value) {
7
+ var countryCode = this.parent.countryCode;
8
+ var isSA = countryCode.iso2 === 'SA';
9
+ var digits = countryCode.digits;
10
+ var mobileValue = value || '';
11
+ var valueLen = mobileValue.length;
12
+ var isNumber = mobileValue.match(/^[0-9]/g);
13
+ if (!isNumber)
14
+ return this.createError({ message: 'enter_valid_mobile_number' });
15
+ var isStartWithZero = mobileValue.startsWith('05');
16
+ var isStartWith5 = mobileValue.startsWith('5');
17
+ var isSaudiNumber = isStartWith5 || isStartWithZero;
18
+ if (isSA) {
19
+ if (!isSaudiNumber)
20
+ return this.createError({ message: 'start_with_number' });
21
+ var requiredLen = isStartWith5 ? digits - 1 : digits;
22
+ return valueLen === requiredLen ? true : this.createError({ message: 'enter_valid_mobile_number' });
23
+ }
24
+ return valueLen === digits ? true : this.createError({ message: 'enter_valid_mobile_number' });
25
+ }
26
+ })
27
+ .required('mobile_number_error')
28
+ });
@@ -21,7 +21,7 @@ import { useAppDispatch, useLanguage } from '../../../../hooks';
21
21
  import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
22
22
  import { clearError, connectSelector, createNIDAuth } from '../../../app/connect/connectStore';
23
23
  import Form from '../../../../components/Form';
24
- import Button, { AbsherButton } from '../../../shared/Button';
24
+ import Button, { MobileButton } from '../../../shared/Button';
25
25
  import { ScreenContainer } from '../../../shared/Containers';
26
26
  import Collapse from '../../../../components/Collapse';
27
27
  import Box from '@mui/material/Box';
@@ -86,6 +86,6 @@ var NID = function (_a) {
86
86
  dispatch(handlePrevScreenStep('CONNECT_MOBILE_STEP'));
87
87
  };
88
88
  var disabled = !methods.formState.isValid || !!error;
89
- 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 }), _jsxs(Collapse, __assign({ in: !collapse }, { children: [_jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') })), _jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(AbsherButton, __assign({ onClick: function () { return onBack(); }, disabled: loading || settingsStore.loading, hideIcon: true, isAr: isAr }, { children: t('mobile_button_label') }))] }))] })) })) }));
89
+ 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 }), _jsxs(Collapse, __assign({ in: !collapse }, { children: [_jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') })), _jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(MobileButton, __assign({ onClick: function () { return onBack(); }, disabled: loading || settingsStore.loading, isAr: isAr }, { children: t('mobile_button_label') }))] }))] })) })) }));
90
90
  };
91
91
  export default React.memo(NID);
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { ButtonProps } from '../../../components/Button';
3
+ interface MobileButtonProps extends ButtonProps {
4
+ isAr: boolean;
5
+ loading?: boolean;
6
+ hideIcon?: boolean;
7
+ }
8
+ export default function MobileButton({ children, isAr, hideIcon, disabled, ...props }: MobileButtonProps): JSX.Element;
9
+ export {};
@@ -0,0 +1,67 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx } from "react/jsx-runtime";
24
+ import Button from '../../../components/Button';
25
+ import Icon from '../../../components/Icon';
26
+ import { alpha, styled } from '@mui/material/styles';
27
+ import Box from '@mui/material/Box';
28
+ import { ICONS_NAMES } from '../../../constants';
29
+ var IconStyled = styled(Icon, { shouldForwardProp: function (prop) { return prop !== 'disabled'; } })(function (_a) {
30
+ var theme = _a.theme, disabled = _a.disabled;
31
+ return (__assign({ width: theme.spacing(3), height: theme.spacing(3), marginInlineStart: theme.spacing(0.75) }, (disabled && {
32
+ opacity: 0.3
33
+ })));
34
+ });
35
+ var ButtonBoxStyled = styled(Box)(function (_a) {
36
+ var theme = _a.theme;
37
+ return ({
38
+ margin: theme.spacing(0, 2.5, 2.5, 2.5)
39
+ });
40
+ });
41
+ var ButtonStyled = styled(Button)(function (_a) {
42
+ var theme = _a.theme;
43
+ return ({
44
+ paddingInlineStart: theme.spacing(0.75),
45
+ backgroundColor: theme.palette.common.white,
46
+ border: "1px solid ".concat(theme.palette.primary.main),
47
+ color: theme.palette.primary.main,
48
+ '&:hover': {
49
+ backgroundColor: theme.palette.primary.main,
50
+ color: theme.palette.common.white,
51
+ img: {
52
+ filter: 'brightness(0) invert(1)'
53
+ }
54
+ },
55
+ '&:active': {
56
+ backgroundColor: theme.palette.common.white
57
+ },
58
+ '&:disabled': {
59
+ backgroundColor: theme.palette.common.white,
60
+ color: alpha(theme.palette.primary.main, 0.3)
61
+ }
62
+ });
63
+ });
64
+ export default function MobileButton(_a) {
65
+ var children = _a.children, isAr = _a.isAr, hideIcon = _a.hideIcon, disabled = _a.disabled, props = __rest(_a, ["children", "isAr", "hideIcon", "disabled"]);
66
+ return (_jsx(ButtonBoxStyled, { children: _jsx(ButtonStyled, __assign({ disabled: disabled, type: 'button', startIcon: !hideIcon && _jsx(IconStyled, { disabled: disabled, src: ICONS_NAMES.MOBILE_ICON }) }, props, { children: children })) }));
67
+ }
@@ -1,4 +1,5 @@
1
1
  import Button from './Button';
2
2
  import AbsherButton from './AbsherButton';
3
- export { AbsherButton };
3
+ import MobileButton from './MobileButton';
4
+ export { AbsherButton, MobileButton };
4
5
  export default Button;
@@ -1,4 +1,5 @@
1
1
  import Button from './Button';
2
2
  import AbsherButton from './AbsherButton';
3
- export { AbsherButton };
3
+ import MobileButton from './MobileButton';
4
+ export { AbsherButton, MobileButton };
4
5
  export default Button;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "1.0.48",
3
+ "version": "1.0.51",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",