@tap-payments/auth-jsconnect 1.0.51 → 1.0.54

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 (105) hide show
  1. package/build/@types/app.d.ts +3 -3
  2. package/build/@types/form.d.ts +23 -3
  3. package/build/api/data.d.ts +1 -1
  4. package/build/api/data.js +2 -2
  5. package/build/api/entity.d.ts +5 -2
  6. package/build/api/index.d.ts +4 -4
  7. package/build/api/lead.d.ts +1 -1
  8. package/build/app/rootReducer.d.ts +4 -0
  9. package/build/app/rootReducer.js +9 -1
  10. package/build/app/store.d.ts +8 -0
  11. package/build/assets/locales/ar.json +2 -1
  12. package/build/assets/locales/en.json +3 -2
  13. package/build/components/AnimationFlow/AnimationFlow.d.ts +3 -1
  14. package/build/components/AnimationFlow/AnimationFlow.js +9 -1
  15. package/build/components/AnimationFlow/Error.d.ts +6 -0
  16. package/build/components/AnimationFlow/Error.js +32 -0
  17. package/build/components/AnimationFlow/Loader.d.ts +2 -0
  18. package/build/components/AnimationFlow/Loader.js +16 -0
  19. package/build/components/Loader/Loader.d.ts +1 -0
  20. package/build/components/Loader/Loader.js +1 -1
  21. package/build/components/SimpleList/SimpleList.js +1 -0
  22. package/build/constants/app.d.ts +24 -0
  23. package/build/constants/app.js +61 -19
  24. package/build/constants/dummy.d.ts +2 -0
  25. package/build/constants/dummy.js +12 -6
  26. package/build/features/app/bank/bankStore.d.ts +36 -0
  27. package/build/features/app/bank/bankStore.js +218 -0
  28. package/build/features/app/business/businessStore.d.ts +2 -3
  29. package/build/features/app/business/businessStore.js +79 -85
  30. package/build/features/app/connect/connectStore.js +31 -30
  31. package/build/features/app/individual/individualStore.d.ts +36 -0
  32. package/build/features/app/individual/individualStore.js +222 -0
  33. package/build/features/app/password/passwordStore.d.ts +36 -0
  34. package/build/features/app/password/passwordStore.js +218 -0
  35. package/build/features/app/tax/taxStore.d.ts +38 -0
  36. package/build/features/app/tax/taxStore.js +271 -0
  37. package/build/features/bank/Bank.d.ts +2 -1
  38. package/build/features/bank/Bank.js +17 -7
  39. package/build/features/bank/screens/BankDetails/BankDetails.js +1 -2
  40. package/build/features/bank/screens/Verify/OTPInput.d.ts +5 -0
  41. package/build/features/bank/screens/Verify/OTPInput.js +42 -0
  42. package/build/features/bank/screens/Verify/Verify.d.ts +5 -0
  43. package/build/features/bank/screens/Verify/Verify.js +78 -0
  44. package/build/features/bank/screens/Verify/index.d.ts +2 -0
  45. package/build/features/bank/screens/Verify/index.js +2 -0
  46. package/build/features/bank/screens/Verify/validation.d.ts +8 -0
  47. package/build/features/bank/screens/Verify/validation.js +4 -0
  48. package/build/features/business/Business.js +2 -2
  49. package/build/features/business/screens/Activities/Activities.js +8 -8
  50. package/build/features/business/screens/Activities/ActivitiesList.js +7 -7
  51. package/build/features/business/screens/Activities/SalesChannels.js +1 -1
  52. package/build/features/business/screens/BusinessType/CRNumber.d.ts +2 -1
  53. package/build/features/business/screens/BusinessType/CRNumber.js +2 -2
  54. package/build/features/business/screens/BusinessType/CompanyLicense.js +2 -1
  55. package/build/features/business/screens/BusinessType/FLNumber.d.ts +2 -1
  56. package/build/features/business/screens/BusinessType/FLNumber.js +2 -2
  57. package/build/features/business/screens/BusinessType/FreelanceLicense.js +2 -1
  58. package/build/features/business/screens/Confirm/Confirm.js +1 -1
  59. package/build/features/business/screens/Customers/Customers.js +3 -3
  60. package/build/features/business/screens/Customers/ExpectedCustomers.js +3 -3
  61. package/build/features/connect/Connect.js +2 -2
  62. package/build/features/connect/screens/Merchant/BrandList.d.ts +0 -2
  63. package/build/features/connect/screens/Merchant/BrandList.js +16 -40
  64. package/build/features/connect/screens/Merchant/Merchant.js +42 -23
  65. package/build/features/connect/screens/Merchant/SocialMedia.d.ts +2 -1
  66. package/build/features/connect/screens/Merchant/SocialMedia.js +30 -3
  67. package/build/features/connect/screens/Merchant/validation.d.ts +6 -1
  68. package/build/features/connect/screens/Merchant/validation.js +67 -7
  69. package/build/features/connect/screens/Mobile/MobileNumber.js +1 -1
  70. package/build/features/featuresScreens.js +20 -10
  71. package/build/features/individual/Individual.d.ts +2 -1
  72. package/build/features/individual/Individual.js +17 -9
  73. package/build/features/individual/screens/Verify/OTPInput.d.ts +5 -0
  74. package/build/features/individual/screens/Verify/OTPInput.js +42 -0
  75. package/build/features/individual/screens/Verify/Verify.d.ts +5 -0
  76. package/build/features/individual/screens/Verify/Verify.js +78 -0
  77. package/build/features/individual/screens/Verify/index.d.ts +2 -0
  78. package/build/features/individual/screens/Verify/index.js +2 -0
  79. package/build/features/individual/screens/Verify/validation.d.ts +8 -0
  80. package/build/features/individual/screens/Verify/validation.js +4 -0
  81. package/build/features/password/Password.d.ts +2 -1
  82. package/build/features/password/Password.js +17 -9
  83. package/build/features/password/screens/Verify/OTPInput.d.ts +5 -0
  84. package/build/features/password/screens/Verify/OTPInput.js +42 -0
  85. package/build/features/password/screens/Verify/Verify.d.ts +5 -0
  86. package/build/features/password/screens/Verify/Verify.js +78 -0
  87. package/build/features/password/screens/Verify/index.d.ts +2 -0
  88. package/build/features/password/screens/Verify/index.js +2 -0
  89. package/build/features/password/screens/Verify/validation.d.ts +8 -0
  90. package/build/features/password/screens/Verify/validation.js +4 -0
  91. package/build/features/tax/Tax.d.ts +2 -1
  92. package/build/features/tax/Tax.js +17 -9
  93. package/build/features/tax/screens/Success/Success.js +6 -0
  94. package/build/features/tax/screens/TaxDetails/TaxDetails.js +6 -7
  95. package/build/features/tax/screens/Verify/OTPInput.d.ts +5 -0
  96. package/build/features/tax/screens/Verify/OTPInput.js +42 -0
  97. package/build/features/tax/screens/Verify/Verify.d.ts +5 -0
  98. package/build/features/tax/screens/Verify/Verify.js +78 -0
  99. package/build/features/tax/screens/Verify/index.d.ts +2 -0
  100. package/build/features/tax/screens/Verify/index.js +2 -0
  101. package/build/features/tax/screens/Verify/validation.d.ts +8 -0
  102. package/build/features/tax/screens/Verify/validation.js +4 -0
  103. package/build/hooks/useAppDispatch.d.ts +4 -0
  104. package/build/utils/string.js +0 -1
  105. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  interface CRNumberProps {
3
3
  show: boolean;
4
+ readOnly: boolean;
4
5
  }
5
- declare const _default: React.MemoExoticComponent<({ show }: CRNumberProps) => JSX.Element>;
6
+ declare const _default: React.MemoExoticComponent<({ show, readOnly }: CRNumberProps) => JSX.Element>;
6
7
  export default _default;
@@ -22,7 +22,7 @@ import Input from '../../../shared/Input';
22
22
  import Collapse from '../../../../components/Collapse';
23
23
  var CRNumber = function (_a) {
24
24
  var _b;
25
- var show = _a.show;
25
+ var show = _a.show, readOnly = _a.readOnly;
26
26
  var t = useTranslation().t;
27
27
  var control = useFormContext().control;
28
28
  var crNumberControl = useController({ control: control, name: 'crNumber' });
@@ -36,6 +36,6 @@ var CRNumber = function (_a) {
36
36
  };
37
37
  var crNumberValue = crNumberControl.field.value;
38
38
  var error = (_b = crNumberControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
39
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { label: t('enter_commercial_register_no'), onChange: handleFLNumberChange, inputProps: { maxLength: CR_NUMBER_LENGTH }, value: crNumberValue, endAdornment: (crNumberValue === null || crNumberValue === void 0 ? void 0 : crNumberValue.length) === CR_NUMBER_LENGTH ? (_jsx(CheckIcon, {})) : (crNumberValue && _jsx(ClearIcon, { onClick: clearCRNumber })), placeholder: '0123456789', warningType: 'alert', warningMessage: error && t(error, { length: CR_NUMBER_LENGTH }) }) }) })));
39
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { readOnly: readOnly, label: t('enter_commercial_register_no'), onChange: handleFLNumberChange, inputProps: { maxLength: CR_NUMBER_LENGTH }, value: crNumberValue, endAdornment: (crNumberValue === null || crNumberValue === void 0 ? void 0 : crNumberValue.length) === CR_NUMBER_LENGTH ? (_jsx(CheckIcon, {})) : (crNumberValue && _jsx(ClearIcon, { onClick: clearCRNumber })), placeholder: '0123456789', warningType: 'alert', warningMessage: error && t(error, { length: CR_NUMBER_LENGTH }) }) }) })));
40
40
  };
41
41
  export default React.memo(CRNumber);
@@ -115,12 +115,13 @@ var CompanyLicense = function (_a) {
115
115
  };
116
116
  var hasList = (licenseList === null || licenseList === void 0 ? void 0 : licenseList.length) > 0;
117
117
  var showCRNumber = !anchorEl;
118
+ var crReadonly = !isOtherLicense(selectedLicense);
118
119
  return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: hasList }, { children: [_jsx(InputStyled, { label: t('enter_commercial_register_no'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_cr'), value: t(getLicenseName(selectedLicense)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: licenseList, onSelectItem: onSelectItem, renderItem: function (item) {
119
120
  return (_jsxs(_Fragment, { children: [_jsx(LicenseContainer, { children: _jsx(LicenseNameText, __assign({ isSelected: getLicenseNumber(item) === getLicenseNumber(selectedLicense) }, { children: isOtherLicense(item)
120
121
  ? t(getLicenseNumber(item))
121
122
  : isAr
122
123
  ? getLicenseName(item)
123
124
  : getLicenseNumber(item) + '-' + getLicenseName(item) })) }), getLicenseNumber(item) === getLicenseNumber(selectedLicense) && _jsx(CheckIcon, {})] }));
124
- } }) }))] })), _jsx(CRNumber, { show: showCRNumber })] }) })));
125
+ } }) }))] })), _jsx(CRNumber, { show: showCRNumber, readOnly: crReadonly })] }) })));
125
126
  };
126
127
  export default React.memo(CompanyLicense);
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  interface FLNumberProps {
3
3
  show: boolean;
4
+ readOnly: boolean;
4
5
  }
5
- declare const _default: React.MemoExoticComponent<({ show }: FLNumberProps) => JSX.Element>;
6
+ declare const _default: React.MemoExoticComponent<({ show, readOnly }: FLNumberProps) => JSX.Element>;
6
7
  export default _default;
@@ -22,7 +22,7 @@ import Input from '../../../shared/Input';
22
22
  import Collapse from '../../../../components/Collapse';
23
23
  var FLNumber = function (_a) {
24
24
  var _b;
25
- var show = _a.show;
25
+ var show = _a.show, readOnly = _a.readOnly;
26
26
  var t = useTranslation().t;
27
27
  var control = useFormContext().control;
28
28
  var flNumberControl = useController({ control: control, name: 'flNumber' });
@@ -36,6 +36,6 @@ var FLNumber = function (_a) {
36
36
  };
37
37
  var flNumberValue = flNumberControl.field.value;
38
38
  var error = (_b = flNumberControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
39
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { label: t('enter_license_no'), onChange: handleFLNumberChange, inputProps: { maxLength: FL_NUMBER_LENGTH }, value: flNumberValue, endAdornment: (flNumberValue === null || flNumberValue === void 0 ? void 0 : flNumberValue.length) === FL_NUMBER_LENGTH ? (_jsx(CheckIcon, {})) : (flNumberValue && _jsx(ClearIcon, { onClick: clearFLNumber })), placeholder: '12345678', warningType: 'alert', warningMessage: error && t(error, { length: FL_NUMBER_LENGTH }) }) }) })));
39
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { readOnly: readOnly, label: t('enter_license_no'), onChange: handleFLNumberChange, inputProps: { maxLength: FL_NUMBER_LENGTH }, value: flNumberValue, endAdornment: (flNumberValue === null || flNumberValue === void 0 ? void 0 : flNumberValue.length) === FL_NUMBER_LENGTH ? (_jsx(CheckIcon, {})) : (flNumberValue && _jsx(ClearIcon, { onClick: clearFLNumber })), placeholder: '12345678', warningType: 'alert', warningMessage: error && t(error, { length: FL_NUMBER_LENGTH }) }) }) })));
40
40
  };
41
41
  export default React.memo(FLNumber);
@@ -115,12 +115,13 @@ var FreelanceLicense = function (_a) {
115
115
  };
116
116
  var hasList = (licenseList === null || licenseList === void 0 ? void 0 : licenseList.length) > 0;
117
117
  var showFLNumber = !anchorEl;
118
+ var flReadonly = !isOtherLicense(selectedLicense);
118
119
  return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: hasList }, { children: [_jsx(InputStyled, { label: t('enter_freelance_license'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_fl'), value: t(getLicenseName(selectedLicense)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: licenseList, onSelectItem: onSelectItem, renderItem: function (item) {
119
120
  return (_jsxs(_Fragment, { children: [_jsx(LicenseContainer, { children: _jsx(LicenseNameText, __assign({ isSelected: getLicenseNumber(item) === getLicenseNumber(selectedLicense) }, { children: isOtherLicense(item)
120
121
  ? t(getLicenseNumber(item))
121
122
  : isAr
122
123
  ? getLicenseName(item)
123
124
  : getLicenseNumber(item) + '-' + getLicenseName(item) })) }), getLicenseNumber(item) === getLicenseNumber(selectedLicense) && _jsx(CheckIcon, {})] }));
124
- } }) }))] })), _jsx(FLNumber, { show: showFLNumber })] }) })));
125
+ } }) }))] })), _jsx(FLNumber, { show: showFLNumber, readOnly: flReadonly })] }) })));
125
126
  };
126
127
  export default React.memo(FreelanceLicense);
@@ -51,6 +51,6 @@ var Confirm = function () {
51
51
  dispatch(handlePrevScreenStep());
52
52
  };
53
53
  var disabled = !methods.formState.isValid || !!error;
54
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(InputStyled, { label: t(isCR ? 'signup_business_cr_info_title' : 'signup_business_fl_info_title'), value: licenseNumber, disabled: true }), _jsx(InputStyled, { label: t('signup_brand_name_label'), value: brandName, disabled: true }), _jsx(InputStyled, { sx: { marginBlockEnd: 0 }, label: t('signup_legal_name_label'), value: legalName, disabled: true }), _jsx(Button, __assign({ disabled: disabled, loading: loading, error: t(error || ''), onBackClicked: function () { return onBack(); }, isAr: isAr }, { children: t('confirm') }))] })) })) }));
54
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(InputStyled, { label: t(isCR ? 'signup_business_cr_info_title' : 'signup_business_fl_info_title'), value: licenseNumber, disabled: true }), _jsx(InputStyled, { label: t('signup_brand_name_label'), placeholder: t('signup_brand_name_label'), value: brandName, disabled: true }), _jsx(InputStyled, { sx: { marginBlockEnd: 0 }, label: t('signup_legal_name_label'), placeholder: t('signup_legal_name_label'), value: legalName, disabled: true }), _jsx(Button, __assign({ disabled: disabled, loading: loading, error: t(error || ''), onBackClicked: function () { return onBack(); }, isAr: isAr }, { children: t('confirm') }))] })) })) }));
55
55
  };
56
56
  export default React.memo(Confirm);
@@ -68,11 +68,11 @@ var Customers = function (_a) {
68
68
  dispatch(clearError());
69
69
  }, [methods.formState.isValid]);
70
70
  React.useEffect(function () {
71
- var customerLocations = customerData.customerLocations, expectedCustomers = customerData.expectedCustomers, expectedSalesRange = customerData.expectedSalesRange;
71
+ var customerLocations = customerData.customerLocations, expectedCustomer = customerData.expectedCustomer, expectedSalesRange = customerData.expectedSalesRange;
72
72
  methods.setValue('customerLocations', customerLocations);
73
- methods.setValue('expectedCustomers', expectedCustomers);
73
+ methods.setValue('expectedCustomer', expectedCustomer);
74
74
  methods.setValue('expectedSalesRange', expectedSalesRange);
75
- }, [customerData.customerLocations, customerData.expectedCustomers, customerData.expectedSalesRange]);
75
+ }, [customerData.customerLocations, customerData.expectedCustomer, customerData.expectedSalesRange]);
76
76
  var isCustomerLocationsListActive = listActive === ListType.CustomerLocationsList;
77
77
  var isExpectedCustomersListActive = listActive === ListType.ExpectedCustomersList;
78
78
  var isExpectedSalesListActive = listActive === ListType.ExpectedSalesList;
@@ -51,7 +51,7 @@ var ExpectedCustomers = function (_a) {
51
51
  var t = useTranslation().t;
52
52
  var isAr = useLanguage().isAr;
53
53
  var control = useFormContext().control;
54
- var expectedCustomersControl = useController({ name: 'expectedCustomers', control: control });
54
+ var expectedCustomerControl = useController({ name: 'expectedCustomer', control: control });
55
55
  var data = useSelector(businessSelector).data;
56
56
  var activitiesData = data.activitiesData;
57
57
  var response = activitiesData.responseBody;
@@ -72,10 +72,10 @@ var ExpectedCustomers = function (_a) {
72
72
  }
73
73
  }, [response === null || response === void 0 ? void 0 : response.expectedCustomerSales]);
74
74
  var onSelectItem = function (expectedCustomers) {
75
- expectedCustomersControl.field.onChange(expectedCustomers);
75
+ expectedCustomerControl.field.onChange(expectedCustomers);
76
76
  onCloseList();
77
77
  };
78
- var expectedCustomersValue = expectedCustomersControl.field.value;
78
+ var expectedCustomersValue = expectedCustomerControl.field.value;
79
79
  var expectedCustomersSelected = expectedCustomersValue;
80
80
  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.titleAr : expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.title, 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) {
81
81
  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.titleAr : item.title })) }), item.id === (expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.id) && _jsx(CheckIconStyled, {})] }));
@@ -27,14 +27,14 @@ var Connect = memo(function (props) {
27
27
  var open = React.useState(true)[0];
28
28
  var theme = useAppTheme().theme;
29
29
  var dispatch = useAppDispatch();
30
- var data = useAppSelector(settingsSelector).data;
30
+ var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, settingLoading = _a.loading;
31
31
  useAppConfig(__assign({ navigation: CONNECT_SCREENS_NAVIGATION }, props));
32
32
  useErrorListener();
33
33
  var activeScreen = data.activeScreen;
34
34
  useEffect(function () {
35
35
  dispatch(getCountries());
36
36
  }, []);
37
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(AnimationFlow, __assign({ open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: connectFeatureScreens.map(function (_a, index) {
37
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(AnimationFlow, __assign({ loading: settingLoading, error: error, open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: connectFeatureScreens.map(function (_a, index) {
38
38
  var Element = _a.element, name = _a.name;
39
39
  var isActive = activeScreen.name === name;
40
40
  return (_jsx(Collapse, __assign({ in: isActive, timeout: { enter: 1000, exit: 800 } }, { children: _jsx(Element, {}) }), index));
@@ -5,8 +5,6 @@ interface BrandListProps {
5
5
  list: Array<BrandInfo>;
6
6
  onListOpen?: () => void;
7
7
  onListClose?: () => void;
8
- showTerms?: () => void;
9
- hideTerms?: () => void;
10
8
  }
11
9
  declare const _default: React.MemoExoticComponent<({ show, list, ...rest }: BrandListProps) => JSX.Element>;
12
10
  export default _default;
@@ -20,18 +20,10 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25
- if (ar || !(i in from)) {
26
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
27
- ar[i] = from[i];
28
- }
29
- }
30
- return to.concat(ar || Array.prototype.slice.call(from));
31
- };
32
23
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
33
24
  import * as React from 'react';
34
25
  import { useTranslation } from 'react-i18next';
26
+ import { useFormContext, useController } from 'react-hook-form';
35
27
  import Box from '@mui/material/Box';
36
28
  import { styled } from '@mui/material/styles';
37
29
  import { useLanguage } from '../../../../hooks';
@@ -42,7 +34,6 @@ import SimpleList from '../../../../components/SimpleList';
42
34
  import Text from '../../../../components/Text';
43
35
  import ExpandIcon from '../../../../components/ExpandIcon';
44
36
  import Collapse from '../../../../components/Collapse';
45
- import { OTHER_BRAND } from '../../../../constants';
46
37
  var InputStyled = styled(Input)(function () { return ({
47
38
  '& .MuiInputBase-input': {
48
39
  cursor: 'pointer'
@@ -57,11 +48,14 @@ var BrandNameText = styled(Text, { shouldForwardProp: function (prop) { return p
57
48
  });
58
49
  var BrandList = function (_a) {
59
50
  var show = _a.show, list = _a.list, rest = __rest(_a, ["show", "list"]);
60
- var _b = React.useState(list), brandList = _b[0], setBrandList = _b[1];
61
- var _c = React.useState(), selectedBrand = _c[0], setSelectedBrand = _c[1];
62
- var _d = React.useState(null), anchorEl = _d[0], setAnchorEl = _d[1];
51
+ var _b = React.useState(null), anchorEl = _b[0], setAnchorEl = _b[1];
63
52
  var t = useTranslation().t;
64
53
  var isAr = useLanguage().isAr;
54
+ var _c = useFormContext(), setValue = _c.setValue, control = _c.control;
55
+ var linksControl = useController({ control: control, name: 'links' });
56
+ var selectedBrandControl = useController({ control: control, name: 'selectedBrandItem' });
57
+ var links = linksControl.field.value;
58
+ var selectedBrand = selectedBrandControl.field.value;
65
59
  var onOpenBrandList = function (event) {
66
60
  var _a;
67
61
  setAnchorEl(event.currentTarget);
@@ -72,42 +66,24 @@ var BrandList = function (_a) {
72
66
  setAnchorEl(null);
73
67
  (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
74
68
  };
75
- React.useEffect(function () {
76
- var array = list;
77
- if ((array === null || array === void 0 ? void 0 : array.length) > 0) {
78
- var hasOther = array === null || array === void 0 ? void 0 : array.find(function (item) { return isOtherLicense(item); });
79
- var first = array[0];
80
- if (first) {
81
- setSelectedBrand(first);
82
- if (!hasOther)
83
- array = __spreadArray(__spreadArray([], array, true), [OTHER_BRAND], false);
84
- setBrandList(array);
85
- }
86
- }
87
- }, [show, list]);
88
69
  var getBrandName = function (item) {
89
70
  var _a, _b;
90
- return (isAr ? (_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en) || '';
71
+ return (isAr ? (_a = item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item.name) === null || _b === void 0 ? void 0 : _b.en) || '';
91
72
  };
92
73
  var getBrandId = function (item) {
93
- return (item === null || item === void 0 ? void 0 : item.id) || '';
74
+ return item.id || '';
94
75
  };
95
76
  var isOtherLicense = function (item) {
96
- return (item === null || item === void 0 ? void 0 : item.id) === 'other';
77
+ return item.id === 'other';
97
78
  };
98
79
  var onSelectItem = function (brand) {
99
- var _a, _b;
100
- setSelectedBrand(brand);
80
+ selectedBrandControl.field.onChange(brand);
101
81
  onCloseBrandList();
102
- if (isOtherLicense(brand)) {
103
- (_a = rest.showTerms) === null || _a === void 0 ? void 0 : _a.call(rest);
104
- return;
105
- }
106
- (_b = rest.hideTerms) === null || _b === void 0 ? void 0 : _b.call(rest);
82
+ var website = brand.website;
83
+ setValue('links', __assign(__assign({}, links), { website: website }), { shouldValidate: true });
107
84
  };
108
- var hasList = (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0;
109
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsxs(Collapse, __assign({ in: hasList }, { children: [_jsx(InputStyled, { label: t('select_brand_label'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseBrandList(); } : onOpenBrandList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_brand'), value: t(getBrandName(selectedBrand)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'id', list: brandList, onSelectItem: onSelectItem, renderItem: function (item) {
110
- return (_jsxs(_Fragment, { children: [_jsx(BrandContainer, { children: _jsx(BrandNameText, __assign({ isSelected: getBrandId(item) === getBrandId(selectedBrand) }, { children: isOtherLicense(item) ? t(getBrandName(item)) : getBrandName(item) })) }), getBrandId(item) === getBrandId(selectedBrand) && _jsx(CheckIcon, {})] }));
111
- } }) }))] })) }) })));
85
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputStyled, { label: t('select_brand_label'), readOnly: true, onClick: !!anchorEl ? onCloseBrandList : onOpenBrandList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_brand'), value: t(getBrandName(selectedBrand)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'id', list: list, onSelectItem: onSelectItem, renderItem: function (item) {
86
+ return (_jsxs(_Fragment, { children: [_jsx(BrandContainer, { children: _jsx(BrandNameText, __assign({ isSelected: getBrandId(item) === getBrandId(selectedBrand) }, { children: isOtherLicense(item) ? t(getBrandName(item)) : getBrandName(item) })) }), getBrandId(item) === getBrandId(selectedBrand) && _jsx(CheckIcon, {})] }));
87
+ } }) }))] }) })));
112
88
  };
113
89
  export default React.memo(BrandList);
@@ -23,27 +23,34 @@ import { ScreenContainer } from '../../../shared/Containers';
23
23
  import Button from '../../../shared/Button';
24
24
  import { clearError, connectSelector, updateLeadBrand } from '../../../app/connect/connectStore';
25
25
  import { useLanguage } from '../../../../hooks';
26
- import { MerchantValidationSchema } from './validation';
26
+ import { MerchantValidationSchema, ValidationOptions } from './validation';
27
27
  import BrandName from './BrandName';
28
28
  import SocialMedia from './SocialMedia';
29
29
  import TAC from './TAC';
30
30
  import BrandList from './BrandList';
31
31
  var Merchant = function (_a) {
32
- var _b, _c, _d, _e, _f, _g, _h;
33
- var _j = React.useState(false), brandNameChecking = _j[0], setBrandNameChecking = _j[1];
34
- var _k = useSelector(connectSelector), data = _k.data, loading = _k.loading, error = _k.error;
32
+ var _b, _c, _d;
33
+ var _e = React.useState(false), brandNameChecking = _e[0], setBrandNameChecking = _e[1];
34
+ var _f = React.useState(ValidationOptions.NEW_USER), userType = _f[0], setUserType = _f[1];
35
+ var _g = React.useState(false), listActive = _g[0], setListActive = _g[1];
36
+ var _h = useSelector(connectSelector), data = _h.data, loading = _h.loading, error = _h.error;
35
37
  var isNewUser = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.new_user;
36
- var _l = React.useState(isNewUser), isOther = _l[0], setIsOther = _l[1];
38
+ var isAbsher = data.otpData.isAbsher;
39
+ var brandList = ((_c = data.brandData.responseBody) === null || _c === void 0 ? void 0 : _c.brands) || [];
40
+ var _j = data.brandData, brandName = _j.brandName, links = _j.links, selectedBrandItem = _j.selectedBrandItem, termAndConditionChecked = _j.termAndConditionChecked, responseBody = _j.responseBody;
37
41
  var methods = useForm({
38
- resolver: yupResolver(MerchantValidationSchema(isOther)),
39
- defaultValues: data.brandData,
42
+ resolver: yupResolver(MerchantValidationSchema(userType)),
43
+ defaultValues: {
44
+ brandName: brandName,
45
+ links: links,
46
+ selectedBrandItem: selectedBrandItem,
47
+ termAndConditionChecked: termAndConditionChecked
48
+ },
40
49
  mode: 'onChange'
41
50
  });
42
51
  var t = useTranslation().t;
43
52
  var isAr = useLanguage().isAr;
44
53
  var dispatch = useAppDispatch();
45
- var isAbsher = data.otpData.isAbsher;
46
- var _m = React.useState(false), listActive = _m[0], setListActive = _m[1];
47
54
  var onSubmit = function (formData) {
48
55
  dispatch(updateLeadBrand(formData));
49
56
  };
@@ -54,26 +61,38 @@ var Merchant = function (_a) {
54
61
  }
55
62
  dispatch(handlePrevScreenStep(isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
56
63
  };
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]);
65
64
  React.useEffect(function () {
66
65
  if (error)
67
66
  dispatch(clearError());
68
67
  }, [methods.formState.isValid]);
69
68
  React.useEffect(function () {
70
- var _a, _b;
71
- if (((_b = (_a = data.brandData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.response_code) === '5')
69
+ if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.response_code) === '5')
72
70
  methods.setError('brandName', { message: 'Profile Name already exists' });
73
- }, [(_c = data.brandData) === null || _c === void 0 ? void 0 : _c.responseBody]);
71
+ }, [responseBody]);
72
+ React.useEffect(function () {
73
+ if (isNewUser === true) {
74
+ setUserType(ValidationOptions.NEW_USER);
75
+ }
76
+ if (isNewUser === false && methods.getValues('selectedBrandItem').id === 'other') {
77
+ setUserType(ValidationOptions.EXISTING_USER_WITH_OTHER_BRAND);
78
+ methods.clearErrors();
79
+ setTimeout(function () { return methods.setValue('brandName', '', { shouldValidate: true }); }, 100);
80
+ }
81
+ if (isNewUser === false && methods.getValues('selectedBrandItem').id !== 'other') {
82
+ setUserType(ValidationOptions.EXISTING_USER_WITH_EXIST_BRAND);
83
+ methods.clearErrors();
84
+ var sites_1 = __assign(__assign({}, links), { website: selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.website });
85
+ setTimeout(function () { return methods.setValue('links', sites_1, { shouldValidate: true }); }, 100);
86
+ }
87
+ }, [methods.getValues('selectedBrandItem'), isNewUser]);
88
+ React.useEffect(function () {
89
+ if (selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.id)
90
+ methods.setValue('selectedBrandItem', selectedBrandItem, { shouldValidate: true });
91
+ }, [selectedBrandItem]);
74
92
  var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
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';
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;
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') })) }))] })) })) }));
93
+ var disabled = brandErrChecks || brandNameChecking || ((_d = data.brandData.responseBody) === null || _d === void 0 ? void 0 : _d.response_code) === '5';
94
+ var isBrandListAvailable = userType !== ValidationOptions.NEW_USER && brandList.length > 0;
95
+ var askingForBrandInfo = userType === ValidationOptions.NEW_USER || userType === ValidationOptions.EXISTING_USER_WITH_OTHER_BRAND;
96
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: isBrandListAvailable, list: brandList, onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); } }), _jsx(BrandName, { show: !listActive && askingForBrandInfo, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(SocialMedia, { show: !listActive, isNewUser: isNewUser }), _jsx(TAC, { show: !listActive && askingForBrandInfo }), _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') })) }))] })) })) }));
78
97
  };
79
98
  export default React.memo(Merchant);
@@ -3,6 +3,7 @@ import { Theme, SxProps } from '@mui/material/styles';
3
3
  interface SocialMediaProps {
4
4
  show: boolean;
5
5
  sx?: SxProps<Theme>;
6
+ isNewUser: boolean;
6
7
  }
7
- declare const _default: React.MemoExoticComponent<({ show, sx }: SocialMediaProps) => JSX.Element>;
8
+ declare const _default: React.MemoExoticComponent<({ show, sx, isNewUser }: SocialMediaProps) => JSX.Element>;
8
9
  export default _default;
@@ -57,12 +57,13 @@ var ClearIconStyled = styled(ClearIcon)(function (_a) {
57
57
  });
58
58
  var SocialMedia = function (_a) {
59
59
  var _b, _c, _d;
60
- var show = _a.show, sx = _a.sx;
60
+ var show = _a.show, sx = _a.sx, isNewUser = _a.isNewUser;
61
61
  var _e = React.useState(SocialMediaTypes.WEB), socialMediaType = _e[0], setSocialMediaType = _e[1];
62
62
  var t = useTranslation().t;
63
- var control = useFormContext().control;
63
+ var _f = useFormContext(), control = _f.control, setValue = _f.setValue, watch = _f.watch;
64
64
  var linksControl = useController({ control: control, name: 'links' });
65
65
  var links = linksControl.field.value;
66
+ var brandName = watch('brandName');
66
67
  var handleChange = function (_a) {
67
68
  var _b;
68
69
  var target = _a.target;
@@ -72,6 +73,32 @@ var SocialMedia = function (_a) {
72
73
  var _a;
73
74
  linksControl.field.onChange(__assign(__assign({}, links), (_a = {}, _a[socialMediaType] = '', _a)));
74
75
  };
76
+ var handleBlueWebsite = function () {
77
+ if (!!links.website) {
78
+ var website = links.website;
79
+ var isWebHasPrefix = !!website.includes('www.');
80
+ var isWebHasSuffix = !!website.includes('.com');
81
+ if (!isWebHasPrefix)
82
+ website = "www.".concat(website);
83
+ if (!isWebHasSuffix)
84
+ website = "".concat(website, ".com");
85
+ setValue('links', __assign(__assign({}, links), { website: website }), { shouldValidate: true });
86
+ }
87
+ };
88
+ React.useEffect(function () {
89
+ if (!!brandName) {
90
+ var website = "www.".concat(brandName.replaceAll(' ', '-'), ".com");
91
+ setValue('links', __assign(__assign({}, links), { website: website }), { shouldValidate: true });
92
+ }
93
+ if (!brandName && isNewUser === false) {
94
+ var website = "other.com";
95
+ setValue('links', __assign(__assign({}, links), { website: website }), { shouldValidate: true });
96
+ }
97
+ if (!brandName && isNewUser === true) {
98
+ var website = '';
99
+ setValue('links', __assign(__assign({}, links), { website: website }));
100
+ }
101
+ }, [brandName]);
75
102
  var websiteValue = links.website || '';
76
103
  var twitterValue = links.twitter || '';
77
104
  var instagramValue = links.instagram || '';
@@ -81,6 +108,6 @@ var SocialMedia = function (_a) {
81
108
  var instagramError = (_d = errors === null || errors === void 0 ? void 0 : errors.instagram) === null || _d === void 0 ? void 0 : _d.message;
82
109
  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
110
  setSocialMediaType(value);
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 })) }) }))] })) })));
111
+ } }), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.WEB, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: websiteValue, onBlur: function () { return handleBlueWebsite(); }, 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
112
  };
86
113
  export default React.memo(SocialMedia);
@@ -1,5 +1,10 @@
1
1
  import * as yup from 'yup';
2
- export declare const MerchantValidationSchema: (isOther: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
2
+ export declare enum ValidationOptions {
3
+ NEW_USER = "NEW_USER",
4
+ EXISTING_USER_WITH_EXIST_BRAND = "EXISTING_USER_WITH_EXIST_BRAND",
5
+ EXISTING_USER_WITH_OTHER_BRAND = "EXISTING_USER_WITH_OTHER_BRAND"
6
+ }
7
+ export declare const MerchantValidationSchema: (userType: ValidationOptions) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
8
  brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
4
9
  termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, boolean | undefined>;
5
10
  links: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
@@ -1,15 +1,75 @@
1
1
  import { REGEX_WEBSITE } from '../../../../constants';
2
2
  import * as yup from 'yup';
3
- export var MerchantValidationSchema = function (isOther) {
4
- return yup.object().shape({
5
- brandName: isOther
6
- ? yup
3
+ export var ValidationOptions;
4
+ (function (ValidationOptions) {
5
+ ValidationOptions["NEW_USER"] = "NEW_USER";
6
+ ValidationOptions["EXISTING_USER_WITH_EXIST_BRAND"] = "EXISTING_USER_WITH_EXIST_BRAND";
7
+ ValidationOptions["EXISTING_USER_WITH_OTHER_BRAND"] = "EXISTING_USER_WITH_OTHER_BRAND";
8
+ })(ValidationOptions || (ValidationOptions = {}));
9
+ export var MerchantValidationSchema = function (userType) {
10
+ var askingForBrandInfo = userType === ValidationOptions.NEW_USER || userType === ValidationOptions.EXISTING_USER_WITH_OTHER_BRAND;
11
+ if (askingForBrandInfo) {
12
+ return yup.object().shape({
13
+ brandName: yup
7
14
  .string()
8
15
  .min(3, 'enter_brand_name_english_chars_numbers_space')
9
16
  .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(),
17
+ .required('enter_valid_brand_name'),
18
+ termAndConditionChecked: yup.boolean().required().isTrue('check_terms_cond'),
19
+ links: yup.object().shape({
20
+ website: yup.string().when(['instagram', 'twitter'], function (instagram, twitter) {
21
+ if (!instagram && !twitter) {
22
+ return yup
23
+ .string()
24
+ .matches(REGEX_WEBSITE, 'ide_not_valid_url')
25
+ .transform(function (value) { return (!!value ? value : null); })
26
+ .nullable()
27
+ .required('enter_at_least_one');
28
+ }
29
+ else {
30
+ return yup
31
+ .string()
32
+ .matches(REGEX_WEBSITE, 'ide_not_valid_url')
33
+ .transform(function (value) { return (!!value ? value : null); })
34
+ .nullable()
35
+ .optional();
36
+ }
37
+ }),
38
+ instagram: yup
39
+ .string()
40
+ .nullable()
41
+ .transform(function (value) { return (!!value ? value : null); })
42
+ .when(['twitter', 'website'], function (twitter, website) {
43
+ if (!website && !twitter) {
44
+ return yup.string().min(2, 'enter_at_least_one').required('enter_at_least_one');
45
+ }
46
+ else {
47
+ return yup.string().optional();
48
+ }
49
+ }),
50
+ twitter: yup
51
+ .string()
52
+ .nullable()
53
+ .transform(function (value) { return (!!value ? value : null); })
54
+ .min(2, 'enter_at_least_one')
55
+ .when(['website', 'instagram'], function (website, instagram) {
56
+ if (!website && !instagram) {
57
+ return yup.string().min(2, 'enter_at_least_one').required('enter_at_least_one');
58
+ }
59
+ else {
60
+ return yup.string().optional();
61
+ }
62
+ })
63
+ }, [
64
+ ['instagram', 'website'],
65
+ ['twitter', 'website'],
66
+ ['instagram', 'twitter']
67
+ ])
68
+ });
69
+ }
70
+ return yup.object().shape({
71
+ brandName: yup.string().optional(),
72
+ termAndConditionChecked: yup.boolean().optional(),
13
73
  links: yup.object().shape({
14
74
  website: yup.string().when(['instagram', 'twitter'], function (instagram, twitter) {
15
75
  if (!instagram && !twitter) {
@@ -116,7 +116,7 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
116
116
  setValue('mobile', '');
117
117
  countryCodeControl.field.onChange(country);
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: 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) {
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: !anchorEl ? error && t(error, { length: requiredLen, number: '05|5' }) : undefined }), _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
  });