@tap-payments/auth-jsconnect 1.0.49 → 1.0.50

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.
@@ -154,7 +154,7 @@ export var settingsSlice = createSlice({
154
154
  },
155
155
  handleActiveFlowScreens: function (state, action) {
156
156
  state.data.featureScreensNavigation = action.payload;
157
- state.data.activeScreen = action.payload[3];
157
+ state.data.activeScreen = action.payload[0];
158
158
  },
159
159
  handleSetAppConfig: function (state, action) {
160
160
  var _a = action.payload, appInfo = _a.appInfo, businessCountryCode = _a.businessCountryCode, language = _a.language, onError = _a.onError, onFlowCompleted = _a.onFlowCompleted, publicKey = _a.publicKey;
@@ -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;
@@ -138,6 +138,6 @@ var BrandName = function (_a) {
138
138
  var clearBrandName = function () {
139
139
  brandControl.field.onChange('');
140
140
  };
141
- 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: 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
+ 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 })) })] })) })));
142
142
  };
143
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",