@tap-payments/auth-jsconnect 2.0.45 → 2.0.46
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 +47 -2
- package/build/@types/app.js +22 -0
- package/build/@types/form.d.ts +19 -1
- package/build/@types/index.d.ts +1 -0
- package/build/@types/index.js +1 -0
- package/build/@types/user.d.ts +141 -0
- package/build/@types/user.js +1 -0
- package/build/api/board.d.ts +16 -0
- package/build/api/board.js +10 -1
- package/build/api/country.d.ts +4 -0
- package/build/api/country.js +9 -1
- package/build/api/entity.d.ts +3 -3
- package/build/api/index.d.ts +8 -3
- package/build/api/individual.d.ts +54 -4
- package/build/api/individual.js +9 -1
- package/build/api/user.d.ts +6 -0
- package/build/api/user.js +9 -1
- package/build/app/settings.js +11 -8
- package/build/assets/locales/ar.json +28 -2
- package/build/assets/locales/en.json +28 -1
- package/build/components/SimpleList/SimpleList.d.ts +2 -0
- package/build/constants/api.d.ts +1 -0
- package/build/constants/api.js +3 -1
- package/build/constants/app.d.ts +1 -0
- package/build/constants/app.js +20 -7
- package/build/constants/assets.d.ts +4 -0
- package/build/constants/assets.js +4 -0
- package/build/features/app/bank/bankStore.d.ts +1 -0
- package/build/features/app/bank/bankStore.js +19 -13
- package/build/features/app/brand/brandStore.d.ts +2 -0
- package/build/features/app/brand/brandStore.js +69 -49
- package/build/features/app/business/businessStore.js +3 -3
- package/build/features/app/connect/connectStore.js +6 -6
- package/build/features/app/connectExpress/connectExpressStore.js +15 -9
- package/build/features/app/entity/entityStore.d.ts +2 -0
- package/build/features/app/entity/entityStore.js +5 -3
- package/build/features/app/individual/individualStore.d.ts +93 -4
- package/build/features/app/individual/individualStore.js +613 -129
- package/build/features/app/password/passwordStore.js +2 -2
- package/build/features/app/tax/taxStore.js +30 -29
- package/build/features/bank/Bank.js +2 -2
- package/build/features/bank/screens/BankDetails/BankDetails.js +8 -7
- package/build/features/bank/screens/BankDetails/BankName.js +13 -10
- package/build/features/bank/screens/BankDetails/BankStatement.js +8 -2
- package/build/features/bank/screens/BankDetails/Beneficiary.js +12 -13
- package/build/features/bank/screens/BankDetails/IBAN.js +14 -10
- package/build/features/bank/screens/BankDetails/validation.d.ts +14 -14
- package/build/features/bank/screens/BankDetails/validation.js +34 -15
- package/build/features/bank/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
- package/build/features/brand/Brand.js +2 -2
- package/build/features/brand/screens/BrandActivities/ActivitiesList.d.ts +3 -3
- package/build/features/brand/screens/BrandActivities/ActivitiesList.js +8 -6
- package/build/features/brand/screens/BrandActivities/BrandActivities.js +12 -2
- package/build/features/brand/screens/BrandActivities/CustomerBase.d.ts +2 -2
- package/build/features/brand/screens/BrandActivities/CustomerBase.js +9 -6
- package/build/features/brand/screens/BrandActivities/ExpectedSalesRange.js +10 -7
- package/build/features/brand/screens/BrandActivities/validation.d.ts +7 -7
- package/build/features/brand/screens/BrandActivities/validation.js +26 -15
- package/build/features/brand/screens/BrandInfo/BrandInfo.js +11 -4
- package/build/features/brand/screens/BrandInfo/BrandName.js +13 -12
- package/build/features/brand/screens/BrandInfo/SalesChannels.js +21 -9
- package/build/features/brand/screens/BrandInfo/validation.d.ts +7 -7
- package/build/features/brand/screens/BrandInfo/validation.js +46 -36
- package/build/features/brand/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
- package/build/features/business/Business.js +2 -2
- package/build/features/business/screens/Activities/ActivitiesList.d.ts +3 -3
- package/build/features/business/screens/BusinessType/LicenseCertificate.js +2 -1
- package/build/features/business/screens/BusinessType/LicenseType.d.ts +2 -2
- package/build/features/business/screens/Customers/CustomerLocations.d.ts +2 -2
- package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
- package/build/features/connect/Connect.js +2 -2
- package/build/features/connect/screens/Merchant/BrandList.js +4 -4
- package/build/features/connect/screens/Merchant/BrandName.js +6 -5
- package/build/features/connect/screens/Merchant/validation.js +2 -2
- package/build/features/connectExpress/ConnectExpress.js +2 -2
- package/build/features/connectExpress/screens/CollectBusinessInfo/BrandName.js +1 -3
- package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseType.d.ts +2 -2
- package/build/features/connectExpress/screens/CollectBusinessInfo/validation.js +5 -5
- package/build/features/connectExpress/screens/CreateAccountLoader/CreateAccountLoader.js +23 -3
- package/build/features/connectExpress/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +3 -3
- package/build/features/entity/Entity.js +2 -2
- package/build/features/entity/screens/EntityCapital/ActivityList.d.ts +3 -3
- package/build/features/entity/screens/EntityName/EntityTypeList.d.ts +3 -3
- package/build/features/entity/screens/EntityName/LicenseCertificate.js +9 -3
- package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
- package/build/features/featuresScreens.js +10 -0
- package/build/features/individual/Individual.js +2 -2
- package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.d.ts +13 -0
- package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +48 -25
- package/build/features/individual/screens/AdditionalIndividualInfo/CivilIDFile.js +6 -1
- package/build/features/individual/screens/AdditionalIndividualInfo/InfluencerSwitch.js +9 -2
- package/build/features/individual/screens/AdditionalIndividualInfo/MonthlyIncome.js +11 -17
- package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +12 -16
- package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.d.ts +2 -2
- package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.js +9 -2
- package/build/features/individual/screens/AdditionalIndividualInfo/ShareCount.d.ts +6 -0
- package/build/features/individual/screens/AdditionalIndividualInfo/ShareCount.js +35 -0
- package/build/features/individual/screens/AdditionalIndividualInfo/ShareValue.d.ts +6 -0
- package/build/features/individual/screens/AdditionalIndividualInfo/ShareValue.js +41 -0
- package/build/features/individual/screens/AdditionalIndividualInfo/SignatureFile.js +8 -2
- package/build/features/individual/screens/AdditionalIndividualInfo/SourceOfIncome.js +9 -6
- package/build/features/individual/screens/AdditionalIndividualInfo/validation.d.ts +25 -23
- package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +19 -25
- package/build/features/individual/screens/IndividualList/CollectPhoneEmail.d.ts +10 -0
- package/build/features/individual/screens/IndividualList/CollectPhoneEmail.js +31 -0
- package/build/features/individual/screens/IndividualList/Email.d.ts +6 -0
- package/build/features/individual/screens/IndividualList/Email.js +48 -0
- package/build/features/individual/screens/IndividualList/IndividualList.d.ts +31 -0
- package/build/features/individual/screens/IndividualList/IndividualList.js +58 -0
- package/build/features/individual/screens/IndividualList/MobileNumber.d.ts +12 -0
- package/build/features/individual/screens/IndividualList/MobileNumber.js +143 -0
- package/build/features/individual/screens/IndividualList/UserList.d.ts +5 -0
- package/build/features/individual/screens/IndividualList/UserList.js +186 -0
- package/build/features/individual/screens/IndividualList/index.d.ts +3 -0
- package/build/features/individual/screens/IndividualList/index.js +2 -0
- package/build/features/individual/screens/IndividualList/validation.d.ts +12 -0
- package/build/features/individual/screens/IndividualList/validation.js +39 -0
- package/build/features/individual/screens/IndividualPersonalInfo/BirthCity.d.ts +8 -0
- package/build/features/individual/screens/IndividualPersonalInfo/BirthCity.js +109 -0
- package/build/features/individual/screens/{AdditionalIndividualInfo/EmployerLocation.d.ts → IndividualPersonalInfo/BirthCountry.d.ts} +2 -2
- package/build/features/individual/screens/{AdditionalIndividualInfo/EmployerLocation.js → IndividualPersonalInfo/BirthCountry.js} +14 -24
- package/build/features/individual/screens/IndividualPersonalInfo/DOB.d.ts +7 -0
- package/build/features/individual/screens/IndividualPersonalInfo/DOB.js +46 -0
- package/build/features/individual/screens/IndividualPersonalInfo/Email.d.ts +6 -0
- package/build/features/individual/screens/IndividualPersonalInfo/Email.js +50 -0
- package/build/features/individual/screens/IndividualPersonalInfo/ExpiryDate.d.ts +7 -0
- package/build/features/individual/screens/IndividualPersonalInfo/ExpiryDate.js +50 -0
- package/build/features/individual/screens/IndividualPersonalInfo/Gender.d.ts +34 -0
- package/build/features/individual/screens/IndividualPersonalInfo/Gender.js +81 -0
- package/build/features/individual/screens/IndividualPersonalInfo/ID.d.ts +6 -0
- package/build/features/individual/screens/IndividualPersonalInfo/ID.js +48 -0
- package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.d.ts +21 -0
- package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.js +139 -0
- package/build/features/individual/screens/IndividualPersonalInfo/IssuedCountry.d.ts +10 -0
- package/build/features/individual/screens/IndividualPersonalInfo/IssuedCountry.js +88 -0
- package/build/features/individual/screens/IndividualPersonalInfo/MobileNumber.d.ts +10 -0
- package/build/features/individual/screens/IndividualPersonalInfo/MobileNumber.js +145 -0
- package/build/features/individual/screens/IndividualPersonalInfo/Name.d.ts +6 -0
- package/build/features/individual/screens/IndividualPersonalInfo/Name.js +52 -0
- package/build/features/individual/screens/IndividualPersonalInfo/Nationality.d.ts +10 -0
- package/build/features/individual/screens/IndividualPersonalInfo/Nationality.js +88 -0
- package/build/features/individual/screens/IndividualPersonalInfo/index.d.ts +3 -0
- package/build/features/individual/screens/IndividualPersonalInfo/index.js +2 -0
- package/build/features/individual/screens/IndividualPersonalInfo/validation.d.ts +38 -0
- package/build/features/individual/screens/IndividualPersonalInfo/validation.js +68 -0
- package/build/features/individual/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
- package/build/features/individual/screens/Verify/Verify.js +10 -17
- package/build/features/password/Password.js +2 -2
- package/build/features/password/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
- package/build/features/shared/Address/Address.d.ts +6 -1
- package/build/features/shared/Address/Address.js +40 -30
- package/build/features/shared/Address/CountryList.d.ts +1 -1
- package/build/features/shared/Address/InputSelect.d.ts +1 -1
- package/build/features/shared/Address/InputText.d.ts +2 -1
- package/build/features/shared/Address/InputText.js +2 -2
- package/build/features/shared/Button/Button.js +11 -0
- package/build/features/shared/Button/FlowsButtons.d.ts +1 -0
- package/build/features/shared/Button/FlowsButtons.js +5 -5
- package/build/features/shared/Button/ListButton.d.ts +18 -0
- package/build/features/shared/Button/ListButton.js +125 -0
- package/build/features/shared/Button/index.d.ts +2 -1
- package/build/features/shared/Button/index.js +2 -1
- package/build/features/shared/CreateAccountLoading/CreateAccountLoading.d.ts +2 -1
- package/build/features/shared/CreateAccountLoading/CreateAccountLoading.js +2 -2
- package/build/features/shared/SalesChannels/SalesChannel.d.ts +2 -1
- package/build/features/shared/SalesChannels/SalesChannel.js +2 -2
- package/build/features/shared/SuccessFlowButtons/SuccessFlowButtons.d.ts +2 -1
- package/build/features/shared/SuccessFlowButtons/SuccessFlowButtons.js +8 -6
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +6 -1
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.js +33 -11
- package/build/features/signIn/SignIn.js +2 -2
- package/build/features/tax/Tax.js +2 -2
- package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
- package/build/features/tax/screens/TaxDetails/TaxDetails.js +2 -1
- package/build/features/tax/screens/TaxDetails/TaxDocument.js +8 -2
- package/build/features/tax/screens/TaxDetails/VATId.js +8 -3
- package/build/features/tax/screens/TaxDetails/validation.d.ts +4 -4
- package/build/features/tax/screens/TaxDetails/validation.js +10 -5
- package/build/utils/array.d.ts +1 -0
- package/build/utils/array.js +10 -2
- package/build/utils/common.d.ts +1 -0
- package/build/utils/common.js +6 -0
- package/build/utils/date.d.ts +1 -0
- package/build/utils/date.js +7 -1
- package/build/utils/error.d.ts +1 -0
- package/build/utils/error.js +3 -0
- package/build/utils/html.d.ts +1 -1
- package/build/utils/html.js +4 -1
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.js +1 -0
- package/build/utils/string.d.ts +15 -2
- package/build/utils/string.js +37 -3
- package/build/utils/validation.d.ts +1 -0
- package/build/utils/validation.js +3 -0
- package/package.json +129 -129
- package/build/features/individual/screens/AdditionalIndividualInfo/EmployerName.d.ts +0 -6
- package/build/features/individual/screens/AdditionalIndividualInfo/EmployerName.js +0 -46
- package/build/features/individual/screens/ShowIndividualInfo/ShowOwnerInfo.d.ts +0 -19
- package/build/features/individual/screens/ShowIndividualInfo/ShowOwnerInfo.js +0 -52
- package/build/features/individual/screens/ShowIndividualInfo/index.d.ts +0 -3
- package/build/features/individual/screens/ShowIndividualInfo/index.js +0 -2
- package/build/features/individual/screens/ShowIndividualInfo/info.d.ts +0 -7
- package/build/features/individual/screens/ShowIndividualInfo/info.js +0 -28
|
@@ -41,6 +41,7 @@ import Tooltip from '../../../../components/Tooltip';
|
|
|
41
41
|
import { useTranslation } from 'react-i18next';
|
|
42
42
|
import { useController, useFormContext } from 'react-hook-form';
|
|
43
43
|
import { useLanguage, useAppSelector } from '../../../../hooks';
|
|
44
|
+
import { FieldType } from '../../../../@types';
|
|
44
45
|
import Collapse from '../../../../components/Collapse';
|
|
45
46
|
import SimpleList from '../../../../components/SimpleList';
|
|
46
47
|
import ExpandIcon from '../../../../components/ExpandIcon';
|
|
@@ -102,20 +103,21 @@ export var NameContainer = styled(Text, { shouldForwardProp: function (prop) { r
|
|
|
102
103
|
return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25), textAlign: 'start' }));
|
|
103
104
|
});
|
|
104
105
|
var ActivitiesList = function (_a) {
|
|
105
|
-
var _b, _c, _d;
|
|
106
|
+
var _b, _c, _d, _e;
|
|
106
107
|
var show = _a.show, rest = __rest(_a, ["show"]);
|
|
107
|
-
var
|
|
108
|
-
var
|
|
108
|
+
var _f = React.useState([]), activitiesMenuList = _f[0], setActivitiesMenuList = _f[1];
|
|
109
|
+
var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
|
|
109
110
|
var t = useTranslation().t;
|
|
110
111
|
var isAr = useLanguage().isAr;
|
|
111
112
|
var control = useFormContext().control;
|
|
112
113
|
var data = useAppSelector(brandSelector).data;
|
|
113
114
|
var activitiesControl = useController({ name: 'activities', control: control });
|
|
114
115
|
var controlValue = activitiesControl.field.value;
|
|
115
|
-
var
|
|
116
|
+
var _h = React.useState(false), isHovered = _h[0], setIsHovered = _h[1];
|
|
116
117
|
var verify = data.verify;
|
|
117
|
-
var
|
|
118
|
+
var _j = verify.responseBody || {}, activities = _j.activities, brand = _j.brand;
|
|
118
119
|
var isCR = ((_d = (_c = (_b = verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.license) === null || _d === void 0 ? void 0 : _d.type) === 'commercial_registration';
|
|
120
|
+
var disabled = ((_e = brand === null || brand === void 0 ? void 0 : brand.data_status) === null || _e === void 0 ? void 0 : _e.activities) === FieldType.NON_EDITABLE;
|
|
119
121
|
React.useEffect(function () {
|
|
120
122
|
if ((activities === null || activities === void 0 ? void 0 : activities.length) > 0) {
|
|
121
123
|
var list = __spreadArray([], activities, true);
|
|
@@ -154,7 +156,7 @@ var ActivitiesList = function (_a) {
|
|
|
154
156
|
var getSelectedActivityFlag = function (item) {
|
|
155
157
|
return controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.id === item.id; });
|
|
156
158
|
};
|
|
157
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(LabelContainerStyled, { children: [_jsxs(InputLabelStyled, { children: [t(isCR ? 'activities' : 'category'), " ", _jsx(MandatoryStyled, { children: "*" })] }), _jsx(Tooltip, __assign({ title: t('activities_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, value: getSelectedActivities(), placeholder: isCR ? t('choose_activities') : t('category_name'), onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name.en', searchValuePath: ['name.ar', 'name.en'], list: activitiesMenuList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
159
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(LabelContainerStyled, { children: [_jsxs(InputLabelStyled, { children: [t(isCR ? 'activities' : 'category'), " ", _jsx(MandatoryStyled, { children: "*" })] }), _jsx(Tooltip, __assign({ title: t('activities_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, disabled: disabled, value: getSelectedActivities(), placeholder: isCR ? t('choose_activities') : t('category_name'), onClick: disabled ? undefined : !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: disabled ? _jsx(_Fragment, {}) : _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name.en', searchValuePath: ['name.ar', 'name.en'], list: activitiesMenuList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
158
160
|
var _a, _b, _c;
|
|
159
161
|
return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: item.id === ((_a = getSelectedActivityFlag(item)) === null || _a === void 0 ? void 0 : _a.id) }, { children: isAr ? (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = item === null || item === void 0 ? void 0 : item.name) === null || _c === void 0 ? void 0 : _c.en })) })), getSelectedActivityFlag(item) && _jsx(CheckIconStyled, {})] }));
|
|
160
162
|
} }) }))] })] }) })));
|
|
@@ -38,6 +38,8 @@ var BrandActivities = function (_a) {
|
|
|
38
38
|
var _b = React.useState(), listActive = _b[0], setListActive = _b[1];
|
|
39
39
|
var dispatch = useAppDispatch();
|
|
40
40
|
var _c = useAppSelector(brandSelector), data = _c.data, loading = _c.loading, error = _c.error;
|
|
41
|
+
var brand = (data.verify.responseBody || {}).brand;
|
|
42
|
+
var _d = data.brandActivities, activities = _d.activities, customerLocations = _d.customerLocations, expectedCustomer = _d.expectedCustomer, expectedSale = _d.expectedSale, termAndConditionChecked = _d.termAndConditionChecked, refundPolicy = _d.refundPolicy, transactionPolicy = _d.transactionPolicy;
|
|
41
43
|
var ListType;
|
|
42
44
|
(function (ListType) {
|
|
43
45
|
ListType["ActivitiesList"] = "ActivitiesList";
|
|
@@ -46,8 +48,16 @@ var BrandActivities = function (_a) {
|
|
|
46
48
|
ListType["ExpectedSalesList"] = "ExpectedSalesList";
|
|
47
49
|
})(ListType || (ListType = {}));
|
|
48
50
|
var methods = useForm({
|
|
49
|
-
resolver: yupResolver(BrandActivitiesValidationSchema),
|
|
50
|
-
defaultValues:
|
|
51
|
+
resolver: yupResolver(BrandActivitiesValidationSchema(brand)),
|
|
52
|
+
defaultValues: {
|
|
53
|
+
activities: activities,
|
|
54
|
+
customerLocations: customerLocations,
|
|
55
|
+
expectedCustomer: expectedCustomer,
|
|
56
|
+
expectedSale: expectedSale,
|
|
57
|
+
termAndConditionChecked: termAndConditionChecked,
|
|
58
|
+
refundPolicy: refundPolicy,
|
|
59
|
+
transactionPolicy: transactionPolicy
|
|
60
|
+
},
|
|
51
61
|
mode: 'onChange'
|
|
52
62
|
});
|
|
53
63
|
useSetFromDefaultValues(methods, data.brandActivities, true);
|
|
@@ -48,7 +48,7 @@ export declare const NameContainer: import("@emotion/styled").StyledComponent<im
|
|
|
48
48
|
export declare const CheckIconStyled: import("@emotion/styled").StyledComponent<{
|
|
49
49
|
children?: React.ReactNode;
|
|
50
50
|
classes?: Partial<import("@mui/material").SvgIconClasses> | undefined;
|
|
51
|
-
color?: "inherit" | "disabled" | "error" | "
|
|
51
|
+
color?: "inherit" | "disabled" | "error" | "info" | "success" | "primary" | "secondary" | "action" | "warning" | undefined;
|
|
52
52
|
fontSize?: "small" | "inherit" | "medium" | "large" | undefined;
|
|
53
53
|
htmlColor?: string | undefined;
|
|
54
54
|
inheritViewBox?: boolean | undefined;
|
|
@@ -62,7 +62,7 @@ export declare const CheckIconStyled: import("@emotion/styled").StyledComponent<
|
|
|
62
62
|
export declare const RemainingCheck: import("@emotion/styled").StyledComponent<{
|
|
63
63
|
children?: React.ReactNode;
|
|
64
64
|
classes?: Partial<import("@mui/material").SvgIconClasses> | undefined;
|
|
65
|
-
color?: "inherit" | "disabled" | "error" | "
|
|
65
|
+
color?: "inherit" | "disabled" | "error" | "info" | "success" | "primary" | "secondary" | "action" | "warning" | undefined;
|
|
66
66
|
fontSize?: "small" | "inherit" | "medium" | "large" | undefined;
|
|
67
67
|
htmlColor?: string | undefined;
|
|
68
68
|
inheritViewBox?: boolean | undefined;
|
|
@@ -35,6 +35,7 @@ import Tooltip from '../../../../components/Tooltip';
|
|
|
35
35
|
import SimpleList from '../../../../components/SimpleList';
|
|
36
36
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
37
37
|
import { useLanguage, useAppSelector, useAppDispatch } from '../../../../hooks';
|
|
38
|
+
import { FieldType } from '../../../../@types';
|
|
38
39
|
import { brandSelector, clearError } from '../../../app/brand/brandStore';
|
|
39
40
|
import Search from '../../../../features/shared/Search';
|
|
40
41
|
import { InfoIconStyled, InfoOutlinedIconStyled, LabelContainerStyled } from './ActivitiesList';
|
|
@@ -79,18 +80,20 @@ var SimpleListStyled = styled((SimpleList))(function () { return ({
|
|
|
79
80
|
height: 'fit-content'
|
|
80
81
|
}); });
|
|
81
82
|
var CustomerBase = function (_a) {
|
|
83
|
+
var _b, _c, _d, _e;
|
|
82
84
|
var rest = __rest(_a, []);
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
+
var _f = React.useState([]), customerLocationsList = _f[0], setCustomerLocationsList = _f[1];
|
|
86
|
+
var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
|
|
85
87
|
var t = useTranslation().t;
|
|
86
88
|
var isAr = useLanguage().isAr;
|
|
87
89
|
var control = useFormContext().control;
|
|
88
90
|
var dispatch = useAppDispatch();
|
|
89
91
|
var customerLocationsControl = useController({ name: 'customerLocations', control: control });
|
|
90
|
-
var
|
|
91
|
-
var
|
|
92
|
-
var brandActivities = data.brandActivities;
|
|
92
|
+
var _h = useAppSelector(brandSelector), data = _h.data, error = _h.error;
|
|
93
|
+
var _j = React.useState(false), isHovered = _j[0], setIsHovered = _j[1];
|
|
94
|
+
var brandActivities = data.brandActivities, verify = data.verify;
|
|
93
95
|
var response = brandActivities.responseBody;
|
|
96
|
+
var disabled = ((_e = (_d = (_c = (_b = verify.responseBody) === null || _b === void 0 ? void 0 : _b.brand) === null || _c === void 0 ? void 0 : _c.data_status) === null || _d === void 0 ? void 0 : _d.customer_base) === null || _e === void 0 ? void 0 : _e.location) === FieldType.NON_EDITABLE;
|
|
94
97
|
var onOpenList = function (event) {
|
|
95
98
|
var _a;
|
|
96
99
|
setAnchorEl(event.currentTarget);
|
|
@@ -136,7 +139,7 @@ var CustomerBase = function (_a) {
|
|
|
136
139
|
};
|
|
137
140
|
var customerLocationsValue = customerLocationsControl.field.value;
|
|
138
141
|
var customerLocationSelected = customerLocationsValue === null || customerLocationsValue === void 0 ? void 0 : customerLocationsValue[0];
|
|
139
|
-
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(BaseLabelStyled, { children: t('select_customer_base') }), _jsx(Tooltip, __assign({ title: t('customer_base_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(InputStyled, { readOnly: true, placeholder: t('choose_expected_sales'), value: isAr ? customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name.ar : customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name.en, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { searchKeyPath: 'name.en', list: customerLocationsList, placeholder: 'choose_customer_base', onSelectItem: onSelectItem, renderItem: function (item) {
|
|
142
|
+
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(BaseLabelStyled, { children: t('select_customer_base') }), _jsx(Tooltip, __assign({ title: t('customer_base_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(InputStyled, { readOnly: true, disabled: disabled, placeholder: t('choose_expected_sales'), value: isAr ? customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name.ar : customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name.en, onClick: disabled ? undefined : !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: disabled ? _jsx(_Fragment, {}) : _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { searchKeyPath: 'name.en', list: customerLocationsList, placeholder: 'choose_customer_base', onSelectItem: onSelectItem, renderItem: function (item) {
|
|
140
143
|
return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (customerLocationsValue === null || customerLocationsValue === void 0 ? void 0 : customerLocationsValue.id) }, { children: isAr ? item.name.ar : item.name.en })) })), item.id === (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(CheckIconStyled, {}), checkRemainingCondition(item) && item.id != (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(RemainingCheck, {})] }));
|
|
141
144
|
} })] }))] }) })));
|
|
142
145
|
};
|
|
@@ -9,13 +9,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import * as React from 'react';
|
|
14
14
|
import Box from '@mui/material/Box';
|
|
15
15
|
import { styled } from '@mui/material/styles';
|
|
16
16
|
import { useTranslation } from 'react-i18next';
|
|
17
17
|
import { useController, useFormContext } from 'react-hook-form';
|
|
18
18
|
import { useLanguage, useAppSelector, useAppDispatch } from '../../../../hooks';
|
|
19
|
+
import { FieldType } from '../../../../@types';
|
|
19
20
|
import SimpleList from '../../../../components/SimpleList';
|
|
20
21
|
import Collapse from '../../../../components/Collapse';
|
|
21
22
|
import ExpandIcon from '../../../../components/ExpandIcon';
|
|
@@ -46,21 +47,23 @@ var SimpleListStyled = styled((SimpleList))(function () { return ({
|
|
|
46
47
|
height: 'fit-content'
|
|
47
48
|
}); });
|
|
48
49
|
var ExpectedSalesRange = function (_a) {
|
|
50
|
+
var _b, _c, _d, _e;
|
|
49
51
|
var show = _a.show, onListClose = _a.onListClose, onListOpen = _a.onListOpen;
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
52
|
+
var _f = React.useState([]), expectedSalesRangeList = _f[0], setExpectedSalesRangeList = _f[1];
|
|
53
|
+
var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
|
|
54
|
+
var _h = React.useState(''), subIndex = _h[0], setSubIndex = _h[1];
|
|
53
55
|
var t = useTranslation().t;
|
|
54
56
|
var isAr = useLanguage().isAr;
|
|
55
57
|
var control = useFormContext().control;
|
|
56
58
|
var dispatch = useAppDispatch();
|
|
57
59
|
var expectedSaleControl = useController({ name: 'expectedSale', control: control });
|
|
58
|
-
var
|
|
60
|
+
var _j = useAppSelector(brandSelector), data = _j.data, error = _j.error;
|
|
59
61
|
var settingsData = useAppSelector(settingsSelector).data;
|
|
60
|
-
var brandActivities = data.brandActivities;
|
|
62
|
+
var brandActivities = data.brandActivities, verify = data.verify;
|
|
61
63
|
var expectedSales = (brandActivities.responseBody || {}).expectedSales;
|
|
62
64
|
var expectedSalesRangeValue = expectedSaleControl.field.value;
|
|
63
65
|
var countryCode = settingsData.businessCountry;
|
|
66
|
+
var disabled = ((_e = (_d = (_c = (_b = verify.responseBody) === null || _b === void 0 ? void 0 : _b.brand) === null || _c === void 0 ? void 0 : _c.data_status) === null || _d === void 0 ? void 0 : _d.operations) === null || _e === void 0 ? void 0 : _e.sales_range) === FieldType.NON_EDITABLE;
|
|
64
67
|
var handleOpenMainMenu = function (event) {
|
|
65
68
|
setAnchorEl(event.currentTarget);
|
|
66
69
|
onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
|
|
@@ -112,7 +115,7 @@ var ExpectedSalesRange = function (_a) {
|
|
|
112
115
|
}, [anchorEl, expectedSalesRangeValue]);
|
|
113
116
|
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_sales_monthly', {
|
|
114
117
|
currency: t(findCurrencyByIso2(countryCode.iso2))
|
|
115
|
-
}) }), _jsx(InputStyled, { readOnly: true, value: (isAr ? expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.name.ar : expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.name.en) || '', onClick: !!anchorEl ? handleCloseMainMenu : handleOpenMainMenu, placeholder: t('choose_expected_sales'), endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { sx: { maxHeight: '350px', paddingTop: 0 }, list: expectedSalesRangeList, listItemProps: { sx: { padding: 0 } }, onSelectItem: function (item) {
|
|
118
|
+
}) }), _jsx(InputStyled, { readOnly: true, disabled: disabled, value: (isAr ? expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.name.ar : expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.name.en) || '', onClick: disabled ? undefined : !!anchorEl ? handleCloseMainMenu : handleOpenMainMenu, placeholder: t('choose_expected_sales'), endAdornment: disabled ? _jsx(_Fragment, {}) : _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { sx: { maxHeight: '350px', paddingTop: 0 }, list: expectedSalesRangeList, listItemProps: { sx: { padding: 0 } }, onSelectItem: function (item) {
|
|
116
119
|
var isOnlyOneItem = !item.sub || item.sub.length === 1;
|
|
117
120
|
if (isOnlyOneItem)
|
|
118
121
|
onSelectItem(item);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
-
export declare const BrandActivitiesValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
-
activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
2
|
+
export declare const BrandActivitiesValidationSchema: (brand: any) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
activities: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
4
4
|
ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
5
5
|
en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
6
6
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
@@ -16,14 +16,14 @@ export declare const BrandActivitiesValidationSchema: yup.ObjectSchema<import("y
|
|
|
16
16
|
ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
17
17
|
en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
18
18
|
}>>[] | undefined>;
|
|
19
|
-
customerLocations: import("yup/lib/array").RequiredArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined>;
|
|
19
|
+
customerLocations: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | import("yup/lib/array").RequiredArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined>;
|
|
20
20
|
expectedCustomers: any;
|
|
21
21
|
expectedSalesRange: any;
|
|
22
22
|
termAndConditionChecked: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
|
|
23
23
|
refundPolicy: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
|
|
24
24
|
transactionPolicy: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
|
|
25
25
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
26
|
-
activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
26
|
+
activities: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
27
27
|
ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
28
28
|
en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
29
29
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
@@ -39,14 +39,14 @@ export declare const BrandActivitiesValidationSchema: yup.ObjectSchema<import("y
|
|
|
39
39
|
ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
40
40
|
en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
41
41
|
}>>[] | undefined>;
|
|
42
|
-
customerLocations: import("yup/lib/array").RequiredArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined>;
|
|
42
|
+
customerLocations: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | import("yup/lib/array").RequiredArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined>;
|
|
43
43
|
expectedCustomers: any;
|
|
44
44
|
expectedSalesRange: any;
|
|
45
45
|
termAndConditionChecked: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
|
|
46
46
|
refundPolicy: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
|
|
47
47
|
transactionPolicy: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
|
|
48
48
|
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
49
|
-
activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
49
|
+
activities: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
50
50
|
ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
51
51
|
en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
52
52
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
@@ -62,7 +62,7 @@ export declare const BrandActivitiesValidationSchema: yup.ObjectSchema<import("y
|
|
|
62
62
|
ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
63
63
|
en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
64
64
|
}>>[] | undefined>;
|
|
65
|
-
customerLocations: import("yup/lib/array").RequiredArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined>;
|
|
65
|
+
customerLocations: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | import("yup/lib/array").RequiredArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined>;
|
|
66
66
|
expectedCustomers: any;
|
|
67
67
|
expectedSalesRange: any;
|
|
68
68
|
termAndConditionChecked: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
|
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
+
import { FieldType } from '../../../../@types';
|
|
2
3
|
var objectElements = {
|
|
3
4
|
id: yup.number(),
|
|
4
5
|
name_ar: yup.string(),
|
|
5
6
|
name_en: yup.string()
|
|
6
7
|
};
|
|
7
|
-
export var BrandActivitiesValidationSchema =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
export var BrandActivitiesValidationSchema = function (brand) {
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
var _d = brand || {}, activities = _d.activities, operations = _d.operations, data_status = _d.data_status;
|
|
11
|
+
var _e = operations || {}, customer_base = _e.customer_base, sales = _e.sales;
|
|
12
|
+
var isActivitiesOptional = !((activities === null || activities === void 0 ? void 0 : activities.length) > 0) && (data_status === null || data_status === void 0 ? void 0 : data_status.activities) === FieldType.NON_EDITABLE;
|
|
13
|
+
var isCustomerLocationsOptional = !(((_a = customer_base === null || customer_base === void 0 ? void 0 : customer_base.locations) === null || _a === void 0 ? void 0 : _a.length) > 0) && ((_b = data_status === null || data_status === void 0 ? void 0 : data_status.customer_base) === null || _b === void 0 ? void 0 : _b.location) === FieldType.NON_EDITABLE;
|
|
14
|
+
var isExpectedSalesRangeOptional = !(sales === null || sales === void 0 ? void 0 : sales.id) && ((_c = data_status === null || data_status === void 0 ? void 0 : data_status.operations) === null || _c === void 0 ? void 0 : _c.sales_range) === FieldType.NON_EDITABLE;
|
|
15
|
+
return yup.object().shape({
|
|
16
|
+
activities: isActivitiesOptional
|
|
17
|
+
? yup.array().optional()
|
|
18
|
+
: yup
|
|
19
|
+
.array()
|
|
20
|
+
.min(1, 'activities_list_alert')
|
|
21
|
+
.of(yup.object().shape({
|
|
22
|
+
ar: yup.string(),
|
|
23
|
+
en: yup.string()
|
|
24
|
+
})),
|
|
25
|
+
customerLocations: isCustomerLocationsOptional ? yup.array().optional() : yup.array().required('please_choose_base'),
|
|
26
|
+
expectedCustomers: yup.object().shape(objectElements).required('select_expected_customers_serve'),
|
|
27
|
+
expectedSalesRange: isExpectedSalesRangeOptional ? yup.object().optional() : yup.object().shape(objectElements).required('select_expected_sales'),
|
|
28
|
+
termAndConditionChecked: yup.boolean().isTrue('check_terms_cond').required('check_terms_cond'),
|
|
29
|
+
refundPolicy: yup.boolean().required().isTrue('refund_policy_error'),
|
|
30
|
+
transactionPolicy: yup.boolean().required().isTrue('transaction_policy_error')
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -35,13 +35,20 @@ var BrandInfo = function (_a) {
|
|
|
35
35
|
var _c = React.useState(false), brandNameChecking = _c[0], setBrandNameChecking = _c[1];
|
|
36
36
|
var dispatch = useAppDispatch();
|
|
37
37
|
var _d = useAppSelector(brandSelector), data = _d.data, loading = _d.loading, error = _d.error;
|
|
38
|
-
var
|
|
38
|
+
var _e = data.brandData, brandName = _e.brandName, segment = _e.segment, teamSize = _e.teamSize, salesChannels = _e.salesChannels, termAndConditionChecked = _e.termAndConditionChecked, selectedBrandItem = _e.selectedBrandItem, responseBody = _e.responseBody;
|
|
39
39
|
var methods = useForm({
|
|
40
|
-
resolver: yupResolver(BrandValidationSchema),
|
|
41
|
-
defaultValues:
|
|
40
|
+
resolver: yupResolver(BrandValidationSchema((responseBody === null || responseBody === void 0 ? void 0 : responseBody.brand) || {})),
|
|
41
|
+
defaultValues: {
|
|
42
|
+
brandName: brandName,
|
|
43
|
+
segment: segment,
|
|
44
|
+
teamSize: teamSize,
|
|
45
|
+
salesChannels: salesChannels,
|
|
46
|
+
termAndConditionChecked: termAndConditionChecked,
|
|
47
|
+
selectedBrandItem: selectedBrandItem
|
|
48
|
+
},
|
|
42
49
|
mode: 'onChange'
|
|
43
50
|
});
|
|
44
|
-
useSetFromDefaultValues(methods, data.brandData);
|
|
51
|
+
useSetFromDefaultValues(methods, data.brandData, true);
|
|
45
52
|
var onSubmit = function (data) {
|
|
46
53
|
dispatch(updateBrand(data));
|
|
47
54
|
};
|
|
@@ -47,25 +47,25 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
};
|
|
48
48
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
49
|
import * as React from 'react';
|
|
50
|
+
import { debounce } from 'lodash-es';
|
|
51
|
+
import axios from 'axios';
|
|
50
52
|
import { useTranslation } from 'react-i18next';
|
|
51
53
|
import { useController, useFormContext } from 'react-hook-form';
|
|
52
54
|
import Box from '@mui/material/Box';
|
|
53
|
-
import axios from 'axios';
|
|
54
55
|
import { styled, alpha } from '@mui/material/styles';
|
|
55
56
|
import InfoIcon from '@mui/icons-material/Info';
|
|
56
57
|
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
|
|
57
|
-
import { ScreenContainer } from '../../../shared/Containers';
|
|
58
58
|
import CircularProgress from '@mui/material/CircularProgress';
|
|
59
|
+
import { FieldType } from '../../../../@types';
|
|
60
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
61
|
+
import Tooltip from '../../../../components/Tooltip';
|
|
62
|
+
import Collapse from '../../../../components/Collapse';
|
|
59
63
|
import Text from '../../../../components/Text';
|
|
60
64
|
import Input from '../../../shared/Input';
|
|
61
65
|
import ClearIcon from '../../../shared/ClearIcon';
|
|
62
|
-
import
|
|
63
|
-
import Collapse from '../../../../components/Collapse';
|
|
64
|
-
import { removeAllOtherThanCharsNumbersAndSpace } from '../../../../utils';
|
|
66
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
65
67
|
import CheckIcon from '../../../shared/CheckIcon';
|
|
66
68
|
import { checkBrandNameAvailability, brandSelector } from '../../../app/brand/brandStore';
|
|
67
|
-
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
68
|
-
import { debounce } from 'lodash-es';
|
|
69
69
|
var LabelContainerStyled = styled(Box)(function (_a) {
|
|
70
70
|
var theme = _a.theme;
|
|
71
71
|
return ({
|
|
@@ -98,16 +98,18 @@ var InfoIconStyled = styled(InfoIcon)(function (_a) {
|
|
|
98
98
|
});
|
|
99
99
|
var cancelToken = null;
|
|
100
100
|
var BrandName = function (_a) {
|
|
101
|
-
var _b;
|
|
101
|
+
var _b, _c;
|
|
102
102
|
var show = _a.show, brandNameChecking = _a.brandNameChecking, fetchingBrandName = _a.fetchingBrandName;
|
|
103
103
|
var dispatch = useAppDispatch();
|
|
104
|
-
var
|
|
104
|
+
var _d = React.useState(false), isHovered = _d[0], setIsHovered = _d[1];
|
|
105
105
|
var t = useTranslation().t;
|
|
106
106
|
var data = useAppSelector(brandSelector).data;
|
|
107
107
|
var control = useFormContext().control;
|
|
108
108
|
var brandControl = useController({ control: control, name: 'brandName' });
|
|
109
109
|
var brandNameValue = brandControl.field.value;
|
|
110
110
|
var error = (_b = brandControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
111
|
+
var brand = (data.verify.responseBody || {}).brand;
|
|
112
|
+
var isNonEditable = ((_c = brand === null || brand === void 0 ? void 0 : brand.data_status) === null || _c === void 0 ? void 0 : _c.name) === FieldType.NON_EDITABLE;
|
|
111
113
|
var checkBrand = debounce(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
112
114
|
var onSuccess;
|
|
113
115
|
return __generator(this, function (_a) {
|
|
@@ -122,8 +124,7 @@ var BrandName = function (_a) {
|
|
|
122
124
|
}); }, 500);
|
|
123
125
|
var handleBrandNameChange = function (_a) {
|
|
124
126
|
var target = _a.target;
|
|
125
|
-
|
|
126
|
-
brandControl.field.onChange(value);
|
|
127
|
+
brandControl.field.onChange(target.value);
|
|
127
128
|
};
|
|
128
129
|
React.useEffect(function () {
|
|
129
130
|
var _a, _b, _c;
|
|
@@ -137,6 +138,6 @@ var BrandName = function (_a) {
|
|
|
137
138
|
var clearBrandName = function () {
|
|
138
139
|
brandControl.field.onChange('');
|
|
139
140
|
};
|
|
140
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('signup_brand_name_label') }), _jsx(Tooltip, __assign({ title: t('brand_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { onChange: handleBrandNameChange, value: brandNameValue || '', placeholder: t('signup_brand_name_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: brandNameChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && brandNameValue ? (_jsx(CheckIcon, {})) : (brandNameValue && _jsx(ClearIcon, { onClick: clearBrandName })) })] })) })));
|
|
141
|
+
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 || '', disabled: isNonEditable, placeholder: t('signup_brand_name_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: brandNameChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && brandNameValue ? (_jsx(CheckIcon, {})) : (brandNameValue && _jsx(ClearIcon, { onClick: clearBrandName })) })] })) })));
|
|
141
142
|
};
|
|
142
143
|
export default React.memo(BrandName);
|
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useController, useFormContext } from 'react-hook-form';
|
|
4
|
+
import { FieldType } from '../../../../@types';
|
|
4
5
|
import { useAppSelector, useAppDispatch } from '../../../../hooks';
|
|
5
|
-
import { brandSelector, clearError } from '../../../app/brand/brandStore';
|
|
6
6
|
import { mapSalesChannel } from '../../../../utils';
|
|
7
|
+
import { brandSelector, clearError } from '../../../app/brand/brandStore';
|
|
7
8
|
import SalesChannel from '../../../shared/SalesChannels';
|
|
8
9
|
var SalesChannels = function (_a) {
|
|
9
|
-
var _b;
|
|
10
|
-
var
|
|
10
|
+
var _b, _c;
|
|
11
|
+
var _d = useFormContext(), control = _d.control, setValue = _d.setValue, getValues = _d.getValues;
|
|
11
12
|
var dispatch = useAppDispatch();
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
13
|
+
var _e = useController({ control: control, name: 'salesChannels' }), fieldState = _e.fieldState, field = _e.field;
|
|
14
|
+
var _f = useAppSelector(brandSelector), data = _f.data, error = _f.error;
|
|
15
|
+
var verify = data.verify, brandData = data.brandData;
|
|
16
|
+
var selectedBrandItem = brandData.selectedBrandItem, defaultSalesChannels = brandData.salesChannels;
|
|
17
|
+
var _g = verify.responseBody || {}, channelList = _g.channel_list, brand = _g.brand;
|
|
18
|
+
var isNonEditable = ((_b = brand === null || brand === void 0 ? void 0 : brand.data_status) === null || _b === void 0 ? void 0 : _b.name) === FieldType.NON_EDITABLE;
|
|
19
|
+
var selectedBrandControl = getValues('selectedBrandItem');
|
|
20
|
+
React.useEffect(function () {
|
|
21
|
+
if (selectedBrandItem.id) {
|
|
22
|
+
setValue('selectedBrandItem', selectedBrandItem);
|
|
23
|
+
var sales = mapSalesChannel(selectedBrandItem.channel_services || []);
|
|
24
|
+
field.onChange(sales);
|
|
25
|
+
}
|
|
26
|
+
}, [selectedBrandItem]);
|
|
16
27
|
React.useEffect(function () {
|
|
17
|
-
|
|
28
|
+
var _a;
|
|
29
|
+
if ((defaultSalesChannels === null || defaultSalesChannels === void 0 ? void 0 : defaultSalesChannels.length) > 0 && ((_a = field === null || field === void 0 ? void 0 : field.value) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
18
30
|
var sales = mapSalesChannel(defaultSalesChannels);
|
|
19
31
|
field.onChange(sales);
|
|
20
32
|
}
|
|
@@ -25,6 +37,6 @@ var SalesChannels = function (_a) {
|
|
|
25
37
|
dispatch(clearError());
|
|
26
38
|
field.onChange(channels);
|
|
27
39
|
};
|
|
28
|
-
return _jsx(SalesChannel, { error: (
|
|
40
|
+
return (_jsx(SalesChannel, { disabled: isNonEditable, error: (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message, list: channelList, selectFirstIconListener: selectedBrandControl === null || selectedBrandControl === void 0 ? void 0 : selectedBrandControl.id, onChange: onChange, defaultValue: selectedSalesChannels }));
|
|
29
41
|
};
|
|
30
42
|
export default SalesChannels;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
-
export declare const BrandValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
-
brandName:
|
|
2
|
+
export declare const BrandValidationSchema: (brand: any) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
4
4
|
segment: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
5
5
|
teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
6
|
-
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
6
|
+
salesChannels: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
7
7
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
8
8
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
9
9
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
@@ -13,10 +13,10 @@ export declare const BrandValidationSchema: yup.ObjectSchema<import("yup/lib/obj
|
|
|
13
13
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
14
14
|
}>>[] | undefined>;
|
|
15
15
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
16
|
-
brandName:
|
|
16
|
+
brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
17
17
|
segment: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
18
18
|
teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
19
|
-
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
19
|
+
salesChannels: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
20
20
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
21
21
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
22
22
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
@@ -26,10 +26,10 @@ export declare const BrandValidationSchema: yup.ObjectSchema<import("yup/lib/obj
|
|
|
26
26
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
27
27
|
}>>[] | undefined>;
|
|
28
28
|
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
29
|
-
brandName:
|
|
29
|
+
brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
30
30
|
segment: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
31
31
|
teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
32
|
-
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
32
|
+
salesChannels: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined> | import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
33
33
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
34
34
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
35
35
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
@@ -7,7 +7,8 @@ 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 {
|
|
10
|
+
import { FieldType } from '../../../../@types';
|
|
11
|
+
import { REGEX_WEBSITE, LINKEDIN_URL, SOCIAL_USERNAME, DIGITS_ONLY, REGEX_ALPHANUMERIC } from '../../../../constants';
|
|
11
12
|
import * as yup from 'yup';
|
|
12
13
|
var validationSalesChannels = function (channels) {
|
|
13
14
|
if (channels === void 0) { channels = []; }
|
|
@@ -69,38 +70,47 @@ var validationSalesChannels = function (channels) {
|
|
|
69
70
|
}
|
|
70
71
|
return true;
|
|
71
72
|
};
|
|
72
|
-
export var BrandValidationSchema =
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
73
|
+
export var BrandValidationSchema = function (brand) {
|
|
74
|
+
var _a = brand || {}, name = _a.name, channel_services = _a.channel_services, data_status = _a.data_status;
|
|
75
|
+
var isNameOptional = !name && (data_status === null || data_status === void 0 ? void 0 : data_status.name) === FieldType.NON_EDITABLE;
|
|
76
|
+
var isSalesChannelsOptional = !channel_services && (data_status === null || data_status === void 0 ? void 0 : data_status.channel_services) === FieldType.NON_EDITABLE;
|
|
77
|
+
return yup.object().shape({
|
|
78
|
+
brandName: isNameOptional
|
|
79
|
+
? yup.string().optional()
|
|
80
|
+
: yup
|
|
81
|
+
.string()
|
|
82
|
+
.test({
|
|
83
|
+
test: function (value) {
|
|
84
|
+
if ((value === null || value === void 0 ? void 0 : value.length) === 0)
|
|
85
|
+
return true;
|
|
86
|
+
if (value && value.length >= 3)
|
|
87
|
+
return true;
|
|
88
|
+
return this.createError({ message: 'enter_brand_name_english_chars_numbers_space' });
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
.required('enter_brand_name_english_chars_numbers_space'),
|
|
92
|
+
segment: yup.object().required('alert_choose_segment'),
|
|
93
|
+
teamSize: yup.object().required('alert_choose_teamSize'),
|
|
94
|
+
salesChannels: isSalesChannelsOptional
|
|
95
|
+
? yup.array().optional()
|
|
96
|
+
: yup
|
|
97
|
+
.array()
|
|
98
|
+
.min(1, 'choose_atleast_one_channel')
|
|
99
|
+
.of(yup.object().shape({
|
|
100
|
+
id: yup.string().required('choose_atleast_one_channel')
|
|
101
|
+
}))
|
|
102
|
+
.test({
|
|
103
|
+
test: function (value) {
|
|
104
|
+
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
105
|
+
if (length === 0)
|
|
106
|
+
return true;
|
|
107
|
+
var channels = __spreadArray([], (value || []), true);
|
|
108
|
+
var result = validationSalesChannels(channels);
|
|
109
|
+
if (result === true)
|
|
110
|
+
return true;
|
|
111
|
+
return this.createError({ message: result });
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
.required('choose_atleast_one_channel')
|
|
115
|
+
});
|
|
116
|
+
};
|