@tap-payments/auth-jsconnect 2.0.43 → 2.0.44

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 (32) hide show
  1. package/build/features/app/business/businessStore.d.ts +2 -11
  2. package/build/features/app/business/businessStore.js +168 -156
  3. package/build/features/app/connect/connectStore.js +4 -4
  4. package/build/features/app/entity/entityStore.js +6 -4
  5. package/build/features/app/individual/individualStore.js +14 -0
  6. package/build/features/bank/screens/BankDetails/IBAN.js +1 -4
  7. package/build/features/bank/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  8. package/build/features/business/screens/Activities/validation.js +1 -4
  9. package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  10. package/build/features/connect/screens/Individual/Individual.js +4 -0
  11. package/build/features/connect/screens/Merchant/Merchant.js +4 -10
  12. package/build/features/connect/screens/Merchant/SalesChannels.d.ts +1 -2
  13. package/build/features/connect/screens/Merchant/SalesChannels.js +6 -4
  14. package/build/features/connect/screens/Merchant/SocialMedia.d.ts +1 -3
  15. package/build/features/connect/screens/Merchant/SocialMedia.js +33 -7
  16. package/build/features/connect/screens/Merchant/validation.js +5 -3
  17. package/build/features/connect/screens/ThankYou/ThankYou.js +2 -8
  18. package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  19. package/build/features/individual/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  20. package/build/features/password/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  21. package/build/features/shared/Button/Button.js +0 -1
  22. package/build/features/shared/SuccessScreen/SuccessScreen.d.ts +1 -1
  23. package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  24. package/build/utils/array.d.ts +0 -1
  25. package/build/utils/array.js +0 -8
  26. package/build/utils/index.d.ts +0 -1
  27. package/build/utils/index.js +0 -1
  28. package/build/utils/string.d.ts +0 -1
  29. package/build/utils/string.js +2 -14
  30. package/package.json +1 -1
  31. package/build/utils/date.d.ts +0 -1
  32. package/build/utils/date.js +0 -5
@@ -421,7 +421,7 @@ var initialState = {
421
421
  licenseNumber: '',
422
422
  licenseType: BusinessType.CR,
423
423
  activities: [],
424
- operationStartDate: moment(new Date()).format('YYYY-MM-DD'),
424
+ operationStartDate: '',
425
425
  uploading: false
426
426
  },
427
427
  customersData: {
@@ -485,8 +485,9 @@ export var entitySlice = createSlice({
485
485
  var _a;
486
486
  return (_a = brand === null || brand === void 0 ? void 0 : brand.activities) === null || _a === void 0 ? void 0 : _a.find(function (value) { return value.id === activity.id; });
487
487
  });
488
- state.data.entityData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [];
489
- state.data.entityData.responseBody = __assign(__assign({}, state.data.entityData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities, operationStartDate: startDate || issuingDate, selectedActivities: (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [] });
488
+ var defaultActivities = (activities === null || activities === void 0 ? void 0 : activities.length) ? [activities[0]] : [];
489
+ state.data.entityData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : defaultActivities;
490
+ state.data.entityData.responseBody = __assign(__assign({}, state.data.entityData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities, operationStartDate: startDate || issuingDate, selectedActivities: (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : defaultActivities });
490
491
  })
491
492
  .addCase(verifyLeadToken.rejected, function (state, action) {
492
493
  state.error = action.error.message;
@@ -546,7 +547,8 @@ export var entitySlice = createSlice({
546
547
  var _a;
547
548
  return (_a = brand === null || brand === void 0 ? void 0 : brand.activities) === null || _a === void 0 ? void 0 : _a.find(function (value) { return value.id === activity.id; });
548
549
  });
549
- state.data.entityData.responseBody = __assign(__assign({}, state.data.entityData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities, selectedActivities: (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [], operationStartDate: startDate || issuingDate });
550
+ var defaultActivities = (activities === null || activities === void 0 ? void 0 : activities.length) ? [activities[0]] : [];
551
+ state.data.entityData.responseBody = __assign(__assign({}, state.data.entityData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities, selectedActivities: (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : defaultActivities, operationStartDate: startDate || issuingDate });
550
552
  })
551
553
  .addCase(verifyEntityLeadOTP.rejected, function (state, action) {
552
554
  state.loading = false;
@@ -387,11 +387,18 @@ export var individualSlice = createSlice({
387
387
  (sourceIncomeList === null || sourceIncomeList === void 0 ? void 0 : sourceIncomeList[0]);
388
388
  if (!!selectedSourceIncome)
389
389
  state.data.individualData.sourceIncome = selectedSourceIncome;
390
+ var selectedMonthlyIncome = (monthlyIncomeList === null || monthlyIncomeList === void 0 ? void 0 : monthlyIncomeList.find(function (income) { return (income === null || income === void 0 ? void 0 : income.id) === (monthly_income === null || monthly_income === void 0 ? void 0 : monthly_income.id); })) ||
391
+ (monthlyIncomeList === null || monthlyIncomeList === void 0 ? void 0 : monthlyIncomeList[2]);
392
+ if (!!selectedMonthlyIncome)
393
+ state.data.individualData.monthlyIncome = selectedMonthlyIncome;
390
394
  var code = (user === null || user === void 0 ? void 0 : user.employer_country) || countryCode;
391
395
  if (!!code) {
392
396
  var employerLocation = (countries || []).find(function (country) { return country.iso2 === code; });
393
397
  state.data.individualData.employerLocation = employerLocation;
394
398
  }
399
+ var selectedOccupation = (occupationList === null || occupationList === void 0 ? void 0 : occupationList.find(function (o) { return (o === null || o === void 0 ? void 0 : o.id) === (occupation === null || occupation === void 0 ? void 0 : occupation.id); })) || (occupationList === null || occupationList === void 0 ? void 0 : occupationList[0]);
400
+ if (!!selectedOccupation)
401
+ state.data.individualData.occupation = selectedOccupation;
395
402
  state.data.individualData.isPEP = is_relative_PEP;
396
403
  state.data.individualData.isInfluencer = is_influencer;
397
404
  })
@@ -440,11 +447,18 @@ export var individualSlice = createSlice({
440
447
  (sourceIncomeList === null || sourceIncomeList === void 0 ? void 0 : sourceIncomeList[0]);
441
448
  if (!!selectedSourceIncome)
442
449
  state.data.individualData.sourceIncome = selectedSourceIncome;
450
+ var selectedMonthlyIncome = (monthlyIncomeList === null || monthlyIncomeList === void 0 ? void 0 : monthlyIncomeList.find(function (income) { return (income === null || income === void 0 ? void 0 : income.id) === (monthly_income === null || monthly_income === void 0 ? void 0 : monthly_income.id); })) ||
451
+ (monthlyIncomeList === null || monthlyIncomeList === void 0 ? void 0 : monthlyIncomeList[2]);
452
+ if (!!selectedMonthlyIncome)
453
+ state.data.individualData.monthlyIncome = selectedMonthlyIncome;
443
454
  var code = (user === null || user === void 0 ? void 0 : user.employer_country) || countryCode;
444
455
  if (!!code) {
445
456
  var employerLocation = (countries || []).find(function (country) { return country.iso2 === code; });
446
457
  state.data.individualData.employerLocation = employerLocation;
447
458
  }
459
+ var selectedOccupation = (occupationList === null || occupationList === void 0 ? void 0 : occupationList.find(function (o) { return (o === null || o === void 0 ? void 0 : o.id) === (occupation === null || occupation === void 0 ? void 0 : occupation.id); })) || (occupationList === null || occupationList === void 0 ? void 0 : occupationList[0]);
460
+ if (!!selectedOccupation)
461
+ state.data.individualData.occupation = selectedOccupation;
448
462
  state.data.individualData.isPEP = is_relative_PEP;
449
463
  state.data.individualData.isInfluencer = is_influencer;
450
464
  })
@@ -50,8 +50,6 @@ import axios from 'axios';
50
50
  import ClearIcon from '../../../shared/ClearIcon';
51
51
  import CheckIcon from '../../../shared/CheckIcon';
52
52
  import CircularProgress from '@mui/material/CircularProgress';
53
- import { settingsSelector } from '../../../../app/settings';
54
- import { useAppSelector } from '../../../../hooks';
55
53
  var InputStyled = styled(Input)(function () { return ({
56
54
  input: {
57
55
  textTransform: 'uppercase'
@@ -62,7 +60,6 @@ var IBAN = function (_a) {
62
60
  var _b;
63
61
  var fetchingIban = _a.fetchingIban, ibanChecking = _a.ibanChecking;
64
62
  var dispatch = useAppDispatch();
65
- var settingsData = useAppSelector(settingsSelector).data;
66
63
  var t = useTranslation().t;
67
64
  var control = useFormContext().control;
68
65
  var ibanControl = useController({ name: 'iban', control: control });
@@ -95,6 +92,6 @@ var IBAN = function (_a) {
95
92
  var clearValue = function () {
96
93
  ibanControl.field.onChange('');
97
94
  };
98
- return (_jsx(ScreenContainer, { children: _jsx(InputStyled, { label: t('enter_iban'), inputProps: { maxLength: MAX_IBAN_VALUE }, onChange: handleIbanChange, value: ibanValue, placeholder: t('iban_input_placeholder', { countrycode: settingsData.businessCountry.iso2.toUpperCase() }), warningType: 'alert', warningMessage: error && t(error), required: true, endAdornment: ibanChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && ibanValue ? (_jsx(CheckIcon, {})) : (ibanValue && _jsx(ClearIcon, { onClick: clearValue })) }) }));
95
+ return (_jsx(ScreenContainer, { children: _jsx(InputStyled, { label: t('enter_iban'), inputProps: { maxLength: MAX_IBAN_VALUE }, onChange: handleIbanChange, value: ibanValue, placeholder: t('enter_iban_placeholder'), warningType: 'alert', warningMessage: error && t(error), required: true, endAdornment: ibanChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && ibanValue ? (_jsx(CheckIcon, {})) : (ibanValue && _jsx(ClearIcon, { onClick: clearValue })) }) }));
99
96
  };
100
97
  export default IBAN;
@@ -16,7 +16,7 @@ import { styled } from '@mui/material/styles';
16
16
  import { FlowsButtons } from '../../../shared/Button';
17
17
  import { ICONS_NAMES, PASSWORD_OPERATION_TYPE } from '../../../../constants';
18
18
  import { useAppSelector, useLanguage } from '../../../../hooks';
19
- import { getResetFlowUrl, showLastFour, concatenateObjectValues, shortenBankName } from '../../../../utils';
19
+ import { getResetFlowUrl, showLastFour, concatenateObjectValues } from '../../../../utils';
20
20
  import { bankSelector } from '../../../app/bank/bankStore';
21
21
  import Box from '@mui/material/Box';
22
22
  import Text from '../../../../components/Text';
@@ -55,7 +55,7 @@ var SuccessWithFlowButtons = function () {
55
55
  ? concatenateObjectValues(ar || en, ['first', 'last'])
56
56
  : concatenateObjectValues(en, ['first', 'last']);
57
57
  var licenseNumber = ((_a = entity === null || entity === void 0 ? void 0 : entity.license) === null || _a === void 0 ? void 0 : _a.number) || '';
58
- var bankName = shortenBankName(bank === null || bank === void 0 ? void 0 : bank.name) || t('bank');
58
+ var bankName = (bank === null || bank === void 0 ? void 0 : bank.name) || t('bank');
59
59
  var iban = showLastFour((bank === null || bank === void 0 ? void 0 : bank.iban) || '');
60
60
  var taxID = (entity === null || entity === void 0 ? void 0 : entity.vat_id) || '';
61
61
  var brandName = (isAr ? (_b = brand === null || brand === void 0 ? void 0 : brand.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = brand === null || brand === void 0 ? void 0 : brand.name) === null || _c === void 0 ? void 0 : _c.en) || '';
@@ -1,9 +1,6 @@
1
1
  import * as yup from 'yup';
2
2
  export var ActivitiesValidationSchema = yup.object().shape({
3
- activities: yup
4
- .array()
5
- .min(1, 'activities_list_alert')
6
- .of(yup.object().shape({
3
+ activities: yup.array().of(yup.object().shape({
7
4
  ar: yup.string(),
8
5
  en: yup.string()
9
6
  })),
@@ -17,7 +17,7 @@ import { FlowsButtons } from '../../../shared/Button';
17
17
  import { ICONS_NAMES, PASSWORD_OPERATION_TYPE } from '../../../../constants';
18
18
  import { useAppSelector, useLanguage } from '../../../../hooks';
19
19
  import { businessSelector } from '../../../app/business/businessStore';
20
- import { concatenateObjectValues, getResetFlowUrl, shortenBankName, showLastFour } from '../../../../utils';
20
+ import { concatenateObjectValues, getResetFlowUrl, showLastFour } from '../../../../utils';
21
21
  import Box from '@mui/material/Box';
22
22
  import Text from '../../../../components/Text';
23
23
  import Container from '../../../shared/Containers/ScreenContainer';
@@ -55,7 +55,7 @@ var SuccessWithFlowButtons = function () {
55
55
  ? concatenateObjectValues(ar || en, ['first', 'last'])
56
56
  : concatenateObjectValues(en, ['first', 'last']);
57
57
  var licenseNumber = ((_a = entity === null || entity === void 0 ? void 0 : entity.license) === null || _a === void 0 ? void 0 : _a.number) || '';
58
- var bankName = shortenBankName(bank === null || bank === void 0 ? void 0 : bank.bank_name) || t('bank');
58
+ var bankName = (bank === null || bank === void 0 ? void 0 : bank.bank_name) || t('bank');
59
59
  var iban = showLastFour((bank === null || bank === void 0 ? void 0 : bank.iban) || '');
60
60
  var taxID = (entity === null || entity === void 0 ? void 0 : entity.vat_id) || '';
61
61
  var brandName = (isAr ? (_b = brand === null || brand === void 0 ? void 0 : brand.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = brand === null || brand === void 0 ? void 0 : brand.name) === null || _c === void 0 ? void 0 : _c.en) || '';
@@ -67,6 +67,10 @@ var Individual = function (_a) {
67
67
  mode: 'onChange'
68
68
  });
69
69
  useSetFromDefaultValues(methods, defaultValues, true);
70
+ React.useEffect(function () {
71
+ if (defaultValues.countryCode.iso2 !== methods.getValues('countryCode.iso2'))
72
+ methods.setValue('countryCode', defaultValues.countryCode);
73
+ }, [defaultValues.countryCode]);
70
74
  var onSubmit = function (formData) {
71
75
  dispatch(updateLeadIndividual(formData));
72
76
  };
@@ -23,7 +23,7 @@ import Button from '../../../shared/Button';
23
23
  import { clearError, connectSelector, updateLeadBrand } from '../../../app/connect/connectStore';
24
24
  import { useLanguage } from '../../../../hooks';
25
25
  import { AuthForType } from '../../../../@types';
26
- import { findFirstId, isKW, mapSalesChannel } from '../../../../utils';
26
+ import { isKW, mapSalesChannel } from '../../../../utils';
27
27
  import { MerchantValidationSchema } from './validation';
28
28
  import BrandName from './BrandName';
29
29
  import SocialMedia from './SocialMedia';
@@ -35,12 +35,11 @@ var Merchant = function (_a) {
35
35
  var _d = React.useState(false), brandNameChecking = _d[0], setBrandNameChecking = _d[1];
36
36
  var _e = React.useState(false), isBrandListOpen = _e[0], setIsBrandListOpen = _e[1];
37
37
  var _f = React.useState(false), isRequiredNewBrand = _f[0], setIsRequiredNewBrand = _f[1];
38
- var _g = React.useState(''), activeIconId = _g[0], setActiveIconId = _g[1];
39
- var _h = useAppSelector(connectSelector), data = _h.data, loading = _h.loading, error = _h.error;
38
+ var _g = useAppSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error;
40
39
  var settingsData = useAppSelector(settingsSelector).data;
41
40
  var isNewIndividual = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.is_new_individual;
42
41
  var startWithNID = data.otpData.authFor === AuthForType.NATIONAL_ID;
43
- var _j = data.brandData, brandName = _j.brandName, selectedBrandItem = _j.selectedBrandItem, termAndConditionChecked = _j.termAndConditionChecked, responseBody = _j.responseBody, salesChannels = _j.salesChannels;
42
+ var _h = data.brandData, brandName = _h.brandName, selectedBrandItem = _h.selectedBrandItem, termAndConditionChecked = _h.termAndConditionChecked, responseBody = _h.responseBody, salesChannels = _h.salesChannels;
44
43
  var brandList = (responseBody || {}).brand_list;
45
44
  var methods = useForm({
46
45
  resolver: yupResolver(MerchantValidationSchema(isRequiredNewBrand)),
@@ -77,21 +76,16 @@ var Merchant = function (_a) {
77
76
  if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.response_code) === '5')
78
77
  methods.setError('brandName', { message: 'brand_name_already_exist' });
79
78
  }, [responseBody]);
80
- var onSaleIconChange = function (id) {
81
- setActiveIconId(id);
82
- };
83
79
  React.useEffect(function () {
84
80
  if (selectedBrandItem.id) {
85
81
  methods.setValue('selectedBrandItem', selectedBrandItem);
86
82
  var sales = mapSalesChannel(selectedBrandItem.channel_services || []);
87
- setActiveIconId(findFirstId(sales));
88
83
  methods.setValue('salesChannels', sales, { shouldValidate: true });
89
84
  }
90
85
  }, [selectedBrandItem]);
91
86
  React.useEffect(function () {
92
87
  if (salesChannels.length > 0) {
93
88
  var sales = mapSalesChannel(salesChannels);
94
- setActiveIconId(findFirstId(sales));
95
89
  methods.setValue('salesChannels', sales, { shouldValidate: true });
96
90
  }
97
91
  }, [salesChannels]);
@@ -107,6 +101,6 @@ var Merchant = function (_a) {
107
101
  React.useEffect(function () {
108
102
  setIsRequiredNewBrand(isOtherBrand || isNewBrand);
109
103
  }, [isOtherBrand, isNewBrand]);
110
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: !(isOtherBrand || isNewBrand), list: brandList, onListOpen: function () { return setIsBrandListOpen(true); }, onListClose: function () { return setIsBrandListOpen(false); } }), _jsx(BrandName, { show: (isNewBrand || isOtherBrand) && !isBrandListOpen, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(Collapse, __assign({ in: !isBrandListOpen }, { children: _jsx(SalesChannels, { onSaleIconChange: onSaleIconChange }) })), _jsx(SocialMedia, { show: !isBrandListOpen, activeIconId: activeIconId, onSaleIconChange: onSaleIconChange }), _jsx(TAC, { show: (isNewBrand || isOtherBrand) && !isBrandListOpen }), _jsx(Collapse, __assign({ in: !isBrandListOpen, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
104
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: !(isOtherBrand || isNewBrand), list: brandList, onListOpen: function () { return setIsBrandListOpen(true); }, onListClose: function () { return setIsBrandListOpen(false); } }), _jsx(BrandName, { show: (isNewBrand || isOtherBrand) && !isBrandListOpen, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(Collapse, __assign({ in: !isBrandListOpen }, { children: _jsx(SalesChannels, {}) })), _jsx(SocialMedia, { show: !isBrandListOpen }), _jsx(TAC, { show: (isNewBrand || isOtherBrand) && !isBrandListOpen }), _jsx(Collapse, __assign({ in: !isBrandListOpen, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
111
105
  };
112
106
  export default React.memo(Merchant);
@@ -2,7 +2,6 @@ import * as React from 'react';
2
2
  export declare const MandatoryStyled: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
3
3
  export declare const CollapseStyled: import("@emotion/styled").StyledComponent<import("../../../../components/Collapse").CollapseProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
4
4
  interface SalesChannelsProps {
5
- onSaleIconChange: (id: string) => void;
6
5
  }
7
- declare const SalesChannels: ({ onSaleIconChange }: SalesChannelsProps) => JSX.Element;
6
+ declare const SalesChannels: ({}: SalesChannelsProps) => JSX.Element;
8
7
  export default SalesChannels;
@@ -29,7 +29,6 @@ import { connectSelector, clearError } from '../../../app/connect/connectStore';
29
29
  import CheckBox from '../../../../components/CheckBox';
30
30
  import Warning from '../../../../components/Warning';
31
31
  import Collapse from '../../../../components/Collapse';
32
- import { findFirstId } from '../../../../utils';
33
32
  var InputLabelStyled = styled(Text)(function (_a) {
34
33
  var theme = _a.theme;
35
34
  return (__assign({ margin: theme.spacing(2.5, 2.5, 0.5, 2.5), color: alpha(theme.palette.text.primary, 0.4) }, theme.typography.caption));
@@ -75,7 +74,6 @@ export var CollapseStyled = styled(Collapse)(function (_a) {
75
74
  });
76
75
  var SalesChannels = function (_a) {
77
76
  var _b;
78
- var onSaleIconChange = _a.onSaleIconChange;
79
77
  var t = useTranslation().t;
80
78
  var isAr = useLanguage().isAr;
81
79
  var _c = useFormContext(), control = _c.control, getValues = _c.getValues;
@@ -92,12 +90,16 @@ var SalesChannels = function (_a) {
92
90
  dispatch(clearError());
93
91
  if (isChecked(channel.id)) {
94
92
  var filterChannels = channelsControl.field.value.filter(function (item) { return item.id !== channel.id; });
95
- onSaleIconChange(findFirstId([filterChannels.at(-1)]));
96
93
  channelsControl.field.onChange(filterChannels);
97
94
  }
98
95
  else {
99
- onSaleIconChange(findFirstId([channel]));
96
+ var brandName = getValues('brandName');
100
97
  var newChannel = __assign({}, channel);
98
+ if (newChannel.code === 'website' && brandName) {
99
+ var brandValue = brandName.replaceAll(' ', '-').toLowerCase();
100
+ var address = (brandValue[brandValue.length - 1] === '-' ? brandValue.slice(0, -1) : brandValue) + '.com';
101
+ newChannel.address = 'www.' + address;
102
+ }
101
103
  channelsControl.field.onChange(__spreadArray(__spreadArray([], channelsControl.field.value, true), [newChannel], false));
102
104
  }
103
105
  };
@@ -1,8 +1,6 @@
1
1
  import * as React from 'react';
2
2
  interface SocialMediaProps {
3
3
  show: boolean;
4
- activeIconId: string;
5
- onSaleIconChange: (id: string) => void;
6
4
  }
7
- declare const _default: React.MemoExoticComponent<({ show, activeIconId, onSaleIconChange }: SocialMediaProps) => JSX.Element>;
5
+ declare const _default: React.MemoExoticComponent<({ show }: SocialMediaProps) => JSX.Element>;
8
6
  export default _default;
@@ -79,12 +79,16 @@ var SocialMediaButtonStyled = styled(ToggleButton, {
79
79
  });
80
80
  var SocialMedia = function (_a) {
81
81
  var _b;
82
- var show = _a.show, activeIconId = _a.activeIconId, onSaleIconChange = _a.onSaleIconChange;
82
+ var show = _a.show;
83
+ var _c = React.useState(''), activeSocialId = _c[0], setActiveSocialId = _c[1];
83
84
  var t = useTranslation().t;
84
85
  var isAr = useLanguage().isAr;
85
- var _c = useFormContext(), setValue = _c.setValue, watch = _c.watch, getFieldState = _c.getFieldState;
86
+ var _d = useFormContext(), setValue = _d.setValue, watch = _d.watch, getFieldState = _d.getFieldState;
86
87
  var selectedChannels = watch('salesChannels');
87
88
  var salesChannelsState = getFieldState('salesChannels');
89
+ var onChangeIcons = function (id) {
90
+ setActiveSocialId(id);
91
+ };
88
92
  var onChangeInput = function (value, id) {
89
93
  if (selectedChannels.length <= 0)
90
94
  return;
@@ -119,6 +123,28 @@ var SocialMedia = function (_a) {
119
123
  });
120
124
  setValue('salesChannels', __spreadArray([], updatedChannels, true), { shouldValidate: true });
121
125
  };
126
+ var setDefaultActiveSocialId = React.useCallback(function () {
127
+ var _a;
128
+ var idExist = selectedChannels.find(function (channel) {
129
+ var _a;
130
+ if ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) {
131
+ return channel.sub.find(function (subChannel) { return subChannel.id === activeSocialId; });
132
+ }
133
+ return channel.id === activeSocialId;
134
+ });
135
+ if (selectedChannels.length >= 1 && !idExist) {
136
+ var firstChannel = selectedChannels[0];
137
+ if ((_a = firstChannel.sub) === null || _a === void 0 ? void 0 : _a.length) {
138
+ setActiveSocialId(firstChannel.sub[0].id);
139
+ }
140
+ else {
141
+ setActiveSocialId(firstChannel.id);
142
+ }
143
+ }
144
+ }, [selectedChannels]);
145
+ React.useEffect(function () {
146
+ setDefaultActiveSocialId();
147
+ }, [setDefaultActiveSocialId]);
122
148
  var getPlaceHolder = function (item) {
123
149
  var _a, _b;
124
150
  if (isAr)
@@ -132,19 +158,19 @@ var SocialMedia = function (_a) {
132
158
  }, [salesChannelsState]);
133
159
  var linksErrorMsg = (_b = salesChannelsState.error) === null || _b === void 0 ? void 0 : _b.message;
134
160
  return (_jsx(Box, { children: _jsx(Collapse, __assign({ in: show && selectedChannels.length > 0 }, { children: _jsxs(Box, __assign({ sx: { mb: 3, direction: 'ltr' } }, { children: [_jsx(SocialMediaGroupStyled, __assign({ exclusive: true, onChange: function (e, value) {
135
- onSaleIconChange(value);
161
+ onChangeIcons(value);
136
162
  } }, { children: selectedChannels.map(function (channel, index) {
137
163
  var _a;
138
- var isActive = activeIconId === channel.id;
164
+ var isActive = activeSocialId === channel.id;
139
165
  return ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) ? (channel.sub.map(function (sub, subIndex) {
140
- var isSubActive = activeIconId === sub.id;
166
+ var isSubActive = activeSocialId === sub.id;
141
167
  return (_jsx(SocialMediaButtonStyled, __assign({ isShow: true, isActive: isSubActive, value: sub.id }, { children: _jsx(ToggleIconStyled, { isActive: isSubActive, src: (sub === null || sub === void 0 ? void 0 : sub.logo) || '' }) }), "sub_".concat(subIndex)));
142
168
  })) : (_jsx(SocialMediaButtonStyled, __assign({ isShow: true, isActive: isActive, value: channel.id || '' }, { children: _jsx(ToggleIconStyled, { isActive: isActive, src: (channel === null || channel === void 0 ? void 0 : channel.logo) || '' }) }), index));
143
169
  }) })), selectedChannels.map(function (channel, index) {
144
170
  var _a;
145
- var isActive = activeIconId === channel.id;
171
+ var isActive = activeSocialId === channel.id;
146
172
  return ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) ? (channel.sub.map(function (sub, subIndex) {
147
- var isSubActive = activeIconId === sub.id;
173
+ var isSubActive = activeSocialId === sub.id;
148
174
  return (_jsx(Collapse, __assign({ in: isSubActive, timeout: 300 }, { children: _jsx(InputStyled, { onChange: function (e) {
149
175
  onChangeInput(e.target.value, sub.id);
150
176
  }, value: sub.address || '', startAdornment: _jsx(TextStyled, __assign({ sx: __assign({}, (isTwitter(sub.code) && { fontSize: '20px' })) }, { children: isWebsite(sub.code) ? "https://" : isTwitter(sub.code) ? "@" : '' })), placeholder: t(getPlaceHolder(sub)) }) }), "sub_".concat(subIndex)));
@@ -7,7 +7,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
7
7
  }
8
8
  return to.concat(ar || Array.prototype.slice.call(from));
9
9
  };
10
- import { REGEX_WEBSITE, REGEX_BRAND_NAME, LINKEDIN_URL, SOCIAL_USERNAME, DIGITS_ONLY, REGEX_ALPHANUMERIC } from '../../../../constants';
10
+ import { REGEX_WEBSITE, REGEX_BRAND_NAME, LINKEDIN_URL, SOCIAL_USERNAME, DIGITS_ONLY, REGEX_PHONE_APP_NAME } from '../../../../constants';
11
11
  import * as yup from 'yup';
12
12
  var validationSalesChannels = function (channels) {
13
13
  if (channels === void 0) { channels = []; }
@@ -37,6 +37,8 @@ var validationSalesChannels = function (channels) {
37
37
  if (atLestOne)
38
38
  return "enter_at_least_one_".concat(key);
39
39
  }
40
+ console.log('dic', dic);
41
+ console.log('typeDic', typeDic);
40
42
  for (var key in typeDic) {
41
43
  var value = typeDic[key];
42
44
  if (key === 'website' && value && !value.match(REGEX_WEBSITE)) {
@@ -57,10 +59,10 @@ var validationSalesChannels = function (channels) {
57
59
  if (key === 'physical_store' && value && value.length < 3) {
58
60
  return 'invalid_physical_store_location';
59
61
  }
60
- if (key === 'ios' && value && !value.match(REGEX_ALPHANUMERIC)) {
62
+ if (key === 'ios' && value && !value.match(REGEX_PHONE_APP_NAME)) {
61
63
  return 'invalid_ios_app';
62
64
  }
63
- if (key === 'android' && value && !value.match(REGEX_ALPHANUMERIC)) {
65
+ if (key === 'android' && value && !value.match(REGEX_PHONE_APP_NAME)) {
64
66
  return 'invalid_android_app';
65
67
  }
66
68
  if (key === 'call_center' && value && !value.match(DIGITS_ONLY)) {
@@ -1,15 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
- import { useTranslation, Trans } from 'react-i18next';
3
+ import { useTranslation } from 'react-i18next';
4
4
  import SuccessScreen from '../../../shared/SuccessScreen';
5
- import { connectSelector } from '../../../../features/app/connect/connectStore';
6
- import { useAppSelector } from '../../../../hooks';
7
- import { maskEmail } from '../../../../utils';
8
5
  var ThankYou = function (_a) {
9
- var _b, _c;
10
6
  var t = useTranslation().t;
11
- var data = useAppSelector(connectSelector).data;
12
- var email = maskEmail((_c = (_b = data.individualData.responseBody) === null || _b === void 0 ? void 0 : _b.contact) === null || _c === void 0 ? void 0 : _c.email);
13
- return (_jsx(SuccessScreen, { title: t("connect_completed_title"), description: _jsx(Trans, { i18nKey: 'connect_completed_description', values: { email: email } }), showEmailProviders: true }));
7
+ return (_jsx(SuccessScreen, { title: t("connect_completed_title"), description: t("connect_completed_description"), showEmailProviders: true }));
14
8
  };
15
9
  export default React.memo(ThankYou);
@@ -16,7 +16,7 @@ import { styled } from '@mui/material/styles';
16
16
  import { FlowsButtons } from '../../../shared/Button';
17
17
  import { ICONS_NAMES, PASSWORD_OPERATION_TYPE } from '../../../../constants';
18
18
  import { useAppSelector, useLanguage } from '../../../../hooks';
19
- import { getResetFlowUrl, shortenBankName, showLastFour } from '../../../../utils';
19
+ import { getResetFlowUrl, showLastFour } from '../../../../utils';
20
20
  import { entitySelector } from '../../../app/entity/entityStore';
21
21
  import Box from '@mui/material/Box';
22
22
  import Text from '../../../../components/Text';
@@ -52,7 +52,7 @@ var SuccessWithFlowButtons = function () {
52
52
  var _f = useState([]), buttons = _f[0], setButtons = _f[1];
53
53
  var username = ((nameObj === null || nameObj === void 0 ? void 0 : nameObj.first) || '') + ' ' + ((nameObj === null || nameObj === void 0 ? void 0 : nameObj.last) || '');
54
54
  var licenseNumber = ((_a = entity === null || entity === void 0 ? void 0 : entity.license) === null || _a === void 0 ? void 0 : _a.number) || '';
55
- var bankName = shortenBankName(bank === null || bank === void 0 ? void 0 : bank.bank_name) || t('bank');
55
+ var bankName = (bank === null || bank === void 0 ? void 0 : bank.bank_name) || t('bank');
56
56
  var iban = showLastFour((bank === null || bank === void 0 ? void 0 : bank.iban) || '');
57
57
  var taxID = vatID || '';
58
58
  var brandName = (isAr ? (_b = brand === null || brand === void 0 ? void 0 : brand.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = brand === null || brand === void 0 ? void 0 : brand.name) === null || _c === void 0 ? void 0 : _c.en) || '';
@@ -16,7 +16,7 @@ import { styled } from '@mui/material/styles';
16
16
  import { FlowsButtons } from '../../../shared/Button';
17
17
  import { ICONS_NAMES, PASSWORD_OPERATION_TYPE } from '../../../../constants';
18
18
  import { useAppSelector, useLanguage } from '../../../../hooks';
19
- import { concatenateObjectValues, getResetFlowUrl, shortenBankName, showLastFour } from '../../../../utils';
19
+ import { concatenateObjectValues, getResetFlowUrl, showLastFour } from '../../../../utils';
20
20
  import { individualSelector } from '../../../app/individual/individualStore';
21
21
  import Box from '@mui/material/Box';
22
22
  import Text from '../../../../components/Text';
@@ -55,7 +55,7 @@ var SuccessWithFlowButtons = function () {
55
55
  ? concatenateObjectValues(ar || en, ['first', 'last'])
56
56
  : concatenateObjectValues(en, ['first', 'last']);
57
57
  var licenseNumber = ((_a = entity === null || entity === void 0 ? void 0 : entity.license) === null || _a === void 0 ? void 0 : _a.number) || '';
58
- var bankName = shortenBankName(bank === null || bank === void 0 ? void 0 : bank.bank_name) || t('bank');
58
+ var bankName = (bank === null || bank === void 0 ? void 0 : bank.bank_name) || t('bank');
59
59
  var iban = showLastFour((bank === null || bank === void 0 ? void 0 : bank.iban) || '');
60
60
  var taxID = (entity === null || entity === void 0 ? void 0 : entity.vat_id) || '';
61
61
  var brandName = (isAr ? (_b = brand === null || brand === void 0 ? void 0 : brand.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = brand === null || brand === void 0 ? void 0 : brand.name) === null || _c === void 0 ? void 0 : _c.en) || '';
@@ -16,7 +16,7 @@ import { styled } from '@mui/material/styles';
16
16
  import { FlowsButtons } from '../../../shared/Button';
17
17
  import { ICONS_NAMES, PASSWORD_OPERATION_TYPE } from '../../../../constants';
18
18
  import { useAppSelector, useLanguage } from '../../../../hooks';
19
- import { getResetFlowUrl, showLastFour, concatenateObjectValues, shortenBankName } from '../../../../utils';
19
+ import { getResetFlowUrl, showLastFour, concatenateObjectValues } from '../../../../utils';
20
20
  import { passwordSelector } from '../../../app/password/passwordStore';
21
21
  import Box from '@mui/material/Box';
22
22
  import Text from '../../../../components/Text';
@@ -55,7 +55,7 @@ var SuccessWithFlowButtons = function () {
55
55
  ? concatenateObjectValues(ar || en, ['first', 'last'])
56
56
  : concatenateObjectValues(en, ['first', 'last']);
57
57
  var licenseNumber = ((_a = entity === null || entity === void 0 ? void 0 : entity.license) === null || _a === void 0 ? void 0 : _a.number) || '';
58
- var bankName = shortenBankName(bank === null || bank === void 0 ? void 0 : bank.bank_name) || t('bank');
58
+ var bankName = (bank === null || bank === void 0 ? void 0 : bank.bank_name) || t('bank');
59
59
  var iban = showLastFour((bank === null || bank === void 0 ? void 0 : bank.iban) || '');
60
60
  var taxID = (entity === null || entity === void 0 ? void 0 : entity.vat_id) || '';
61
61
  var brandName = (isAr ? (_b = brand === null || brand === void 0 ? void 0 : brand.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = brand === null || brand === void 0 ? void 0 : brand.name) === null || _c === void 0 ? void 0 : _c.en) || '';
@@ -54,7 +54,6 @@ var ButtonBoxStyled = styled(Box)(function (_a) {
54
54
  return ({
55
55
  margin: theme.spacing(0, 2.5, 2.5, 2.5),
56
56
  marginBlockStart: theme.spacing(5),
57
- maxHeight: theme.spacing(5.375),
58
57
  display: 'flex',
59
58
  alignItems: 'center',
60
59
  justifyContent: 'center'
@@ -6,7 +6,7 @@ export interface ThankYouProps {
6
6
  successTitle?: string;
7
7
  loading?: boolean;
8
8
  error?: string;
9
- description?: string | React.ReactElement;
9
+ description?: string;
10
10
  }
11
11
  declare const _default: React.MemoExoticComponent<({ title, description, showEmailProviders, onSuccess, successTitle, loading, error }: ThankYouProps) => JSX.Element>;
12
12
  export default _default;
@@ -16,7 +16,7 @@ import { styled } from '@mui/material/styles';
16
16
  import { FlowsButtons } from '../../../shared/Button';
17
17
  import { ICONS_NAMES, PASSWORD_OPERATION_TYPE } from '../../../../constants';
18
18
  import { useAppSelector, useLanguage } from '../../../../hooks';
19
- import { getResetFlowUrl, showLastFour, concatenateObjectValues, shortenBankName } from '../../../../utils';
19
+ import { getResetFlowUrl, showLastFour, concatenateObjectValues } from '../../../../utils';
20
20
  import { taxSelector } from '../../../app/tax/taxStore';
21
21
  import Box from '@mui/material/Box';
22
22
  import Text from '../../../../components/Text';
@@ -55,7 +55,7 @@ var SuccessWithFlowButtons = function () {
55
55
  ? concatenateObjectValues(ar || en, ['first', 'last'])
56
56
  : concatenateObjectValues(en, ['first', 'last']);
57
57
  var licenseNumber = ((_a = entity === null || entity === void 0 ? void 0 : entity.license) === null || _a === void 0 ? void 0 : _a.number) || '';
58
- var bankName = shortenBankName(bank === null || bank === void 0 ? void 0 : bank.bank_name) || t('bank');
58
+ var bankName = (bank === null || bank === void 0 ? void 0 : bank.bank_name) || t('bank');
59
59
  var iban = showLastFour((bank === null || bank === void 0 ? void 0 : bank.iban) || '');
60
60
  var taxID = vatID || '';
61
61
  var brandName = (isAr ? (_b = brand === null || brand === void 0 ? void 0 : brand.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = brand === null || brand === void 0 ? void 0 : brand.name) === null || _c === void 0 ? void 0 : _c.en) || '';
@@ -59,4 +59,3 @@ export declare const fixBrandList: (items: Array<{
59
59
  }>, salesChannel: Array<SaleChannel>) => {
60
60
  channel_services: any[];
61
61
  }[];
62
- export declare const findFirstId: (items: Array<SaleChannel>) => string;
@@ -121,11 +121,3 @@ export var fixBrandList = function (items, salesChannel) {
121
121
  return __assign(__assign({}, item), { channel_services: removeDuplicationById(mapBrandSalesChannel(salesChannel, item.channel_services || [])) });
122
122
  });
123
123
  };
124
- export var findFirstId = function (items) {
125
- var first = items[0];
126
- if (!first)
127
- return '';
128
- if (first.sub && first.sub.length > 0)
129
- return first.sub[0].id;
130
- return first.id;
131
- };
@@ -8,4 +8,3 @@ export * from './string';
8
8
  export * from './device';
9
9
  export * from './rsa';
10
10
  export * from './common';
11
- export * from './date';
@@ -8,4 +8,3 @@ export * from './string';
8
8
  export * from './device';
9
9
  export * from './rsa';
10
10
  export * from './common';
11
- export * from './date';
@@ -1,6 +1,5 @@
1
1
  import { DeviceInfo } from '../@types';
2
2
  export declare const maskPhone: (str?: string) => string;
3
- export declare const shortenBankName: (str: string) => string;
4
3
  export declare const maskID: (str: string) => string;
5
4
  export declare const maskEmail: (str: string) => string;
6
5
  export declare const showLastFour: (str: string) => string;
@@ -8,25 +8,13 @@ export var maskPhone = function (str) {
8
8
  var lastTwo = str.substring(str.length - 2, str.length);
9
9
  return ' ••••' + lastTwo;
10
10
  };
11
- export var shortenBankName = function (str) {
12
- if (str)
13
- return str.slice(0, 20);
14
- return '';
15
- };
16
11
  export var maskID = function (str) {
17
12
  var lastTwo = str.substring(str.length - 2, str.length);
18
13
  return ' ••••' + lastTwo;
19
14
  };
20
15
  export var maskEmail = function (str) {
21
- if (str) {
22
- var name_1 = str.split('@')[0];
23
- var maskedName = name_1[0] + '*' + name_1[name_1.length - 1];
24
- var domain = str.split('@')[1].split('.')[0];
25
- var maskedDomain = '@' + domain[0] + '*' + domain[domain.length - 1];
26
- var TLD = '.' + str.split('@')[1].split('.')[1];
27
- return maskedName + maskedDomain + TLD;
28
- }
29
- return '';
16
+ var lastTwo = str.substring(str.length - 2, str.length);
17
+ return ' ••••' + lastTwo;
30
18
  };
31
19
  export var showLastFour = function (str) {
32
20
  if (str && str.length >= 4) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.0.43",
3
+ "version": "2.0.44",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",
@@ -1 +0,0 @@
1
- export declare const dateFormat: (date: Date, fmt?: string) => string;
@@ -1,5 +0,0 @@
1
- import moment from 'moment';
2
- export var dateFormat = function (date, fmt) {
3
- if (fmt === void 0) { fmt = 'YYYY-MM-DD'; }
4
- return moment(date).format('YYYY-MM-DD');
5
- };