@redneckz/wildless-cms-uni-blocks 0.14.1080 → 0.14.1082

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.
Files changed (109) hide show
  1. package/bundle/bundle.umd.js +68 -39
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
  4. package/bundle/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +4 -1
  5. package/bundle/retail/hooks/useSendCode.d.ts +18 -0
  6. package/bundle/retail/utils/yandexMetrika.d.ts +1 -1
  7. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +6 -0
  8. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  9. package/dist/components/CreditCardForm/creditCardFormAspects.js +2 -1
  10. package/dist/components/CreditCardForm/creditCardFormAspects.js.map +1 -1
  11. package/dist/retail/components/Fields/CurrencyField.js +3 -1
  12. package/dist/retail/components/Fields/CurrencyField.js.map +1 -1
  13. package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
  14. package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +11 -30
  15. package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  16. package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +4 -1
  17. package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +11 -2
  18. package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  19. package/dist/retail/hooks/useSendCode.d.ts +18 -0
  20. package/dist/retail/hooks/useSendCode.js +38 -0
  21. package/dist/retail/hooks/useSendCode.js.map +1 -0
  22. package/dist/retail/utils/commonAspects.js +2 -1
  23. package/dist/retail/utils/commonAspects.js.map +1 -1
  24. package/dist/retail/utils/yandexMetrika.d.ts +1 -1
  25. package/dist/retail/utils/yandexMetrika.js +1 -2
  26. package/dist/retail/utils/yandexMetrika.js.map +1 -1
  27. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +6 -0
  28. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  29. package/lib/components/CreditCardForm/creditCardFormAspects.js +2 -1
  30. package/lib/components/CreditCardForm/creditCardFormAspects.js.map +1 -1
  31. package/lib/retail/components/Fields/CurrencyField.js +3 -1
  32. package/lib/retail/components/Fields/CurrencyField.js.map +1 -1
  33. package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
  34. package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +13 -32
  35. package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  36. package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +4 -1
  37. package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +11 -2
  38. package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  39. package/lib/retail/hooks/useSendCode.d.ts +18 -0
  40. package/lib/retail/hooks/useSendCode.js +35 -0
  41. package/lib/retail/hooks/useSendCode.js.map +1 -0
  42. package/lib/retail/utils/commonAspects.js +2 -1
  43. package/lib/retail/utils/commonAspects.js.map +1 -1
  44. package/lib/retail/utils/yandexMetrika.d.ts +1 -1
  45. package/lib/retail/utils/yandexMetrika.js +1 -2
  46. package/lib/retail/utils/yandexMetrika.js.map +1 -1
  47. package/mobile/bundle/bundle.umd.js +68 -39
  48. package/mobile/bundle/bundle.umd.min.js +1 -1
  49. package/mobile/bundle/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
  50. package/mobile/bundle/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +4 -1
  51. package/mobile/bundle/retail/hooks/useSendCode.d.ts +18 -0
  52. package/mobile/bundle/retail/utils/yandexMetrika.d.ts +1 -1
  53. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +6 -0
  54. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  55. package/mobile/dist/components/CreditCardForm/creditCardFormAspects.js +2 -1
  56. package/mobile/dist/components/CreditCardForm/creditCardFormAspects.js.map +1 -1
  57. package/mobile/dist/retail/components/Fields/CurrencyField.js +3 -1
  58. package/mobile/dist/retail/components/Fields/CurrencyField.js.map +1 -1
  59. package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
  60. package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +11 -30
  61. package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  62. package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +4 -1
  63. package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +11 -2
  64. package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  65. package/mobile/dist/retail/hooks/useSendCode.d.ts +18 -0
  66. package/mobile/dist/retail/hooks/useSendCode.js +38 -0
  67. package/mobile/dist/retail/hooks/useSendCode.js.map +1 -0
  68. package/mobile/dist/retail/utils/commonAspects.js +2 -1
  69. package/mobile/dist/retail/utils/commonAspects.js.map +1 -1
  70. package/mobile/dist/retail/utils/yandexMetrika.d.ts +1 -1
  71. package/mobile/dist/retail/utils/yandexMetrika.js +1 -2
  72. package/mobile/dist/retail/utils/yandexMetrika.js.map +1 -1
  73. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +6 -0
  74. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  75. package/mobile/lib/components/CreditCardForm/creditCardFormAspects.js +2 -1
  76. package/mobile/lib/components/CreditCardForm/creditCardFormAspects.js.map +1 -1
  77. package/mobile/lib/retail/components/Fields/CurrencyField.js +3 -1
  78. package/mobile/lib/retail/components/Fields/CurrencyField.js.map +1 -1
  79. package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
  80. package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +13 -32
  81. package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  82. package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +4 -1
  83. package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +11 -2
  84. package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  85. package/mobile/lib/retail/hooks/useSendCode.d.ts +18 -0
  86. package/mobile/lib/retail/hooks/useSendCode.js +35 -0
  87. package/mobile/lib/retail/hooks/useSendCode.js.map +1 -0
  88. package/mobile/lib/retail/utils/commonAspects.js +2 -1
  89. package/mobile/lib/retail/utils/commonAspects.js.map +1 -1
  90. package/mobile/lib/retail/utils/yandexMetrika.d.ts +1 -1
  91. package/mobile/lib/retail/utils/yandexMetrika.js +1 -2
  92. package/mobile/lib/retail/utils/yandexMetrika.js.map +1 -1
  93. package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +6 -0
  94. package/mobile/src/components/CreditCardForm/creditCardFormAspects.ts +2 -1
  95. package/mobile/src/retail/components/Fields/CurrencyField.tsx +3 -1
  96. package/mobile/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +17 -35
  97. package/mobile/src/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +16 -1
  98. package/mobile/src/retail/hooks/useSendCode.ts +52 -0
  99. package/mobile/src/retail/utils/commonAspects.ts +2 -1
  100. package/mobile/src/retail/utils/yandexMetrika.ts +1 -3
  101. package/package.json +1 -1
  102. package/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +6 -0
  103. package/src/components/CreditCardForm/creditCardFormAspects.ts +2 -1
  104. package/src/retail/components/Fields/CurrencyField.tsx +3 -1
  105. package/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +17 -35
  106. package/src/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +16 -1
  107. package/src/retail/hooks/useSendCode.ts +52 -0
  108. package/src/retail/utils/commonAspects.ts +2 -1
  109. package/src/retail/utils/yandexMetrika.ts +1 -3
@@ -1,20 +1,14 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { useCallback, useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
3
- import { useSessionStore } from '@redneckz/uni-jsx/lib/Store/useSessionStore';
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 { sendCode } from '../../api/sendCode';
12
- import { CaptchaDialog } from '../CaptchaDialog/CaptchaDialog';
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 = useCallback(async () => {
62
- const response = await sendCode({
63
- phoneNumber,
64
- smsCodesSetName: { key: 'AUTHENTICATION' },
65
- });
66
-
67
- if (response.ok) {
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: aspectForType[productType || 'default'] },
62
+ params: { yandexId: YANDEX_ID, targetName },
62
63
  },
63
64
  ];
64
65
  };
@@ -1,3 +1 @@
1
- import { projectSettings } from '../../ProjectSettings';
2
-
3
- export const YANDEX_ID = projectSettings.YANDEX_METRIKA_ID || '92511315';
1
+ export const YANDEX_ID = '92511315';