@redneckz/wildless-cms-uni-blocks 0.14.652 → 0.14.654
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/RetailAPI/updateRefreshToken.d.ts +1 -0
- package/bundle/api/RetailAPI/updateUserTask.d.ts +7 -0
- package/bundle/bundle.umd.js +60 -8
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/ApplicationLeadForm/getInitialFormState.d.ts +3 -0
- package/bundle/components/CreditForm/getZeroStepData.d.ts +3 -0
- package/bundle/hooks/useInterval.d.ts +1 -0
- package/dist/api/RetailAPI/doRequest.js +1 -0
- package/dist/api/RetailAPI/doRequest.js.map +1 -1
- package/dist/api/RetailAPI/updateRefreshToken.d.ts +1 -0
- package/dist/api/RetailAPI/updateRefreshToken.js +31 -0
- package/dist/api/RetailAPI/updateRefreshToken.js.map +1 -0
- package/dist/api/RetailAPI/updateUserTask.d.ts +7 -0
- package/dist/api/RetailAPI/updateUserTask.js.map +1 -1
- package/dist/components/ApplicationLeadForm/getInitialFormState.d.ts +3 -0
- package/dist/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
- package/dist/components/CreditForm/CreditForm.js +9 -1
- package/dist/components/CreditForm/CreditForm.js.map +1 -1
- package/dist/components/CreditForm/CreditFormStatusTracker.js +8 -6
- package/dist/components/CreditForm/CreditFormStatusTracker.js.map +1 -1
- package/dist/components/CreditForm/getCreditFormTaskData.js +3 -0
- package/dist/components/CreditForm/getCreditFormTaskData.js.map +1 -1
- package/dist/components/CreditForm/getZeroStepData.d.ts +3 -0
- package/dist/components/CreditForm/getZeroStepData.js +16 -0
- package/dist/components/CreditForm/getZeroStepData.js.map +1 -0
- package/dist/hooks/useInterval.d.ts +1 -0
- package/dist/hooks/useInterval.js +14 -0
- package/dist/hooks/useInterval.js.map +1 -0
- package/lib/api/RetailAPI/doRequest.js +1 -0
- package/lib/api/RetailAPI/doRequest.js.map +1 -1
- package/lib/api/RetailAPI/updateRefreshToken.d.ts +1 -0
- package/lib/api/RetailAPI/updateRefreshToken.js +28 -0
- package/lib/api/RetailAPI/updateRefreshToken.js.map +1 -0
- package/lib/api/RetailAPI/updateUserTask.d.ts +7 -0
- package/lib/api/RetailAPI/updateUserTask.js.map +1 -1
- package/lib/components/ApplicationLeadForm/getInitialFormState.d.ts +3 -0
- package/lib/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
- package/lib/components/CreditForm/CreditForm.js +10 -2
- package/lib/components/CreditForm/CreditForm.js.map +1 -1
- package/lib/components/CreditForm/CreditFormStatusTracker.js +8 -6
- package/lib/components/CreditForm/CreditFormStatusTracker.js.map +1 -1
- package/lib/components/CreditForm/getCreditFormTaskData.js +3 -0
- package/lib/components/CreditForm/getCreditFormTaskData.js.map +1 -1
- package/lib/components/CreditForm/getZeroStepData.d.ts +3 -0
- package/lib/components/CreditForm/getZeroStepData.js +13 -0
- package/lib/components/CreditForm/getZeroStepData.js.map +1 -0
- package/lib/hooks/useInterval.d.ts +1 -0
- package/lib/hooks/useInterval.js +11 -0
- package/lib/hooks/useInterval.js.map +1 -0
- package/mobile/bundle/api/RetailAPI/updateRefreshToken.d.ts +1 -0
- package/mobile/bundle/api/RetailAPI/updateUserTask.d.ts +7 -0
- package/mobile/bundle/bundle.umd.js +60 -8
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/ApplicationLeadForm/getInitialFormState.d.ts +3 -0
- package/mobile/bundle/components/CreditForm/getZeroStepData.d.ts +3 -0
- package/mobile/bundle/hooks/useInterval.d.ts +1 -0
- package/mobile/dist/api/RetailAPI/doRequest.js +1 -0
- package/mobile/dist/api/RetailAPI/doRequest.js.map +1 -1
- package/mobile/dist/api/RetailAPI/updateRefreshToken.d.ts +1 -0
- package/mobile/dist/api/RetailAPI/updateRefreshToken.js +31 -0
- package/mobile/dist/api/RetailAPI/updateRefreshToken.js.map +1 -0
- package/mobile/dist/api/RetailAPI/updateUserTask.d.ts +7 -0
- package/mobile/dist/api/RetailAPI/updateUserTask.js.map +1 -1
- package/mobile/dist/components/ApplicationLeadForm/getInitialFormState.d.ts +3 -0
- package/mobile/dist/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
- package/mobile/dist/components/CreditForm/CreditForm.js +9 -1
- package/mobile/dist/components/CreditForm/CreditForm.js.map +1 -1
- package/mobile/dist/components/CreditForm/CreditFormStatusTracker.js +8 -6
- package/mobile/dist/components/CreditForm/CreditFormStatusTracker.js.map +1 -1
- package/mobile/dist/components/CreditForm/getCreditFormTaskData.js +3 -0
- package/mobile/dist/components/CreditForm/getCreditFormTaskData.js.map +1 -1
- package/mobile/dist/components/CreditForm/getZeroStepData.d.ts +3 -0
- package/mobile/dist/components/CreditForm/getZeroStepData.js +16 -0
- package/mobile/dist/components/CreditForm/getZeroStepData.js.map +1 -0
- package/mobile/dist/hooks/useInterval.d.ts +1 -0
- package/mobile/dist/hooks/useInterval.js +14 -0
- package/mobile/dist/hooks/useInterval.js.map +1 -0
- package/mobile/lib/api/RetailAPI/doRequest.js +1 -0
- package/mobile/lib/api/RetailAPI/doRequest.js.map +1 -1
- package/mobile/lib/api/RetailAPI/updateRefreshToken.d.ts +1 -0
- package/mobile/lib/api/RetailAPI/updateRefreshToken.js +28 -0
- package/mobile/lib/api/RetailAPI/updateRefreshToken.js.map +1 -0
- package/mobile/lib/api/RetailAPI/updateUserTask.d.ts +7 -0
- package/mobile/lib/api/RetailAPI/updateUserTask.js.map +1 -1
- package/mobile/lib/components/ApplicationLeadForm/getInitialFormState.d.ts +3 -0
- package/mobile/lib/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
- package/mobile/lib/components/CreditForm/CreditForm.js +10 -2
- package/mobile/lib/components/CreditForm/CreditForm.js.map +1 -1
- package/mobile/lib/components/CreditForm/CreditFormStatusTracker.js +8 -6
- package/mobile/lib/components/CreditForm/CreditFormStatusTracker.js.map +1 -1
- package/mobile/lib/components/CreditForm/getCreditFormTaskData.js +3 -0
- package/mobile/lib/components/CreditForm/getCreditFormTaskData.js.map +1 -1
- package/mobile/lib/components/CreditForm/getZeroStepData.d.ts +3 -0
- package/mobile/lib/components/CreditForm/getZeroStepData.js +13 -0
- package/mobile/lib/components/CreditForm/getZeroStepData.js.map +1 -0
- package/mobile/lib/hooks/useInterval.d.ts +1 -0
- package/mobile/lib/hooks/useInterval.js +11 -0
- package/mobile/lib/hooks/useInterval.js.map +1 -0
- package/mobile/src/api/RetailAPI/doRequest.ts +1 -0
- package/mobile/src/api/RetailAPI/updateRefreshToken.ts +42 -0
- package/mobile/src/api/RetailAPI/updateUserTask.ts +8 -0
- package/mobile/src/components/ApplicationLeadForm/getInitialFormState.tsx +3 -0
- package/mobile/src/components/CreditForm/CreditForm.tsx +11 -2
- package/mobile/src/components/CreditForm/CreditFormStatusTracker.tsx +3 -0
- package/mobile/src/components/CreditForm/getCreditFormTaskData.ts +3 -0
- package/mobile/src/components/CreditForm/getZeroStepData.ts +17 -0
- package/mobile/src/hooks/useInterval.ts +14 -0
- package/package.json +1 -1
- package/src/api/RetailAPI/doRequest.ts +1 -0
- package/src/api/RetailAPI/updateRefreshToken.ts +42 -0
- package/src/api/RetailAPI/updateUserTask.ts +8 -0
- package/src/components/ApplicationLeadForm/getInitialFormState.tsx +3 -0
- package/src/components/CreditForm/CreditForm.fixture.tsx +7 -0
- package/src/components/CreditForm/CreditForm.tsx +11 -2
- package/src/components/CreditForm/CreditFormStatusTracker.tsx +3 -0
- package/src/components/CreditForm/getCreditFormTaskData.ts +3 -0
- package/src/components/CreditForm/getZeroStepData.ts +17 -0
- package/src/hooks/useInterval.ts +14 -0
|
@@ -36,6 +36,11 @@ type ParticipantIncome = {
|
|
|
36
36
|
value: number;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
export type PaymentType = {
|
|
40
|
+
key: 'ANNUITY' | 'DIFFERENTIAL';
|
|
41
|
+
value: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
39
44
|
export type Participant = {
|
|
40
45
|
birthDate?: string;
|
|
41
46
|
id: number;
|
|
@@ -100,6 +105,9 @@ export type Participant = {
|
|
|
100
105
|
paymentSystemTypeCd?: string;
|
|
101
106
|
classCard?: Option;
|
|
102
107
|
codeWord?: string;
|
|
108
|
+
loanAmount?: number;
|
|
109
|
+
creditPeriod?: number;
|
|
110
|
+
paymentTypeCd?: PaymentType;
|
|
103
111
|
};
|
|
104
112
|
|
|
105
113
|
export type UpdateUserTaskBody = {
|
|
@@ -130,6 +130,9 @@ export interface FormState extends FormConsents {
|
|
|
130
130
|
cardCategory?: { key: ''; text: '' };
|
|
131
131
|
codeWord?: string;
|
|
132
132
|
esiaAccountTypeCd?: Option;
|
|
133
|
+
moneyValue?: number;
|
|
134
|
+
monthsValue?: number;
|
|
135
|
+
isAnnuity?: boolean;
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
const initialFormState = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import { useCallback, useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
|
+
import { updateRefreshToken } from '../../api/RetailAPI/updateRefreshToken';
|
|
3
4
|
import { type SectionsProps } from '../../model/InputSectionsType';
|
|
4
5
|
import { BlockWrapper } from '../../ui-kit/BlockWrapper';
|
|
5
6
|
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
@@ -27,6 +28,8 @@ const WIZARD_TITLES = [
|
|
|
27
28
|
export const CreditForm = JSX<CreditFormWizardProps>(({ className, ...rest }) => {
|
|
28
29
|
const [step, setStep] = useState(0);
|
|
29
30
|
|
|
31
|
+
useEffect(updateRefreshToken, []);
|
|
32
|
+
|
|
30
33
|
const handleNextStep = useCallback(() => {
|
|
31
34
|
setStep((_) => Math.min(_ + 1, WIZARD_STEPS));
|
|
32
35
|
}, []);
|
|
@@ -61,9 +64,15 @@ export const CreditForm = JSX<CreditFormWizardProps>(({ className, ...rest }) =>
|
|
|
61
64
|
finishForm={setIsFormFinished}
|
|
62
65
|
renderStep={
|
|
63
66
|
isStartStep
|
|
64
|
-
? ({ registerSubmit }) => (
|
|
67
|
+
? ({ registerSubmit, field }) => (
|
|
65
68
|
<CalculatorCredit
|
|
66
69
|
{...{
|
|
70
|
+
// TODO: Remove "as never"
|
|
71
|
+
defaultParams: {
|
|
72
|
+
sum: field('moneyValue' as never).value,
|
|
73
|
+
period: field('monthsValue' as never).value,
|
|
74
|
+
isAnnuity: field('isAnnuity' as never).value,
|
|
75
|
+
},
|
|
67
76
|
title: 'Калькулятор кредита',
|
|
68
77
|
footnote:
|
|
69
78
|
'Расчёт является предварительным. Точные условия будут предоставлены в отделении Банка.',
|
|
@@ -23,6 +23,7 @@ export const CreditFormStatusTracker = JSX(() => {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const trackStatus = () =>
|
|
26
|
+
taskId &&
|
|
26
27
|
getTaskStatus({ taskId }).then((res) => {
|
|
27
28
|
if (res.statusCd && res.statusCd !== STATUS_TYPE.process) {
|
|
28
29
|
clearInterval(pullingInterval);
|
|
@@ -31,6 +32,8 @@ export const CreditFormStatusTracker = JSX(() => {
|
|
|
31
32
|
});
|
|
32
33
|
|
|
33
34
|
const pullingInterval = setInterval(trackStatus, 30000);
|
|
35
|
+
|
|
36
|
+
return () => clearInterval(pullingInterval);
|
|
34
37
|
}, []);
|
|
35
38
|
|
|
36
39
|
return renderStatus(status);
|
|
@@ -4,6 +4,7 @@ import { getFirstStepData } from './getFirstStepData';
|
|
|
4
4
|
import { getFourthStepData } from './getFourthStepData';
|
|
5
5
|
import { getSecondStepData } from './getSecondStepData';
|
|
6
6
|
import { getThirdStepData } from './getThirdStepData';
|
|
7
|
+
import { getZeroStepData } from './getZeroStepData';
|
|
7
8
|
|
|
8
9
|
type getCreditFormTaskDataProps = {
|
|
9
10
|
participantId: number;
|
|
@@ -48,6 +49,8 @@ export const getCreditFormTaskData = ({
|
|
|
48
49
|
|
|
49
50
|
const getCurrentStepData = (step: number, formData: FormState): Partial<Participant> => {
|
|
50
51
|
switch (step) {
|
|
52
|
+
case 0:
|
|
53
|
+
return getZeroStepData(formData);
|
|
51
54
|
case 1:
|
|
52
55
|
return getFirstStepData(formData);
|
|
53
56
|
case 2:
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Participant, type PaymentType } from '../../api/RetailAPI/updateUserTask';
|
|
2
|
+
import { type FormState } from '../ApplicationLeadForm/getInitialFormState';
|
|
3
|
+
|
|
4
|
+
const PAYMENT_TYPE_DATA: Record<string, PaymentType> = {
|
|
5
|
+
annuity: { key: 'ANNUITY', value: 'Аннуитетный' },
|
|
6
|
+
differential: { key: 'DIFFERENTIAL', value: 'Дифференцированный ' },
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const getZeroStepData = (formData: FormState): Partial<Participant> => {
|
|
10
|
+
const { moneyValue, monthsValue, isAnnuity } = formData;
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
loanAmount: moneyValue,
|
|
14
|
+
creditPeriod: monthsValue,
|
|
15
|
+
paymentTypeCd: PAYMENT_TYPE_DATA[isAnnuity ? 'annuity' : 'differential'],
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
|
|
3
|
+
export const useInterval = (handler: (stop: () => void) => void, period: number) => {
|
|
4
|
+
const timer = useRef<any | null>(null);
|
|
5
|
+
const clearTimer = useCallback(() => timer.current && clearInterval(timer.current as number), []);
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
timer.current = setInterval(() => handler(clearTimer), period);
|
|
9
|
+
|
|
10
|
+
return clearTimer;
|
|
11
|
+
}, [handler, period]);
|
|
12
|
+
|
|
13
|
+
return clearTimer;
|
|
14
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { doRequest } from './doRequest';
|
|
2
|
+
|
|
3
|
+
interface UpdateRefreshTokenBody {
|
|
4
|
+
refresh_token: string;
|
|
5
|
+
access_token: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const PORTAL_NATURAL_URL = '/';
|
|
9
|
+
|
|
10
|
+
const UPDATING_INTERVAL = 60000 * 4;
|
|
11
|
+
|
|
12
|
+
export const updateRefreshToken = () => {
|
|
13
|
+
const refreshToken = globalThis.sessionStorage?.getItem('refreshToken');
|
|
14
|
+
const accessToken = globalThis.sessionStorage?.getItem('accessToken');
|
|
15
|
+
const taskId = globalThis.localStorage.getItem('taskId');
|
|
16
|
+
|
|
17
|
+
if (!accessToken || !refreshToken || !taskId) {
|
|
18
|
+
globalThis.location.href = PORTAL_NATURAL_URL;
|
|
19
|
+
|
|
20
|
+
return () => null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const timer = setInterval(async () => {
|
|
24
|
+
const res = await doRequest<UpdateRefreshTokenBody | Response>('/auth/refresh', 'POST', {
|
|
25
|
+
// eslint-disable-next-line camelcase
|
|
26
|
+
refresh_token: refreshToken,
|
|
27
|
+
// eslint-disable-next-line camelcase
|
|
28
|
+
access_token: accessToken,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (res instanceof Response) {
|
|
32
|
+
globalThis.location.href = PORTAL_NATURAL_URL;
|
|
33
|
+
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
sessionStorage.setItem('refreshToken', res.refresh_token);
|
|
38
|
+
sessionStorage.setItem('accessToken', res.access_token);
|
|
39
|
+
}, UPDATING_INTERVAL);
|
|
40
|
+
|
|
41
|
+
return () => clearInterval(timer);
|
|
42
|
+
};
|
|
@@ -36,6 +36,11 @@ type ParticipantIncome = {
|
|
|
36
36
|
value: number;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
export type PaymentType = {
|
|
40
|
+
key: 'ANNUITY' | 'DIFFERENTIAL';
|
|
41
|
+
value: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
39
44
|
export type Participant = {
|
|
40
45
|
birthDate?: string;
|
|
41
46
|
id: number;
|
|
@@ -100,6 +105,9 @@ export type Participant = {
|
|
|
100
105
|
paymentSystemTypeCd?: string;
|
|
101
106
|
classCard?: Option;
|
|
102
107
|
codeWord?: string;
|
|
108
|
+
loanAmount?: number;
|
|
109
|
+
creditPeriod?: number;
|
|
110
|
+
paymentTypeCd?: PaymentType;
|
|
103
111
|
};
|
|
104
112
|
|
|
105
113
|
export type UpdateUserTaskBody = {
|
|
@@ -130,6 +130,9 @@ export interface FormState extends FormConsents {
|
|
|
130
130
|
cardCategory?: { key: ''; text: '' };
|
|
131
131
|
codeWord?: string;
|
|
132
132
|
esiaAccountTypeCd?: Option;
|
|
133
|
+
moneyValue?: number;
|
|
134
|
+
monthsValue?: number;
|
|
135
|
+
isAnnuity?: boolean;
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
const initialFormState = {
|
|
@@ -3,6 +3,13 @@ import { DialogManager } from '../../ui-kit/DialogManager/DialogManager';
|
|
|
3
3
|
import { PopupManager } from '../../ui-kit/PopupManager/PopupManager';
|
|
4
4
|
import { CreditForm } from './CreditForm';
|
|
5
5
|
|
|
6
|
+
const MOCK_TOKEN = 'mockKEY';
|
|
7
|
+
const MOCK_TASK_ID = '111111';
|
|
8
|
+
|
|
9
|
+
globalThis.sessionStorage?.setItem('refreshToken', MOCK_TOKEN);
|
|
10
|
+
globalThis.sessionStorage?.setItem('accessToken', MOCK_TOKEN);
|
|
11
|
+
globalThis.localStorage.setItem('taskId', MOCK_TASK_ID);
|
|
12
|
+
|
|
6
13
|
export default {
|
|
7
14
|
default: (
|
|
8
15
|
<div>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import { useCallback, useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
|
+
import { updateRefreshToken } from '../../api/RetailAPI/updateRefreshToken';
|
|
3
4
|
import { type SectionsProps } from '../../model/InputSectionsType';
|
|
4
5
|
import { BlockWrapper } from '../../ui-kit/BlockWrapper';
|
|
5
6
|
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
@@ -27,6 +28,8 @@ const WIZARD_TITLES = [
|
|
|
27
28
|
export const CreditForm = JSX<CreditFormWizardProps>(({ className, ...rest }) => {
|
|
28
29
|
const [step, setStep] = useState(0);
|
|
29
30
|
|
|
31
|
+
useEffect(updateRefreshToken, []);
|
|
32
|
+
|
|
30
33
|
const handleNextStep = useCallback(() => {
|
|
31
34
|
setStep((_) => Math.min(_ + 1, WIZARD_STEPS));
|
|
32
35
|
}, []);
|
|
@@ -61,9 +64,15 @@ export const CreditForm = JSX<CreditFormWizardProps>(({ className, ...rest }) =>
|
|
|
61
64
|
finishForm={setIsFormFinished}
|
|
62
65
|
renderStep={
|
|
63
66
|
isStartStep
|
|
64
|
-
? ({ registerSubmit }) => (
|
|
67
|
+
? ({ registerSubmit, field }) => (
|
|
65
68
|
<CalculatorCredit
|
|
66
69
|
{...{
|
|
70
|
+
// TODO: Remove "as never"
|
|
71
|
+
defaultParams: {
|
|
72
|
+
sum: field('moneyValue' as never).value,
|
|
73
|
+
period: field('monthsValue' as never).value,
|
|
74
|
+
isAnnuity: field('isAnnuity' as never).value,
|
|
75
|
+
},
|
|
67
76
|
title: 'Калькулятор кредита',
|
|
68
77
|
footnote:
|
|
69
78
|
'Расчёт является предварительным. Точные условия будут предоставлены в отделении Банка.',
|
|
@@ -23,6 +23,7 @@ export const CreditFormStatusTracker = JSX(() => {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const trackStatus = () =>
|
|
26
|
+
taskId &&
|
|
26
27
|
getTaskStatus({ taskId }).then((res) => {
|
|
27
28
|
if (res.statusCd && res.statusCd !== STATUS_TYPE.process) {
|
|
28
29
|
clearInterval(pullingInterval);
|
|
@@ -31,6 +32,8 @@ export const CreditFormStatusTracker = JSX(() => {
|
|
|
31
32
|
});
|
|
32
33
|
|
|
33
34
|
const pullingInterval = setInterval(trackStatus, 30000);
|
|
35
|
+
|
|
36
|
+
return () => clearInterval(pullingInterval);
|
|
34
37
|
}, []);
|
|
35
38
|
|
|
36
39
|
return renderStatus(status);
|
|
@@ -4,6 +4,7 @@ import { getFirstStepData } from './getFirstStepData';
|
|
|
4
4
|
import { getFourthStepData } from './getFourthStepData';
|
|
5
5
|
import { getSecondStepData } from './getSecondStepData';
|
|
6
6
|
import { getThirdStepData } from './getThirdStepData';
|
|
7
|
+
import { getZeroStepData } from './getZeroStepData';
|
|
7
8
|
|
|
8
9
|
type getCreditFormTaskDataProps = {
|
|
9
10
|
participantId: number;
|
|
@@ -48,6 +49,8 @@ export const getCreditFormTaskData = ({
|
|
|
48
49
|
|
|
49
50
|
const getCurrentStepData = (step: number, formData: FormState): Partial<Participant> => {
|
|
50
51
|
switch (step) {
|
|
52
|
+
case 0:
|
|
53
|
+
return getZeroStepData(formData);
|
|
51
54
|
case 1:
|
|
52
55
|
return getFirstStepData(formData);
|
|
53
56
|
case 2:
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Participant, type PaymentType } from '../../api/RetailAPI/updateUserTask';
|
|
2
|
+
import { type FormState } from '../ApplicationLeadForm/getInitialFormState';
|
|
3
|
+
|
|
4
|
+
const PAYMENT_TYPE_DATA: Record<string, PaymentType> = {
|
|
5
|
+
annuity: { key: 'ANNUITY', value: 'Аннуитетный' },
|
|
6
|
+
differential: { key: 'DIFFERENTIAL', value: 'Дифференцированный ' },
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const getZeroStepData = (formData: FormState): Partial<Participant> => {
|
|
10
|
+
const { moneyValue, monthsValue, isAnnuity } = formData;
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
loanAmount: moneyValue,
|
|
14
|
+
creditPeriod: monthsValue,
|
|
15
|
+
paymentTypeCd: PAYMENT_TYPE_DATA[isAnnuity ? 'annuity' : 'differential'],
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
|
|
3
|
+
export const useInterval = (handler: (stop: () => void) => void, period: number) => {
|
|
4
|
+
const timer = useRef<any | null>(null);
|
|
5
|
+
const clearTimer = useCallback(() => timer.current && clearInterval(timer.current as number), []);
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
timer.current = setInterval(() => handler(clearTimer), period);
|
|
9
|
+
|
|
10
|
+
return clearTimer;
|
|
11
|
+
}, [handler, period]);
|
|
12
|
+
|
|
13
|
+
return clearTimer;
|
|
14
|
+
};
|