@tap-payments/auth-jsconnect 2.0.35-test → 2.0.35
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.
- package/build/@types/app.d.ts +52 -21
- package/build/@types/app.js +10 -3
- package/build/@types/form.d.ts +18 -10
- package/build/api/auth.d.ts +24 -2
- package/build/api/auth.js +36 -1
- package/build/api/axios.js +2 -2
- package/build/api/brand.d.ts +2 -1
- package/build/api/brand.js +10 -1
- package/build/api/country.d.ts +3 -1
- package/build/api/country.js +3 -1
- package/build/api/data.d.ts +38 -7
- package/build/api/data.js +57 -17
- package/build/api/entity.d.ts +53 -5
- package/build/api/entity.js +39 -9
- package/build/api/firebase.d.ts +1 -1
- package/build/api/firebase.js +3 -1
- package/build/api/index.d.ts +44 -14
- package/build/api/individual.d.ts +76 -19
- package/build/api/individual.js +29 -2
- package/build/api/lead.d.ts +9 -6
- package/build/api/lead.js +8 -1
- package/build/app/rootReducer.d.ts +1 -1
- package/build/app/rootReducer.js +2 -2
- package/build/app/settings.d.ts +8 -2
- package/build/app/settings.js +29 -12
- package/build/app/store.d.ts +3 -3
- package/build/assets/locales/ar.json +258 -183
- package/build/assets/locales/en.json +190 -108
- package/build/components/AnimationFlow/AnimationFlow.d.ts +5 -1
- package/build/components/AnimationFlow/AnimationFlow.js +6 -8
- package/build/components/AnimationFlow/BottomSheet.d.ts +2 -1
- package/build/components/AnimationFlow/BottomSheet.js +4 -3
- package/build/components/AnimationFlow/Dialog.d.ts +5 -1
- package/build/components/AnimationFlow/Dialog.js +11 -5
- package/build/components/ArabicDatePicker/ArabicDatePicker.d.ts +13 -0
- package/build/components/ArabicDatePicker/ArabicDatePicker.js +94 -0
- package/build/components/ArabicDatePicker/index.d.ts +2 -0
- package/build/components/ArabicDatePicker/index.js +2 -0
- package/build/components/ArabicDatePicker/style.css +24 -0
- package/build/components/FileInput/DragAndDrop.d.ts +10 -1
- package/build/components/FileInput/DragAndDrop.js +108 -8
- package/build/components/Lottie/Lottie.d.ts +878 -0
- package/build/components/Lottie/Lottie.js +58 -0
- package/build/components/Lottie/files/pulsating_circle_waves.json +236 -0
- package/build/components/Lottie/files/success.json +425 -0
- package/build/components/Lottie/index.d.ts +3 -0
- package/build/components/Lottie/index.js +3 -0
- package/build/components/OTPField/OTPField.d.ts +2 -1
- package/build/components/OTPField/OTPField.js +2 -2
- package/build/components/OTPTimer/OTPTimer.js +1 -1
- package/build/components/ProgressBar/CircularProgressBar.d.ts +14 -0
- package/build/components/ProgressBar/CircularProgressBar.js +48 -0
- package/build/components/ProgressBar/index.d.ts +2 -0
- package/build/components/ProgressBar/index.js +2 -0
- package/build/components/RadioLabel/RadioLabel.d.ts +2 -1
- package/build/components/RadioLabel/RadioLabel.js +2 -2
- package/build/components/SocialMediaGroup/SocialMediaGroup.d.ts +2 -6
- package/build/components/SocialMediaGroup/SocialMediaGroup.js +4 -49
- package/build/constants/api.d.ts +6 -0
- package/build/constants/api.js +14 -1
- package/build/constants/app.d.ts +7 -5
- package/build/constants/app.js +56 -23
- package/build/constants/assets.d.ts +14 -0
- package/build/constants/assets.js +16 -2
- package/build/constants/dummy.d.ts +1 -1
- package/build/constants/dummy.js +2 -2
- package/build/constants/validation.d.ts +8 -0
- package/build/constants/validation.js +9 -1
- package/build/features/app/auth/authStore.d.ts +47 -0
- package/build/features/app/auth/authStore.js +260 -0
- package/build/features/app/bank/bankStore.d.ts +16 -0
- package/build/features/app/bank/bankStore.js +86 -39
- package/build/features/app/business/businessStore.d.ts +22 -3
- package/build/features/app/business/businessStore.js +432 -291
- package/build/features/app/connect/connectStore.d.ts +33 -31
- package/build/features/app/connect/connectStore.js +394 -308
- package/build/features/app/entity/entityStore.d.ts +30 -5
- package/build/features/app/entity/entityStore.js +258 -47
- package/build/features/app/individual/individualStore.d.ts +17 -0
- package/build/features/app/individual/individualStore.js +170 -84
- package/build/features/app/password/passwordStore.js +1 -1
- package/build/features/app/tax/taxStore.js +18 -14
- package/build/features/auth/Auth.d.ts +10 -0
- package/build/features/auth/Auth.js +87 -0
- package/build/features/auth/index.d.ts +1 -0
- package/build/features/auth/index.js +1 -0
- package/build/features/auth/screens/NID/DOB.d.ts +7 -0
- package/build/features/auth/screens/NID/DOB.js +47 -0
- package/build/features/auth/screens/NID/IDNumber.d.ts +3 -0
- package/build/features/auth/screens/NID/IDNumber.js +64 -0
- package/build/features/auth/screens/NID/NID.d.ts +5 -0
- package/build/features/auth/screens/NID/NID.js +68 -0
- package/build/features/auth/screens/NID/TAC.d.ts +3 -0
- package/build/features/auth/screens/NID/TAC.js +87 -0
- package/build/features/auth/screens/NID/index.d.ts +3 -0
- package/build/features/auth/screens/NID/index.js +2 -0
- package/build/features/auth/screens/NID/validation.d.ts +27 -0
- package/build/features/auth/screens/NID/validation.js +19 -0
- package/build/features/auth/screens/OTP/OTP.d.ts +5 -0
- package/build/features/auth/screens/OTP/OTP.js +76 -0
- package/build/features/{otp/screens/OTPVerify/Verify.d.ts → auth/screens/OTP/OTPInput.d.ts} +0 -0
- package/build/features/{otp/screens/OTPVerify → auth/screens/OTP}/OTPInput.js +11 -7
- package/build/features/auth/screens/OTP/index.d.ts +3 -0
- package/build/features/auth/screens/OTP/index.js +2 -0
- package/build/features/{otp/screens/OTPVerify → auth/screens/OTP}/validation.d.ts +0 -0
- package/build/features/{otp/screens/OTPVerify → auth/screens/OTP}/validation.js +0 -0
- package/build/features/bank/Bank.js +12 -6
- package/build/features/bank/screens/BankDetails/BankDetails.js +18 -5
- package/build/features/bank/screens/BankDetails/BankName.js +2 -1
- package/build/features/bank/screens/BankDetails/BankStatement.js +41 -8
- package/build/features/bank/screens/BankDetails/Beneficiary.js +10 -11
- package/build/features/bank/screens/BankDetails/validation.js +2 -2
- package/build/features/bank/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +12 -8
- package/build/features/business/Business.d.ts +1 -1
- package/build/features/business/Business.js +14 -7
- package/build/features/business/screens/Activities/Activities.js +16 -17
- package/build/features/business/screens/Activities/ActivitiesList.d.ts +37 -1
- package/build/features/business/screens/Activities/ActivitiesList.js +51 -12
- package/build/features/business/screens/Activities/OperationStartDate.d.ts +15 -1
- package/build/features/business/screens/Activities/OperationStartDate.js +21 -2
- package/build/features/business/screens/Activities/validation.d.ts +0 -51
- package/build/features/business/screens/Activities/validation.js +0 -9
- package/build/features/business/screens/BusinessType/BusinessType.js +20 -7
- package/build/features/business/screens/BusinessType/EntityName.d.ts +6 -0
- package/build/features/business/screens/BusinessType/EntityName.js +56 -0
- package/build/features/business/screens/BusinessType/LicenseCertificate.d.ts +6 -0
- package/build/features/business/screens/BusinessType/LicenseCertificate.js +76 -0
- package/build/features/business/screens/BusinessType/LicenseList.js +24 -7
- package/build/features/business/screens/BusinessType/LicenseNumber.js +14 -8
- package/build/features/business/screens/BusinessType/LicenseType.d.ts +6 -0
- package/build/features/business/screens/BusinessType/LicenseType.js +67 -0
- package/build/features/business/screens/BusinessType/validation.d.ts +19 -0
- package/build/features/business/screens/BusinessType/validation.js +50 -1
- package/build/features/business/screens/CivilID/CivilID.d.ts +5 -0
- package/build/features/business/screens/CivilID/CivilID.js +67 -0
- package/build/features/business/screens/CivilID/IDNumber.d.ts +7 -0
- package/build/features/business/screens/CivilID/IDNumber.js +59 -0
- package/build/features/business/screens/CivilID/index.d.ts +3 -0
- package/build/features/business/screens/CivilID/index.js +2 -0
- package/build/features/business/screens/CivilID/validation.d.ts +8 -0
- package/build/features/business/screens/CivilID/validation.js +4 -0
- package/build/features/business/screens/Customers/CustomerLocations.d.ts +15 -2
- package/build/features/business/screens/Customers/CustomerLocations.js +32 -8
- package/build/features/business/screens/Customers/Customers.js +15 -9
- package/build/features/business/screens/Customers/ExpectedCustomers.js +16 -4
- package/build/features/business/screens/Customers/ExpectedSalesRange.js +32 -14
- package/build/features/business/screens/Customers/RefundPolicy.js +8 -2
- package/build/features/business/screens/Customers/TransactionPolicy.js +8 -2
- package/build/features/business/screens/IDBOD/IDBOD.js +15 -2
- package/build/features/business/screens/OTP/OTP.js +15 -2
- package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +10 -7
- package/build/features/business/screens/Verify/Verify.js +4 -4
- package/build/features/business/screens/VerifyPACI/VerifyPACI.d.ts +5 -0
- package/build/features/business/screens/VerifyPACI/VerifyPACI.js +159 -0
- package/build/features/business/screens/VerifyPACI/VerifyPACILoading.d.ts +6 -0
- package/build/features/business/screens/VerifyPACI/VerifyPACILoading.js +23 -0
- package/build/features/business/screens/VerifyPACI/VerifyPACISuccess.d.ts +5 -0
- package/build/features/business/screens/VerifyPACI/VerifyPACISuccess.js +8 -0
- package/build/features/business/screens/VerifyPACI/index.d.ts +3 -0
- package/build/features/business/screens/VerifyPACI/index.js +2 -0
- package/build/features/connect/Connect.d.ts +2 -1
- package/build/features/connect/Connect.js +47 -12
- package/build/features/connect/screens/CivilID/CivilID.d.ts +5 -0
- package/build/features/connect/screens/CivilID/CivilID.js +99 -0
- package/build/features/connect/screens/CivilID/IDNumber.d.ts +7 -0
- package/build/features/connect/screens/CivilID/IDNumber.js +59 -0
- package/build/features/connect/screens/CivilID/index.d.ts +3 -0
- package/build/features/connect/screens/CivilID/index.js +2 -0
- package/build/features/connect/screens/CivilID/validation.d.ts +8 -0
- package/build/features/connect/screens/CivilID/validation.js +4 -0
- package/build/features/connect/screens/Individual/Email.js +11 -3
- package/build/features/connect/screens/Individual/Individual.js +41 -27
- package/build/features/connect/screens/Merchant/BrandList.js +15 -7
- package/build/features/connect/screens/Merchant/BrandName.js +7 -4
- package/build/features/connect/screens/Merchant/Merchant.js +41 -64
- package/build/features/connect/screens/Merchant/SalesChannels.d.ts +3 -1
- package/build/features/connect/screens/Merchant/SalesChannels.js +30 -31
- package/build/features/connect/screens/Merchant/SocialMedia.d.ts +1 -4
- package/build/features/connect/screens/Merchant/SocialMedia.js +129 -109
- package/build/features/connect/screens/Merchant/TAC.js +8 -2
- package/build/features/connect/screens/Merchant/validation.d.ts +13 -123
- package/build/features/connect/screens/Merchant/validation.js +108 -173
- package/build/features/connect/screens/Mobile/Mobile.js +30 -12
- package/build/features/connect/screens/NID/NID.js +2 -1
- package/build/features/connect/screens/OTP/OTP.js +20 -6
- package/build/features/connect/screens/OTP/OTPInput.js +3 -2
- package/build/features/connect/screens/VerifyPACI/VerifyPACI.d.ts +5 -0
- package/build/features/connect/screens/VerifyPACI/VerifyPACI.js +159 -0
- package/build/features/connect/screens/VerifyPACI/VerifyPACILoading.d.ts +6 -0
- package/build/features/connect/screens/VerifyPACI/VerifyPACILoading.js +23 -0
- package/build/features/connect/screens/VerifyPACI/VerifyPACISuccess.d.ts +5 -0
- package/build/features/connect/screens/VerifyPACI/VerifyPACISuccess.js +8 -0
- package/build/features/connect/screens/VerifyPACI/index.d.ts +3 -0
- package/build/features/connect/screens/VerifyPACI/index.js +2 -0
- package/build/features/entity/Entity.d.ts +1 -1
- package/build/features/entity/Entity.js +16 -9
- package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.d.ts +55 -0
- package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.js +149 -0
- package/build/features/entity/screens/EntityInfoConfirm/Article.d.ts +3 -0
- package/build/features/entity/screens/EntityInfoConfirm/Article.js +73 -0
- package/build/features/entity/screens/EntityInfoConfirm/EntityInfo.js +71 -2
- package/build/features/entity/screens/EntityInfoConfirm/LicenseName.d.ts +5 -0
- package/build/features/entity/screens/EntityInfoConfirm/LicenseName.js +32 -0
- package/build/features/entity/screens/EntityInfoConfirm/LicenseNumber.d.ts +5 -0
- package/build/features/entity/screens/EntityInfoConfirm/LicenseNumber.js +49 -0
- package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.d.ts +6 -0
- package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.js +33 -0
- package/build/features/entity/screens/EntityInfoConfirm/validation.d.ts +68 -0
- package/build/features/entity/screens/EntityInfoConfirm/validation.js +24 -0
- package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +6 -5
- package/build/features/entity/screens/Verify/Verify.js +18 -5
- package/build/features/featuresScreens.d.ts +1 -1
- package/build/features/featuresScreens.js +31 -6
- package/build/features/individual/Individual.d.ts +1 -1
- package/build/features/individual/Individual.js +14 -7
- package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +18 -25
- package/build/features/individual/screens/AdditionalIndividualInfo/MonthlyIncome.js +15 -3
- package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +11 -3
- package/build/features/individual/screens/AdditionalIndividualInfo/SourceOfIncome.js +2 -2
- package/build/features/individual/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +12 -8
- package/build/features/individual/screens/Verify/Verify.js +18 -5
- package/build/features/password/Password.d.ts +1 -1
- package/build/features/password/Password.js +14 -7
- package/build/features/password/screens/CreatePassword/CreatePassword.js +16 -3
- package/build/features/password/screens/OTP/OTP.js +15 -2
- package/build/features/password/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +12 -9
- package/build/features/password/screens/Verify/Verify.js +16 -3
- package/build/features/shared/Background/Background.d.ts +6 -5
- package/build/features/shared/Background/Background.js +16 -5
- package/build/features/shared/Button/EmailProvidersButtons.d.ts +2 -1
- package/build/features/shared/Button/EmailProvidersButtons.js +7 -2
- package/build/features/shared/Button/MobileButton.d.ts +2 -1
- package/build/features/shared/Button/MobileButton.js +2 -2
- package/build/features/shared/Dialog/CloseDialog.d.ts +11 -0
- package/build/features/shared/Dialog/CloseDialog.js +71 -0
- package/build/features/shared/Dialog/DialogContainer.d.ts +8 -0
- package/build/features/shared/Dialog/DialogContainer.js +56 -0
- package/build/features/shared/Dialog/index.d.ts +4 -0
- package/build/features/shared/Dialog/index.js +4 -0
- package/build/features/shared/Input/Input.d.ts +1 -1
- package/build/features/shared/Input/Input.js +2 -2
- package/build/features/shared/SuccessScreen/SuccessScreen.js +1 -1
- package/build/features/shared/UploadFile/UploadFile.d.ts +10 -3
- package/build/features/shared/UploadFile/UploadFile.js +24 -9
- package/build/features/signIn/SignIn.d.ts +1 -1
- package/build/features/signIn/SignIn.js +14 -6
- package/build/features/signIn/screens/Email/Email.js +4 -2
- package/build/features/signIn/screens/Mobile/Mobile.js +5 -1
- package/build/features/signIn/screens/OTP/OTP.js +14 -1
- package/build/features/signIn/screens/Password/Password.js +15 -2
- package/build/features/tax/Tax.d.ts +1 -1
- package/build/features/tax/Tax.js +16 -8
- package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +11 -7
- package/build/features/tax/screens/TaxDetails/TaxDetails.js +16 -3
- package/build/features/tax/screens/Verify/Verify.js +16 -3
- package/build/hooks/index.d.ts +2 -0
- package/build/hooks/index.js +2 -0
- package/build/hooks/useAppConfig.d.ts +3 -1
- package/build/hooks/useAppConfig.js +4 -2
- package/build/hooks/useAppDispatch.d.ts +1 -1
- package/build/hooks/useErrorListener.js +0 -6
- package/build/hooks/useScreen.d.ts +3 -0
- package/build/hooks/useScreen.js +14 -0
- package/build/hooks/useSetFromDefaultValues.d.ts +2 -0
- package/build/hooks/useSetFromDefaultValues.js +24 -0
- package/build/index.d.ts +3 -3
- package/build/index.js +5 -5
- package/build/utils/array.d.ts +13 -1
- package/build/utils/array.js +26 -0
- package/build/utils/common.d.ts +1 -0
- package/build/utils/common.js +3 -0
- package/build/utils/device.d.ts +1 -0
- package/build/utils/device.js +13 -0
- package/build/utils/html.d.ts +1 -0
- package/build/utils/html.js +6 -0
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.js +1 -0
- package/build/utils/locale.js +1 -1
- package/build/utils/object.d.ts +1 -0
- package/build/utils/object.js +12 -0
- package/build/utils/rsa.d.ts +2 -2
- package/build/utils/rsa.js +1 -1
- package/build/utils/string.d.ts +33 -20
- package/build/utils/string.js +71 -1
- package/build/utils/validation.d.ts +2 -0
- package/build/utils/validation.js +6 -0
- package/package.json +5 -4
- package/build/features/app/otp/otpStore.d.ts +0 -28
- package/build/features/app/otp/otpStore.js +0 -153
- package/build/features/business/screens/Activities/SalesChannels.d.ts +0 -5
- package/build/features/business/screens/Activities/SalesChannels.js +0 -112
- package/build/features/otp/OTP.d.ts +0 -7
- package/build/features/otp/OTP.js +0 -58
- package/build/features/otp/index.d.ts +0 -0
- package/build/features/otp/index.js +0 -1
- package/build/features/otp/screens/OTPVerify/OTPInput.d.ts +0 -6
- package/build/features/otp/screens/OTPVerify/Verify.js +0 -49
- package/build/features/otp/screens/OTPVerify/index.d.ts +0 -2
- package/build/features/otp/screens/OTPVerify/index.js +0 -2
|
@@ -54,8 +54,8 @@ import Input from '../../../shared/Input';
|
|
|
54
54
|
import { useController, useFormContext } from 'react-hook-form';
|
|
55
55
|
import ClearIcon from '../../../shared/ClearIcon';
|
|
56
56
|
import CheckIcon from '../../../shared/CheckIcon';
|
|
57
|
-
import { checkEmailAvailability } from '../../../app/connect/connectStore';
|
|
58
|
-
import { useAppDispatch } from '../../../../hooks';
|
|
57
|
+
import { checkEmailAvailability, connectSelector } from '../../../app/connect/connectStore';
|
|
58
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
59
59
|
import { debounce } from 'lodash-es';
|
|
60
60
|
import Collapse from '../../../../components/Collapse';
|
|
61
61
|
import { styled } from '@mui/material/styles';
|
|
@@ -72,7 +72,9 @@ var cancelToken = null;
|
|
|
72
72
|
var Email = function (_a) {
|
|
73
73
|
var _b;
|
|
74
74
|
var show = _a.show, fetchingEmail = _a.fetchingEmail, emailChecking = _a.emailChecking;
|
|
75
|
+
var _c = React.useState(''), storedEmail = _c[0], setStoredEmail = _c[1];
|
|
75
76
|
var dispatch = useAppDispatch();
|
|
77
|
+
var data = useAppSelector(connectSelector).data;
|
|
76
78
|
var t = useTranslation().t;
|
|
77
79
|
var control = useFormContext().control;
|
|
78
80
|
var emailControl = useController({ name: 'email', control: control });
|
|
@@ -93,9 +95,15 @@ var Email = function (_a) {
|
|
|
93
95
|
var handleEmailChange = function (event) {
|
|
94
96
|
emailControl.field.onChange(event.target.value);
|
|
95
97
|
};
|
|
98
|
+
React.useEffect(function () {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
var email = (_b = (_a = data.otpData.responseBody) === null || _a === void 0 ? void 0 : _a.contact) === null || _b === void 0 ? void 0 : _b.email;
|
|
101
|
+
if (!!email)
|
|
102
|
+
setStoredEmail(email);
|
|
103
|
+
}, [data.otpData.responseBody]);
|
|
96
104
|
React.useEffect(function () {
|
|
97
105
|
var isValid = emailValue && !error && emailValue.length > 3;
|
|
98
|
-
if (isValid) {
|
|
106
|
+
if (isValid && emailValue != storedEmail) {
|
|
99
107
|
fetchingEmail(true);
|
|
100
108
|
checkEmail(emailValue);
|
|
101
109
|
}
|
|
@@ -9,6 +9,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
12
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
24
|
import { styled } from '@mui/material/styles';
|
|
14
25
|
import Email from './Email';
|
|
@@ -17,8 +28,8 @@ import * as React from 'react';
|
|
|
17
28
|
import { useTranslation } from 'react-i18next';
|
|
18
29
|
import { useForm, FormProvider } from 'react-hook-form';
|
|
19
30
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
20
|
-
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
21
|
-
import { handlePrevScreenStep } from '../../../../app/settings';
|
|
31
|
+
import { useAppDispatch, useAppSelector, useSetFromDefaultValues } from '../../../../hooks';
|
|
32
|
+
import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
|
|
22
33
|
import { IndividualValidation, IndividualMobileValidation } from './validation';
|
|
23
34
|
import Form from '../../../../components/Form';
|
|
24
35
|
import Button from '../../../shared/Button';
|
|
@@ -27,58 +38,61 @@ import { clearError, connectSelector, resetIndividualScreen, updateLeadIndividua
|
|
|
27
38
|
import { useLanguage } from '../../../../hooks';
|
|
28
39
|
import MobileNumber from './MobileNumber';
|
|
29
40
|
import { countriesCode } from '../../../../constants';
|
|
41
|
+
import { AuthForType } from '../../../../@types';
|
|
30
42
|
import Collapse from '../../../../components/Collapse';
|
|
43
|
+
import { isKW } from '../../../../utils';
|
|
31
44
|
var FormStyled = styled(Form)(function () { return ({
|
|
32
45
|
display: 'flex',
|
|
33
46
|
flexDirection: 'column'
|
|
34
47
|
}); });
|
|
35
48
|
var Individual = function (_a) {
|
|
36
|
-
var _b,
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
49
|
+
var _b = React.useState(false), listActive = _b[0], setListActive = _b[1];
|
|
50
|
+
var _c = React.useState(false), emailChecking = _c[0], setEmailChecking = _c[1];
|
|
51
|
+
var settingsData = useAppSelector(settingsSelector).data;
|
|
52
|
+
var _d = useAppSelector(connectSelector), data = _d.data, loading = _d.loading, error = _d.error;
|
|
40
53
|
var dispatch = useAppDispatch();
|
|
41
54
|
var t = useTranslation().t;
|
|
42
55
|
var isAr = useLanguage().isAr;
|
|
43
|
-
var
|
|
44
|
-
var
|
|
56
|
+
var individualData = data.individualData, otpData = data.otpData, mobileData = data.mobileData;
|
|
57
|
+
var startWithNID = otpData.authFor === AuthForType.NATIONAL_ID;
|
|
58
|
+
var isMobile = mobileData.mobile;
|
|
59
|
+
var _e = otpData.responseBody || {}, contact = _e.contact, name = _e.name, userInfoMissed = _e.userInfoMissed, is_new_individual = _e.is_new_individual;
|
|
60
|
+
var responseBody = individualData.responseBody, defaultValues = __rest(individualData, ["responseBody"]);
|
|
61
|
+
var is_available = (responseBody || {}).is_available;
|
|
45
62
|
var methods = useForm({
|
|
46
|
-
resolver: yupResolver(
|
|
47
|
-
defaultValues:
|
|
63
|
+
resolver: yupResolver(isMobile ? IndividualValidation : IndividualMobileValidation),
|
|
64
|
+
defaultValues: defaultValues,
|
|
48
65
|
mode: 'onChange'
|
|
49
66
|
});
|
|
67
|
+
useSetFromDefaultValues(methods, defaultValues, true);
|
|
50
68
|
var onSubmit = function (formData) {
|
|
51
69
|
dispatch(updateLeadIndividual(formData));
|
|
52
70
|
};
|
|
53
71
|
var onBack = function () {
|
|
72
|
+
var _a;
|
|
54
73
|
dispatch(resetIndividualScreen());
|
|
55
|
-
|
|
74
|
+
var code = (_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2;
|
|
75
|
+
var screen = isKW(code) ? 'CONNECT_CIVIL_ID_STEP' : startWithNID ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP';
|
|
76
|
+
dispatch(handlePrevScreenStep(screen));
|
|
56
77
|
};
|
|
57
78
|
React.useEffect(function () {
|
|
58
79
|
if (error)
|
|
59
80
|
dispatch(clearError());
|
|
60
81
|
}, [methods.formState.isValid]);
|
|
61
|
-
React.useEffect(function () {
|
|
62
|
-
var name = individualData.name, email = individualData.email, mobile = individualData.mobile, countryCode = individualData.countryCode;
|
|
63
|
-
if (!!name)
|
|
64
|
-
methods.setValue('name', name, { shouldValidate: true });
|
|
65
|
-
if (!!email)
|
|
66
|
-
methods.setValue('email', email, { shouldValidate: true });
|
|
67
|
-
if (!!mobile)
|
|
68
|
-
methods.setValue('mobile', mobile, { shouldValidate: true });
|
|
69
|
-
if (!!countryCode)
|
|
70
|
-
methods.setValue('countryCode', countryCode, { shouldValidate: true });
|
|
71
|
-
}, [individualData.name, individualData.email, individualData.mobile, individualData.countryCode]);
|
|
72
82
|
var handleMenuListClick = function () {
|
|
73
83
|
listActive ? setListActive(false) : setListActive(true);
|
|
74
84
|
};
|
|
75
85
|
React.useEffect(function () {
|
|
76
|
-
|
|
77
|
-
if (((_b = (_a = data.individualData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.is_available) === false)
|
|
86
|
+
if (is_available === false)
|
|
78
87
|
methods.setError('email', { message: 'tap_js_email_already_exist' });
|
|
79
|
-
}, [
|
|
88
|
+
}, [responseBody]);
|
|
89
|
+
var isLeadEmailAvailable = (contact === null || contact === void 0 ? void 0 : contact.email) === methods.watch('email');
|
|
90
|
+
var isEmailValid = typeof is_available === 'undefined' ? isLeadEmailAvailable : is_available;
|
|
80
91
|
var emailErrChecks = !methods.formState.isValid || !!methods.formState.errors.email || !!error;
|
|
81
|
-
var disabled = emailErrChecks || emailChecking || !
|
|
82
|
-
|
|
92
|
+
var disabled = emailErrChecks || emailChecking || !isEmailValid;
|
|
93
|
+
var isNameRequired = (userInfoMissed && !name) || is_new_individual;
|
|
94
|
+
var isEmailRequired = (userInfoMissed && !(contact === null || contact === void 0 ? void 0 : contact.email)) || is_new_individual;
|
|
95
|
+
var isMobileRequired = (userInfoMissed && !(contact === null || contact === void 0 ? void 0 : contact.phone)) || is_new_individual;
|
|
96
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Name, { show: !listActive && isNameRequired }), _jsx(MobileNumber, { show: !isMobile && isMobileRequired, onListOpen: function () { return handleMenuListClick(); }, onListClose: function () { return handleMenuListClick(); }, countries: countriesCode }), _jsx(Email, { show: !listActive && isEmailRequired, fetchingEmail: function (v) { return setEmailChecking(v); }, emailChecking: emailChecking }), _jsx(Collapse, __assign({ in: !listActive }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
|
|
83
97
|
};
|
|
84
98
|
export default React.memo(Individual);
|
|
@@ -34,6 +34,7 @@ import SimpleList from '../../../../components/SimpleList';
|
|
|
34
34
|
import Text from '../../../../components/Text';
|
|
35
35
|
import ExpandIcon from '../../../../components/ExpandIcon';
|
|
36
36
|
import Collapse from '../../../../components/Collapse';
|
|
37
|
+
import { mapSalesChannel } from '../../../../utils';
|
|
37
38
|
var InputStyled = styled(Input)(function () { return ({
|
|
38
39
|
'& .MuiInputBase-input': {
|
|
39
40
|
cursor: 'pointer'
|
|
@@ -51,7 +52,7 @@ var BrandList = function (_a) {
|
|
|
51
52
|
var _b = React.useState(null), anchorEl = _b[0], setAnchorEl = _b[1];
|
|
52
53
|
var t = useTranslation().t;
|
|
53
54
|
var isAr = useLanguage().isAr;
|
|
54
|
-
var
|
|
55
|
+
var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
|
|
55
56
|
var selectedBrandControl = useController({ control: control, name: 'selectedBrandItem' });
|
|
56
57
|
var selectedBrand = selectedBrandControl.field.value;
|
|
57
58
|
var onOpenBrandList = function (event) {
|
|
@@ -64,22 +65,29 @@ var BrandList = function (_a) {
|
|
|
64
65
|
setAnchorEl(null);
|
|
65
66
|
(_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
66
67
|
};
|
|
67
|
-
var getBrandName = function (
|
|
68
|
-
var _a
|
|
69
|
-
return (isAr ?
|
|
68
|
+
var getBrandName = function (_a) {
|
|
69
|
+
var name = _a.name;
|
|
70
|
+
return (isAr ? name === null || name === void 0 ? void 0 : name.ar : name === null || name === void 0 ? void 0 : name.en) || '';
|
|
70
71
|
};
|
|
71
72
|
var getBrandId = function (item) {
|
|
72
73
|
return item.id || '';
|
|
73
74
|
};
|
|
74
|
-
var
|
|
75
|
-
return item
|
|
75
|
+
var isOtherBrand = function (item) {
|
|
76
|
+
return getBrandId(item) === 'other';
|
|
76
77
|
};
|
|
77
78
|
var onSelectItem = function (brand) {
|
|
78
79
|
selectedBrandControl.field.onChange(brand);
|
|
80
|
+
if (!isOtherBrand(brand)) {
|
|
81
|
+
setValue('salesChannels', mapSalesChannel(brand.channel_services || []), { shouldValidate: true });
|
|
82
|
+
}
|
|
83
|
+
if (isOtherBrand(brand)) {
|
|
84
|
+
setValue('salesChannels', [], { shouldValidate: true });
|
|
85
|
+
setValue('brandName', '');
|
|
86
|
+
}
|
|
79
87
|
onCloseBrandList();
|
|
80
88
|
};
|
|
81
89
|
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) {
|
|
82
|
-
return (_jsxs(_Fragment, { children: [_jsx(BrandContainer, { children: _jsx(BrandNameText, __assign({ isSelected: getBrandId(item) === getBrandId(selectedBrand) }, { children:
|
|
90
|
+
return (_jsxs(_Fragment, { children: [_jsx(BrandContainer, { children: _jsx(BrandNameText, __assign({ isSelected: getBrandId(item) === getBrandId(selectedBrand) }, { children: isOtherBrand(item) ? t(getBrandName(item)) : getBrandName(item) })) }), getBrandId(item) === getBrandId(selectedBrand) && _jsx(CheckIcon, {})] }));
|
|
83
91
|
} }) }))] }) })));
|
|
84
92
|
};
|
|
85
93
|
export default React.memo(BrandList);
|
|
@@ -63,8 +63,8 @@ import Tooltip from '../../../../components/Tooltip';
|
|
|
63
63
|
import Collapse from '../../../../components/Collapse';
|
|
64
64
|
import { removeAllOtherThanCharsNumbersAndSpace } from '../../../../utils';
|
|
65
65
|
import CheckIcon from '../../../shared/CheckIcon';
|
|
66
|
-
import { checkBrandNameAvailability } from '../../../app/connect/connectStore';
|
|
67
|
-
import { useAppDispatch } from '../../../../hooks';
|
|
66
|
+
import { checkBrandNameAvailability, connectSelector } from '../../../app/connect/connectStore';
|
|
67
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
68
68
|
import { debounce } from 'lodash-es';
|
|
69
69
|
var LabelContainerStyled = styled(Box)(function (_a) {
|
|
70
70
|
var theme = _a.theme;
|
|
@@ -103,6 +103,7 @@ var BrandName = function (_a) {
|
|
|
103
103
|
var dispatch = useAppDispatch();
|
|
104
104
|
var _c = React.useState(false), isHovered = _c[0], setIsHovered = _c[1];
|
|
105
105
|
var t = useTranslation().t;
|
|
106
|
+
var data = useAppSelector(connectSelector).data;
|
|
106
107
|
var control = useFormContext().control;
|
|
107
108
|
var brandControl = useController({ control: control, name: 'brandName' });
|
|
108
109
|
var brandNameValue = brandControl.field.value;
|
|
@@ -125,8 +126,10 @@ var BrandName = function (_a) {
|
|
|
125
126
|
brandControl.field.onChange(value);
|
|
126
127
|
};
|
|
127
128
|
React.useEffect(function () {
|
|
129
|
+
var _a, _b, _c;
|
|
128
130
|
var isValid = brandNameValue && !error && brandNameValue.length > 2;
|
|
129
|
-
|
|
131
|
+
var brand = (_c = (_b = (_a = data.otpData.responseBody) === null || _a === void 0 ? void 0 : _a.brand) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.en;
|
|
132
|
+
if (isValid && (brandNameValue === null || brandNameValue === void 0 ? void 0 : brandNameValue.toLowerCase()) != brand) {
|
|
130
133
|
fetchingBrandName(true);
|
|
131
134
|
checkBrand(brandNameValue);
|
|
132
135
|
}
|
|
@@ -134,6 +137,6 @@ var BrandName = function (_a) {
|
|
|
134
137
|
var clearBrandName = function () {
|
|
135
138
|
brandControl.field.onChange('');
|
|
136
139
|
};
|
|
137
|
-
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 })) })] })) })));
|
|
140
|
+
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 })) })] })) })));
|
|
138
141
|
};
|
|
139
142
|
export default React.memo(BrandName);
|
|
@@ -16,14 +16,15 @@ import { useTranslation } from 'react-i18next';
|
|
|
16
16
|
import Collapse from '@mui/material/Collapse';
|
|
17
17
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
18
18
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
19
|
-
import { handlePrevScreenStep } from '../../../../app/settings';
|
|
19
|
+
import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
|
|
20
20
|
import Form from '../../../../components/Form';
|
|
21
|
-
import { INSTAGRAM_URL, TWITTER_URL } from '../../../../constants';
|
|
22
21
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
23
22
|
import Button from '../../../shared/Button';
|
|
24
23
|
import { clearError, connectSelector, updateLeadBrand } from '../../../app/connect/connectStore';
|
|
25
24
|
import { useLanguage } from '../../../../hooks';
|
|
26
|
-
import {
|
|
25
|
+
import { AuthForType } from '../../../../@types';
|
|
26
|
+
import { isKW, mapSalesChannel } from '../../../../utils';
|
|
27
|
+
import { MerchantValidationSchema } from './validation';
|
|
27
28
|
import BrandName from './BrandName';
|
|
28
29
|
import SocialMedia from './SocialMedia';
|
|
29
30
|
import TAC from './TAC';
|
|
@@ -32,37 +33,40 @@ import SalesChannels from './SalesChannels';
|
|
|
32
33
|
var Merchant = function (_a) {
|
|
33
34
|
var _b, _c;
|
|
34
35
|
var _d = React.useState(false), brandNameChecking = _d[0], setBrandNameChecking = _d[1];
|
|
35
|
-
var _e = React.useState(
|
|
36
|
-
var _f = React.useState(false),
|
|
36
|
+
var _e = React.useState(false), isBrandListOpen = _e[0], setIsBrandListOpen = _e[1];
|
|
37
|
+
var _f = React.useState(false), isRequiredNewBrand = _f[0], setIsRequiredNewBrand = _f[1];
|
|
37
38
|
var _g = useAppSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error;
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
39
|
+
var settingsData = useAppSelector(settingsSelector).data;
|
|
40
|
+
var isNewIndividual = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.is_new_individual;
|
|
41
|
+
var startWithNID = data.otpData.authFor === AuthForType.NATIONAL_ID;
|
|
42
|
+
var _h = data.brandData, brandName = _h.brandName, selectedBrandItem = _h.selectedBrandItem, termAndConditionChecked = _h.termAndConditionChecked, responseBody = _h.responseBody, salesChannels = _h.salesChannels;
|
|
43
|
+
var brandList = (responseBody || {}).brand_list;
|
|
43
44
|
var methods = useForm({
|
|
44
|
-
resolver: yupResolver(MerchantValidationSchema(
|
|
45
|
+
resolver: yupResolver(MerchantValidationSchema(isRequiredNewBrand)),
|
|
45
46
|
defaultValues: {
|
|
46
47
|
brandName: brandName,
|
|
47
|
-
links: links,
|
|
48
48
|
selectedBrandItem: selectedBrandItem,
|
|
49
|
-
termAndConditionChecked: termAndConditionChecked
|
|
49
|
+
termAndConditionChecked: termAndConditionChecked,
|
|
50
|
+
salesChannels: salesChannels
|
|
50
51
|
},
|
|
51
52
|
mode: 'onChange'
|
|
52
53
|
});
|
|
53
54
|
var t = useTranslation().t;
|
|
54
55
|
var isAr = useLanguage().isAr;
|
|
55
56
|
var dispatch = useAppDispatch();
|
|
56
|
-
var
|
|
57
|
+
var brandListItem = methods.watch('selectedBrandItem');
|
|
57
58
|
var onSubmit = function (formData) {
|
|
58
|
-
dispatch(updateLeadBrand(formData));
|
|
59
|
+
dispatch(updateLeadBrand(__assign(__assign({}, formData), { isNewBrand: isRequiredNewBrand })));
|
|
59
60
|
};
|
|
60
61
|
var onBack = function () {
|
|
61
|
-
|
|
62
|
+
var _a;
|
|
63
|
+
if (isNewIndividual) {
|
|
62
64
|
dispatch(handlePrevScreenStep('CONNECT_INDIVIDUAL_STEP'));
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
65
|
-
|
|
67
|
+
var code = (_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2;
|
|
68
|
+
var screen = isKW(code) ? 'CONNECT_CIVIL_ID_STEP' : startWithNID ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP';
|
|
69
|
+
dispatch(handlePrevScreenStep(screen));
|
|
66
70
|
};
|
|
67
71
|
React.useEffect(function () {
|
|
68
72
|
if (error)
|
|
@@ -70,60 +74,33 @@ var Merchant = function (_a) {
|
|
|
70
74
|
}, [methods.formState.isValid]);
|
|
71
75
|
React.useEffect(function () {
|
|
72
76
|
if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.response_code) === '5')
|
|
73
|
-
methods.setError('brandName', { message: '
|
|
77
|
+
methods.setError('brandName', { message: 'brand_name_already_exist' });
|
|
74
78
|
}, [responseBody]);
|
|
75
79
|
React.useEffect(function () {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
if (selectedBrandItem.id) {
|
|
81
|
+
methods.setValue('selectedBrandItem', selectedBrandItem);
|
|
82
|
+
var sales = mapSalesChannel(selectedBrandItem.channel_services || []);
|
|
83
|
+
methods.setValue('salesChannels', sales, { shouldValidate: true });
|
|
79
84
|
}
|
|
80
|
-
if (isNewUser === false && (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0 && (formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) === 'other') {
|
|
81
|
-
setUserType(ValidationOptions.EXISTING_USER_WITH_OTHER_BRAND);
|
|
82
|
-
methods.clearErrors();
|
|
83
|
-
setTimeout(function () {
|
|
84
|
-
var sites = { website: '', twitter: '', instagram: '' };
|
|
85
|
-
methods.setValue('brandName', '', { shouldValidate: true });
|
|
86
|
-
methods.setValue('links', sites);
|
|
87
|
-
methods.setValue('salesChannels', []);
|
|
88
|
-
}, 100);
|
|
89
|
-
}
|
|
90
|
-
if (isNewUser === false && (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0 && (formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) !== 'other') {
|
|
91
|
-
setUserType(ValidationOptions.EXISTING_USER_WITH_EXIST_BRAND);
|
|
92
|
-
methods.clearErrors();
|
|
93
|
-
var twitter = ((_b = (_a = formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.social) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.includes('twitter.com'); })) === null || _b === void 0 ? void 0 : _b.replaceAll("".concat(TWITTER_URL, "/"), '')) || '';
|
|
94
|
-
var instagram = ((_d = (_c = formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.social) === null || _c === void 0 ? void 0 : _c.find(function (item) { return item.includes('instagram.com'); })) === null || _d === void 0 ? void 0 : _d.replaceAll("".concat(INSTAGRAM_URL, "/"), '')) || '';
|
|
95
|
-
var website = (_e = formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.website) === null || _e === void 0 ? void 0 : _e.replaceAll(/(https|http):\/\//g, '');
|
|
96
|
-
var sites_1 = __assign(__assign({}, links), { website: website, twitter: twitter, instagram: instagram });
|
|
97
|
-
setTimeout(function () { return methods.setValue('links', sites_1, { shouldValidate: true }); }, 100);
|
|
98
|
-
var selectedChannels = (!!(channelList === null || channelList === void 0 ? void 0 : channelList[0]) && [channelList === null || channelList === void 0 ? void 0 : channelList[0]]) || [];
|
|
99
|
-
var _f = formDataSelectedBrand || {}, websiteUrl = _f.website, social = _f.social;
|
|
100
|
-
var isHasWebsite = (websiteUrl === null || websiteUrl === void 0 ? void 0 : websiteUrl.length) > 0;
|
|
101
|
-
var isHasTwitter = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('twitter.com'); });
|
|
102
|
-
var isHasInstagram = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('instagram.com'); });
|
|
103
|
-
var websiteData = channelList === null || channelList === void 0 ? void 0 : channelList.find(function (c) { return c.name_en.toLocaleLowerCase() === 'website'; });
|
|
104
|
-
var socialData = channelList === null || channelList === void 0 ? void 0 : channelList.find(function (c) { return c.name_en.toLocaleLowerCase() === 'social'; });
|
|
105
|
-
if (isHasWebsite && (isHasTwitter || isHasInstagram))
|
|
106
|
-
selectedChannels = [websiteData, socialData];
|
|
107
|
-
else if (isHasTwitter || isHasInstagram)
|
|
108
|
-
selectedChannels = [socialData];
|
|
109
|
-
else if (isHasWebsite)
|
|
110
|
-
selectedChannels = [websiteData];
|
|
111
|
-
methods.setValue('salesChannels', selectedChannels);
|
|
112
|
-
}
|
|
113
|
-
}, [formDataSelectedBrand, isNewUser]);
|
|
114
|
-
React.useEffect(function () {
|
|
115
|
-
if (!(formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) && (selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.id))
|
|
116
|
-
methods.setValue('selectedBrandItem', selectedBrandItem, { shouldValidate: true });
|
|
117
85
|
}, [selectedBrandItem]);
|
|
118
86
|
React.useEffect(function () {
|
|
119
|
-
|
|
87
|
+
if (salesChannels.length > 0) {
|
|
88
|
+
var sales = mapSalesChannel(salesChannels);
|
|
89
|
+
methods.setValue('salesChannels', sales, { shouldValidate: true });
|
|
90
|
+
}
|
|
120
91
|
}, [salesChannels]);
|
|
92
|
+
React.useEffect(function () {
|
|
93
|
+
if (termAndConditionChecked === true)
|
|
94
|
+
methods.setValue('termAndConditionChecked', termAndConditionChecked);
|
|
95
|
+
}, [termAndConditionChecked]);
|
|
121
96
|
var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
|
|
122
97
|
var disabled = brandErrChecks || brandNameChecking || ((_c = data.brandData.responseBody) === null || _c === void 0 ? void 0 : _c.response_code) === '5';
|
|
123
|
-
var
|
|
124
|
-
var
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
98
|
+
var hasBrandList = (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0;
|
|
99
|
+
var isOtherBrand = (brandListItem === null || brandListItem === void 0 ? void 0 : brandListItem.id) === 'other' && hasBrandList;
|
|
100
|
+
var isNewBrand = (brandList === null || brandList === void 0 ? void 0 : brandList.length) === 0 || BrandList === undefined;
|
|
101
|
+
React.useEffect(function () {
|
|
102
|
+
setIsRequiredNewBrand(isOtherBrand || isNewBrand);
|
|
103
|
+
}, [isOtherBrand, isNewBrand]);
|
|
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') })) }))] })) })) }));
|
|
128
105
|
};
|
|
129
106
|
export default React.memo(Merchant);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
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
|
+
}
|
|
6
|
+
declare const SalesChannels: ({}: SalesChannelsProps) => JSX.Element;
|
|
5
7
|
export default SalesChannels;
|
|
@@ -19,7 +19,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
19
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
20
|
};
|
|
21
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
-
import * as React from 'react';
|
|
23
22
|
import Box from '@mui/material/Box';
|
|
24
23
|
import { alpha, styled } from '@mui/material/styles';
|
|
25
24
|
import { useTranslation } from 'react-i18next';
|
|
@@ -30,7 +29,6 @@ import { connectSelector, clearError } from '../../../app/connect/connectStore';
|
|
|
30
29
|
import CheckBox from '../../../../components/CheckBox';
|
|
31
30
|
import Warning from '../../../../components/Warning';
|
|
32
31
|
import Collapse from '../../../../components/Collapse';
|
|
33
|
-
import { ScreenContainer } from '../../../shared/Containers';
|
|
34
32
|
var InputLabelStyled = styled(Text)(function (_a) {
|
|
35
33
|
var theme = _a.theme;
|
|
36
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));
|
|
@@ -53,6 +51,7 @@ var TextStyled = styled(Text)(function (_a) {
|
|
|
53
51
|
var CheckBoxStyled = styled(CheckBox)(function (_a) {
|
|
54
52
|
var theme = _a.theme;
|
|
55
53
|
return ({
|
|
54
|
+
paddingInline: '15px',
|
|
56
55
|
marginInlineEnd: theme.spacing(-1),
|
|
57
56
|
'& .MuiSvgIcon-root': {
|
|
58
57
|
fontSize: 30
|
|
@@ -73,42 +72,42 @@ export var CollapseStyled = styled(Collapse)(function (_a) {
|
|
|
73
72
|
marginBlockStart: theme.spacing(2)
|
|
74
73
|
});
|
|
75
74
|
});
|
|
76
|
-
var SalesChannels = function () {
|
|
77
|
-
var
|
|
78
|
-
var _b = React.useState([]), channelsMenuList = _b[0], setChannelsMenuList = _b[1];
|
|
75
|
+
var SalesChannels = function (_a) {
|
|
76
|
+
var _b;
|
|
79
77
|
var t = useTranslation().t;
|
|
80
78
|
var isAr = useLanguage().isAr;
|
|
81
79
|
var _c = useFormContext(), control = _c.control, getValues = _c.getValues;
|
|
82
80
|
var dispatch = useAppDispatch();
|
|
83
|
-
var channelsControl = useController({ name: 'salesChannels'
|
|
84
|
-
var channelsChecked = channelsControl.field.value;
|
|
85
|
-
var warningMessage = (_a = channelsControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
|
|
81
|
+
var channelsControl = useController({ control: control, name: 'salesChannels' });
|
|
86
82
|
var _d = useAppSelector(connectSelector), data = _d.data, error = _d.error;
|
|
87
|
-
var channelList = (data.brandData.responseBody || {}).
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
}, [channelList]);
|
|
95
|
-
var handleSalesChannelChange = function (event) {
|
|
96
|
-
var selected = channelsMenuList.find(function (channel) { return channel.id === event.target.id; });
|
|
97
|
-
var isExists = channelsChecked === null || channelsChecked === void 0 ? void 0 : channelsChecked.find(function (channel) { return channel.id === (selected === null || selected === void 0 ? void 0 : selected.id); });
|
|
98
|
-
if (isExists) {
|
|
99
|
-
var updatedIdList = channelsChecked === null || channelsChecked === void 0 ? void 0 : channelsChecked.filter(function (channel) { return channel.id !== (selected === null || selected === void 0 ? void 0 : selected.id); });
|
|
100
|
-
channelsControl.field.onChange(updatedIdList);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
channelsControl.field.onChange(__spreadArray(__spreadArray([], channelsChecked, true), [selected], false));
|
|
83
|
+
var channelList = (data.brandData.responseBody || {}).channel_list;
|
|
84
|
+
var isChecked = function (id) {
|
|
85
|
+
var item = channelsControl.field.value.find(function (item) { return item.id === id; });
|
|
86
|
+
return !!item;
|
|
87
|
+
};
|
|
88
|
+
var onChange = function (channel) {
|
|
104
89
|
if (error)
|
|
105
90
|
dispatch(clearError());
|
|
91
|
+
if (isChecked(channel.id)) {
|
|
92
|
+
var filterChannels = channelsControl.field.value.filter(function (item) { return item.id !== channel.id; });
|
|
93
|
+
channelsControl.field.onChange(filterChannels);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
var brandName = getValues('brandName');
|
|
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
|
+
}
|
|
103
|
+
channelsControl.field.onChange(__spreadArray(__spreadArray([], channelsControl.field.value, true), [newChannel], false));
|
|
104
|
+
}
|
|
106
105
|
};
|
|
107
|
-
var
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
var warningMessage = (_b = channelsControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
107
|
+
var isSalesChannelError = warningMessage === 'choose_atleast_one_channel';
|
|
108
|
+
return (_jsxs(Box, __assign({ sx: { mb: 3 } }, { children: [_jsxs(InputLabelStyled, { children: [t('channel_of_service'), " ", _jsx(MandatoryStyled, { children: "*" })] }), (channelList || []).map(function (channel, index) {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
return (_jsxs(ContainerStyled, { children: [_jsx(CheckBoxStyled, { id: channel.id, disableRipple: true, disableFocusRipple: true, focusRipple: false, checked: isChecked(channel.id), onChange: function () { return onChange(channel); } }), _jsxs(TextStyled, { children: [isAr ? (_a = channel === null || channel === void 0 ? void 0 : channel.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = channel === null || channel === void 0 ? void 0 : channel.name) === null || _b === void 0 ? void 0 : _b.en, " "] })] }, channel.id));
|
|
111
|
+
}), _jsx(CollapseStyled, __assign({ in: isSalesChannelError }, { children: _jsx(Warning, __assign({ warningType: 'alert' }, { children: t(warningMessage) })) }))] })));
|
|
113
112
|
};
|
|
114
113
|
export default SalesChannels;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Theme, SxProps } from '@mui/material/styles';
|
|
3
2
|
interface SocialMediaProps {
|
|
4
3
|
show: boolean;
|
|
5
|
-
sx?: SxProps<Theme>;
|
|
6
|
-
isNewUser: boolean;
|
|
7
4
|
}
|
|
8
|
-
declare const _default: React.MemoExoticComponent<({ show
|
|
5
|
+
declare const _default: React.MemoExoticComponent<({ show }: SocialMediaProps) => JSX.Element>;
|
|
9
6
|
export default _default;
|