@tap-payments/auth-jsconnect 2.1.23-test → 2.1.25-test
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 +48 -1
- package/build/@types/app.js +12 -0
- package/build/@types/form.d.ts +24 -8
- package/build/api/axios.js +2 -2
- package/build/api/data.d.ts +8 -0
- package/build/api/data.js +16 -0
- package/build/api/entity.d.ts +28 -1
- package/build/api/entity.js +26 -1
- package/build/api/index.d.ts +13 -3
- package/build/api/index.js +2 -2
- package/build/api/individual.d.ts +4 -0
- package/build/api/location.d.ts +5 -0
- package/build/api/location.js +19 -0
- package/build/app/rootReducer.d.ts +1 -0
- package/build/app/rootReducer.js +3 -1
- package/build/app/settings.js +1 -1
- package/build/app/store.d.ts +2 -0
- package/build/assets/locales/ar.json +21 -1
- package/build/assets/locales/en.json +21 -1
- package/build/components/SimpleList/SimpleList.d.ts +2 -1
- package/build/components/SimpleList/SimpleList.js +22 -10
- package/build/constants/api.d.ts +3 -0
- package/build/constants/api.js +7 -1
- package/build/constants/app.d.ts +7 -1
- package/build/constants/app.js +51 -8
- package/build/constants/validation.d.ts +1 -0
- package/build/constants/validation.js +1 -0
- package/build/features/app/brand/brandStore.d.ts +97 -0
- package/build/features/app/brand/brandStore.js +618 -0
- package/build/features/app/entity/entityStore.d.ts +11 -23
- package/build/features/app/entity/entityStore.js +212 -295
- package/build/features/bank/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +3 -2
- package/build/features/brand/Brand.d.ts +7 -0
- package/build/features/brand/Brand.js +69 -0
- package/build/features/brand/index.d.ts +1 -0
- package/build/features/brand/index.js +1 -0
- package/build/features/{entity/screens/Customers/CustomerLocations.d.ts → brand/screens/BrandActivities/ActivitiesList.d.ts} +34 -61
- package/build/features/{entity/screens/EntityInfoConfirm → brand/screens/BrandActivities}/ActivitiesList.js +59 -40
- package/build/features/brand/screens/BrandActivities/BrandActivities.d.ts +5 -0
- package/build/features/brand/screens/BrandActivities/BrandActivities.js +72 -0
- package/build/features/brand/screens/BrandActivities/CustomerBase.d.ts +82 -0
- package/build/features/{entity/screens/Customers/CustomerLocations.js → brand/screens/BrandActivities/CustomerBase.js} +8 -35
- package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/ExpectedCustomers.d.ts +0 -0
- package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/ExpectedCustomers.js +6 -6
- package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/ExpectedSalesRange.d.ts +0 -0
- package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/ExpectedSalesRange.js +6 -6
- package/build/features/brand/screens/BrandActivities/OperationStartDate.d.ts +20 -0
- package/build/features/brand/screens/BrandActivities/OperationStartDate.js +45 -0
- package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/RefundPolicy.d.ts +0 -0
- package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/RefundPolicy.js +2 -2
- package/build/features/brand/screens/BrandActivities/TAC.d.ts +6 -0
- package/build/features/brand/screens/BrandActivities/TAC.js +87 -0
- package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/TransactionPolicy.d.ts +0 -0
- package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/TransactionPolicy.js +0 -0
- package/build/features/brand/screens/BrandActivities/index.d.ts +2 -0
- package/build/features/brand/screens/BrandActivities/index.js +2 -0
- package/build/features/brand/screens/BrandActivities/validation.d.ts +71 -0
- package/build/features/{entity/screens/Customers → brand/screens/BrandActivities}/validation.js +9 -1
- package/build/features/brand/screens/BrandInfo/BrandInfo.d.ts +5 -0
- package/build/features/brand/screens/BrandInfo/BrandInfo.js +72 -0
- package/build/features/brand/screens/BrandInfo/BrandName.d.ts +8 -0
- package/build/features/brand/screens/BrandInfo/BrandName.js +142 -0
- package/build/features/brand/screens/BrandInfo/SalesChannels.d.ts +5 -0
- package/build/features/brand/screens/BrandInfo/SalesChannels.js +30 -0
- package/build/features/brand/screens/BrandInfo/Segments.d.ts +8 -0
- package/build/features/brand/screens/BrandInfo/Segments.js +83 -0
- package/build/features/brand/screens/BrandInfo/TeamSize.d.ts +8 -0
- package/build/features/brand/screens/BrandInfo/TeamSize.js +83 -0
- package/build/features/brand/screens/BrandInfo/index.d.ts +2 -0
- package/build/features/brand/screens/BrandInfo/index.js +2 -0
- package/build/features/brand/screens/BrandInfo/validation.d.ts +41 -0
- package/build/features/brand/screens/BrandInfo/validation.js +106 -0
- package/build/features/brand/screens/ResetPasswordSuccess/ResetPasswordSuccess.d.ts +5 -0
- package/build/features/brand/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +9 -0
- package/build/features/brand/screens/ResetPasswordSuccess/index.d.ts +3 -0
- package/build/features/brand/screens/ResetPasswordSuccess/index.js +2 -0
- package/build/features/brand/screens/Success/Success.d.ts +5 -0
- package/build/features/brand/screens/Success/Success.js +20 -0
- package/build/features/brand/screens/Success/index.d.ts +3 -0
- package/build/features/brand/screens/Success/index.js +2 -0
- package/build/features/brand/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.d.ts +3 -0
- package/build/features/brand/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +117 -0
- package/build/features/brand/screens/SuccessWithFlowButtons/index.d.ts +2 -0
- package/build/features/brand/screens/SuccessWithFlowButtons/index.js +2 -0
- package/build/features/brand/screens/Verify/OTPInput.d.ts +7 -0
- package/build/features/brand/screens/Verify/OTPInput.js +47 -0
- package/build/features/brand/screens/Verify/Verify.d.ts +5 -0
- package/build/features/brand/screens/Verify/Verify.js +91 -0
- package/build/features/brand/screens/Verify/index.d.ts +2 -0
- package/build/features/brand/screens/Verify/index.js +2 -0
- package/build/features/brand/screens/Verify/validation.d.ts +8 -0
- package/build/features/brand/screens/Verify/validation.js +4 -0
- package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +4 -2
- package/build/features/connect/screens/Merchant/validation.js +2 -2
- package/build/features/entity/screens/EntityCapital/ActivityList.d.ts +90 -0
- package/build/features/entity/screens/EntityCapital/ActivityList.js +178 -0
- package/build/features/entity/screens/EntityCapital/CapitalPaid.d.ts +5 -0
- package/build/features/entity/screens/EntityCapital/CapitalPaid.js +47 -0
- package/build/features/entity/screens/EntityCapital/CapitalShareCount.d.ts +5 -0
- package/build/features/entity/screens/EntityCapital/CapitalShareCount.js +42 -0
- package/build/features/entity/screens/EntityCapital/CapitalShareValue.d.ts +5 -0
- package/build/features/entity/screens/EntityCapital/CapitalShareValue.js +47 -0
- package/build/features/entity/screens/EntityCapital/EntityCapital.d.ts +5 -0
- package/build/features/entity/screens/EntityCapital/EntityCapital.js +75 -0
- package/build/features/entity/screens/EntityCapital/index.d.ts +2 -0
- package/build/features/entity/screens/EntityCapital/index.js +2 -0
- package/build/features/entity/screens/EntityCapital/validation.d.ts +62 -0
- package/build/features/entity/screens/EntityCapital/validation.js +25 -0
- package/build/features/entity/screens/EntityName/EntityName.d.ts +5 -0
- package/build/features/entity/screens/EntityName/EntityName.js +87 -0
- package/build/features/entity/screens/EntityName/EntityTypeList.d.ts +90 -0
- package/build/features/entity/screens/EntityName/EntityTypeList.js +151 -0
- package/build/features/entity/screens/EntityName/ExpiryDate.d.ts +19 -0
- package/build/features/entity/screens/EntityName/ExpiryDate.js +46 -0
- package/build/features/entity/screens/EntityName/IssuingDate.d.ts +19 -0
- package/build/features/entity/screens/EntityName/IssuingDate.js +46 -0
- package/build/features/entity/screens/EntityName/LegalName.d.ts +5 -0
- package/build/features/entity/screens/EntityName/LegalName.js +48 -0
- package/build/features/entity/screens/{EntityInfoConfirm → EntityName}/LicenseNumber.d.ts +0 -0
- package/build/features/entity/screens/{EntityInfoConfirm → EntityName}/LicenseNumber.js +12 -18
- package/build/features/entity/screens/EntityName/UnifiedNumber.d.ts +6 -0
- package/build/features/entity/screens/EntityName/UnifiedNumber.js +43 -0
- package/build/features/entity/screens/EntityName/index.d.ts +2 -0
- package/build/features/entity/screens/EntityName/index.js +2 -0
- package/build/features/entity/screens/EntityName/validation.d.ts +48 -0
- package/build/features/entity/screens/EntityName/validation.js +112 -0
- package/build/features/featuresScreens.d.ts +1 -0
- package/build/features/featuresScreens.js +35 -6
- package/build/features/individual/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +4 -2
- package/build/features/password/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +4 -2
- package/build/features/shared/AcceptancePayouts/AcceptancePayouts.js +1 -1
- package/build/features/shared/Address/Address.d.ts +11 -0
- package/build/features/shared/Address/Address.js +63 -0
- package/build/features/shared/Address/CountryList.d.ts +72 -0
- package/build/features/shared/Address/CountryList.js +89 -0
- package/build/features/{entity/screens/EntityInfoConfirm/ActivitiesList.d.ts → shared/Address/InputSelect.d.ts} +27 -11
- package/build/features/shared/Address/InputSelect.js +172 -0
- package/build/features/shared/Address/InputText.d.ts +11 -0
- package/build/features/shared/Address/InputText.js +12 -0
- package/build/features/shared/Address/index.d.ts +2 -0
- package/build/features/shared/Address/index.js +2 -0
- package/build/features/shared/Input/Input.d.ts +7 -5
- package/build/features/shared/Input/Input.js +2 -2
- package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +4 -2
- package/build/hooks/useAppDispatch.d.ts +1 -0
- package/build/index.d.ts +3 -2
- package/build/index.js +4 -1
- package/package.json +1 -1
- package/build/api/ip.d.ts +0 -4
- package/build/api/ip.js +0 -12
- package/build/features/entity/screens/Customers/Customers.d.ts +0 -5
- package/build/features/entity/screens/Customers/Customers.js +0 -90
- package/build/features/entity/screens/Customers/index.d.ts +0 -3
- package/build/features/entity/screens/Customers/index.js +0 -2
- package/build/features/entity/screens/Customers/validation.d.ts +0 -20
- package/build/features/entity/screens/EntityInfoConfirm/Article.d.ts +0 -3
- package/build/features/entity/screens/EntityInfoConfirm/Article.js +0 -76
- package/build/features/entity/screens/EntityInfoConfirm/EntityInfo.d.ts +0 -5
- package/build/features/entity/screens/EntityInfoConfirm/EntityInfo.js +0 -84
- package/build/features/entity/screens/EntityInfoConfirm/LicenseName.d.ts +0 -5
- package/build/features/entity/screens/EntityInfoConfirm/LicenseName.js +0 -32
- package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.d.ts +0 -6
- package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.js +0 -33
- package/build/features/entity/screens/EntityInfoConfirm/index.d.ts +0 -2
- package/build/features/entity/screens/EntityInfoConfirm/index.js +0 -2
- package/build/features/entity/screens/EntityInfoConfirm/validation.d.ts +0 -141
- package/build/features/entity/screens/EntityInfoConfirm/validation.js +0 -83
|
@@ -13,33 +13,28 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import * as React from 'react';
|
|
14
14
|
import { useTranslation } from 'react-i18next';
|
|
15
15
|
import { useController, useFormContext } from 'react-hook-form';
|
|
16
|
+
import { useAppSelector } from '../../../../hooks';
|
|
17
|
+
import { BusinessType, FieldType } from '../../../../@types';
|
|
18
|
+
import { isSA, removeAllOtherThanCharsAndNumber } from '../../../../utils';
|
|
19
|
+
import { settingsSelector } from '../../../../app/settings';
|
|
20
|
+
import { CR_NUMBER_LENGTH, FL_NUMBER_ENTITY_LENGTH, KW_MAX_LICENSE_LENGTH, KW_MIN_LICENSE_LENGTH } from '../../../../constants';
|
|
16
21
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
17
22
|
import Input from '../../../shared/Input';
|
|
18
|
-
import { useAppSelector } from '../../../../hooks';
|
|
19
23
|
import { entitySelector } from '../../../app/entity/entityStore';
|
|
20
|
-
import { isSA, removeAllOtherThanCharsAndNumber } from '../../../../utils';
|
|
21
|
-
import { BusinessType } from '../../../../@types';
|
|
22
|
-
import { CR_NUMBER_LENGTH, FL_NUMBER_LENGTH, KW_MAX_LICENSE_LENGTH, KW_MIN_LICENSE_LENGTH } from '../../../../constants';
|
|
23
24
|
import Collapse from '../../../../components/Collapse';
|
|
24
|
-
import { settingsSelector } from '../../../../app/settings';
|
|
25
25
|
var LicenseNumber = function (_a) {
|
|
26
26
|
var _b, _c, _d, _e;
|
|
27
27
|
var show = _a.show;
|
|
28
28
|
var t = useTranslation().t;
|
|
29
29
|
var data = useAppSelector(entitySelector).data;
|
|
30
30
|
var settingsData = useAppSelector(settingsSelector).data;
|
|
31
|
-
var
|
|
31
|
+
var control = useFormContext().control;
|
|
32
32
|
var entity = (data.verify.responseBody || {}).entity;
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var resLicenseNumber = (_d = entity === null || entity === void 0 ? void 0 : entity.license) === null || _d === void 0 ? void 0 : _d.number;
|
|
38
|
-
var licenseNumber = data.entityData.licenseNumber;
|
|
33
|
+
var type = data.entityNameData.licenseType;
|
|
34
|
+
var number = (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.number;
|
|
35
|
+
var disabled = ((_d = (_c = entity === null || entity === void 0 ? void 0 : entity.data_status) === null || _c === void 0 ? void 0 : _c.license) === null || _d === void 0 ? void 0 : _d.number) === FieldType.NON_EDITABLE;
|
|
36
|
+
var hide = !number && disabled;
|
|
39
37
|
var isSACountry = React.useMemo(function () { return isSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
40
|
-
React.useEffect(function () {
|
|
41
|
-
setValue('licenseNumber', licenseNumber, { shouldValidate: true });
|
|
42
|
-
}, [licenseNumber]);
|
|
43
38
|
var handleChange = function (_a) {
|
|
44
39
|
var target = _a.target;
|
|
45
40
|
var value = removeAllOtherThanCharsAndNumber(target.value);
|
|
@@ -49,9 +44,8 @@ var LicenseNumber = function (_a) {
|
|
|
49
44
|
var licenseNumberValue = licenseNumberControl.field.value;
|
|
50
45
|
var error = (_e = licenseNumberControl.fieldState.error) === null || _e === void 0 ? void 0 : _e.message;
|
|
51
46
|
var isCR = type === BusinessType.CR;
|
|
52
|
-
var length = !isSACountry ? KW_MAX_LICENSE_LENGTH : isCR ? CR_NUMBER_LENGTH :
|
|
47
|
+
var length = !isSACountry ? KW_MAX_LICENSE_LENGTH : isCR ? CR_NUMBER_LENGTH : FL_NUMBER_ENTITY_LENGTH;
|
|
53
48
|
var minLength = !isSACountry ? KW_MIN_LICENSE_LENGTH : length;
|
|
54
|
-
|
|
55
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, __assign({ sx: { mt: 2.5 } }, { children: _jsx(Input, { label: t('license_number_label'), onChange: handleChange, disabled: disabled, inputProps: { maxLength: length }, value: licenseNumberValue, sx: { '& .MuiInputBase-input': { cursor: 'auto' } }, placeholder: isCR ? t('cr_number_hint') : t('fl_number_hint'), warningType: 'alert', warningMessage: error && t(error, { length: minLength }) }) })) })));
|
|
49
|
+
return (_jsx(Collapse, __assign({ in: show && !hide }, { children: _jsx(ScreenContainer, __assign({ sx: { mt: 2.5 } }, { children: _jsx(Input, { label: t('license_number_label'), onChange: handleChange, disabled: disabled, inputProps: { maxLength: length }, value: licenseNumberValue, sx: { '& .MuiInputBase-input': { cursor: 'auto' } }, placeholder: isCR ? t('cr_number_hint') : t('fl_number_hint'), warningType: 'alert', warningMessage: error && t(error, { length: minLength }) }) })) })));
|
|
56
50
|
};
|
|
57
51
|
export default React.memo(LicenseNumber);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { useTranslation } from 'react-i18next';
|
|
15
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
16
|
+
import { useAppSelector } from '../../../../hooks';
|
|
17
|
+
import { FieldType } from '../../../../@types';
|
|
18
|
+
import { removeAllOtherThanCharsAndNumber } from '../../../../utils';
|
|
19
|
+
import Collapse from '../../../../components/Collapse';
|
|
20
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
21
|
+
import Input from '../../../shared/Input';
|
|
22
|
+
import { entitySelector } from '../../../app/entity/entityStore';
|
|
23
|
+
var UnifiedNumber = function (_a) {
|
|
24
|
+
var _b, _c, _d, _e, _f;
|
|
25
|
+
var show = _a.show;
|
|
26
|
+
var t = useTranslation().t;
|
|
27
|
+
var data = useAppSelector(entitySelector).data;
|
|
28
|
+
var control = useFormContext().control;
|
|
29
|
+
var entity = (data.verify.responseBody || {}).entity;
|
|
30
|
+
var number = (_c = (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.additional_info) === null || _c === void 0 ? void 0 : _c.unified_number;
|
|
31
|
+
var disabled = ((_e = (_d = entity === null || entity === void 0 ? void 0 : entity.data_status) === null || _d === void 0 ? void 0 : _d.license) === null || _e === void 0 ? void 0 : _e.additional_info) === FieldType.NON_EDITABLE;
|
|
32
|
+
var hide = !number && disabled;
|
|
33
|
+
var handleChange = function (_a) {
|
|
34
|
+
var target = _a.target;
|
|
35
|
+
var value = removeAllOtherThanCharsAndNumber(target.value);
|
|
36
|
+
unifiedNumberControl.field.onChange(value);
|
|
37
|
+
};
|
|
38
|
+
var unifiedNumberControl = useController({ control: control, name: 'unifiedNumber' });
|
|
39
|
+
var unifiedNumberValue = unifiedNumberControl.field.value;
|
|
40
|
+
var error = (_f = unifiedNumberControl.fieldState.error) === null || _f === void 0 ? void 0 : _f.message;
|
|
41
|
+
return (_jsx(Collapse, __assign({ in: show && !hide }, { children: _jsx(ScreenContainer, __assign({ sx: { mt: 2.5 } }, { children: _jsx(Input, { label: t('unified_number_label'), onChange: handleChange, disabled: disabled, value: unifiedNumberValue, sx: { '& .MuiInputBase-input': { cursor: 'auto' } }, placeholder: t('unified_number_hint'), warningType: 'alert', warningMessage: error && t(error) }) })) })));
|
|
42
|
+
};
|
|
43
|
+
export default React.memo(UnifiedNumber);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as yup from 'yup';
|
|
2
|
+
export declare const EntityNameValidationSchema: (entity: any) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
legalName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
4
|
+
licenseType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
5
|
+
entityType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
6
|
+
licenseNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
7
|
+
unifiedNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
8
|
+
issuingDate: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
9
|
+
expiryDate: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
10
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
11
|
+
legalName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
12
|
+
licenseType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
13
|
+
entityType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
14
|
+
licenseNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
15
|
+
unifiedNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
16
|
+
issuingDate: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
17
|
+
expiryDate: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
18
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
19
|
+
legalName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
20
|
+
licenseType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
21
|
+
entityType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
22
|
+
licenseNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
23
|
+
unifiedNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
24
|
+
issuingDate: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
25
|
+
expiryDate: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
26
|
+
}>>>;
|
|
27
|
+
export declare const EntityNameKWValidationSchema: (entity: any) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
28
|
+
legalName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
29
|
+
licenseType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
30
|
+
entityType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
31
|
+
licenseNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
32
|
+
issuingDate: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
33
|
+
expiryDate: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
34
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
35
|
+
legalName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
36
|
+
licenseType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
37
|
+
entityType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
38
|
+
licenseNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
39
|
+
issuingDate: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
40
|
+
expiryDate: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
41
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
42
|
+
legalName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
43
|
+
licenseType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
44
|
+
entityType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
45
|
+
licenseNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
46
|
+
issuingDate: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
47
|
+
expiryDate: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
48
|
+
}>>>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as yup from 'yup';
|
|
2
|
+
import { BusinessType, FieldType } from '../../../../@types';
|
|
3
|
+
import { KW_MIN_LICENSE_LENGTH, CR_MIN_LICENSE_LENGTH, FL_MIN_LICENSE_LENGTH } from '../../../../constants';
|
|
4
|
+
export var EntityNameValidationSchema = function (entity) {
|
|
5
|
+
var _a, _b, _c, _d, _e;
|
|
6
|
+
var _f = entity || {}, legal_name = _f.legal_name, data_status = _f.data_status, license = _f.license;
|
|
7
|
+
var isLegalNameOptional = !((legal_name === null || legal_name === void 0 ? void 0 : legal_name.ar) || (legal_name === null || legal_name === void 0 ? void 0 : legal_name.en)) && (data_status === null || data_status === void 0 ? void 0 : data_status.legal_name) === FieldType.NON_EDITABLE;
|
|
8
|
+
var isEntityTypeOptional = !(license === null || license === void 0 ? void 0 : license.type) && (data_status === null || data_status === void 0 ? void 0 : data_status.type) === FieldType.NON_EDITABLE;
|
|
9
|
+
var isLicenseNumberOptional = !(license === null || license === void 0 ? void 0 : license.number) && ((_a = data_status === null || data_status === void 0 ? void 0 : data_status.license) === null || _a === void 0 ? void 0 : _a.number) === FieldType.NON_EDITABLE;
|
|
10
|
+
var isUnifiedNumberOptional = !((_b = license === null || license === void 0 ? void 0 : license.additional_info) === null || _b === void 0 ? void 0 : _b.unified_number) && ((_c = data_status === null || data_status === void 0 ? void 0 : data_status.license) === null || _c === void 0 ? void 0 : _c.additional_info) === FieldType.NON_EDITABLE;
|
|
11
|
+
var isIssuingDateOptional = !(license === null || license === void 0 ? void 0 : license.issuing_date) && ((_d = data_status === null || data_status === void 0 ? void 0 : data_status.license) === null || _d === void 0 ? void 0 : _d.issuing_date) === FieldType.NON_EDITABLE;
|
|
12
|
+
var isExpiryDateOptional = !(license === null || license === void 0 ? void 0 : license.expiry_date) && ((_e = data_status === null || data_status === void 0 ? void 0 : data_status.license) === null || _e === void 0 ? void 0 : _e.expiry_date) === FieldType.NON_EDITABLE;
|
|
13
|
+
return yup.object().shape({
|
|
14
|
+
legalName: isLegalNameOptional
|
|
15
|
+
? yup.string().optional()
|
|
16
|
+
: yup
|
|
17
|
+
.string()
|
|
18
|
+
.required('')
|
|
19
|
+
.test({
|
|
20
|
+
test: function (value) {
|
|
21
|
+
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
22
|
+
if (length === 0)
|
|
23
|
+
return true;
|
|
24
|
+
return length >= 3 ? true : this.createError({ message: 'enter_legal_name_min_three_chars' });
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
27
|
+
licenseType: yup.string().optional(),
|
|
28
|
+
entityType: isEntityTypeOptional ? yup.string().optional() : yup.string().required('entity_type_required'),
|
|
29
|
+
licenseNumber: isLicenseNumberOptional
|
|
30
|
+
? yup.string().optional()
|
|
31
|
+
: yup
|
|
32
|
+
.string()
|
|
33
|
+
.test({
|
|
34
|
+
test: function (value) {
|
|
35
|
+
var type = this.parent.licenseType;
|
|
36
|
+
var isCR = type === BusinessType.CR;
|
|
37
|
+
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
38
|
+
if (length === 0)
|
|
39
|
+
return true;
|
|
40
|
+
if (isCR) {
|
|
41
|
+
return length > CR_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'cr_max_length' });
|
|
42
|
+
}
|
|
43
|
+
return length > FL_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'fl_max_length' });
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
.required(''),
|
|
47
|
+
unifiedNumber: isUnifiedNumberOptional
|
|
48
|
+
? yup.string().optional()
|
|
49
|
+
: yup
|
|
50
|
+
.string()
|
|
51
|
+
.when('licenseType', function (licenseType) {
|
|
52
|
+
var isCR = licenseType === BusinessType.CR;
|
|
53
|
+
if (isCR) {
|
|
54
|
+
return yup.string().required('unified_number_required');
|
|
55
|
+
}
|
|
56
|
+
return yup.string().optional();
|
|
57
|
+
})
|
|
58
|
+
.required(''),
|
|
59
|
+
issuingDate: isIssuingDateOptional ? yup.string().optional() : yup.string().required('choose_any_issuing_date'),
|
|
60
|
+
expiryDate: isExpiryDateOptional ? yup.string().optional() : yup.string().required('choose_any_expiry_date')
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
export var EntityNameKWValidationSchema = function (entity) {
|
|
64
|
+
var _a, _b, _c;
|
|
65
|
+
var _d = entity || {}, legal_name = _d.legal_name, data_status = _d.data_status, license = _d.license;
|
|
66
|
+
var isLegalNameOptional = !((legal_name === null || legal_name === void 0 ? void 0 : legal_name.ar) || (legal_name === null || legal_name === void 0 ? void 0 : legal_name.en)) && (data_status === null || data_status === void 0 ? void 0 : data_status.legal_name) === FieldType.NON_EDITABLE;
|
|
67
|
+
var isEntityTypeOptional = !(license === null || license === void 0 ? void 0 : license.type) && (data_status === null || data_status === void 0 ? void 0 : data_status.type) === FieldType.NON_EDITABLE;
|
|
68
|
+
var isLicenseNumberOptional = !(license === null || license === void 0 ? void 0 : license.number) && ((_a = data_status === null || data_status === void 0 ? void 0 : data_status.license) === null || _a === void 0 ? void 0 : _a.number) === FieldType.NON_EDITABLE;
|
|
69
|
+
var isIssuingDateOptional = !(license === null || license === void 0 ? void 0 : license.issuing_date) && ((_b = data_status === null || data_status === void 0 ? void 0 : data_status.license) === null || _b === void 0 ? void 0 : _b.issuing_date) === FieldType.NON_EDITABLE;
|
|
70
|
+
var isExpiryDateOptional = !(license === null || license === void 0 ? void 0 : license.expiry_date) && ((_c = data_status === null || data_status === void 0 ? void 0 : data_status.license) === null || _c === void 0 ? void 0 : _c.expiry_date) === FieldType.NON_EDITABLE;
|
|
71
|
+
return yup.object().shape({
|
|
72
|
+
legalName: isLegalNameOptional
|
|
73
|
+
? yup.string().optional()
|
|
74
|
+
: yup
|
|
75
|
+
.string()
|
|
76
|
+
.required('')
|
|
77
|
+
.test({
|
|
78
|
+
test: function (value) {
|
|
79
|
+
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
80
|
+
if (length === 0)
|
|
81
|
+
return true;
|
|
82
|
+
return length >= 3 ? true : this.createError({ message: 'enter_legal_name_min_three_chars' });
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
licenseType: yup.string().optional(),
|
|
86
|
+
entityType: isEntityTypeOptional ? yup.string().optional() : yup.string().required('entity_type_required'),
|
|
87
|
+
licenseNumber: isLicenseNumberOptional
|
|
88
|
+
? yup.string().optional()
|
|
89
|
+
: yup
|
|
90
|
+
.string()
|
|
91
|
+
.when('licenseType', function (licenseType) {
|
|
92
|
+
var isCR = licenseType === BusinessType.CR;
|
|
93
|
+
if (!isCR) {
|
|
94
|
+
return yup.string().optional();
|
|
95
|
+
}
|
|
96
|
+
return yup
|
|
97
|
+
.string()
|
|
98
|
+
.required('')
|
|
99
|
+
.test({
|
|
100
|
+
test: function (value) {
|
|
101
|
+
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
102
|
+
if (length === 0)
|
|
103
|
+
return true;
|
|
104
|
+
return length >= KW_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'cr_kw_max_length' });
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
})
|
|
108
|
+
.required(''),
|
|
109
|
+
issuingDate: isIssuingDateOptional ? yup.string().optional() : yup.string().required('choose_any_issuing_date'),
|
|
110
|
+
expiryDate: isExpiryDateOptional ? yup.string().optional() : yup.string().required('choose_any_expiry_date')
|
|
111
|
+
});
|
|
112
|
+
};
|
|
@@ -8,3 +8,4 @@ export declare const taxFeatureScreens: Array<FeatureScreenStep>;
|
|
|
8
8
|
export declare const signInFeatureScreens: Array<FeatureScreenStep>;
|
|
9
9
|
export declare const entityFeatureScreens: Array<FeatureScreenStep>;
|
|
10
10
|
export declare const authFeatureScreens: Array<FeatureScreenStep>;
|
|
11
|
+
export declare const brandFeatureScreens: Array<FeatureScreenStep>;
|
|
@@ -43,11 +43,17 @@ import SignInEmailPage from './signIn/screens/Email';
|
|
|
43
43
|
import SignInOTPPage from './signIn/screens/OTP';
|
|
44
44
|
import SignInPasswordPage from './signIn/screens/Password';
|
|
45
45
|
import EntityVerifyPage from './entity/screens/Verify';
|
|
46
|
-
import
|
|
47
|
-
import
|
|
46
|
+
import EntityNamePage from './entity/screens/EntityName';
|
|
47
|
+
import EntityCapitalPage from './entity/screens/EntityCapital';
|
|
48
48
|
import EntitySuccessPage from './entity/screens/Success';
|
|
49
49
|
import EntitySuccessWithFlowPage from './entity/screens/SuccessWithFlowButtons';
|
|
50
50
|
import EntityResetPasswordSuccessPage from './entity/screens/ResetPasswordSuccess';
|
|
51
|
+
import BrandVerifyPage from './brand/screens/Verify';
|
|
52
|
+
import BrandInfoPage from './brand/screens/BrandInfo';
|
|
53
|
+
import BrandActivitiesPage from './brand/screens/BrandActivities';
|
|
54
|
+
import BrandSuccessPage from './brand/screens/Success';
|
|
55
|
+
import BrandSuccessWithFlowPage from './brand/screens/SuccessWithFlowButtons';
|
|
56
|
+
import BrandResetPasswordSuccessPage from './brand/screens/ResetPasswordSuccess';
|
|
51
57
|
import AuthNIDPage from './auth/screens/NID';
|
|
52
58
|
import AuthVerifyPage from './auth/screens/OTP';
|
|
53
59
|
export var connectFeatureScreens = [
|
|
@@ -225,12 +231,12 @@ export var entityFeatureScreens = [
|
|
|
225
231
|
element: EntityVerifyPage
|
|
226
232
|
},
|
|
227
233
|
{
|
|
228
|
-
name: '
|
|
229
|
-
element:
|
|
234
|
+
name: 'ENTITY_NAME_STEP',
|
|
235
|
+
element: EntityNamePage
|
|
230
236
|
},
|
|
231
237
|
{
|
|
232
|
-
name: '
|
|
233
|
-
element:
|
|
238
|
+
name: 'ENTITY_CAPITAL_STEP',
|
|
239
|
+
element: EntityCapitalPage
|
|
234
240
|
},
|
|
235
241
|
{
|
|
236
242
|
name: 'ENTITY_DETAILS_SUCCESS_STEP',
|
|
@@ -252,3 +258,26 @@ export var authFeatureScreens = [
|
|
|
252
258
|
element: AuthVerifyPage
|
|
253
259
|
}
|
|
254
260
|
];
|
|
261
|
+
export var brandFeatureScreens = [
|
|
262
|
+
{
|
|
263
|
+
name: 'BRAND_VERIFY_STEP',
|
|
264
|
+
element: BrandVerifyPage
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: 'BRAND_INFO_STEP',
|
|
268
|
+
element: BrandInfoPage
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: 'BRAND_ACTIVITIES_STEP',
|
|
272
|
+
element: BrandActivitiesPage
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
name: 'BRAND_DETAILS_SUCCESS_STEP',
|
|
276
|
+
element: BrandSuccessPage
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: 'BRAND_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
|
|
280
|
+
element: BrandSuccessWithFlowPage
|
|
281
|
+
},
|
|
282
|
+
{ name: 'BRAND_RESET_PASSWORD_SUCCESS', element: BrandResetPasswordSuccessPage }
|
|
283
|
+
];
|
|
@@ -16,7 +16,7 @@ import { styled } from '@mui/material/styles';
|
|
|
16
16
|
import { FlowsButtons } from '../../../shared/Button';
|
|
17
17
|
import { ICONS_NAMES, PASSWORD_OPERATION_TYPE } from '../../../../constants';
|
|
18
18
|
import { useAppSelector, useLanguage } from '../../../../hooks';
|
|
19
|
-
import { concatenateObjectValues, getResetFlowUrl, shortenString, showLastFour } from '../../../../utils';
|
|
19
|
+
import { concatenateObjectValues, getResetFlowUrl, shortenBrand, shortenString, showLastFour } from '../../../../utils';
|
|
20
20
|
import { individualSelector } from '../../../app/individual/individualStore';
|
|
21
21
|
import Box from '@mui/material/Box';
|
|
22
22
|
import Text from '../../../../components/Text';
|
|
@@ -80,6 +80,7 @@ var SuccessWithFlowButtons = function () {
|
|
|
80
80
|
var title = t("".concat(name, "_flow_").concat(type), {
|
|
81
81
|
individual_name: username.toLowerCase() + maskedId,
|
|
82
82
|
business_type: entityLegalName,
|
|
83
|
+
brand: brandName,
|
|
83
84
|
license_number: licenseNumber ? t('masking_symbols') + showLastFour(licenseNumber) : '',
|
|
84
85
|
bank_name: bankName,
|
|
85
86
|
iban: iban ? t('masking_symbols') + iban : '',
|
|
@@ -109,7 +110,8 @@ var SuccessWithFlowButtons = function () {
|
|
|
109
110
|
return (_jsxs(ContainerStyled, { children: [_jsxs(TitleStyled, { children: [t('account_details'), " "] }), _jsx(AcceptancePayouts, { showAcceptance: isAcceptance, showPayout: isPayout }), _jsx(ButtonGroupStyled, { children: _jsx(FlowsButtons, { buttons: buttons, data: {
|
|
110
111
|
flowName: data.flowName,
|
|
111
112
|
email: email,
|
|
112
|
-
emailUrl: url
|
|
113
|
+
emailUrl: url,
|
|
114
|
+
brandName: shortenBrand(brandName)
|
|
113
115
|
} }) })] }));
|
|
114
116
|
};
|
|
115
117
|
export default memo(SuccessWithFlowButtons);
|
|
@@ -16,7 +16,7 @@ import { styled } from '@mui/material/styles';
|
|
|
16
16
|
import { FlowsButtons } from '../../../shared/Button';
|
|
17
17
|
import { ICONS_NAMES, PASSWORD_OPERATION_TYPE } from '../../../../constants';
|
|
18
18
|
import { useAppSelector, useLanguage } from '../../../../hooks';
|
|
19
|
-
import { getResetFlowUrl, showLastFour, concatenateObjectValues, shortenString } from '../../../../utils';
|
|
19
|
+
import { getResetFlowUrl, showLastFour, concatenateObjectValues, shortenString, shortenBrand } from '../../../../utils';
|
|
20
20
|
import { passwordSelector } from '../../../app/password/passwordStore';
|
|
21
21
|
import Box from '@mui/material/Box';
|
|
22
22
|
import Text from '../../../../components/Text';
|
|
@@ -80,6 +80,7 @@ var SuccessWithFlowButtons = function () {
|
|
|
80
80
|
var title = t("".concat(name, "_flow_").concat(type), {
|
|
81
81
|
individual_name: username.toLowerCase() + maskedId,
|
|
82
82
|
business_type: entityLegalName,
|
|
83
|
+
brand: brandName,
|
|
83
84
|
license_number: licenseNumber ? t('masking_symbols') + showLastFour(licenseNumber) : '',
|
|
84
85
|
bank_name: bankName,
|
|
85
86
|
iban: iban ? t('masking_symbols') + iban : '',
|
|
@@ -109,7 +110,8 @@ var SuccessWithFlowButtons = function () {
|
|
|
109
110
|
return (_jsxs(ContainerStyled, { children: [_jsxs(TitleStyled, { children: [t('account_details'), " "] }), _jsx(AcceptancePayouts, { showAcceptance: isAcceptance, showPayout: isPayout }), _jsx(ButtonGroupStyled, { children: _jsx(FlowsButtons, { buttons: buttons, data: {
|
|
110
111
|
flowName: data.flowName,
|
|
111
112
|
email: email,
|
|
112
|
-
emailUrl: url
|
|
113
|
+
emailUrl: url,
|
|
114
|
+
brandName: shortenBrand(brandName)
|
|
113
115
|
} }) })] }));
|
|
114
116
|
};
|
|
115
117
|
export default memo(SuccessWithFlowButtons);
|
|
@@ -17,7 +17,7 @@ import Text from '../../../components/Text';
|
|
|
17
17
|
import { ICONS_NAMES } from '../../../constants';
|
|
18
18
|
import { useTranslation } from 'react-i18next';
|
|
19
19
|
import { useLanguage } from '../../../hooks';
|
|
20
|
-
var BoxStyled = styled(Box, { shouldForwardProp: function (prop) { return prop !== 'enabled'; } })(function (_a) {
|
|
20
|
+
var BoxStyled = styled(Box, { shouldForwardProp: function (prop) { return prop !== 'enabled' && prop !== 'isAr'; } })(function (_a) {
|
|
21
21
|
var _b;
|
|
22
22
|
var theme = _a.theme, enabled = _a.enabled, isAr = _a.isAr;
|
|
23
23
|
return (_b = {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CountryCode, AddressFormat } from '../../../@types';
|
|
3
|
+
interface Props {
|
|
4
|
+
countryList: CountryCode[];
|
|
5
|
+
format: AddressFormat[];
|
|
6
|
+
onAddressChange: (value: Record<string, string>, isValid: boolean) => void;
|
|
7
|
+
defaultValues?: Record<string, string>;
|
|
8
|
+
disableCountry?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export default function Address({ format, countryList, onAddressChange, defaultValues, disableCountry }: Props): JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import React, { useMemo } from 'react';
|
|
14
|
+
import Box from '@mui/material/Box';
|
|
15
|
+
import { useForm, Controller } from 'react-hook-form';
|
|
16
|
+
import CountryListComponent from './CountryList';
|
|
17
|
+
import InputSelect from './InputSelect';
|
|
18
|
+
import InputText from './InputText';
|
|
19
|
+
export default function Address(_a) {
|
|
20
|
+
var format = _a.format, countryList = _a.countryList, onAddressChange = _a.onAddressChange, defaultValues = _a.defaultValues, disableCountry = _a.disableCountry;
|
|
21
|
+
var _b = useForm({ defaultValues: defaultValues, mode: 'onChange' }), watch = _b.watch, control = _b.control, formState = _b.formState, getValues = _b.getValues;
|
|
22
|
+
var values = getValues();
|
|
23
|
+
React.useEffect(function () {
|
|
24
|
+
onAddressChange(values, formState.isValid);
|
|
25
|
+
}, [values, formState.isValid]);
|
|
26
|
+
var countryIso2 = useMemo(function () {
|
|
27
|
+
var _a;
|
|
28
|
+
var index = countryList.findIndex(function (item) { return item.countryId === watch('country'); });
|
|
29
|
+
return (_a = countryList[index]) === null || _a === void 0 ? void 0 : _a.iso2;
|
|
30
|
+
}, [watch('country')]);
|
|
31
|
+
return (_jsx(Box, __assign({ component: 'form' }, { children: format.map(function (item) {
|
|
32
|
+
var isCountry = item.code === 'country';
|
|
33
|
+
var isSelect = item.type === 'select';
|
|
34
|
+
if (isCountry) {
|
|
35
|
+
return (_jsx(Controller, { render: function (_a) {
|
|
36
|
+
var _b;
|
|
37
|
+
var field = _a.field, fieldState = _a.fieldState;
|
|
38
|
+
return (_jsx(CountryListComponent, { label: "address_".concat(item.code, "_label"), placeholder: "address_".concat(item.code, "_placeholder"), list: countryList, onSelect: function (value) {
|
|
39
|
+
console.log('value', value);
|
|
40
|
+
field.onChange(value);
|
|
41
|
+
}, value: field.value, error: (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message, disabled: !!disableCountry, isRequired: item.required }));
|
|
42
|
+
}, rules: {
|
|
43
|
+
required: item.required && "address_".concat(item.code, "_required")
|
|
44
|
+
}, control: control, name: item.code }, item.code));
|
|
45
|
+
}
|
|
46
|
+
if (isSelect) {
|
|
47
|
+
return (_jsx(Controller, { render: function (_a) {
|
|
48
|
+
var _b;
|
|
49
|
+
var field = _a.field, fieldState = _a.fieldState;
|
|
50
|
+
return (_jsx(InputSelect, { label: "address_".concat(item.code, "_label"), placeholder: "address_".concat(item.code, "_placeholder"), countryIso2: countryIso2, fetchURL: item.retrieve_uri, onSelect: function (value) { return field.onChange(value); }, error: (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message, isRequired: item.required, value: field.value || '', disabled: !countryIso2 }));
|
|
51
|
+
}, rules: {
|
|
52
|
+
required: item.required && "address_".concat(item.code, "_required")
|
|
53
|
+
}, control: control, name: item.code }, item.code));
|
|
54
|
+
}
|
|
55
|
+
return (_jsx(Controller, { render: function (_a) {
|
|
56
|
+
var _b;
|
|
57
|
+
var field = _a.field, fieldState = _a.fieldState;
|
|
58
|
+
return (_jsx(InputText, { label: "address_".concat(item.code, "_label"), placeholder: "address_".concat(item.code, "_placeholder"), onChange: function (value) { return field.onChange(value); }, error: (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message, isRequired: item.required, value: field.value || '' }));
|
|
59
|
+
}, rules: {
|
|
60
|
+
required: item.required && "address_".concat(item.code, "_required")
|
|
61
|
+
}, control: control, name: item.code }, item.code));
|
|
62
|
+
}) })));
|
|
63
|
+
}
|