@redneckz/wildless-cms-uni-blocks 0.14.888 → 0.14.890
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/api/LeadServiceAPI.d.ts +8 -0
- package/bundle/api/getSubmitBody.d.ts +494 -0
- package/bundle/bundle.umd.js +659 -556
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/ApplicationForm/ApplicationFormContent.d.ts +1 -1
- package/bundle/retail/api/checkCode.d.ts +9 -1
- package/bundle/retail/api/sendCode.d.ts +1 -1
- package/bundle/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +4 -0
- package/bundle/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +6 -1
- package/dist/api/LeadServiceAPI.d.ts +8 -0
- package/dist/api/LeadServiceAPI.js +41 -49
- package/dist/api/LeadServiceAPI.js.map +1 -1
- package/dist/api/getSubmitBody.d.ts +494 -0
- package/dist/api/getSubmitBody.js +59 -0
- package/dist/api/getSubmitBody.js.map +1 -0
- package/dist/components/ApplicationForm/ApplicationForm.js +30 -5
- package/dist/components/ApplicationForm/ApplicationForm.js.map +1 -1
- package/dist/components/ApplicationForm/ApplicationFormContent.d.ts +1 -1
- package/dist/components/DebitForm/DebitFormProgress.js +3 -3
- package/dist/components/DebitForm/DebitFormProgress.js.map +1 -1
- package/dist/components/DebitForm/PendingStatusContent.js +1 -1
- package/dist/components/DebitForm/PendingStatusContent.js.map +1 -1
- package/dist/retail/api/checkCode.d.ts +9 -1
- package/dist/retail/api/checkCode.js +22 -1
- package/dist/retail/api/checkCode.js.map +1 -1
- package/dist/retail/api/sendCode.d.ts +1 -1
- package/dist/retail/api/sendCode.js +8 -2
- package/dist/retail/api/sendCode.js.map +1 -1
- package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +4 -0
- package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +10 -4
- package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +6 -1
- package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +7 -4
- package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/dist/retail/utils/mockLocalStorage.js +2 -2
- package/dist/retail/utils/mockLocalStorage.js.map +1 -1
- package/lib/api/LeadServiceAPI.d.ts +8 -0
- package/lib/api/LeadServiceAPI.js +41 -49
- package/lib/api/LeadServiceAPI.js.map +1 -1
- package/lib/api/getSubmitBody.d.ts +494 -0
- package/lib/api/getSubmitBody.js +54 -0
- package/lib/api/getSubmitBody.js.map +1 -0
- package/lib/components/ApplicationForm/ApplicationForm.fixture.d.ts +1 -0
- package/lib/components/ApplicationForm/ApplicationForm.js +30 -5
- package/lib/components/ApplicationForm/ApplicationForm.js.map +1 -1
- package/lib/components/ApplicationForm/ApplicationFormContent.d.ts +1 -1
- package/lib/components/DebitForm/DebitFormProgress.js +4 -4
- package/lib/components/DebitForm/DebitFormProgress.js.map +1 -1
- package/lib/components/DebitForm/PendingStatusContent.js +1 -1
- package/lib/components/DebitForm/PendingStatusContent.js.map +1 -1
- package/lib/retail/api/checkCode.d.ts +9 -1
- package/lib/retail/api/checkCode.js +22 -1
- package/lib/retail/api/checkCode.js.map +1 -1
- package/lib/retail/api/sendCode.d.ts +1 -1
- package/lib/retail/api/sendCode.js +7 -1
- package/lib/retail/api/sendCode.js.map +1 -1
- package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +4 -0
- package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +10 -4
- package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +6 -1
- package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +6 -3
- package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/lib/retail/utils/mockLocalStorage.js +2 -2
- package/lib/retail/utils/mockLocalStorage.js.map +1 -1
- package/mobile/bundle/api/LeadServiceAPI.d.ts +8 -0
- package/mobile/bundle/api/getSubmitBody.d.ts +494 -0
- package/mobile/bundle/bundle.umd.js +659 -556
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/ApplicationForm/ApplicationFormContent.d.ts +1 -1
- package/mobile/bundle/retail/api/checkCode.d.ts +9 -1
- package/mobile/bundle/retail/api/sendCode.d.ts +1 -1
- package/mobile/bundle/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +4 -0
- package/mobile/bundle/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +6 -1
- package/mobile/dist/api/LeadServiceAPI.d.ts +8 -0
- package/mobile/dist/api/LeadServiceAPI.js +41 -49
- package/mobile/dist/api/LeadServiceAPI.js.map +1 -1
- package/mobile/dist/api/getSubmitBody.d.ts +494 -0
- package/mobile/dist/api/getSubmitBody.js +59 -0
- package/mobile/dist/api/getSubmitBody.js.map +1 -0
- package/mobile/dist/components/ApplicationForm/ApplicationForm.js +30 -5
- package/mobile/dist/components/ApplicationForm/ApplicationForm.js.map +1 -1
- package/mobile/dist/components/ApplicationForm/ApplicationFormContent.d.ts +1 -1
- package/mobile/dist/components/DebitForm/DebitFormProgress.js +3 -3
- package/mobile/dist/components/DebitForm/DebitFormProgress.js.map +1 -1
- package/mobile/dist/components/DebitForm/PendingStatusContent.js +1 -1
- package/mobile/dist/components/DebitForm/PendingStatusContent.js.map +1 -1
- package/mobile/dist/retail/api/checkCode.d.ts +9 -1
- package/mobile/dist/retail/api/checkCode.js +22 -1
- package/mobile/dist/retail/api/checkCode.js.map +1 -1
- package/mobile/dist/retail/api/sendCode.d.ts +1 -1
- package/mobile/dist/retail/api/sendCode.js +8 -2
- package/mobile/dist/retail/api/sendCode.js.map +1 -1
- package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +4 -0
- package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +10 -4
- package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +6 -1
- package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +7 -4
- package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/mobile/dist/retail/utils/mockLocalStorage.js +2 -2
- package/mobile/dist/retail/utils/mockLocalStorage.js.map +1 -1
- package/mobile/lib/api/LeadServiceAPI.d.ts +8 -0
- package/mobile/lib/api/LeadServiceAPI.js +41 -49
- package/mobile/lib/api/LeadServiceAPI.js.map +1 -1
- package/mobile/lib/api/getSubmitBody.d.ts +494 -0
- package/mobile/lib/api/getSubmitBody.js +54 -0
- package/mobile/lib/api/getSubmitBody.js.map +1 -0
- package/mobile/lib/components/ApplicationForm/ApplicationForm.js +30 -5
- package/mobile/lib/components/ApplicationForm/ApplicationForm.js.map +1 -1
- package/mobile/lib/components/ApplicationForm/ApplicationFormContent.d.ts +1 -1
- package/mobile/lib/components/DebitForm/DebitFormProgress.js +4 -4
- package/mobile/lib/components/DebitForm/DebitFormProgress.js.map +1 -1
- package/mobile/lib/components/DebitForm/PendingStatusContent.js +1 -1
- package/mobile/lib/components/DebitForm/PendingStatusContent.js.map +1 -1
- package/mobile/lib/retail/api/checkCode.d.ts +9 -1
- package/mobile/lib/retail/api/checkCode.js +22 -1
- package/mobile/lib/retail/api/checkCode.js.map +1 -1
- package/mobile/lib/retail/api/sendCode.d.ts +1 -1
- package/mobile/lib/retail/api/sendCode.js +7 -1
- package/mobile/lib/retail/api/sendCode.js.map +1 -1
- package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +4 -0
- package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +10 -4
- package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +6 -1
- package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +6 -3
- package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
- package/mobile/lib/retail/utils/mockLocalStorage.js +2 -2
- package/mobile/lib/retail/utils/mockLocalStorage.js.map +1 -1
- package/mobile/src/api/LeadServiceAPI.ts +64 -82
- package/mobile/src/api/getSubmitBody.ts +94 -0
- package/mobile/src/components/ApplicationForm/ApplicationForm.example.json +2 -2
- package/mobile/src/components/ApplicationForm/ApplicationForm.tsx +33 -4
- package/mobile/src/components/ApplicationForm/ApplicationFormContent.ts +1 -1
- package/mobile/src/components/DebitForm/DebitFormProgress.tsx +4 -9
- package/mobile/src/components/DebitForm/PendingStatusContent.tsx +1 -1
- package/mobile/src/retail/api/checkCode.ts +47 -2
- package/mobile/src/retail/api/sendCode.ts +9 -1
- package/mobile/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +29 -8
- package/mobile/src/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +18 -5
- package/mobile/src/retail/utils/mockLocalStorage.ts +15 -9
- package/package.json +1 -1
- package/src/api/LeadServiceAPI.ts +64 -82
- package/src/api/getSubmitBody.ts +94 -0
- package/src/components/ApplicationForm/ApplicationForm.example.json +2 -2
- package/src/components/ApplicationForm/ApplicationForm.fixture.mobile.tsx +2 -2
- package/src/components/ApplicationForm/ApplicationForm.fixture.tsx +24 -2
- package/src/components/ApplicationForm/ApplicationForm.tsx +33 -4
- package/src/components/ApplicationForm/ApplicationFormContent.ts +1 -1
- package/src/components/DebitForm/DebitFormProgress.tsx +4 -9
- package/src/components/DebitForm/PendingStatusContent.tsx +1 -1
- package/src/retail/api/checkCode.ts +47 -2
- package/src/retail/api/sendCode.ts +9 -1
- package/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +29 -8
- package/src/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +18 -5
- package/src/retail/utils/mockLocalStorage.ts +15 -9
|
@@ -6,6 +6,7 @@ import { useAspects } from '../../hooks/useAspects/useAspects';
|
|
|
6
6
|
import { useForm, type FormFieldRegisterer } from '../../hooks/useForm/useForm';
|
|
7
7
|
import { type FormTypeFieldDef } from '../../model/FormTypeFieldDef';
|
|
8
8
|
import { type SectionsProps } from '../../model/InputSectionsType';
|
|
9
|
+
import { VerifyPhoneDialog } from '../../retail/components/VerifyPhoneDialog/VerifyPhoneDialog';
|
|
9
10
|
import { ApplicationFormLayout } from '../../ui-kit/ApplicationFormLayout/ApplicationFormLayout';
|
|
10
11
|
import { useDialog } from '../../ui-kit/DialogManager/useDialog';
|
|
11
12
|
import { getConsentDataProcessing } from '../../ui-kit/FormField/getConsentDataProcessing';
|
|
@@ -38,6 +39,7 @@ type renderSectionsType = {
|
|
|
38
39
|
const API = LeadServiceAPI();
|
|
39
40
|
|
|
40
41
|
export const ApplicationForm = UniBlock<ApplicationFormProps>(
|
|
42
|
+
// eslint-disable-next-line max-lines-per-function
|
|
41
43
|
({
|
|
42
44
|
className,
|
|
43
45
|
title,
|
|
@@ -66,14 +68,41 @@ export const ApplicationForm = UniBlock<ApplicationFormProps>(
|
|
|
66
68
|
const responseTypeDialog = useDialog(ResponseTypeDialog);
|
|
67
69
|
const aspects = useAspects();
|
|
68
70
|
|
|
71
|
+
const verifyPhoneDialog = useDialog(VerifyPhoneDialog);
|
|
72
|
+
|
|
69
73
|
const handleSubmit = useCallback(
|
|
70
74
|
async (formData: FormState, ev: PreventableEventWithTarget) => {
|
|
71
75
|
const formatData = getFormatData({ ...formData, ...additionalParams });
|
|
72
|
-
const ok = Boolean(await API.send(formatData, router, endpoint === 'lead'));
|
|
73
76
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
if (endpoint === 'initcorporatelead') {
|
|
78
|
+
const { phone } = formatData;
|
|
79
|
+
|
|
80
|
+
const response = await API.sendCode({ phone: String(phone) });
|
|
81
|
+
|
|
82
|
+
if (!response) {
|
|
83
|
+
responseTypeDialog.open({ ok: Boolean(response), typeForm });
|
|
84
|
+
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
verifyPhoneDialog.open({
|
|
89
|
+
phone,
|
|
90
|
+
withDescription: false,
|
|
91
|
+
formatData,
|
|
92
|
+
reqId: String(response),
|
|
93
|
+
isRetail: false,
|
|
94
|
+
onSuccess: () => {
|
|
95
|
+
verifyPhoneDialog.close();
|
|
96
|
+
responseTypeDialog.open({ ok: true, typeForm });
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
const ok = Boolean(await API.send(formatData, router, endpoint === 'lead'));
|
|
101
|
+
|
|
102
|
+
responseTypeDialog.open({ ok, typeForm });
|
|
103
|
+
if (ok) {
|
|
104
|
+
handleAspects({ aspectsAttributes: data, aspects, ev });
|
|
105
|
+
}
|
|
77
106
|
}
|
|
78
107
|
},
|
|
79
108
|
[typeForm],
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import { useMemo } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
2
|
import { ProgressBar } from '../../ui-kit/ProgressBar/ProgressBar';
|
|
4
3
|
|
|
5
4
|
export interface DebitFormProgressProps {
|
|
@@ -10,17 +9,13 @@ export interface DebitFormProgressProps {
|
|
|
10
9
|
|
|
11
10
|
export const DebitFormProgress = JSX<DebitFormProgressProps>(
|
|
12
11
|
({ step = 1, totalSteps = 2, stepsTitles = [] }) => {
|
|
13
|
-
const
|
|
12
|
+
const isFinalStep = step === totalSteps;
|
|
13
|
+
const progress = isFinalStep ? 100 : 85;
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
<div className="py-lg px-5xl bg-white col-span-12">
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Шаг {step} из {totalSteps}.
|
|
20
|
-
</span>
|
|
21
|
-
{stepsTitles[step] || null}
|
|
22
|
-
<ProgressBar step={progress} showPercentage={false} />
|
|
23
|
-
</div>
|
|
17
|
+
{stepsTitles[step] || null}
|
|
18
|
+
<ProgressBar step={progress} showPercentage={false} />
|
|
24
19
|
</div>
|
|
25
20
|
);
|
|
26
21
|
},
|
|
@@ -2,5 +2,5 @@ import { JSX } from '@redneckz/uni-jsx';
|
|
|
2
2
|
import { DebitFormStatus } from './DebitFormStatus';
|
|
3
3
|
|
|
4
4
|
export const PendingStatusContent = JSX(() => (
|
|
5
|
-
<DebitFormStatus title="
|
|
5
|
+
<DebitFormStatus title="Не закрывайте заявку" description="Идёт проверка данных" />
|
|
6
6
|
));
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { LeadServiceAPI, type LeadRequest } from '../../api/LeadServiceAPI';
|
|
1
2
|
import { fetchRetailJSON } from './doRequest';
|
|
3
|
+
const API = LeadServiceAPI();
|
|
2
4
|
|
|
3
5
|
export type CheckCodeBody = {
|
|
4
6
|
smsText: string;
|
|
5
7
|
smsCodesSetName: {
|
|
6
8
|
key: 'AUTHENTICATION' | 'SEND_TASK';
|
|
7
9
|
};
|
|
10
|
+
reqId?: string;
|
|
11
|
+
body?: LeadRequest;
|
|
8
12
|
};
|
|
9
13
|
|
|
10
14
|
export type CheckCodeResponse = {
|
|
@@ -13,8 +17,32 @@ export type CheckCodeResponse = {
|
|
|
13
17
|
refresh_token: string;
|
|
14
18
|
};
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
type RetailBody = {
|
|
21
|
+
smsText: string;
|
|
22
|
+
smsCodesSetName: {
|
|
23
|
+
key: 'AUTHENTICATION' | 'SEND_TASK';
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type MainBody = {
|
|
28
|
+
code: string;
|
|
29
|
+
reqId: string;
|
|
30
|
+
body: LeadRequest;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type TransformedBody = RetailBody | MainBody;
|
|
34
|
+
|
|
35
|
+
export const checkCode = async (body: CheckCodeBody, isRetail: boolean) => {
|
|
36
|
+
const transformedBody = transformBody(body, isRetail);
|
|
37
|
+
|
|
38
|
+
return isRetail
|
|
39
|
+
? fetchRetailJSON<CheckCodeResponse>('/sms/checkCode', 'POST', transformedBody).then(saveToken)
|
|
40
|
+
: fetchMain(transformedBody as MainBody).then((res) => {
|
|
41
|
+
if (res === null) {
|
|
42
|
+
throw new Error('Неверный код');
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
18
46
|
|
|
19
47
|
export const saveToken = (data: CheckCodeResponse | null) => {
|
|
20
48
|
if (data?.access_token && data?.refresh_token) {
|
|
@@ -22,3 +50,20 @@ export const saveToken = (data: CheckCodeResponse | null) => {
|
|
|
22
50
|
globalThis.sessionStorage.setItem('refreshToken', data.refresh_token);
|
|
23
51
|
}
|
|
24
52
|
};
|
|
53
|
+
|
|
54
|
+
const fetchMain = (body: MainBody) => API.checkCode(body);
|
|
55
|
+
|
|
56
|
+
const transformBody = (
|
|
57
|
+
{ smsText, smsCodesSetName, body, reqId }: CheckCodeBody,
|
|
58
|
+
isRetail: boolean,
|
|
59
|
+
): TransformedBody => {
|
|
60
|
+
if (isRetail) {
|
|
61
|
+
return { smsText, smsCodesSetName };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!reqId || !body) {
|
|
65
|
+
throw new Error('Произошла ошибка, попробуйте позднее');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return { code: smsText, reqId, body };
|
|
69
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { LeadServiceAPI } from '../../api/LeadServiceAPI';
|
|
1
2
|
import { doRequest } from './doRequest';
|
|
3
|
+
const API = LeadServiceAPI();
|
|
2
4
|
|
|
3
5
|
export type SendCodeBody = {
|
|
4
6
|
phoneNumber: string;
|
|
@@ -7,7 +9,13 @@ export type SendCodeBody = {
|
|
|
7
9
|
};
|
|
8
10
|
};
|
|
9
11
|
|
|
10
|
-
export const sendCode = (body: SendCodeBody) =>
|
|
12
|
+
export const sendCode = (body: SendCodeBody, isRetail: boolean) => {
|
|
13
|
+
return isRetail ? fetchRetail(body) : fetchMain(body);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const fetchRetail = (body: SendCodeBody) =>
|
|
11
17
|
doRequest('/sms/sendCode', 'POST', body)
|
|
12
18
|
.then((res) => res.text())
|
|
13
19
|
.then((text) => text === 'OK');
|
|
20
|
+
|
|
21
|
+
const fetchMain = (body: SendCodeBody) => API.sendCode({ phone: body.phoneNumber });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable max-lines-per-function */
|
|
2
2
|
import { JSX } from '@redneckz/uni-jsx';
|
|
3
3
|
import { useCallback, useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
4
|
-
|
|
5
4
|
import { useSessionStore } from '@redneckz/uni-jsx/lib/Store/useSessionStore';
|
|
5
|
+
import { type LeadRequest } from '../../../api/LeadServiceAPI';
|
|
6
6
|
import { Headline } from '../../../components/Headline/Headline';
|
|
7
7
|
import type { OnCloseProps } from '../../../model/OnCloseProps';
|
|
8
8
|
import { Button } from '../../../ui-kit/Button/Button';
|
|
@@ -32,10 +32,22 @@ export interface VerifyPhoneDialogProps extends OnCloseProps {
|
|
|
32
32
|
withDescription?: boolean;
|
|
33
33
|
consents?: string[];
|
|
34
34
|
onSuccess?: (smsCode?: string) => void;
|
|
35
|
+
formatData?: LeadRequest;
|
|
36
|
+
reqId?: string;
|
|
37
|
+
isRetail?: boolean;
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
|
|
38
|
-
({
|
|
41
|
+
({
|
|
42
|
+
phone,
|
|
43
|
+
withDescription = true,
|
|
44
|
+
consents,
|
|
45
|
+
onSuccess = noop,
|
|
46
|
+
onClose = noop,
|
|
47
|
+
formatData,
|
|
48
|
+
reqId,
|
|
49
|
+
isRetail = true,
|
|
50
|
+
}) => {
|
|
39
51
|
const [values, setValues] = useState(Array(CODE_LENGTH).fill(''));
|
|
40
52
|
const sessionStore = useSessionStore<SmsCodeStore>();
|
|
41
53
|
|
|
@@ -48,7 +60,13 @@ export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
|
|
|
48
60
|
isSubmitButtonDisabled,
|
|
49
61
|
setTimeNextReq,
|
|
50
62
|
setErrorText,
|
|
51
|
-
} = useVerifyPhoneDialogSubmit({
|
|
63
|
+
} = useVerifyPhoneDialogSubmit({
|
|
64
|
+
values,
|
|
65
|
+
onSuccess,
|
|
66
|
+
formatData,
|
|
67
|
+
reqId,
|
|
68
|
+
isRetail,
|
|
69
|
+
});
|
|
52
70
|
|
|
53
71
|
const captchaDialog = useDialog(CaptchaDialog);
|
|
54
72
|
|
|
@@ -57,10 +75,13 @@ export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
|
|
|
57
75
|
const restartTimer = useCountDownTimer({ seconds: timeNextReq, onTick: setTimeNextReq });
|
|
58
76
|
|
|
59
77
|
const handleSendCode = useCallback(async () => {
|
|
60
|
-
const isSuccessSendCode = await sendCode(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
78
|
+
const isSuccessSendCode = await sendCode(
|
|
79
|
+
{
|
|
80
|
+
phoneNumber,
|
|
81
|
+
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
82
|
+
},
|
|
83
|
+
isRetail,
|
|
84
|
+
);
|
|
64
85
|
|
|
65
86
|
if (isSuccessSendCode) {
|
|
66
87
|
setTimeNextReq(TIME_TO_RESEND);
|
|
@@ -76,7 +97,7 @@ export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
|
|
|
76
97
|
}, [phoneNumber, restartTimer, onClose]);
|
|
77
98
|
|
|
78
99
|
useEffect(() => {
|
|
79
|
-
if (!sessionStore.smsCode?.sendTime) {
|
|
100
|
+
if (!sessionStore.smsCode?.sendTime && isRetail) {
|
|
80
101
|
handleSendCode();
|
|
81
102
|
}
|
|
82
103
|
}, []);
|
|
@@ -1,13 +1,18 @@
|
|
|
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 { type LeadRequest } from '../../../api/LeadServiceAPI';
|
|
4
5
|
import { checkCode } from '../../api/checkCode';
|
|
5
6
|
|
|
6
7
|
export const TIME_TO_RESEND = 180;
|
|
8
|
+
export const TIME_TO_MAIN_EXPIRE = 600;
|
|
7
9
|
|
|
8
10
|
type useVerifyPhoneDialogSubmitProps = {
|
|
9
11
|
values: string[];
|
|
10
12
|
onSuccess?: (smsCode?: string) => void;
|
|
13
|
+
formatData?: LeadRequest;
|
|
14
|
+
reqId?: string;
|
|
15
|
+
isRetail?: boolean;
|
|
11
16
|
};
|
|
12
17
|
|
|
13
18
|
export interface SmsCodeStore {
|
|
@@ -20,6 +25,9 @@ export interface SmsCodeStore {
|
|
|
20
25
|
export const useVerifyPhoneDialogSubmit = ({
|
|
21
26
|
values,
|
|
22
27
|
onSuccess,
|
|
28
|
+
formatData,
|
|
29
|
+
reqId,
|
|
30
|
+
isRetail = true,
|
|
23
31
|
}: useVerifyPhoneDialogSubmitProps) => {
|
|
24
32
|
const sessionStore = useSessionStore<SmsCodeStore>();
|
|
25
33
|
const attempts = sessionStore.smsCode?.attempts || 0;
|
|
@@ -41,10 +49,15 @@ export const useVerifyPhoneDialogSubmit = ({
|
|
|
41
49
|
attempts: attempts + 1,
|
|
42
50
|
};
|
|
43
51
|
startLoading();
|
|
44
|
-
await checkCode(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
await checkCode(
|
|
53
|
+
{
|
|
54
|
+
smsText: values.join(''),
|
|
55
|
+
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
56
|
+
body: isRetail ? undefined : formatData,
|
|
57
|
+
reqId: isRetail ? undefined : reqId,
|
|
58
|
+
},
|
|
59
|
+
isRetail,
|
|
60
|
+
);
|
|
48
61
|
setTimeNextReq(0);
|
|
49
62
|
resetError();
|
|
50
63
|
sessionStore.smsCode = null;
|
|
@@ -57,7 +70,7 @@ export const useVerifyPhoneDialogSubmit = ({
|
|
|
57
70
|
}, [values, attempts]);
|
|
58
71
|
|
|
59
72
|
useEffect(() => {
|
|
60
|
-
if (isTimeExpired) {
|
|
73
|
+
if (isTimeExpired && isRetail) {
|
|
61
74
|
setErrorText('Код просрочен');
|
|
62
75
|
} else if (attempts > 2) {
|
|
63
76
|
setErrorText('Исчерпан лимит ввода смс-кода');
|
|
@@ -13,15 +13,21 @@ export const mockLocalStorage = async () => {
|
|
|
13
13
|
globalThis.localStorage.getItem('profileId') ??
|
|
14
14
|
(await createUserProfile({ profile: { phone: PHONE } }));
|
|
15
15
|
|
|
16
|
-
await sendCode(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
await sendCode(
|
|
17
|
+
{
|
|
18
|
+
phoneNumber: PHONE,
|
|
19
|
+
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
20
|
+
},
|
|
21
|
+
true,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
await checkCode(
|
|
25
|
+
{
|
|
26
|
+
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
27
|
+
smsText: '1234',
|
|
28
|
+
},
|
|
29
|
+
true,
|
|
30
|
+
);
|
|
25
31
|
|
|
26
32
|
const task = {
|
|
27
33
|
taskId: globalThis.localStorage.getItem('taskId'),
|