@tap-payments/auth-jsconnect 2.8.59-sandbox → 2.8.60-beta
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/redux.d.ts +0 -1
- package/build/api/entity.d.ts +2 -2
- package/build/api/entity.js +4 -12
- package/build/api/index.d.ts +2 -2
- package/build/constants/api.d.ts +1 -0
- package/build/constants/api.js +2 -0
- package/build/constants/app.d.ts +1 -0
- package/build/constants/app.js +1 -0
- package/build/features/app/bank/bankStore.d.ts +19 -13
- package/build/features/app/bank/bankStore.js +165 -183
- package/build/features/app/board/boardStore.js +10 -16
- package/build/features/app/brand/brandStore.d.ts +31 -16
- package/build/features/app/brand/brandStore.js +239 -243
- package/build/features/app/business/businessStore.js +1 -7
- package/build/features/app/entity/entityStore.d.ts +34 -20
- package/build/features/app/entity/entityStore.js +249 -204
- package/build/features/app/individual/individualStore.d.ts +36 -17
- package/build/features/app/individual/individualStore.js +270 -221
- package/build/features/app/password/passwordStore.d.ts +25 -19
- package/build/features/app/password/passwordStore.js +216 -170
- package/build/features/app/tax/taxStore.d.ts +7 -13
- package/build/features/app/tax/taxStore.js +147 -168
- package/build/features/auth/screens/AuthenticationList/EntityLicenseType.d.ts +26 -4
- package/build/features/bank/screens/BankDetails/BankDetails.js +4 -17
- package/build/features/brand/screens/BrandActivities/ActivitiesList.d.ts +35 -8
- package/build/features/brand/screens/BrandActivities/BrandActivities.js +11 -48
- package/build/features/brand/screens/BrandActivities/CustomerBase.d.ts +3 -3
- package/build/features/brand/screens/BrandActivities/RefundPolicy.d.ts +18 -5
- package/build/features/brand/screens/BrandActivities/TAC.d.ts +7 -2
- package/build/features/brand/screens/BrandInfo/BrandInfo.js +4 -22
- package/build/features/brand/screens/BrandSegmentInfo/BrandSegmentInfo.js +6 -22
- package/build/features/business/screens/Activities/Activities.js +1 -9
- package/build/features/business/screens/Activities/ActivitiesList.d.ts +2 -2
- package/build/features/business/screens/Activities/OperationStartDate.d.ts +1 -1
- package/build/features/business/screens/BrandDetails/SalesChannel.d.ts +1 -1
- package/build/features/business/screens/BusinessType/LicenseType.d.ts +26 -4
- package/build/features/business/screens/Customers/CustomerLocations.d.ts +36 -9
- package/build/features/business/screens/Customers/Customers.js +1 -9
- package/build/features/business/screens/Customers/RefundPolicy.d.ts +18 -5
- package/build/features/connect/screens/BusinessCountry/BusinessCountry.js +1 -7
- package/build/features/connect/screens/Individual/Email.js +1 -3
- package/build/features/connectExpress/screens/AuthenticationList/EntityLicenseType.d.ts +26 -4
- package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseType.d.ts +26 -4
- package/build/features/connectExpress/screens/CollectBusinessInfo/TAC.d.ts +7 -2
- package/build/features/connectExpress/screens/CollectIndividualInfo/Email.js +1 -3
- package/build/features/connectExpress/screens/NID/TAC.d.ts +7 -2
- package/build/features/entity/screens/EntityCapital/ActivityList.d.ts +2 -2
- package/build/features/entity/screens/EntityCapital/EntityCapital.js +9 -33
- package/build/features/entity/screens/EntityName/EntityName.js +14 -31
- package/build/features/entity/screens/EntityName/EntityTypeList.d.ts +35 -8
- package/build/features/entity/screens/EntityName/ExpiryDate.d.ts +1 -1
- package/build/features/entity/screens/EntityName/IssuingDate.d.ts +1 -1
- package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.d.ts +1 -1
- package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +10 -43
- package/build/features/individual/screens/AdditionalIndividualInfo/IsAuthorizedSwitch.d.ts +26 -4
- package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.d.ts +26 -4
- package/build/features/individual/screens/IndividualList/Email.js +2 -3
- package/build/features/individual/screens/IndividualList/IndividualList.d.ts +2 -2
- package/build/features/individual/screens/IndividualList/IndividualList.js +0 -7
- package/build/features/individual/screens/IndividualList/UserList.js +3 -3
- package/build/features/individual/screens/IndividualPersonalInfo/Email.js +2 -4
- package/build/features/individual/screens/IndividualPersonalInfo/Gender.d.ts +26 -4
- package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.d.ts +1 -1
- package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.js +18 -73
- package/build/features/password/Password.js +1 -1
- package/build/features/shared/Address/CountryList.d.ts +23 -7
- package/build/features/shared/Address/InputSelect.d.ts +23 -7
- package/build/features/shared/Button/FlowsButtons.js +1 -7
- package/build/features/shared/Input/Input.d.ts +2 -2
- package/build/features/shared/UploadFile/FileUpload.d.ts +7 -2
- package/build/features/shared/UploadFile/UploadFile.d.ts +7 -2
- package/build/features/shared/UploadFile/UploadWrapper.d.ts +7 -2
- package/build/features/shared/UploadMultipleFile/UploadFile.d.ts +7 -2
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +7 -2
- package/build/features/signIn/SignIn.js +2 -10
- package/build/features/tax/screens/TaxDetails/TaxDetails.js +2 -7
- package/build/hooks/index.d.ts +0 -1
- package/build/hooks/index.js +0 -1
- package/build/utils/common.js +3 -3
- package/package.json +2 -2
- package/build/hooks/useFormDirtyCheck.d.ts +0 -10
- package/build/hooks/useFormDirtyCheck.js +0 -66
|
@@ -2,9 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import { Control, FieldValues } from 'react-hook-form';
|
|
3
3
|
import { FileDetails } from '../../../@types';
|
|
4
4
|
import { FileRemoveType } from '../../../constants';
|
|
5
|
-
export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").
|
|
5
|
+
export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
component?: React.ElementType<any> | undefined;
|
|
8
|
+
ref?: React.Ref<unknown> | undefined;
|
|
9
|
+
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
10
|
+
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
6
11
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
7
|
-
},
|
|
12
|
+
}, ("border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "color" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform") | "children" | "component" | "ref" | "sx"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
8
13
|
interface UploadWrapperProps {
|
|
9
14
|
id: string;
|
|
10
15
|
control: Control<FieldValues, any>;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
3
|
import { FileInfo, FileType } from '../../../constants';
|
|
4
|
-
export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").
|
|
4
|
+
export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
component?: React.ElementType<any> | undefined;
|
|
7
|
+
ref?: React.Ref<unknown> | undefined;
|
|
8
|
+
sx?: SxProps<Theme> | undefined;
|
|
9
|
+
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
5
10
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
6
|
-
},
|
|
11
|
+
}, ("border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "color" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform") | "children" | "component" | "ref" | "sx"> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
|
|
7
12
|
export type UploadFileProps = {
|
|
8
13
|
index: number;
|
|
9
14
|
purpose: string;
|
|
@@ -2,9 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import { Control, FieldValues } from 'react-hook-form';
|
|
3
3
|
import { FileDetails } from '../../../@types';
|
|
4
4
|
import { FileType } from '../../../constants';
|
|
5
|
-
export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").
|
|
5
|
+
export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
component?: React.ElementType<any> | undefined;
|
|
8
|
+
ref?: React.Ref<unknown> | undefined;
|
|
9
|
+
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
10
|
+
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
6
11
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
7
|
-
},
|
|
12
|
+
}, ("border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "color" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform") | "children" | "component" | "ref" | "sx"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
8
13
|
interface UploadMultipleFileProps {
|
|
9
14
|
id: string;
|
|
10
15
|
control: Control<FieldValues, any>;
|
|
@@ -10,10 +10,10 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import
|
|
13
|
+
import { memo } from 'react';
|
|
14
14
|
import { createRoot } from 'react-dom/client';
|
|
15
15
|
import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener, useAppDispatch } from '../../hooks';
|
|
16
|
-
import {
|
|
16
|
+
import { settingsSelector } from '../../app/settings';
|
|
17
17
|
import AnimationFlow from '../../components/AnimationFlow';
|
|
18
18
|
import { store } from '../../app/store';
|
|
19
19
|
import { ReduxProvider, ThemeProvider } from '../../components/Providers';
|
|
@@ -33,14 +33,6 @@ var SignIn = memo(function (props) {
|
|
|
33
33
|
useErrorListener(signInError || error);
|
|
34
34
|
useStepStartedListener();
|
|
35
35
|
var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open, merchant = data.merchant, isMaturityExpress = data.isMaturityExpress, appConfig = data.appConfig;
|
|
36
|
-
React.useEffect(function () {
|
|
37
|
-
if (settingLoading || !props.open)
|
|
38
|
-
return;
|
|
39
|
-
if (!data.isValidOperator) {
|
|
40
|
-
dispatch(handleCurrentActiveScreen('SIGIN_OPERATOR_ERROR_STEP'));
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
}, [data.isValidOperator, settingLoading]);
|
|
44
36
|
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ open: open, isTapOrigin: isTapOrigin, loading: settingLoading }, { children: _jsx(AnimationFlow, __assign({ pointerEvents: loading ? 'none' : 'auto', isTapOrigin: isTapOrigin, open: open, error: error, loading: settingLoading, breakpoint: 'sm', screenId: activeScreen.name, merchantInfo: merchant, isMaturityExpress: isMaturityExpress, dialogEdgeFormat: data.appConfig.dialogEdgeFormat, features: appConfig.features }, { children: _jsx(FeatureContainer, __assign({ isMaturityExpress: isMaturityExpress }, { children: signInFeatureScreens.map(function (_a, index) {
|
|
45
37
|
var Element = _a.element, name = _a.name;
|
|
46
38
|
var isActive = activeScreen.name === name;
|
|
@@ -16,7 +16,7 @@ import { useForm, FormProvider } from 'react-hook-form';
|
|
|
16
16
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
17
17
|
import { styled } from '@mui/material/styles';
|
|
18
18
|
import Form from '../../../../components/Form';
|
|
19
|
-
import { useAppDispatch, useLanguage, useAppSelector, useSetFromDefaultValues, useFormReadOnly, useDataNoneEditable, useFormErrorAndUpdateReadOnly, useExcludeReadOnlyFelids, useDataVerified
|
|
19
|
+
import { useAppDispatch, useLanguage, useAppSelector, useSetFromDefaultValues, useFormReadOnly, useDataNoneEditable, useFormErrorAndUpdateReadOnly, useExcludeReadOnlyFelids, useDataVerified } from '../../../../hooks';
|
|
20
20
|
import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
|
|
21
21
|
import { DocumentPurpose } from '../../../../@types';
|
|
22
22
|
import { deepCopy, getFileDetailsFromDocument, isSA } from '../../../../utils';
|
|
@@ -55,18 +55,13 @@ var TaxDetails = function () {
|
|
|
55
55
|
var noneEditable = useDataNoneEditable(data_status, ['tax_number', 'documents', 'is_vat_acknowledged']);
|
|
56
56
|
var readOnly = useFormErrorAndUpdateReadOnly(methods, originalReadOnly, noneEditable);
|
|
57
57
|
var dataVerified = useDataVerified(data_verification, ['tax_number']);
|
|
58
|
-
var isDirty = useFormDirtyCheck(methods, {
|
|
59
|
-
vatId: entity === null || entity === void 0 ? void 0 : entity.vat_id,
|
|
60
|
-
confirmPolicy: entity === null || entity === void 0 ? void 0 : entity.is_vat_acknowledged
|
|
61
|
-
}).isDirty;
|
|
62
58
|
var getFelids = useExcludeReadOnlyFelids(methods, readOnly).getFelids;
|
|
63
59
|
var isVatIdVerified = dataVerified['tax_number'] && vat_id === methods.watch('vatId');
|
|
64
60
|
var t = useTranslation().t;
|
|
65
61
|
var isAr = useLanguage().isAr;
|
|
66
62
|
var isSACountry = React.useMemo(function () { return isSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
67
63
|
var onSubmit = function (data) {
|
|
68
|
-
|
|
69
|
-
dispatch(updateTaxInfo(formData));
|
|
64
|
+
dispatch(updateTaxInfo(deepCopy(getFelids(data))));
|
|
70
65
|
};
|
|
71
66
|
var onBack = function () {
|
|
72
67
|
if ((flows === null || flows === void 0 ? void 0 : flows.length) > 0) {
|
package/build/hooks/index.d.ts
CHANGED
package/build/hooks/index.js
CHANGED
package/build/utils/common.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { axiosInstance } from '../api';
|
|
2
|
-
import { ENDPOINT_PATHS, CONNECT_SANDBOX_URL,
|
|
2
|
+
import { ENDPOINT_PATHS, CONNECT_SANDBOX_URL, CONNECT_BETA_URL } from '../constants';
|
|
3
3
|
export var sleep = function (milliseconds) {
|
|
4
4
|
if (milliseconds === void 0) { milliseconds = 1000; }
|
|
5
5
|
return new Promise(function (resolve) { return setTimeout(resolve, milliseconds); });
|
|
@@ -13,7 +13,7 @@ export var dangerousMessage = function (message, callBack) {
|
|
|
13
13
|
export var setBaseUrl = function (publicKey) {
|
|
14
14
|
var isProd = publicKey.includes('pk_live');
|
|
15
15
|
if (isProd) {
|
|
16
|
-
axiosInstance.defaults.baseURL = ENDPOINT_PATHS.
|
|
16
|
+
axiosInstance.defaults.baseURL = ENDPOINT_PATHS.BETA_BASE_URL;
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
axiosInstance.defaults.baseURL = ENDPOINT_PATHS.SANDBOX_BASE_URL;
|
|
@@ -35,7 +35,7 @@ export var updateLocationUrlWithCountry = function (countryIso2) {
|
|
|
35
35
|
window.history.replaceState({}, '', newUrl);
|
|
36
36
|
};
|
|
37
37
|
export var openConnect = function (pk, countryCode) {
|
|
38
|
-
var newUrl = new URL(pk.includes('pk_live') ?
|
|
38
|
+
var newUrl = new URL(pk.includes('pk_live') ? CONNECT_BETA_URL : CONNECT_SANDBOX_URL);
|
|
39
39
|
if (countryCode) {
|
|
40
40
|
newUrl.pathname = "/".concat(countryCode.toLowerCase());
|
|
41
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/auth-jsconnect",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.60-beta",
|
|
4
4
|
"description": "connect library, auth",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"copy:files": "copyfiles -u 1 src/**/*.css build/",
|
|
22
22
|
"tsc:alias": "tsc-alias -p tsconfig.json",
|
|
23
23
|
"ts:build": "rm -rf build && tsc -p tsconfig.json && tsc-alias -p tsconfig.json && yarn copy:files",
|
|
24
|
-
"push": "npm publish --access public --tag
|
|
24
|
+
"push": "npm publish --access public --tag beta"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [],
|
|
27
27
|
"author": {
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FieldValues, UseFormReturn } from 'react-hook-form';
|
|
2
|
-
type UseFormWithDirtyCheck = {
|
|
3
|
-
isDirty: boolean;
|
|
4
|
-
};
|
|
5
|
-
type CustomAttrProps = {
|
|
6
|
-
name: string;
|
|
7
|
-
keys: string[];
|
|
8
|
-
};
|
|
9
|
-
export declare const useFormDirtyCheck: <TFieldValues extends FieldValues>(method: UseFormReturn<TFieldValues, any, undefined>, backendData: TFieldValues, customAttrs?: CustomAttrProps[]) => UseFormWithDirtyCheck;
|
|
10
|
-
export {};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
export var useFormDirtyCheck = function (method, backendData, customAttrs) {
|
|
4
|
-
var _a = React.useState(false), isDirty = _a[0], setIsDirty = _a[1];
|
|
5
|
-
var data = method.watch();
|
|
6
|
-
var isValidData = function (formValue, backendValue) {
|
|
7
|
-
if (_.isUndefined(formValue))
|
|
8
|
-
return false;
|
|
9
|
-
if (_.isArray(formValue) && formValue.length === 0)
|
|
10
|
-
return false;
|
|
11
|
-
if (_.isObject(formValue) && _.isEmpty(formValue))
|
|
12
|
-
return false;
|
|
13
|
-
if (formValue === '' && !backendValue)
|
|
14
|
-
return false;
|
|
15
|
-
return true;
|
|
16
|
-
};
|
|
17
|
-
var isArray = function (data, backendData) {
|
|
18
|
-
return backendData && data && _.isArray(backendData) && _.isArray(data);
|
|
19
|
-
};
|
|
20
|
-
var isObject = function (data, backendData) {
|
|
21
|
-
return backendData && data && _.isObject(data) && _.isObject(backendData);
|
|
22
|
-
};
|
|
23
|
-
var mapArrayOfObjectWithKeys = function (items, keys) {
|
|
24
|
-
return _.map(items, function (item) { return _.pick(item, keys); });
|
|
25
|
-
};
|
|
26
|
-
var mapObjectWithKeys = function (item, keys) {
|
|
27
|
-
return _.pick(item, keys);
|
|
28
|
-
};
|
|
29
|
-
var deepComparison = function (data, backendData, customAttrs) {
|
|
30
|
-
var _loop_1 = function (key) {
|
|
31
|
-
var formValue = data === null || data === void 0 ? void 0 : data[key];
|
|
32
|
-
var backEndValue = backendData === null || backendData === void 0 ? void 0 : backendData[key];
|
|
33
|
-
if (!isValidData(formValue, backEndValue))
|
|
34
|
-
return "continue";
|
|
35
|
-
var customAttr = customAttrs === null || customAttrs === void 0 ? void 0 : customAttrs.find(function (el) { return el.name === key; });
|
|
36
|
-
if (customAttr) {
|
|
37
|
-
var keys = customAttr.keys;
|
|
38
|
-
if (isArray(formValue, backEndValue)) {
|
|
39
|
-
formValue = mapArrayOfObjectWithKeys(formValue, keys);
|
|
40
|
-
backEndValue = mapArrayOfObjectWithKeys(backEndValue, keys);
|
|
41
|
-
if (formValue.length !== backEndValue.length)
|
|
42
|
-
return { value: true };
|
|
43
|
-
if (_.differenceWith(formValue, backEndValue, _.isEqual).length > 0)
|
|
44
|
-
return { value: true };
|
|
45
|
-
}
|
|
46
|
-
if (isObject(formValue, backEndValue)) {
|
|
47
|
-
formValue = mapObjectWithKeys(formValue, keys);
|
|
48
|
-
backEndValue = mapObjectWithKeys(backEndValue, keys);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (!_.isEqual(formValue, backEndValue))
|
|
52
|
-
return { value: true };
|
|
53
|
-
};
|
|
54
|
-
for (var key in backendData) {
|
|
55
|
-
var state_1 = _loop_1(key);
|
|
56
|
-
if (typeof state_1 === "object")
|
|
57
|
-
return state_1.value;
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
};
|
|
61
|
-
React.useEffect(function () {
|
|
62
|
-
var isDirty = deepComparison(data, backendData, customAttrs);
|
|
63
|
-
setIsDirty(isDirty);
|
|
64
|
-
}, [data, backendData]);
|
|
65
|
-
return { isDirty: isDirty };
|
|
66
|
-
};
|