@redneckz/wildless-cms-uni-blocks 0.14.911 → 0.14.913
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 +12 -3
- package/bundle/bundle.umd.js +716 -684
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/ApplicationForm/VerifyPhoneDialog.d.ts +10 -0
- package/bundle/components/ApplicationForm/useVerifyPhoneDialogSubmit.d.ts +18 -0
- package/bundle/components/TariffsTable/TariffsTableCell.d.ts +1 -1
- package/bundle/retail/api/checkCode.d.ts +1 -9
- package/bundle/retail/api/sendCode.d.ts +1 -1
- package/bundle/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +0 -4
- package/bundle/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -6
- package/bundle/ui-kit/ResponseTypeDialog/ResponseTypeDialog.d.ts +1 -1
- package/bundle/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.d.ts +16 -0
- package/bundle/utils/getTimer.d.ts +2 -0
- package/dist/api/LeadServiceAPI.d.ts +12 -3
- package/dist/api/LeadServiceAPI.js +0 -3
- package/dist/api/LeadServiceAPI.js.map +1 -1
- package/dist/components/ApplicationForm/ApplicationForm.js +1 -3
- package/dist/components/ApplicationForm/ApplicationForm.js.map +1 -1
- package/dist/components/ApplicationForm/VerifyPhoneDialog.d.ts +10 -0
- package/dist/components/ApplicationForm/VerifyPhoneDialog.js +37 -0
- package/dist/components/ApplicationForm/VerifyPhoneDialog.js.map +1 -0
- package/dist/components/ApplicationForm/useVerifyPhoneDialogSubmit.d.ts +18 -0
- package/dist/components/ApplicationForm/useVerifyPhoneDialogSubmit.js +50 -0
- package/dist/components/ApplicationForm/useVerifyPhoneDialogSubmit.js.map +1 -0
- package/dist/components/ExchangeRateTile/ExchangeCurrencyCalculator.js +2 -2
- package/dist/components/ExchangeRateTile/ExchangeCurrencyCalculator.js.map +1 -1
- package/dist/components/TariffsTable/TariffsTableCell.d.ts +1 -1
- package/dist/retail/api/checkCode.d.ts +1 -9
- package/dist/retail/api/checkCode.js +1 -22
- package/dist/retail/api/checkCode.js.map +1 -1
- package/dist/retail/api/sendCode.d.ts +1 -1
- package/dist/retail/api/sendCode.js +2 -8
- package/dist/retail/api/sendCode.js.map +1 -1
- package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +0 -4
- package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +5 -24
- package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -6
- package/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +7 -10
- 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/dist/ui-kit/ResponseTypeDialog/ResponseTypeDialog.d.ts +1 -1
- package/dist/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.d.ts +16 -0
- package/dist/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js +17 -0
- package/dist/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js.map +1 -0
- package/dist/utils/getTimer.d.ts +2 -0
- package/dist/utils/getTimer.js +6 -0
- package/dist/utils/getTimer.js.map +1 -0
- package/lib/api/LeadServiceAPI.d.ts +12 -3
- package/lib/api/LeadServiceAPI.js +0 -3
- package/lib/api/LeadServiceAPI.js.map +1 -1
- package/lib/common.css +1 -1
- package/lib/components/ApplicationForm/ApplicationForm.js +1 -3
- package/lib/components/ApplicationForm/ApplicationForm.js.map +1 -1
- package/lib/components/ApplicationForm/VerifyPhoneDialog.d.ts +10 -0
- package/lib/components/ApplicationForm/VerifyPhoneDialog.js +35 -0
- package/lib/components/ApplicationForm/VerifyPhoneDialog.js.map +1 -0
- package/lib/components/ApplicationForm/useVerifyPhoneDialogSubmit.d.ts +18 -0
- package/lib/components/ApplicationForm/useVerifyPhoneDialogSubmit.js +47 -0
- package/lib/components/ApplicationForm/useVerifyPhoneDialogSubmit.js.map +1 -0
- package/lib/components/ExchangeRateTile/ExchangeCurrencyCalculator.js +2 -2
- package/lib/components/ExchangeRateTile/ExchangeCurrencyCalculator.js.map +1 -1
- package/lib/components/TariffsTable/TariffsTableCell.d.ts +1 -1
- package/lib/retail/api/checkCode.d.ts +1 -9
- package/lib/retail/api/checkCode.js +1 -22
- package/lib/retail/api/checkCode.js.map +1 -1
- package/lib/retail/api/sendCode.d.ts +1 -1
- package/lib/retail/api/sendCode.js +1 -7
- package/lib/retail/api/sendCode.js.map +1 -1
- package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +0 -4
- package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +5 -24
- package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -6
- package/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +5 -8
- 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/lib/ui-kit/ResponseTypeDialog/ResponseTypeDialog.d.ts +1 -1
- package/lib/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.d.ts +16 -0
- package/lib/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js +15 -0
- package/lib/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js.map +1 -0
- package/lib/utils/getTimer.d.ts +2 -0
- package/lib/utils/getTimer.js +3 -0
- package/lib/utils/getTimer.js.map +1 -0
- package/mobile/bundle/api/LeadServiceAPI.d.ts +12 -3
- package/mobile/bundle/bundle.umd.js +716 -684
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/ApplicationForm/VerifyPhoneDialog.d.ts +10 -0
- package/mobile/bundle/components/ApplicationForm/useVerifyPhoneDialogSubmit.d.ts +18 -0
- package/mobile/bundle/components/TariffsTable/TariffsTableCell.d.ts +1 -1
- package/mobile/bundle/retail/api/checkCode.d.ts +1 -9
- package/mobile/bundle/retail/api/sendCode.d.ts +1 -1
- package/mobile/bundle/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +0 -4
- package/mobile/bundle/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -6
- package/mobile/bundle/ui-kit/ResponseTypeDialog/ResponseTypeDialog.d.ts +1 -1
- package/mobile/bundle/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.d.ts +16 -0
- package/mobile/bundle/utils/getTimer.d.ts +2 -0
- package/mobile/dist/api/LeadServiceAPI.d.ts +12 -3
- package/mobile/dist/api/LeadServiceAPI.js +0 -3
- package/mobile/dist/api/LeadServiceAPI.js.map +1 -1
- package/mobile/dist/components/ApplicationForm/ApplicationForm.js +1 -3
- package/mobile/dist/components/ApplicationForm/ApplicationForm.js.map +1 -1
- package/mobile/dist/components/ApplicationForm/VerifyPhoneDialog.d.ts +10 -0
- package/mobile/dist/components/ApplicationForm/VerifyPhoneDialog.js +37 -0
- package/mobile/dist/components/ApplicationForm/VerifyPhoneDialog.js.map +1 -0
- package/mobile/dist/components/ApplicationForm/useVerifyPhoneDialogSubmit.d.ts +18 -0
- package/mobile/dist/components/ApplicationForm/useVerifyPhoneDialogSubmit.js +50 -0
- package/mobile/dist/components/ApplicationForm/useVerifyPhoneDialogSubmit.js.map +1 -0
- package/mobile/dist/components/ExchangeRateTile/ExchangeCurrencyCalculator.js +2 -2
- package/mobile/dist/components/ExchangeRateTile/ExchangeCurrencyCalculator.js.map +1 -1
- package/mobile/dist/components/TariffsTable/TariffsTableCell.d.ts +1 -1
- package/mobile/dist/retail/api/checkCode.d.ts +1 -9
- package/mobile/dist/retail/api/checkCode.js +1 -22
- 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 +2 -8
- package/mobile/dist/retail/api/sendCode.js.map +1 -1
- package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +0 -4
- package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +5 -24
- package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -6
- package/mobile/dist/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +7 -10
- 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/dist/ui-kit/ResponseTypeDialog/ResponseTypeDialog.d.ts +1 -1
- package/mobile/dist/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.d.ts +16 -0
- package/mobile/dist/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js +17 -0
- package/mobile/dist/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js.map +1 -0
- package/mobile/dist/utils/getTimer.d.ts +2 -0
- package/mobile/dist/utils/getTimer.js +6 -0
- package/mobile/dist/utils/getTimer.js.map +1 -0
- package/mobile/lib/api/LeadServiceAPI.d.ts +12 -3
- package/mobile/lib/api/LeadServiceAPI.js +0 -3
- package/mobile/lib/api/LeadServiceAPI.js.map +1 -1
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/ApplicationForm/ApplicationForm.js +1 -3
- package/mobile/lib/components/ApplicationForm/ApplicationForm.js.map +1 -1
- package/mobile/lib/components/ApplicationForm/VerifyPhoneDialog.d.ts +10 -0
- package/mobile/lib/components/ApplicationForm/VerifyPhoneDialog.js +35 -0
- package/mobile/lib/components/ApplicationForm/VerifyPhoneDialog.js.map +1 -0
- package/mobile/lib/components/ApplicationForm/useVerifyPhoneDialogSubmit.d.ts +18 -0
- package/mobile/lib/components/ApplicationForm/useVerifyPhoneDialogSubmit.js +47 -0
- package/mobile/lib/components/ApplicationForm/useVerifyPhoneDialogSubmit.js.map +1 -0
- package/mobile/lib/components/ExchangeRateTile/ExchangeCurrencyCalculator.js +2 -2
- package/mobile/lib/components/ExchangeRateTile/ExchangeCurrencyCalculator.js.map +1 -1
- package/mobile/lib/components/TariffsTable/TariffsTableCell.d.ts +1 -1
- package/mobile/lib/retail/api/checkCode.d.ts +1 -9
- package/mobile/lib/retail/api/checkCode.js +1 -22
- 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 +1 -7
- package/mobile/lib/retail/api/sendCode.js.map +1 -1
- package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +0 -4
- package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +5 -24
- package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -6
- package/mobile/lib/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +5 -8
- 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/lib/ui-kit/ResponseTypeDialog/ResponseTypeDialog.d.ts +1 -1
- package/mobile/lib/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.d.ts +16 -0
- package/mobile/lib/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js +15 -0
- package/mobile/lib/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.js.map +1 -0
- package/mobile/lib/utils/getTimer.d.ts +2 -0
- package/mobile/lib/utils/getTimer.js +3 -0
- package/mobile/lib/utils/getTimer.js.map +1 -0
- package/mobile/src/api/LeadServiceAPI.ts +13 -7
- package/mobile/src/components/ApplicationForm/ApplicationForm.tsx +1 -3
- package/mobile/src/components/ApplicationForm/VerifyPhoneDialog.tsx +73 -0
- package/mobile/src/components/ApplicationForm/useVerifyPhoneDialogSubmit.tsx +63 -0
- package/mobile/src/components/ExchangeRateTile/ExchangeCurrencyCalculator.tsx +2 -2
- package/mobile/src/components/TariffsTable/TariffsTableCell.tsx +1 -1
- package/mobile/src/retail/api/checkCode.ts +2 -47
- package/mobile/src/retail/api/sendCode.ts +1 -9
- package/mobile/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +23 -82
- package/mobile/src/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +7 -21
- package/mobile/src/retail/utils/mockLocalStorage.ts +9 -15
- package/mobile/src/ui-kit/ResponseTypeDialog/ResponseTypeDialog.tsx +1 -1
- package/mobile/src/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.tsx +80 -0
- package/mobile/src/utils/getTimer.ts +4 -0
- package/package.json +1 -1
- package/src/api/LeadServiceAPI.ts +13 -7
- package/src/components/ApplicationForm/ApplicationForm.tsx +1 -3
- package/src/components/ApplicationForm/VerifyPhoneDialog.tsx +73 -0
- package/src/components/ApplicationForm/useVerifyPhoneDialogSubmit.tsx +63 -0
- package/src/components/ExchangeRateTile/ExchangeCurrencyCalculator.tsx +2 -2
- package/src/components/TariffsTable/TariffsTableCell.tsx +1 -1
- package/src/retail/api/checkCode.ts +2 -47
- package/src/retail/api/sendCode.ts +1 -9
- package/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +23 -82
- package/src/retail/components/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +7 -21
- package/src/retail/utils/mockLocalStorage.ts +9 -15
- package/src/ui-kit/ResponseTypeDialog/ResponseTypeDialog.tsx +1 -1
- package/src/ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout.tsx +80 -0
- package/src/utils/getTimer.ts +4 -0
- package/bundle/model/onClose.d.ts +0 -3
- package/dist/model/onClose.d.ts +0 -3
- package/dist/model/onClose.js +0 -2
- package/dist/model/onClose.js.map +0 -1
- package/lib/model/onClose.d.ts +0 -3
- package/lib/model/onClose.js +0 -2
- package/lib/model/onClose.js.map +0 -1
- package/mobile/bundle/model/onClose.d.ts +0 -3
- package/mobile/dist/model/onClose.d.ts +0 -3
- package/mobile/dist/model/onClose.js +0 -2
- package/mobile/dist/model/onClose.js.map +0 -1
- package/mobile/lib/model/onClose.d.ts +0 -3
- package/mobile/lib/model/onClose.js +0 -2
- package/mobile/lib/model/onClose.js.map +0 -1
- package/mobile/src/model/onClose.ts +0 -3
- package/src/model/onClose.ts +0 -3
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
import { useBool } from '@redneckz/uni-jsx/lib/hooks/useBool';
|
|
3
|
+
import { LeadServiceAPI, type LeadRequest } from '../../api/LeadServiceAPI';
|
|
4
|
+
import { getTimer } from '../../utils/getTimer';
|
|
5
|
+
const API = LeadServiceAPI();
|
|
6
|
+
|
|
7
|
+
type useVerifyPhoneDialogSubmitProps = {
|
|
8
|
+
values: string[];
|
|
9
|
+
formatData: LeadRequest;
|
|
10
|
+
reqId: string;
|
|
11
|
+
onSuccess?: (smsCode?: string) => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const useVerifyPhoneDialogSubmit = ({
|
|
15
|
+
values,
|
|
16
|
+
onSuccess,
|
|
17
|
+
formatData,
|
|
18
|
+
reqId,
|
|
19
|
+
}: useVerifyPhoneDialogSubmitProps) => {
|
|
20
|
+
const timer = Math.max(getTimer(Date.now()), 0);
|
|
21
|
+
|
|
22
|
+
const [errorText, setErrorText] = useState('');
|
|
23
|
+
const [isLoading, { setTrue: startLoading, setFalse: endLoading }] = useBool(false);
|
|
24
|
+
const [timeNextReq, setTimeNextReq] = useState(timer);
|
|
25
|
+
|
|
26
|
+
const resetError = useCallback(() => setErrorText(''), []);
|
|
27
|
+
|
|
28
|
+
const isSubmitButtonDisabled = !values.every(Boolean);
|
|
29
|
+
|
|
30
|
+
const handleSubmit = useCallback(async () => {
|
|
31
|
+
try {
|
|
32
|
+
startLoading();
|
|
33
|
+
const response = await API.checkCode({
|
|
34
|
+
code: values.join(''),
|
|
35
|
+
body: formatData,
|
|
36
|
+
reqId,
|
|
37
|
+
});
|
|
38
|
+
if (response?.errorDesc) {
|
|
39
|
+
setErrorText(response?.errorDesc);
|
|
40
|
+
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
setTimeNextReq(0);
|
|
44
|
+
resetError();
|
|
45
|
+
onSuccess?.(values.join(''));
|
|
46
|
+
} catch {
|
|
47
|
+
setErrorText('Неверный код');
|
|
48
|
+
} finally {
|
|
49
|
+
endLoading();
|
|
50
|
+
}
|
|
51
|
+
}, [values]);
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
handleSubmit,
|
|
55
|
+
hasError: Boolean(errorText),
|
|
56
|
+
errorText,
|
|
57
|
+
isLoading,
|
|
58
|
+
timeNextReq,
|
|
59
|
+
isSubmitButtonDisabled,
|
|
60
|
+
setTimeNextReq,
|
|
61
|
+
setErrorText,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
@@ -131,7 +131,7 @@ const handleInputSell =
|
|
|
131
131
|
(value: string, currencyFrom: Currency, currencyTo: Currency) => {
|
|
132
132
|
setCalcState({ inputSell: formatValue(value), selectBuy: currencyTo });
|
|
133
133
|
const rate =
|
|
134
|
-
currencyRatesSell.find((_) => _.currency?.currency === currencyTo)?.
|
|
134
|
+
currencyRatesSell.find((_) => _.currency?.currency === currencyTo)?.saleExchangeRate ||
|
|
135
135
|
currencyRatesSell.find((_) => _.currency?.currency === currencyFrom)?.buyExchangeRate;
|
|
136
136
|
if (rate) {
|
|
137
137
|
setCalcState({
|
|
@@ -145,7 +145,7 @@ const handleInputBuy =
|
|
|
145
145
|
(value: string, currencyTo: Currency, currencyFrom: Currency) => {
|
|
146
146
|
setCalcState({ inputBuy: formatValue(value), selectSell: currencyFrom });
|
|
147
147
|
const rate =
|
|
148
|
-
currencyRatesBuy.find((_) => _.currency?.currency === currencyFrom)?.
|
|
148
|
+
currencyRatesBuy.find((_) => _.currency?.currency === currencyFrom)?.buyExchangeRate ||
|
|
149
149
|
currencyRatesBuy.find((_) => _.currency?.currency === currencyTo)?.saleExchangeRate;
|
|
150
150
|
if (rate) {
|
|
151
151
|
setCalcState({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
2
|
import type { JSONRefObject } from '../../data/JSONRefObject';
|
|
3
|
-
import { type OnCloseProps } from '../../model/
|
|
3
|
+
import { type OnCloseProps } from '../../model/OnCloseProps';
|
|
4
4
|
import { TableInnerButton } from '../../ui-kit/InnerTable/InnerTableButton';
|
|
5
5
|
import {
|
|
6
6
|
type TableFetchData,
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { LeadServiceAPI, type LeadRequest } from '../../api/LeadServiceAPI';
|
|
2
1
|
import { fetchRetailJSON } from './doRequest';
|
|
3
|
-
const API = LeadServiceAPI();
|
|
4
2
|
|
|
5
3
|
export type CheckCodeBody = {
|
|
6
4
|
smsText: string;
|
|
7
5
|
smsCodesSetName: {
|
|
8
6
|
key: 'AUTHENTICATION' | 'SEND_TASK';
|
|
9
7
|
};
|
|
10
|
-
reqId?: string;
|
|
11
|
-
body?: LeadRequest;
|
|
12
8
|
};
|
|
13
9
|
|
|
14
10
|
export type CheckCodeResponse = {
|
|
@@ -17,32 +13,8 @@ export type CheckCodeResponse = {
|
|
|
17
13
|
refresh_token: string;
|
|
18
14
|
};
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
};
|
|
16
|
+
export const checkCode = async (body: CheckCodeBody) =>
|
|
17
|
+
fetchRetailJSON<CheckCodeResponse>('/sms/checkCode', 'POST', body).then(saveToken);
|
|
46
18
|
|
|
47
19
|
export const saveToken = (data: CheckCodeResponse | null) => {
|
|
48
20
|
if (data?.access_token && data?.refresh_token) {
|
|
@@ -50,20 +22,3 @@ export const saveToken = (data: CheckCodeResponse | null) => {
|
|
|
50
22
|
globalThis.sessionStorage.setItem('refreshToken', data.refresh_token);
|
|
51
23
|
}
|
|
52
24
|
};
|
|
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,6 +1,4 @@
|
|
|
1
|
-
import { LeadServiceAPI } from '../../api/LeadServiceAPI';
|
|
2
1
|
import { doRequest } from './doRequest';
|
|
3
|
-
const API = LeadServiceAPI();
|
|
4
2
|
|
|
5
3
|
export type SendCodeBody = {
|
|
6
4
|
phoneNumber: string;
|
|
@@ -9,13 +7,7 @@ export type SendCodeBody = {
|
|
|
9
7
|
};
|
|
10
8
|
};
|
|
11
9
|
|
|
12
|
-
export const sendCode = (body: SendCodeBody
|
|
13
|
-
return isRetail ? fetchRetail(body) : fetchMain(body);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const fetchRetail = (body: SendCodeBody) =>
|
|
10
|
+
export const sendCode = (body: SendCodeBody) =>
|
|
17
11
|
doRequest('/sms/sendCode', 'POST', body)
|
|
18
12
|
.then((res) => res.text())
|
|
19
13
|
.then((text) => text === 'OK');
|
|
20
|
-
|
|
21
|
-
const fetchMain = (body: SendCodeBody) => API.sendCode({ phone: body.phoneNumber });
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
2
|
import { useCallback, useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
3
|
import { useSessionStore } from '@redneckz/uni-jsx/lib/Store/useSessionStore';
|
|
4
|
-
import { type LeadRequest } from '../../../api/LeadServiceAPI';
|
|
5
|
-
import { Headline } from '../../../components/Headline/Headline';
|
|
6
4
|
import type { OnCloseProps } from '../../../model/OnCloseProps';
|
|
7
|
-
import { Button } from '../../../ui-kit/Button/Button';
|
|
8
|
-
import { ButtonTitle } from '../../../ui-kit/Button/ButtonTitle';
|
|
9
|
-
import { Dialog } from '../../../ui-kit/DialogManager/Dialog';
|
|
10
5
|
import { useDialog } from '../../../ui-kit/DialogManager/useDialog';
|
|
11
|
-
import { Loader } from '../../../ui-kit/Loader/Loader';
|
|
12
6
|
import { RichText } from '../../../ui-kit/RichText/RichText';
|
|
13
|
-
import { Timer } from '../../../ui-kit/TimerCircle/Timer';
|
|
14
7
|
import { useCountDownTimer } from '../../../ui-kit/TimerCircle/useCountDownTimer';
|
|
8
|
+
import { VerifyPhoneDialogLayout } from '../../../ui-kit/VerifyPhoneDialogLayout/VerfiyPhoneDialogLayout';
|
|
15
9
|
import { formatPhone } from '../../../utils/formatPhone';
|
|
16
10
|
import { noop } from '../../../utils/noop';
|
|
17
11
|
import { sendCode } from '../../api/sendCode';
|
|
18
12
|
import { CaptchaDialog } from '../CaptchaDialog/CaptchaDialog';
|
|
19
|
-
import { InputCode } from './InputCode';
|
|
20
|
-
import { SubmitButton } from './SubmitButton';
|
|
21
13
|
import {
|
|
22
14
|
TIME_TO_RESEND,
|
|
23
15
|
useVerifyPhoneDialogSubmit,
|
|
@@ -31,26 +23,12 @@ export interface VerifyPhoneDialogProps extends OnCloseProps {
|
|
|
31
23
|
withDescription?: boolean;
|
|
32
24
|
consents?: string[];
|
|
33
25
|
onSuccess?: (smsCode?: string) => void;
|
|
34
|
-
formatData?: LeadRequest;
|
|
35
|
-
reqId?: string;
|
|
36
|
-
isRetail?: boolean;
|
|
37
26
|
}
|
|
38
27
|
|
|
39
28
|
export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
phone,
|
|
43
|
-
withDescription = true,
|
|
44
|
-
consents,
|
|
45
|
-
onSuccess = noop,
|
|
46
|
-
onClose = noop,
|
|
47
|
-
formatData,
|
|
48
|
-
reqId,
|
|
49
|
-
isRetail = true,
|
|
50
|
-
}) => {
|
|
51
|
-
const [values, setValues] = useState(Array(CODE_LENGTH).fill(''));
|
|
29
|
+
({ phone, withDescription = true, consents, onSuccess = noop, onClose = noop }) => {
|
|
30
|
+
const [values, setValues] = useState<string[]>(Array(CODE_LENGTH).fill('') as string[]);
|
|
52
31
|
const sessionStore = useSessionStore<SmsCodeStore>();
|
|
53
|
-
const [requestId, setRequestId] = useState(reqId);
|
|
54
32
|
|
|
55
33
|
const {
|
|
56
34
|
handleSubmit,
|
|
@@ -64,9 +42,6 @@ export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
|
|
|
64
42
|
} = useVerifyPhoneDialogSubmit({
|
|
65
43
|
values,
|
|
66
44
|
onSuccess,
|
|
67
|
-
formatData,
|
|
68
|
-
reqId: requestId,
|
|
69
|
-
isRetail,
|
|
70
45
|
});
|
|
71
46
|
|
|
72
47
|
const captchaDialog = useDialog(CaptchaDialog);
|
|
@@ -74,13 +49,10 @@ export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
|
|
|
74
49
|
const restartTimer = useCountDownTimer({ seconds: timeNextReq, onTick: setTimeNextReq });
|
|
75
50
|
|
|
76
51
|
const handleSendCode = useCallback(async () => {
|
|
77
|
-
const response = await sendCode(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
isRetail,
|
|
83
|
-
);
|
|
52
|
+
const response = await sendCode({
|
|
53
|
+
phoneNumber,
|
|
54
|
+
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
55
|
+
});
|
|
84
56
|
|
|
85
57
|
if (response) {
|
|
86
58
|
setTimeNextReq(TIME_TO_RESEND);
|
|
@@ -90,52 +62,37 @@ export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
|
|
|
90
62
|
sendTime: Date.now(),
|
|
91
63
|
attempts: 0,
|
|
92
64
|
};
|
|
93
|
-
|
|
94
|
-
if (!isRetail) {
|
|
95
|
-
setRequestId(String(response));
|
|
96
|
-
}
|
|
97
65
|
} else {
|
|
98
66
|
captchaDialog.open({ phoneNumber, sendCode: handleSendCode });
|
|
99
67
|
}
|
|
100
68
|
}, [phoneNumber, restartTimer, onClose]);
|
|
101
69
|
|
|
102
70
|
useEffect(() => {
|
|
103
|
-
if (!sessionStore.smsCode?.sendTime
|
|
71
|
+
if (!sessionStore.smsCode?.sendTime) {
|
|
104
72
|
handleSendCode();
|
|
105
73
|
}
|
|
106
74
|
}, []);
|
|
107
75
|
|
|
108
76
|
return (
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
</
|
|
77
|
+
<VerifyPhoneDialogLayout
|
|
78
|
+
isSubmitButtonDisabled={isSubmitButtonDisabled}
|
|
79
|
+
onSubmit={handleSubmit}
|
|
80
|
+
onSendCode={handleSendCode}
|
|
81
|
+
timeNextReq={timeNextReq}
|
|
82
|
+
values={values}
|
|
83
|
+
onChange={setValues}
|
|
84
|
+
phone={phone}
|
|
85
|
+
isLoading={isLoading}
|
|
86
|
+
errorText={errorText}
|
|
87
|
+
hasError={hasError}
|
|
88
|
+
onClose={onClose}
|
|
89
|
+
>
|
|
90
|
+
{renderDescription(consents, withDescription)}
|
|
91
|
+
</VerifyPhoneDialogLayout>
|
|
124
92
|
);
|
|
125
93
|
},
|
|
126
94
|
);
|
|
127
95
|
|
|
128
|
-
const renderHeadline = (phone: string) => (
|
|
129
|
-
<Headline
|
|
130
|
-
className="w-full"
|
|
131
|
-
title="Подтвердите номер телефона"
|
|
132
|
-
description={`Мы отправили код на ${phone}`}
|
|
133
|
-
headlineVersion="XS"
|
|
134
|
-
isEmbedded={true}
|
|
135
|
-
as="h6"
|
|
136
|
-
/>
|
|
137
|
-
);
|
|
138
|
-
|
|
139
96
|
const renderDescription = (consents?: string[], isRender = false) =>
|
|
140
97
|
isRender ? (
|
|
141
98
|
<RichText itemSize="list-s">
|
|
@@ -147,19 +104,3 @@ const renderDescription = (consents?: string[], isRender = false) =>
|
|
|
147
104
|
</ul>
|
|
148
105
|
</RichText>
|
|
149
106
|
) : null;
|
|
150
|
-
|
|
151
|
-
const renderNextButton = (disabled: boolean, onClick: () => void) => (
|
|
152
|
-
<SubmitButton text="Далее" disabled={disabled} onClick={onClick} />
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
const renderText = (timeNextReq: number, handleSendCode: () => void) =>
|
|
156
|
-
timeNextReq ? (
|
|
157
|
-
<div className="flex flex-row text-l font-light text-base">
|
|
158
|
-
Получить новый код можно через
|
|
159
|
-
<Timer className="pl-2xs" seconds={timeNextReq} />
|
|
160
|
-
</div>
|
|
161
|
-
) : (
|
|
162
|
-
<Button embedded onClick={handleSendCode}>
|
|
163
|
-
<ButtonTitle>Получить новый код</ButtonTitle>
|
|
164
|
-
</Button>
|
|
165
|
-
);
|
|
@@ -1,18 +1,14 @@
|
|
|
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 {
|
|
4
|
+
import { getTimer } from '../../../utils/getTimer';
|
|
5
5
|
import { checkCode } from '../../api/checkCode';
|
|
6
6
|
|
|
7
7
|
export const TIME_TO_RESEND = 180;
|
|
8
|
-
export const TIME_TO_MAIN_EXPIRE = 600;
|
|
9
8
|
|
|
10
9
|
type useVerifyPhoneDialogSubmitProps = {
|
|
11
10
|
values: string[];
|
|
12
11
|
onSuccess?: (smsCode?: string) => void;
|
|
13
|
-
formatData?: LeadRequest;
|
|
14
|
-
reqId?: string;
|
|
15
|
-
isRetail?: boolean;
|
|
16
12
|
};
|
|
17
13
|
|
|
18
14
|
export interface SmsCodeStore {
|
|
@@ -25,9 +21,6 @@ export interface SmsCodeStore {
|
|
|
25
21
|
export const useVerifyPhoneDialogSubmit = ({
|
|
26
22
|
values,
|
|
27
23
|
onSuccess,
|
|
28
|
-
formatData,
|
|
29
|
-
reqId,
|
|
30
|
-
isRetail = true,
|
|
31
24
|
}: useVerifyPhoneDialogSubmitProps) => {
|
|
32
25
|
const sessionStore = useSessionStore<SmsCodeStore>();
|
|
33
26
|
const attempts = sessionStore.smsCode?.attempts || 0;
|
|
@@ -49,19 +42,14 @@ export const useVerifyPhoneDialogSubmit = ({
|
|
|
49
42
|
attempts: attempts + 1,
|
|
50
43
|
};
|
|
51
44
|
startLoading();
|
|
52
|
-
await checkCode(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
body: isRetail ? undefined : formatData,
|
|
57
|
-
reqId: isRetail ? undefined : reqId,
|
|
58
|
-
},
|
|
59
|
-
isRetail,
|
|
60
|
-
);
|
|
45
|
+
await checkCode({
|
|
46
|
+
smsText: values.join(''),
|
|
47
|
+
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
48
|
+
});
|
|
61
49
|
setTimeNextReq(0);
|
|
62
50
|
resetError();
|
|
63
51
|
sessionStore.smsCode = null;
|
|
64
|
-
|
|
52
|
+
onSuccess?.(values.join(''));
|
|
65
53
|
} catch {
|
|
66
54
|
setErrorText(attempts > 1 ? 'Исчерпан лимит ввода смс-кода' : 'Неверный код');
|
|
67
55
|
} finally {
|
|
@@ -70,7 +58,7 @@ export const useVerifyPhoneDialogSubmit = ({
|
|
|
70
58
|
}, [values, attempts]);
|
|
71
59
|
|
|
72
60
|
useEffect(() => {
|
|
73
|
-
if (isTimeExpired
|
|
61
|
+
if (isTimeExpired) {
|
|
74
62
|
setErrorText('Код просрочен');
|
|
75
63
|
} else if (attempts > 2) {
|
|
76
64
|
setErrorText('Исчерпан лимит ввода смс-кода');
|
|
@@ -88,5 +76,3 @@ export const useVerifyPhoneDialogSubmit = ({
|
|
|
88
76
|
setErrorText,
|
|
89
77
|
};
|
|
90
78
|
};
|
|
91
|
-
|
|
92
|
-
const getTimer = (sendTime: number) => TIME_TO_RESEND - Math.floor((Date.now() - sendTime) / 1000);
|
|
@@ -13,21 +13,15 @@ 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
|
-
|
|
25
|
-
{
|
|
26
|
-
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
27
|
-
smsText: '1234',
|
|
28
|
-
},
|
|
29
|
-
true,
|
|
30
|
-
);
|
|
16
|
+
await sendCode({
|
|
17
|
+
phoneNumber: PHONE,
|
|
18
|
+
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
await checkCode({
|
|
22
|
+
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
23
|
+
smsText: '1234',
|
|
24
|
+
});
|
|
31
25
|
|
|
32
26
|
const task = {
|
|
33
27
|
taskId: globalThis.localStorage.getItem('taskId'),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
2
|
import { Headline } from '../../components/Headline/Headline';
|
|
3
|
-
import { type OnCloseProps } from '../../model/
|
|
3
|
+
import { type OnCloseProps } from '../../model/OnCloseProps';
|
|
4
4
|
import { Button } from '../Button/Button';
|
|
5
5
|
import { Dialog } from '../DialogManager/Dialog';
|
|
6
6
|
import { Img } from '../Img/Img';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { Headline } from '../../components/Headline/Headline';
|
|
3
|
+
import { type OnCloseProps } from '../../model/OnCloseProps';
|
|
4
|
+
import { type VNode } from '../../model/VNode';
|
|
5
|
+
import { InputCode } from '../../retail/components/VerifyPhoneDialog/InputCode';
|
|
6
|
+
import { SubmitButton } from '../../retail/components/VerifyPhoneDialog/SubmitButton';
|
|
7
|
+
import { Button } from '../Button/Button';
|
|
8
|
+
import { ButtonTitle } from '../Button/ButtonTitle';
|
|
9
|
+
import { Dialog } from '../DialogManager/Dialog';
|
|
10
|
+
import { Loader } from '../Loader/Loader';
|
|
11
|
+
import { Timer } from '../TimerCircle/Timer';
|
|
12
|
+
|
|
13
|
+
export interface VerifyPhoneDialogProps extends OnCloseProps {
|
|
14
|
+
isSubmitButtonDisabled: boolean;
|
|
15
|
+
onSubmit: () => Promise<void>;
|
|
16
|
+
onSendCode: () => Promise<void>;
|
|
17
|
+
timeNextReq: number;
|
|
18
|
+
values: string[];
|
|
19
|
+
onChange: (values: string[]) => void;
|
|
20
|
+
phone: string;
|
|
21
|
+
children?: VNode;
|
|
22
|
+
isLoading?: boolean;
|
|
23
|
+
errorText?: string;
|
|
24
|
+
hasError?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const VerifyPhoneDialogLayout = JSX<VerifyPhoneDialogProps>(
|
|
28
|
+
({
|
|
29
|
+
children,
|
|
30
|
+
isLoading,
|
|
31
|
+
isSubmitButtonDisabled,
|
|
32
|
+
timeNextReq,
|
|
33
|
+
onSubmit,
|
|
34
|
+
onSendCode,
|
|
35
|
+
values,
|
|
36
|
+
onChange,
|
|
37
|
+
errorText,
|
|
38
|
+
hasError,
|
|
39
|
+
phone,
|
|
40
|
+
onClose,
|
|
41
|
+
}) => (
|
|
42
|
+
<Dialog maxWidth="lg" onClose={onClose}>
|
|
43
|
+
<div className="flex flex-col gap-xl items-center rounded-md">
|
|
44
|
+
{renderHeadline(phone)}
|
|
45
|
+
<InputCode values={values} setValues={onChange} errorText={errorText} hasError={hasError} />
|
|
46
|
+
{renderText(timeNextReq, onSendCode)}
|
|
47
|
+
{children}
|
|
48
|
+
{renderNextButton(isSubmitButtonDisabled, onSubmit)}
|
|
49
|
+
{isLoading ? <Loader blur={false} /> : null}
|
|
50
|
+
</div>
|
|
51
|
+
</Dialog>
|
|
52
|
+
),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const renderHeadline = (phone: string) => (
|
|
56
|
+
<Headline
|
|
57
|
+
className="w-full"
|
|
58
|
+
title="Подтвердите номер телефона"
|
|
59
|
+
description={`Мы отправили код на ${phone}`}
|
|
60
|
+
headlineVersion="XS"
|
|
61
|
+
isEmbedded={true}
|
|
62
|
+
as="h6"
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const renderNextButton = (disabled: boolean, onClick: () => void) => (
|
|
67
|
+
<SubmitButton text="Далее" disabled={disabled} onClick={onClick} />
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const renderText = (timeNextReq: number, handleSendCode: () => void) =>
|
|
71
|
+
timeNextReq ? (
|
|
72
|
+
<div className="flex flex-row text-l font-light text-base gap-2xs">
|
|
73
|
+
<span> Получить новый код можно через</span>
|
|
74
|
+
<Timer seconds={timeNextReq} />
|
|
75
|
+
</div>
|
|
76
|
+
) : (
|
|
77
|
+
<Button embedded onClick={handleSendCode}>
|
|
78
|
+
<ButtonTitle>Получить новый код</ButtonTitle>
|
|
79
|
+
</Button>
|
|
80
|
+
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type JSONRecord, type JSONScalar } from '@redneckz/json-op';
|
|
2
2
|
import { type Router } from '../external/useRouter';
|
|
3
|
-
import { type MainBody } from '../retail/api/checkCode';
|
|
4
3
|
import { API_BASE_URI } from './apiBaseUrl';
|
|
5
4
|
import { getPhoneBody, getSubmitBody } from './getSubmitBody';
|
|
6
5
|
|
|
@@ -18,7 +17,18 @@ export type LeadRequest = Record<string, JSONRecord | JSONScalar | null> & {
|
|
|
18
17
|
partnerName?: string;
|
|
19
18
|
};
|
|
20
19
|
|
|
21
|
-
export type CheckCodeProps =
|
|
20
|
+
export type CheckCodeProps = {
|
|
21
|
+
reqId: string;
|
|
22
|
+
code: string;
|
|
23
|
+
body: LeadRequest;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type CheckCodeResponse = {
|
|
27
|
+
errorCode?: string;
|
|
28
|
+
errorDesc?: string;
|
|
29
|
+
reqId?: string;
|
|
30
|
+
status?: string;
|
|
31
|
+
} | null;
|
|
22
32
|
|
|
23
33
|
type VerifiedLeadRequest = {
|
|
24
34
|
requestId: string;
|
|
@@ -73,7 +83,7 @@ export function LeadServiceAPI() {
|
|
|
73
83
|
}
|
|
74
84
|
}
|
|
75
85
|
|
|
76
|
-
async function checkCode({ reqId, code, body }: CheckCodeProps) {
|
|
86
|
+
async function checkCode({ reqId, code, body }: CheckCodeProps): Promise<CheckCodeResponse> {
|
|
77
87
|
const submitBody = {
|
|
78
88
|
requestId: reqId,
|
|
79
89
|
confimationCode: code,
|
|
@@ -83,10 +93,6 @@ export function LeadServiceAPI() {
|
|
|
83
93
|
try {
|
|
84
94
|
const response = await LeadServiceFetch(`${API_BASE_URI}/confirmCorporateLead`, submitBody);
|
|
85
95
|
|
|
86
|
-
if (!response?.ok) {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
96
|
return await response.json();
|
|
91
97
|
} catch (e) {
|
|
92
98
|
return null;
|
|
@@ -6,7 +6,6 @@ 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';
|
|
10
9
|
import { ApplicationFormLayout } from '../../ui-kit/ApplicationFormLayout/ApplicationFormLayout';
|
|
11
10
|
import { useDialog } from '../../ui-kit/DialogManager/useDialog';
|
|
12
11
|
import { getConsentDataProcessing } from '../../ui-kit/FormField/getConsentDataProcessing';
|
|
@@ -28,6 +27,7 @@ import { getFormatData } from './getFormatData';
|
|
|
28
27
|
import { getInitialFormState, type FormState } from './getInitialFormState';
|
|
29
28
|
import { renderAgreementSubmit } from './renderAgreementSubmit';
|
|
30
29
|
import { renderContacts } from './renderContacts';
|
|
30
|
+
import { VerifyPhoneDialog } from './VerifyPhoneDialog';
|
|
31
31
|
|
|
32
32
|
export interface ApplicationFormProps extends ApplicationFormContent, UniBlockProps {}
|
|
33
33
|
|
|
@@ -84,10 +84,8 @@ export const ApplicationForm = UniBlock<ApplicationFormProps>(
|
|
|
84
84
|
|
|
85
85
|
verifyPhoneDialog.open({
|
|
86
86
|
phone,
|
|
87
|
-
withDescription: false,
|
|
88
87
|
formatData,
|
|
89
88
|
reqId: String(response),
|
|
90
|
-
isRetail: false,
|
|
91
89
|
onSuccess: () => {
|
|
92
90
|
verifyPhoneDialog.close();
|
|
93
91
|
responseTypeDialog.open({ ok: true, typeForm });
|