@redneckz/wildless-cms-uni-blocks 0.14.1079 → 0.14.1081
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/bundle/bundle.umd.js +65 -38
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
- package/bundle/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +4 -1
- package/bundle/retail/hooks/useSendCode.d.ts +18 -0
- package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +6 -0
- package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
- package/dist/components/CreditCardForm/creditCardFormAspects.js +2 -1
- package/dist/components/CreditCardForm/creditCardFormAspects.js.map +1 -1
- package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
- package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +11 -30
- package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +4 -1
- package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +11 -2
- package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/dist/retail/hooks/useSendCode.d.ts +18 -0
- package/dist/retail/hooks/useSendCode.js +38 -0
- package/dist/retail/hooks/useSendCode.js.map +1 -0
- package/dist/retail/utils/commonAspects.js +2 -1
- package/dist/retail/utils/commonAspects.js.map +1 -1
- package/dist/ui-kit/LinkButton/LinkButton.js +1 -1
- package/dist/ui-kit/LinkButton/LinkButton.js.map +1 -1
- package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +6 -0
- package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
- package/lib/components/CreditCardForm/creditCardFormAspects.js +2 -1
- package/lib/components/CreditCardForm/creditCardFormAspects.js.map +1 -1
- package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
- package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +13 -32
- package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +4 -1
- package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +11 -2
- package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/lib/retail/hooks/useSendCode.d.ts +18 -0
- package/lib/retail/hooks/useSendCode.js +35 -0
- package/lib/retail/hooks/useSendCode.js.map +1 -0
- package/lib/retail/utils/commonAspects.js +2 -1
- package/lib/retail/utils/commonAspects.js.map +1 -1
- package/lib/ui-kit/LinkButton/LinkButton.js +1 -1
- package/lib/ui-kit/LinkButton/LinkButton.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +65 -38
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
- package/mobile/bundle/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +4 -1
- package/mobile/bundle/retail/hooks/useSendCode.d.ts +18 -0
- package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +6 -0
- package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
- package/mobile/dist/components/CreditCardForm/creditCardFormAspects.js +2 -1
- package/mobile/dist/components/CreditCardForm/creditCardFormAspects.js.map +1 -1
- package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
- package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +11 -30
- package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +4 -1
- package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +11 -2
- package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/mobile/dist/retail/hooks/useSendCode.d.ts +18 -0
- package/mobile/dist/retail/hooks/useSendCode.js +38 -0
- package/mobile/dist/retail/hooks/useSendCode.js.map +1 -0
- package/mobile/dist/retail/utils/commonAspects.js +2 -1
- package/mobile/dist/retail/utils/commonAspects.js.map +1 -1
- package/mobile/dist/ui-kit/LinkButton/LinkButton.js +1 -1
- package/mobile/dist/ui-kit/LinkButton/LinkButton.js.map +1 -1
- package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +6 -0
- package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
- package/mobile/lib/components/CreditCardForm/creditCardFormAspects.js +2 -1
- package/mobile/lib/components/CreditCardForm/creditCardFormAspects.js.map +1 -1
- package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
- package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +13 -32
- package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +4 -1
- package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +11 -2
- package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/mobile/lib/retail/hooks/useSendCode.d.ts +18 -0
- package/mobile/lib/retail/hooks/useSendCode.js +35 -0
- package/mobile/lib/retail/hooks/useSendCode.js.map +1 -0
- package/mobile/lib/retail/utils/commonAspects.js +2 -1
- package/mobile/lib/retail/utils/commonAspects.js.map +1 -1
- package/mobile/lib/ui-kit/LinkButton/LinkButton.js +1 -1
- package/mobile/lib/ui-kit/LinkButton/LinkButton.js.map +1 -1
- package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +6 -0
- package/mobile/src/components/CreditCardForm/creditCardFormAspects.ts +2 -1
- package/mobile/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +17 -35
- package/mobile/src/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +16 -1
- package/mobile/src/retail/hooks/useSendCode.ts +52 -0
- package/mobile/src/retail/utils/commonAspects.ts +2 -1
- package/mobile/src/ui-kit/LinkButton/LinkButton.tsx +1 -1
- package/package.json +1 -1
- package/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +6 -0
- package/src/components/CreditCardForm/creditCardFormAspects.ts +2 -1
- package/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +17 -35
- package/src/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +16 -1
- package/src/retail/hooks/useSendCode.ts +52 -0
- package/src/retail/utils/commonAspects.ts +2 -1
- package/src/ui-kit/LinkButton/LinkButton.tsx +1 -1
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
|
+
import { type Aspects } from '../../../hooks/useAspects/useAspects';
|
|
4
4
|
import type { OnCloseProps } from '../../../model/OnCloseProps';
|
|
5
|
-
import { useDialog } from '../../../ui-kit/DialogManager/useDialog';
|
|
6
5
|
import { RichText } from '../../../ui-kit/RichText/RichText';
|
|
7
6
|
import { useCountDownTimer } from '../../../ui-kit/TimerCircle/useCountDownTimer';
|
|
8
7
|
import { VerifyPhoneDialogLayout } from '../../../ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout';
|
|
9
8
|
import { formatPhone } from '../../../utils/formatPhone';
|
|
10
9
|
import { noop } from '../../../utils/noop';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
TIME_TO_RESEND,
|
|
15
|
-
useVerifyPhoneDialogSubmit,
|
|
16
|
-
type SmsCodeStore,
|
|
17
|
-
} from './useVerifyPhoneDialogSubmit';
|
|
10
|
+
import { useSendCode } from '../../hooks/useSendCode';
|
|
11
|
+
import { useVerifyPhoneDialogSubmit } from './useVerifyPhoneDialogSubmit';
|
|
18
12
|
|
|
19
13
|
const CODE_LENGTH = 4;
|
|
20
14
|
|
|
@@ -24,6 +18,8 @@ export interface VerifyPhoneDialogProps extends OnCloseProps {
|
|
|
24
18
|
consents?: string[];
|
|
25
19
|
onSuccess?: (smsCode?: string) => void;
|
|
26
20
|
onFail?: () => void;
|
|
21
|
+
productType?: string;
|
|
22
|
+
aspects?: Aspects;
|
|
27
23
|
}
|
|
28
24
|
|
|
29
25
|
export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
|
|
@@ -34,9 +30,10 @@ export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
|
|
|
34
30
|
onSuccess = noop,
|
|
35
31
|
onClose = noop,
|
|
36
32
|
onFail = noop,
|
|
33
|
+
productType,
|
|
34
|
+
aspects,
|
|
37
35
|
}) => {
|
|
38
36
|
const [values, setValues] = useState<string[]>(Array(CODE_LENGTH).fill('') as string[]);
|
|
39
|
-
const sessionStore = useSessionStore<SmsCodeStore>();
|
|
40
37
|
const phoneNumber = formatPhone(phone);
|
|
41
38
|
|
|
42
39
|
const {
|
|
@@ -53,28 +50,19 @@ export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
|
|
|
53
50
|
phoneNumber,
|
|
54
51
|
onSuccess,
|
|
55
52
|
onFail,
|
|
53
|
+
productType,
|
|
54
|
+
aspects,
|
|
56
55
|
});
|
|
57
56
|
|
|
58
|
-
const captchaDialog = useDialog(CaptchaDialog);
|
|
59
57
|
const restartTimer = useCountDownTimer({ seconds: timeNextReq, onTick: setTimeNextReq });
|
|
60
58
|
|
|
61
|
-
const handleSendCode =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
setTimeNextReq(TIME_TO_RESEND);
|
|
69
|
-
restartTimer(TIME_TO_RESEND);
|
|
70
|
-
setErrorText('');
|
|
71
|
-
sessionStore.smsCode = getDefaultSmsCodeParams(phoneNumber);
|
|
72
|
-
} else if (response.status === 429) {
|
|
73
|
-
captchaDialog.open({ phoneNumber, sendCode: handleSendCode });
|
|
74
|
-
} else {
|
|
75
|
-
onFail();
|
|
76
|
-
}
|
|
77
|
-
}, [phoneNumber, restartTimer]);
|
|
59
|
+
const { handleSendCode, sessionStore } = useSendCode({
|
|
60
|
+
phoneNumber,
|
|
61
|
+
restartTimer,
|
|
62
|
+
setTimeNextReq,
|
|
63
|
+
setErrorText,
|
|
64
|
+
onFail,
|
|
65
|
+
});
|
|
78
66
|
|
|
79
67
|
useEffect(() => {
|
|
80
68
|
if (!sessionStore.smsCode?.sendTime || sessionStore.smsCode?.phoneNumber !== phoneNumber) {
|
|
@@ -102,12 +90,6 @@ export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
|
|
|
102
90
|
},
|
|
103
91
|
);
|
|
104
92
|
|
|
105
|
-
const getDefaultSmsCodeParams = (phoneNumber: string) => ({
|
|
106
|
-
sendTime: Date.now(),
|
|
107
|
-
attempts: 0,
|
|
108
|
-
phoneNumber: phoneNumber,
|
|
109
|
-
});
|
|
110
|
-
|
|
111
93
|
const renderDescription = (consents?: string[], isRender = false) =>
|
|
112
94
|
isRender ? (
|
|
113
95
|
<RichText itemSize="list-s">
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
2
|
import { useBool } from '@redneckz/uni-jsx/lib/hooks/useBool';
|
|
3
3
|
import { useSessionStore } from '@redneckz/uni-jsx/lib/Store/useSessionStore';
|
|
4
|
+
import { handleAspects } from '../../../hooks/useAspects/handleAspects';
|
|
5
|
+
import { type Aspects } from '../../../hooks/useAspects/useAspects';
|
|
6
|
+
import { type PreventableEventWithTarget } from '../../../ui-kit/PreventableEvent';
|
|
4
7
|
import { getTimer } from '../../../utils/getTimer';
|
|
5
8
|
import { checkCode, type CheckCodeResponse } from '../../api/checkCode';
|
|
9
|
+
import { getAspects } from '../../utils/commonAspects';
|
|
6
10
|
import { saveToken } from '../../utils/saveToken';
|
|
7
11
|
|
|
8
12
|
export const TIME_TO_RESEND = 180;
|
|
@@ -12,6 +16,8 @@ type useVerifyPhoneDialogSubmitProps = {
|
|
|
12
16
|
phoneNumber: string;
|
|
13
17
|
onSuccess: (smsCode?: string) => void;
|
|
14
18
|
onFail: () => void;
|
|
19
|
+
productType?: string;
|
|
20
|
+
aspects?: Aspects;
|
|
15
21
|
};
|
|
16
22
|
|
|
17
23
|
export interface SmsCodeStore {
|
|
@@ -27,6 +33,8 @@ export const useVerifyPhoneDialogSubmit = ({
|
|
|
27
33
|
phoneNumber,
|
|
28
34
|
onSuccess,
|
|
29
35
|
onFail,
|
|
36
|
+
productType,
|
|
37
|
+
aspects,
|
|
30
38
|
}: useVerifyPhoneDialogSubmitProps) => {
|
|
31
39
|
const sessionStore = useSessionStore<SmsCodeStore>();
|
|
32
40
|
const attempts = sessionStore.smsCode?.attempts || 0;
|
|
@@ -59,6 +67,13 @@ export const useVerifyPhoneDialogSubmit = ({
|
|
|
59
67
|
setTimeNextReq(0);
|
|
60
68
|
resetError();
|
|
61
69
|
sessionStore.smsCode = null;
|
|
70
|
+
if (productType && aspects) {
|
|
71
|
+
handleAspects({
|
|
72
|
+
aspectsAttributes: getAspects('smsAuth', productType),
|
|
73
|
+
aspects,
|
|
74
|
+
ev: {} as PreventableEventWithTarget,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
62
77
|
onSuccess?.(values.join(''));
|
|
63
78
|
} else if (response.status === 403) {
|
|
64
79
|
setErrorText(attempts > 1 ? 'Исчерпан лимит ввода смс-кода' : 'Неверный код');
|
|
@@ -66,7 +81,7 @@ export const useVerifyPhoneDialogSubmit = ({
|
|
|
66
81
|
onFail();
|
|
67
82
|
}
|
|
68
83
|
endLoading();
|
|
69
|
-
}, [values, attempts]);
|
|
84
|
+
}, [values, attempts, aspects]);
|
|
70
85
|
|
|
71
86
|
useEffect(() => {
|
|
72
87
|
if (isTimeExpired) {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
import { useSessionStore } from '@redneckz/uni-jsx/lib/Store/useSessionStore';
|
|
3
|
+
import { useDialog } from '../../ui-kit/DialogManager/useDialog';
|
|
4
|
+
import { TIME_TO_RESEND } from '../../utils/getTimer';
|
|
5
|
+
import { sendCode } from '../api/sendCode';
|
|
6
|
+
import { CaptchaDialog } from '../components/CaptchaDialog/CaptchaDialog';
|
|
7
|
+
import { type SmsCodeStore } from '../components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit';
|
|
8
|
+
|
|
9
|
+
interface UseSendCodeProps {
|
|
10
|
+
phoneNumber: string;
|
|
11
|
+
restartTimer: (seconds: number) => void;
|
|
12
|
+
setTimeNextReq: (time: number) => void;
|
|
13
|
+
setErrorText: (text: string) => void;
|
|
14
|
+
onFail: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const getDefaultSmsCodeParams = (phoneNumber: string) => ({
|
|
18
|
+
sendTime: Date.now(),
|
|
19
|
+
attempts: 0,
|
|
20
|
+
phoneNumber: phoneNumber,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const useSendCode = ({
|
|
24
|
+
phoneNumber,
|
|
25
|
+
restartTimer,
|
|
26
|
+
setTimeNextReq,
|
|
27
|
+
setErrorText,
|
|
28
|
+
onFail,
|
|
29
|
+
}: UseSendCodeProps) => {
|
|
30
|
+
const sessionStore = useSessionStore<SmsCodeStore>();
|
|
31
|
+
const captchaDialog = useDialog(CaptchaDialog);
|
|
32
|
+
|
|
33
|
+
const handleSendCode = useCallback(async () => {
|
|
34
|
+
const response = await sendCode({
|
|
35
|
+
phoneNumber,
|
|
36
|
+
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (response.ok) {
|
|
40
|
+
setTimeNextReq(TIME_TO_RESEND);
|
|
41
|
+
restartTimer(TIME_TO_RESEND);
|
|
42
|
+
setErrorText('');
|
|
43
|
+
sessionStore.smsCode = getDefaultSmsCodeParams(phoneNumber);
|
|
44
|
+
} else if (response.status === 429) {
|
|
45
|
+
captchaDialog.open({ phoneNumber, sendCode: handleSendCode });
|
|
46
|
+
} else {
|
|
47
|
+
onFail();
|
|
48
|
+
}
|
|
49
|
+
}, [phoneNumber, restartTimer]);
|
|
50
|
+
|
|
51
|
+
return { handleSendCode, sessionStore };
|
|
52
|
+
};
|
|
@@ -54,11 +54,12 @@ const ASPECTS_MAP: Record<string, Record<string, string>> = {
|
|
|
54
54
|
|
|
55
55
|
export const getAspects = (aspectType: string, productType?: string): AspectsDef[] => {
|
|
56
56
|
const aspectForType = ASPECTS_MAP[aspectType];
|
|
57
|
+
const targetName = aspectForType?.[productType || 'default'] || aspectForType?.['default'];
|
|
57
58
|
|
|
58
59
|
return [
|
|
59
60
|
{
|
|
60
61
|
aspectName: 'ymReachGoal',
|
|
61
|
-
params: { yandexId: YANDEX_ID, targetName
|
|
62
|
+
params: { yandexId: YANDEX_ID, targetName },
|
|
62
63
|
},
|
|
63
64
|
];
|
|
64
65
|
};
|
|
@@ -21,7 +21,7 @@ type SaveLinksProps = {
|
|
|
21
21
|
/** @deprecated */
|
|
22
22
|
export const LinkButton = JSX<LinkButtonProps>(
|
|
23
23
|
({ disabled, children, method = 'LINK', href, id, additionalHref, chance, ...rest }) => {
|
|
24
|
-
const [currentLink, setCurrentLink] = useState
|
|
24
|
+
const [currentLink, setCurrentLink] = useState(href);
|
|
25
25
|
const handleFormSubmit = useFormSubmit({ method, href });
|
|
26
26
|
const linksStore = useLocalStore<LinkStoreSlice>();
|
|
27
27
|
|