@redneckz/wildless-cms-uni-blocks 0.14.430 → 0.14.431
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/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +93 -33
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/CalculatorDeposit/CalculatorDepositContent.d.ts +10 -0
- package/bundle/components/CalculatorDeposit/getDepositCalculatorParams.d.ts +5 -0
- package/bundle/components/CalculatorDeposit/renderDepositParamsForm.d.ts +5 -0
- package/bundle/ui-kit/Calculator/renderRate.d.ts +3 -1
- package/dist/components/CalculatorDeposit/CalculatorDeposit.js +31 -26
- package/dist/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
- package/dist/components/CalculatorDeposit/CalculatorDepositContent.d.ts +10 -0
- package/dist/components/CalculatorDeposit/getDepositCalculatorParams.d.ts +5 -0
- package/dist/components/CalculatorDeposit/getDepositCalculatorParams.js +19 -2
- package/dist/components/CalculatorDeposit/getDepositCalculatorParams.js.map +1 -1
- package/dist/components/CalculatorDeposit/renderDepositParamsForm.d.ts +5 -0
- package/dist/components/CalculatorDeposit/renderDepositParamsForm.js +45 -0
- package/dist/components/CalculatorDeposit/renderDepositParamsForm.js.map +1 -0
- package/dist/components/CalculatorDeposit/renderDepositResult.js +1 -1
- package/dist/components/CalculatorDeposit/renderDepositResult.js.map +1 -1
- package/dist/ui-kit/Calculator/CalculatorStyle.js +3 -3
- package/dist/ui-kit/Calculator/CalculatorStyle.js.map +1 -1
- package/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -2
- package/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
- package/dist/ui-kit/Calculator/renderRate.d.ts +3 -1
- package/dist/ui-kit/Calculator/renderRate.js +1 -1
- package/dist/ui-kit/Calculator/renderRate.js.map +1 -1
- package/lib/common.css +1 -1
- package/lib/components/CalculatorDeposit/CalculatorDeposit.fixture.d.ts +1 -0
- package/lib/components/CalculatorDeposit/CalculatorDeposit.js +30 -25
- package/lib/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
- package/lib/components/CalculatorDeposit/CalculatorDepositContent.d.ts +10 -0
- package/lib/components/CalculatorDeposit/getDepositCalculatorParams.d.ts +5 -0
- package/lib/components/CalculatorDeposit/getDepositCalculatorParams.js +19 -2
- package/lib/components/CalculatorDeposit/getDepositCalculatorParams.js.map +1 -1
- package/lib/components/CalculatorDeposit/renderDepositParamsForm.d.ts +4 -0
- package/lib/components/CalculatorDeposit/renderDepositParamsForm.js +42 -0
- package/lib/components/CalculatorDeposit/renderDepositParamsForm.js.map +1 -0
- package/lib/components/CalculatorDeposit/renderDepositResult.js +1 -1
- package/lib/components/CalculatorDeposit/renderDepositResult.js.map +1 -1
- package/lib/ui-kit/Calculator/CalculatorStyle.js +3 -3
- package/lib/ui-kit/Calculator/CalculatorStyle.js.map +1 -1
- package/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -2
- package/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
- package/lib/ui-kit/Calculator/renderRate.d.ts +3 -1
- package/lib/ui-kit/Calculator/renderRate.js +1 -1
- package/lib/ui-kit/Calculator/renderRate.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +93 -33
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/CalculatorDeposit/CalculatorDepositContent.d.ts +10 -0
- package/mobile/bundle/components/CalculatorDeposit/getDepositCalculatorParams.d.ts +5 -0
- package/mobile/bundle/components/CalculatorDeposit/renderDepositParamsForm.d.ts +5 -0
- package/mobile/bundle/ui-kit/Calculator/renderRate.d.ts +3 -1
- package/mobile/dist/components/CalculatorDeposit/CalculatorDeposit.js +31 -26
- package/mobile/dist/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
- package/mobile/dist/components/CalculatorDeposit/CalculatorDepositContent.d.ts +10 -0
- package/mobile/dist/components/CalculatorDeposit/getDepositCalculatorParams.d.ts +5 -0
- package/mobile/dist/components/CalculatorDeposit/getDepositCalculatorParams.js +19 -2
- package/mobile/dist/components/CalculatorDeposit/getDepositCalculatorParams.js.map +1 -1
- package/mobile/dist/components/CalculatorDeposit/renderDepositParamsForm.d.ts +5 -0
- package/mobile/dist/components/CalculatorDeposit/renderDepositParamsForm.js +45 -0
- package/mobile/dist/components/CalculatorDeposit/renderDepositParamsForm.js.map +1 -0
- package/mobile/dist/components/CalculatorDeposit/renderDepositResult.js +1 -1
- package/mobile/dist/components/CalculatorDeposit/renderDepositResult.js.map +1 -1
- package/mobile/dist/ui-kit/Calculator/CalculatorStyle.js +3 -3
- package/mobile/dist/ui-kit/Calculator/CalculatorStyle.js.map +1 -1
- package/mobile/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -2
- package/mobile/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
- package/mobile/dist/ui-kit/Calculator/renderRate.d.ts +3 -1
- package/mobile/dist/ui-kit/Calculator/renderRate.js +1 -1
- package/mobile/dist/ui-kit/Calculator/renderRate.js.map +1 -1
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/CalculatorDeposit/CalculatorDeposit.js +30 -25
- package/mobile/lib/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
- package/mobile/lib/components/CalculatorDeposit/CalculatorDepositContent.d.ts +10 -0
- package/mobile/lib/components/CalculatorDeposit/getDepositCalculatorParams.d.ts +5 -0
- package/mobile/lib/components/CalculatorDeposit/getDepositCalculatorParams.js +19 -2
- package/mobile/lib/components/CalculatorDeposit/getDepositCalculatorParams.js.map +1 -1
- package/mobile/lib/components/CalculatorDeposit/renderDepositParamsForm.d.ts +5 -0
- package/mobile/lib/components/CalculatorDeposit/renderDepositParamsForm.js +42 -0
- package/mobile/lib/components/CalculatorDeposit/renderDepositParamsForm.js.map +1 -0
- package/mobile/lib/components/CalculatorDeposit/renderDepositResult.js +1 -1
- package/mobile/lib/components/CalculatorDeposit/renderDepositResult.js.map +1 -1
- package/mobile/lib/ui-kit/Calculator/CalculatorStyle.js +3 -3
- package/mobile/lib/ui-kit/Calculator/CalculatorStyle.js.map +1 -1
- package/mobile/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -2
- package/mobile/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
- package/mobile/lib/ui-kit/Calculator/renderRate.d.ts +3 -1
- package/mobile/lib/ui-kit/Calculator/renderRate.js +1 -1
- package/mobile/lib/ui-kit/Calculator/renderRate.js.map +1 -1
- package/mobile/src/components/CalculatorDeposit/CalculatorDeposit.tsx +45 -41
- package/mobile/src/components/CalculatorDeposit/CalculatorDepositContent.ts +10 -0
- package/mobile/src/components/CalculatorDeposit/getDepositCalculatorParams.ts +23 -0
- package/mobile/src/components/CalculatorDeposit/renderDepositParamsForm.tsx +59 -0
- package/mobile/src/components/CalculatorDeposit/renderDepositResult.tsx +1 -1
- package/mobile/src/ui-kit/Calculator/CalculatorStyle.tsx +3 -3
- package/mobile/src/ui-kit/Calculator/renderBinaryRadioButtonGroup.tsx +2 -3
- package/mobile/src/ui-kit/Calculator/renderRate.tsx +5 -1
- package/package.json +1 -1
- package/src/components/CalculatorDeposit/CalculatorDeposit.fixture.tsx +20 -0
- package/src/components/CalculatorDeposit/CalculatorDeposit.tsx +45 -41
- package/src/components/CalculatorDeposit/CalculatorDepositContent.ts +10 -0
- package/src/components/CalculatorDeposit/getDepositCalculatorParams.ts +23 -0
- package/src/components/CalculatorDeposit/renderDepositParamsForm.tsx +59 -0
- package/src/components/CalculatorDeposit/renderDepositResult.tsx +1 -1
- package/src/ui-kit/Calculator/CalculatorStyle.tsx +3 -3
- package/src/ui-kit/Calculator/renderBinaryRadioButtonGroup.tsx +2 -3
- package/src/ui-kit/Calculator/renderRate.tsx +5 -1
- package/tailwind.config.cjs +1 -1
- package/bundle/ui-kit/Breadcrumb.d.ts +0 -6
- package/dist/ui-kit/Breadcrumb.d.ts +0 -6
- package/dist/ui-kit/Breadcrumb.js +0 -11
- package/dist/ui-kit/Breadcrumb.js.map +0 -1
- package/lib/ui-kit/Breadcrumb.d.ts +0 -6
- package/lib/ui-kit/Breadcrumb.js +0 -9
- package/lib/ui-kit/Breadcrumb.js.map +0 -1
- package/mobile/bundle/ui-kit/Breadcrumb.d.ts +0 -6
- package/mobile/dist/ui-kit/Breadcrumb.d.ts +0 -6
- package/mobile/dist/ui-kit/Breadcrumb.js +0 -11
- package/mobile/dist/ui-kit/Breadcrumb.js.map +0 -1
- package/mobile/lib/ui-kit/Breadcrumb.d.ts +0 -6
- package/mobile/lib/ui-kit/Breadcrumb.js +0 -9
- package/mobile/lib/ui-kit/Breadcrumb.js.map +0 -1
- package/mobile/src/ui-kit/Breadcrumb.tsx +0 -21
- package/src/ui-kit/Breadcrumb.tsx +0 -21
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable max-lines, max-lines-per-function */
|
|
2
2
|
import { useEffect } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
3
|
import { type JSONRefObject } from '../../data/JSONRefObject';
|
|
4
|
-
import { useForm
|
|
4
|
+
import { useForm } from '../../hooks/useForm';
|
|
5
|
+
import { Button } from '../../ui-kit/Button/Button';
|
|
5
6
|
import { CalculatorLayout } from '../../ui-kit/Calculator/CalculatorLayout';
|
|
6
7
|
import { CalculatorStyle } from '../../ui-kit/Calculator/CalculatorStyle';
|
|
7
8
|
import { getDefaultParamsMax } from '../../ui-kit/Calculator/getDefaultParams';
|
|
@@ -10,7 +11,6 @@ import {
|
|
|
10
11
|
getMonthsDefaultValue,
|
|
11
12
|
} from '../../ui-kit/Calculator/getDefaultValues';
|
|
12
13
|
import { renderMonthsInput } from '../../ui-kit/Calculator/renderMonthsInput';
|
|
13
|
-
import { renderPayout } from '../../ui-kit/Calculator/renderPayout';
|
|
14
14
|
import { renderRate } from '../../ui-kit/Calculator/renderRate';
|
|
15
15
|
import { renderWantedSumInput } from '../../ui-kit/Calculator/renderWantedSumInput';
|
|
16
16
|
import { setDefaultParamsCalc } from '../../ui-kit/Calculator/setDefaultParamsCalc';
|
|
@@ -19,22 +19,21 @@ import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
|
19
19
|
import { clamp } from '../../utils/clamp';
|
|
20
20
|
import { style } from '../../utils/style';
|
|
21
21
|
import { isDefaultParams } from '../CalculatorCredit/isDefaultParams';
|
|
22
|
-
import {
|
|
23
|
-
type CalculatorDepositContent,
|
|
24
|
-
type CalculatorDepositParamsViewSettings,
|
|
25
|
-
} from './CalculatorDepositContent';
|
|
22
|
+
import { type CalculatorDepositContent } from './CalculatorDepositContent';
|
|
26
23
|
import {
|
|
27
24
|
getDepositCalculatorParams,
|
|
28
25
|
type DepositCalculatorData,
|
|
29
|
-
type DepositCalculatorParams,
|
|
30
26
|
type DepositCalculatorSourceBookParams,
|
|
27
|
+
type TariffsButtonContent,
|
|
31
28
|
} from './getDepositCalculatorParams';
|
|
29
|
+
import { renderDepositParamsForm } from './renderDepositParamsForm';
|
|
32
30
|
import { renderDepositResult } from './renderDepositResult';
|
|
33
|
-
import { renderRegistrationType } from './renderRegistrationType';
|
|
34
31
|
|
|
35
32
|
const MAP = {
|
|
36
33
|
isMonthlyInterestPayment: 'isMonthlyInterestPayment',
|
|
37
34
|
isRemoteRegistration: 'isRemoteRegistration',
|
|
35
|
+
isReplenish: 'isReplenish',
|
|
36
|
+
isWithdrawn: 'isWithdrawn',
|
|
38
37
|
moneyValue: 'minSum',
|
|
39
38
|
};
|
|
40
39
|
|
|
@@ -49,22 +48,24 @@ export const CalculatorDeposit = UniBlock<CalculatorDepositProps>(
|
|
|
49
48
|
className,
|
|
50
49
|
title,
|
|
51
50
|
calcSource,
|
|
52
|
-
buttons,
|
|
53
|
-
footnote,
|
|
51
|
+
buttons = [],
|
|
52
|
+
footnote = '',
|
|
54
53
|
paramsViewSettings,
|
|
55
54
|
defaultParams,
|
|
56
55
|
...rest
|
|
57
56
|
}) => {
|
|
58
57
|
const defParams = getDefaultParamsMax(calcSource?.rateRows);
|
|
58
|
+
|
|
59
59
|
const [userInputParams, { field }] = useForm({
|
|
60
60
|
moneyValue: getMoneyDefaultValue(defaultParams, DEPOSIT_DEFAULT_SUM),
|
|
61
61
|
monthsValue: getMonthsDefaultValue(defaultParams),
|
|
62
62
|
isMonthlyInterestPayment: Boolean(defaultParams?.isMonthlyInterestPayment),
|
|
63
63
|
isRemoteRegistration: Boolean(defaultParams?.isRemoteRegistration),
|
|
64
|
+
isReplenish: false,
|
|
65
|
+
isWithdrawn: Boolean(defaultParams?.isWithdrawn ?? false),
|
|
64
66
|
});
|
|
65
|
-
|
|
66
67
|
const calcParams = getDepositCalculatorParams(userInputParams, calcSource, paramsViewSettings);
|
|
67
|
-
const { defaultMonth, rate, income, finalSum } = calcParams;
|
|
68
|
+
const { defaultMonth, rate, income, finalSum, type = '' } = calcParams;
|
|
68
69
|
const { onChange: setMonthsValue } = field('monthsValue');
|
|
69
70
|
const { onChange: setMoneyValue } = field('moneyValue');
|
|
70
71
|
|
|
@@ -77,18 +78,23 @@ export const CalculatorDeposit = UniBlock<CalculatorDepositProps>(
|
|
|
77
78
|
setMoneyValue(clamp(userInputParams.moneyValue, calcParams.minSum, calcParams.maxSum));
|
|
78
79
|
}, [calcParams.minSum, calcParams.maxSum]);
|
|
79
80
|
|
|
81
|
+
const handleDefaultParamsCals = () =>
|
|
82
|
+
setDefaultParamsCalc({
|
|
83
|
+
field,
|
|
84
|
+
defParams: defParams as DepositCalculatorSourceBookParams,
|
|
85
|
+
calcParams,
|
|
86
|
+
monthsValue: 'minMonths',
|
|
87
|
+
map: MAP,
|
|
88
|
+
});
|
|
89
|
+
|
|
80
90
|
useEffect(() => {
|
|
81
91
|
if (!isDefaultParams(defaultParams) && defParams) {
|
|
82
|
-
|
|
83
|
-
field,
|
|
84
|
-
defParams: defParams as DepositCalculatorSourceBookParams,
|
|
85
|
-
calcParams,
|
|
86
|
-
monthsValue: 'minMonths',
|
|
87
|
-
map: MAP,
|
|
88
|
-
});
|
|
92
|
+
handleDefaultParamsCals();
|
|
89
93
|
}
|
|
90
94
|
}, [calcSource, defaultParams]);
|
|
91
95
|
|
|
96
|
+
const isMaxRate = rate === defParams?.rate;
|
|
97
|
+
|
|
92
98
|
return (
|
|
93
99
|
<CalculatorLayout className={className} title={title} {...rest}>
|
|
94
100
|
<section className={style(CalculatorStyle.wrapper, className)}>
|
|
@@ -112,32 +118,30 @@ export const CalculatorDeposit = UniBlock<CalculatorDepositProps>(
|
|
|
112
118
|
</div>
|
|
113
119
|
{renderRate({
|
|
114
120
|
rate,
|
|
121
|
+
children: renderMaxRateButton(handleDefaultParamsCals, isMaxRate),
|
|
122
|
+
})}
|
|
123
|
+
{renderDepositResult({
|
|
124
|
+
income,
|
|
125
|
+
finalSum,
|
|
126
|
+
buttons: [...buttons, getTariffButton(calcSource?.buttons, type)],
|
|
127
|
+
footnotes: [footnote],
|
|
115
128
|
})}
|
|
116
|
-
{renderDepositResult({ income, finalSum, buttons, footnotes: [footnote as string] })}
|
|
117
129
|
</section>
|
|
118
130
|
</CalculatorLayout>
|
|
119
131
|
);
|
|
120
132
|
},
|
|
121
133
|
);
|
|
122
134
|
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
? renderRegistrationType({
|
|
137
|
-
title: 'Оформление',
|
|
138
|
-
...field('isRemoteRegistration'),
|
|
139
|
-
value: params.isRemoteRegistration,
|
|
140
|
-
})
|
|
141
|
-
: null}
|
|
142
|
-
</div>
|
|
143
|
-
);
|
|
135
|
+
const getTariffButton = (buttons: TariffsButtonContent[] = [], btnType = '') => {
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
137
|
+
const { type, ...button } = buttons.find((_) => _.type === btnType) ?? {};
|
|
138
|
+
|
|
139
|
+
return button;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const renderMaxRateButton = (handleDefaultParamsCals: () => void, isMaxRate = false) =>
|
|
143
|
+
isMaxRate ? null : (
|
|
144
|
+
<Button type="button" version="secondary" onClick={handleDefaultParamsCals}>
|
|
145
|
+
Показать максимальную ставку
|
|
146
|
+
</Button>
|
|
147
|
+
);
|
|
@@ -15,13 +15,23 @@ export interface CalculatorDepositParamsViewSettings {
|
|
|
15
15
|
* @default true
|
|
16
16
|
*/
|
|
17
17
|
isShowRemoteRegistration?: boolean;
|
|
18
|
+
/** @title Пополнение */
|
|
19
|
+
isShowReplenish?: boolean;
|
|
20
|
+
/** @title Снятие */
|
|
21
|
+
isShowWithdrawn?: boolean;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
export interface CommonDepositParams {
|
|
25
|
+
/** @title Возможность помолнять */
|
|
26
|
+
isReplenish?: boolean;
|
|
27
|
+
/** @title Возможно снимать */
|
|
28
|
+
isWithdrawn?: boolean;
|
|
21
29
|
/** @title Ежемесячная выплата процентов */
|
|
22
30
|
isMonthlyInterestPayment?: boolean;
|
|
23
31
|
/** @title Дистанционное оформление */
|
|
24
32
|
isRemoteRegistration?: boolean;
|
|
33
|
+
/** @title Тип депозита */
|
|
34
|
+
type?: string;
|
|
25
35
|
}
|
|
26
36
|
|
|
27
37
|
export interface DepositDefaultParams extends CommonDefaultParams, CommonDepositParams {}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type CalcValueProps,
|
|
4
4
|
} from '../../ui-kit/Calculator/CalculatorProps';
|
|
5
5
|
import { checkRangeByKeys, getRangeByKeys } from '../../ui-kit/Calculator/rangeHelpers';
|
|
6
|
+
import type { LinkButtonContent } from '../../ui-kit/LinkButton/LinkButtonContent';
|
|
6
7
|
import { arrayByRange } from '../../utils/arrayByRange';
|
|
7
8
|
import { mergeIntervals } from '../../utils/mergeIntervals';
|
|
8
9
|
import {
|
|
@@ -18,6 +19,9 @@ const DEFAULT_DEPOSIT_CALCULATOR_PARAMS: DepositCalculatorSourceBookParams = {
|
|
|
18
19
|
rate: 0,
|
|
19
20
|
isMonthlyInterestPayment: true,
|
|
20
21
|
isRemoteRegistration: true,
|
|
22
|
+
isReplenish: false,
|
|
23
|
+
isWithdrawn: false,
|
|
24
|
+
type: '',
|
|
21
25
|
};
|
|
22
26
|
|
|
23
27
|
export interface DepositCalculatorSourceBookParams
|
|
@@ -35,8 +39,13 @@ export interface DepositCalculatorParams
|
|
|
35
39
|
finalSum: number;
|
|
36
40
|
}
|
|
37
41
|
|
|
42
|
+
export type TariffsButtonContent = LinkButtonContent & {
|
|
43
|
+
type?: string;
|
|
44
|
+
};
|
|
45
|
+
|
|
38
46
|
export type DepositCalculatorData = {
|
|
39
47
|
rateRows?: DepositCalculatorSourceBookParams[];
|
|
48
|
+
buttons?: TariffsButtonContent[];
|
|
40
49
|
};
|
|
41
50
|
|
|
42
51
|
export const getDepositCalculatorParams = (
|
|
@@ -50,9 +59,23 @@ export const getDepositCalculatorParams = (
|
|
|
50
59
|
: 0;
|
|
51
60
|
const isExcludeMonthlyInterestPayment = !paramsViewSettings?.isShowMonthlyInterestPayment;
|
|
52
61
|
const isExcludeRemoteRegistration = !paramsViewSettings?.isShowRemoteRegistration;
|
|
62
|
+
const isExcludeReplenish = !paramsViewSettings?.isShowReplenish;
|
|
63
|
+
const isExcludeWithdrawn = !paramsViewSettings?.isShowWithdrawn;
|
|
53
64
|
const depositCalculatorSourceBookParams =
|
|
54
65
|
calcSource?.rateRows?.find(
|
|
55
66
|
(row) =>
|
|
67
|
+
checkRowByParam({
|
|
68
|
+
row,
|
|
69
|
+
userInputParams,
|
|
70
|
+
paramKey: 'isReplenish',
|
|
71
|
+
isExclude: isExcludeReplenish,
|
|
72
|
+
}) &&
|
|
73
|
+
checkRowByParam({
|
|
74
|
+
row,
|
|
75
|
+
userInputParams,
|
|
76
|
+
paramKey: 'isWithdrawn',
|
|
77
|
+
isExclude: isExcludeWithdrawn,
|
|
78
|
+
}) &&
|
|
56
79
|
checkRowByParam({
|
|
57
80
|
row,
|
|
58
81
|
userInputParams,
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { FormFieldRegisterer } from '../../hooks/useForm';
|
|
2
|
+
import { renderBinaryRadioButtonGroup } from '../../ui-kit/Calculator/renderBinaryRadioButtonGroup';
|
|
3
|
+
import { renderPayout } from '../../ui-kit/Calculator/renderPayout';
|
|
4
|
+
import type { CalculatorDepositParamsViewSettings } from './CalculatorDepositContent';
|
|
5
|
+
import type { DepositCalculatorParams } from './getDepositCalculatorParams';
|
|
6
|
+
import { renderRegistrationType } from './renderRegistrationType';
|
|
7
|
+
|
|
8
|
+
export const renderDepositParamsForm = (
|
|
9
|
+
params: DepositCalculatorParams & CalculatorDepositParamsViewSettings,
|
|
10
|
+
field: FormFieldRegisterer<any>,
|
|
11
|
+
) => (
|
|
12
|
+
<div className="grid gap-lg">
|
|
13
|
+
<div className="flex gap-lg">
|
|
14
|
+
{params.isShowReplenish
|
|
15
|
+
? renderBinaryRadioButtonGroup({
|
|
16
|
+
title: 'Пополнение',
|
|
17
|
+
...field('isReplenish'),
|
|
18
|
+
value: params.isReplenish,
|
|
19
|
+
orientation: 'vertical',
|
|
20
|
+
items: [
|
|
21
|
+
{ id: 'withReplenish', text: 'С пополнением' },
|
|
22
|
+
{ id: 'withoutReplenish', text: 'Без пополнения' },
|
|
23
|
+
],
|
|
24
|
+
})
|
|
25
|
+
: null}
|
|
26
|
+
{params.isShowWithdrawn
|
|
27
|
+
? renderBinaryRadioButtonGroup({
|
|
28
|
+
title: 'Снятие',
|
|
29
|
+
...field('isWithdrawn'),
|
|
30
|
+
value: params.isWithdrawn,
|
|
31
|
+
orientation: 'vertical',
|
|
32
|
+
items: [
|
|
33
|
+
{ id: 'wthDrawn', text: 'Со снятием' },
|
|
34
|
+
{ id: 'noWithdrawn', text: 'Без снятия' },
|
|
35
|
+
],
|
|
36
|
+
})
|
|
37
|
+
: null}
|
|
38
|
+
</div>
|
|
39
|
+
<div className="border-b border-main-divider w-full" />
|
|
40
|
+
<div className="flex gap-lg">
|
|
41
|
+
{params.isShowMonthlyInterestPayment
|
|
42
|
+
? renderPayout({
|
|
43
|
+
title: 'Выплата процентов',
|
|
44
|
+
...field('isMonthlyInterestPayment'),
|
|
45
|
+
value: params.isMonthlyInterestPayment,
|
|
46
|
+
orientation: 'vertical',
|
|
47
|
+
})
|
|
48
|
+
: null}
|
|
49
|
+
{params.isShowRemoteRegistration
|
|
50
|
+
? renderRegistrationType({
|
|
51
|
+
title: 'Оформление',
|
|
52
|
+
...field('isRemoteRegistration'),
|
|
53
|
+
value: params.isRemoteRegistration,
|
|
54
|
+
orientation: 'vertical',
|
|
55
|
+
})
|
|
56
|
+
: null}
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const CalculatorStyle = {
|
|
2
|
-
wrapper: 'flex flex-col justify-between @4xl:flex-row gap-x-
|
|
2
|
+
wrapper: 'flex flex-col justify-between @4xl:flex-row gap-x-s gap-y-7 @xl:gap-y-4xl',
|
|
3
3
|
input:
|
|
4
|
-
'flex flex-col
|
|
5
|
-
result: 'flex flex-col gap-y-xl
|
|
4
|
+
'flex flex-col lg:max-w-80 gap-2xl border-b border-b-main-divider @xl:border-none pb-3xl @xl:pb-0',
|
|
5
|
+
result: 'flex flex-col gap-y-xl',
|
|
6
6
|
};
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
type RadioButtonItem,
|
|
5
5
|
} from '../../ui-kit/RadioButtonGroup/RadioButtonGroup';
|
|
6
6
|
import { Text } from '../../ui-kit/Text/Text';
|
|
7
|
-
import { style } from '../../utils/style';
|
|
8
7
|
|
|
9
8
|
export interface BinaryRadioButtonGroupProps {
|
|
10
9
|
items: [truthy: RadioButtonItem, falsy: RadioButtonItem];
|
|
@@ -25,7 +24,7 @@ export const renderBinaryRadioButtonGroup = ({
|
|
|
25
24
|
radioGroupClassName,
|
|
26
25
|
onChange,
|
|
27
26
|
}: BinaryRadioButtonGroupProps) => (
|
|
28
|
-
<div className="
|
|
27
|
+
<div className="grid gap-s whitespace-nowrap">
|
|
29
28
|
{title ? (
|
|
30
29
|
<div className="hidden @5xl:block">
|
|
31
30
|
<Text color="text-secondary-text" font="font-light">
|
|
@@ -45,7 +44,7 @@ export const renderBinaryRadioButtonGroup = ({
|
|
|
45
44
|
orientation={orientation}
|
|
46
45
|
items={items}
|
|
47
46
|
checkedItem={items[value ? 0 : 1].id}
|
|
48
|
-
className={
|
|
47
|
+
className={radioGroupClassName}
|
|
49
48
|
onChange={(_) => onChange && onChange(_ === items[0].id)}
|
|
50
49
|
/>
|
|
51
50
|
</div>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { type VNode } from '../../model/VNode';
|
|
1
2
|
import { CalculatorValueBlock } from './CalculatorValueBlock';
|
|
2
3
|
import { Rate, type RateProps } from './Rate';
|
|
3
4
|
import { UnknownRate, type UnknownRateProps } from './UnknownRate';
|
|
4
5
|
|
|
5
6
|
interface RenderRateProps extends RateProps, UnknownRateProps {
|
|
6
7
|
isUnknownRateShown?: boolean;
|
|
8
|
+
children?: VNode;
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export const renderRate = ({
|
|
@@ -13,13 +15,14 @@ export const renderRate = ({
|
|
|
13
15
|
fractionDigits = 2,
|
|
14
16
|
isUnknownRateShown = true,
|
|
15
17
|
color = 'text-secondary-text',
|
|
18
|
+
children,
|
|
16
19
|
...rest
|
|
17
20
|
}: RenderRateProps) =>
|
|
18
21
|
isUnknownRateShown && rate === 0 ? (
|
|
19
22
|
<UnknownRate title={title} {...rest} />
|
|
20
23
|
) : (
|
|
21
24
|
<div>
|
|
22
|
-
<div className="hidden @xl:block">
|
|
25
|
+
<div className="hidden @xl:block min-w-96">
|
|
23
26
|
<Rate
|
|
24
27
|
title={title}
|
|
25
28
|
rate={rate}
|
|
@@ -40,5 +43,6 @@ export const renderRate = ({
|
|
|
40
43
|
{...rest}
|
|
41
44
|
/>
|
|
42
45
|
</div>
|
|
46
|
+
{children}
|
|
43
47
|
</div>
|
|
44
48
|
);
|
package/package.json
CHANGED
|
@@ -37,6 +37,8 @@ export default {
|
|
|
37
37
|
paramsViewSettings={{
|
|
38
38
|
isShowMonthlyInterestPayment: true,
|
|
39
39
|
isShowRemoteRegistration: true,
|
|
40
|
+
isShowReplenish: true,
|
|
41
|
+
isShowWithdrawn: true,
|
|
40
42
|
}}
|
|
41
43
|
/>
|
|
42
44
|
</div>
|
|
@@ -48,6 +50,24 @@ export default {
|
|
|
48
50
|
paramsViewSettings={{
|
|
49
51
|
isShowMonthlyInterestPayment: false,
|
|
50
52
|
isShowRemoteRegistration: true,
|
|
53
|
+
isShowReplenish: true,
|
|
54
|
+
isShowWithdrawn: true,
|
|
55
|
+
}}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
),
|
|
59
|
+
replenish: (
|
|
60
|
+
<div className="container grid grid-cols-12">
|
|
61
|
+
<CalculatorDeposit
|
|
62
|
+
{...calculator}
|
|
63
|
+
paramsViewSettings={{
|
|
64
|
+
isShowReplenish: true,
|
|
65
|
+
isShowWithdrawn: true,
|
|
66
|
+
isShowRemoteRegistration: true,
|
|
67
|
+
isShowMonthlyInterestPayment: true,
|
|
68
|
+
}}
|
|
69
|
+
calcSource={{
|
|
70
|
+
$ref: '/wcms-resources/vklad-calculator-main-data.json',
|
|
51
71
|
}}
|
|
52
72
|
/>
|
|
53
73
|
</div>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable max-lines, max-lines-per-function */
|
|
2
2
|
import { useEffect } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
3
|
import { type JSONRefObject } from '../../data/JSONRefObject';
|
|
4
|
-
import { useForm
|
|
4
|
+
import { useForm } from '../../hooks/useForm';
|
|
5
|
+
import { Button } from '../../ui-kit/Button/Button';
|
|
5
6
|
import { CalculatorLayout } from '../../ui-kit/Calculator/CalculatorLayout';
|
|
6
7
|
import { CalculatorStyle } from '../../ui-kit/Calculator/CalculatorStyle';
|
|
7
8
|
import { getDefaultParamsMax } from '../../ui-kit/Calculator/getDefaultParams';
|
|
@@ -10,7 +11,6 @@ import {
|
|
|
10
11
|
getMonthsDefaultValue,
|
|
11
12
|
} from '../../ui-kit/Calculator/getDefaultValues';
|
|
12
13
|
import { renderMonthsInput } from '../../ui-kit/Calculator/renderMonthsInput';
|
|
13
|
-
import { renderPayout } from '../../ui-kit/Calculator/renderPayout';
|
|
14
14
|
import { renderRate } from '../../ui-kit/Calculator/renderRate';
|
|
15
15
|
import { renderWantedSumInput } from '../../ui-kit/Calculator/renderWantedSumInput';
|
|
16
16
|
import { setDefaultParamsCalc } from '../../ui-kit/Calculator/setDefaultParamsCalc';
|
|
@@ -19,22 +19,21 @@ import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
|
19
19
|
import { clamp } from '../../utils/clamp';
|
|
20
20
|
import { style } from '../../utils/style';
|
|
21
21
|
import { isDefaultParams } from '../CalculatorCredit/isDefaultParams';
|
|
22
|
-
import {
|
|
23
|
-
type CalculatorDepositContent,
|
|
24
|
-
type CalculatorDepositParamsViewSettings,
|
|
25
|
-
} from './CalculatorDepositContent';
|
|
22
|
+
import { type CalculatorDepositContent } from './CalculatorDepositContent';
|
|
26
23
|
import {
|
|
27
24
|
getDepositCalculatorParams,
|
|
28
25
|
type DepositCalculatorData,
|
|
29
|
-
type DepositCalculatorParams,
|
|
30
26
|
type DepositCalculatorSourceBookParams,
|
|
27
|
+
type TariffsButtonContent,
|
|
31
28
|
} from './getDepositCalculatorParams';
|
|
29
|
+
import { renderDepositParamsForm } from './renderDepositParamsForm';
|
|
32
30
|
import { renderDepositResult } from './renderDepositResult';
|
|
33
|
-
import { renderRegistrationType } from './renderRegistrationType';
|
|
34
31
|
|
|
35
32
|
const MAP = {
|
|
36
33
|
isMonthlyInterestPayment: 'isMonthlyInterestPayment',
|
|
37
34
|
isRemoteRegistration: 'isRemoteRegistration',
|
|
35
|
+
isReplenish: 'isReplenish',
|
|
36
|
+
isWithdrawn: 'isWithdrawn',
|
|
38
37
|
moneyValue: 'minSum',
|
|
39
38
|
};
|
|
40
39
|
|
|
@@ -49,22 +48,24 @@ export const CalculatorDeposit = UniBlock<CalculatorDepositProps>(
|
|
|
49
48
|
className,
|
|
50
49
|
title,
|
|
51
50
|
calcSource,
|
|
52
|
-
buttons,
|
|
53
|
-
footnote,
|
|
51
|
+
buttons = [],
|
|
52
|
+
footnote = '',
|
|
54
53
|
paramsViewSettings,
|
|
55
54
|
defaultParams,
|
|
56
55
|
...rest
|
|
57
56
|
}) => {
|
|
58
57
|
const defParams = getDefaultParamsMax(calcSource?.rateRows);
|
|
58
|
+
|
|
59
59
|
const [userInputParams, { field }] = useForm({
|
|
60
60
|
moneyValue: getMoneyDefaultValue(defaultParams, DEPOSIT_DEFAULT_SUM),
|
|
61
61
|
monthsValue: getMonthsDefaultValue(defaultParams),
|
|
62
62
|
isMonthlyInterestPayment: Boolean(defaultParams?.isMonthlyInterestPayment),
|
|
63
63
|
isRemoteRegistration: Boolean(defaultParams?.isRemoteRegistration),
|
|
64
|
+
isReplenish: false,
|
|
65
|
+
isWithdrawn: Boolean(defaultParams?.isWithdrawn ?? false),
|
|
64
66
|
});
|
|
65
|
-
|
|
66
67
|
const calcParams = getDepositCalculatorParams(userInputParams, calcSource, paramsViewSettings);
|
|
67
|
-
const { defaultMonth, rate, income, finalSum } = calcParams;
|
|
68
|
+
const { defaultMonth, rate, income, finalSum, type = '' } = calcParams;
|
|
68
69
|
const { onChange: setMonthsValue } = field('monthsValue');
|
|
69
70
|
const { onChange: setMoneyValue } = field('moneyValue');
|
|
70
71
|
|
|
@@ -77,18 +78,23 @@ export const CalculatorDeposit = UniBlock<CalculatorDepositProps>(
|
|
|
77
78
|
setMoneyValue(clamp(userInputParams.moneyValue, calcParams.minSum, calcParams.maxSum));
|
|
78
79
|
}, [calcParams.minSum, calcParams.maxSum]);
|
|
79
80
|
|
|
81
|
+
const handleDefaultParamsCals = () =>
|
|
82
|
+
setDefaultParamsCalc({
|
|
83
|
+
field,
|
|
84
|
+
defParams: defParams as DepositCalculatorSourceBookParams,
|
|
85
|
+
calcParams,
|
|
86
|
+
monthsValue: 'minMonths',
|
|
87
|
+
map: MAP,
|
|
88
|
+
});
|
|
89
|
+
|
|
80
90
|
useEffect(() => {
|
|
81
91
|
if (!isDefaultParams(defaultParams) && defParams) {
|
|
82
|
-
|
|
83
|
-
field,
|
|
84
|
-
defParams: defParams as DepositCalculatorSourceBookParams,
|
|
85
|
-
calcParams,
|
|
86
|
-
monthsValue: 'minMonths',
|
|
87
|
-
map: MAP,
|
|
88
|
-
});
|
|
92
|
+
handleDefaultParamsCals();
|
|
89
93
|
}
|
|
90
94
|
}, [calcSource, defaultParams]);
|
|
91
95
|
|
|
96
|
+
const isMaxRate = rate === defParams?.rate;
|
|
97
|
+
|
|
92
98
|
return (
|
|
93
99
|
<CalculatorLayout className={className} title={title} {...rest}>
|
|
94
100
|
<section className={style(CalculatorStyle.wrapper, className)}>
|
|
@@ -112,32 +118,30 @@ export const CalculatorDeposit = UniBlock<CalculatorDepositProps>(
|
|
|
112
118
|
</div>
|
|
113
119
|
{renderRate({
|
|
114
120
|
rate,
|
|
121
|
+
children: renderMaxRateButton(handleDefaultParamsCals, isMaxRate),
|
|
122
|
+
})}
|
|
123
|
+
{renderDepositResult({
|
|
124
|
+
income,
|
|
125
|
+
finalSum,
|
|
126
|
+
buttons: [...buttons, getTariffButton(calcSource?.buttons, type)],
|
|
127
|
+
footnotes: [footnote],
|
|
115
128
|
})}
|
|
116
|
-
{renderDepositResult({ income, finalSum, buttons, footnotes: [footnote as string] })}
|
|
117
129
|
</section>
|
|
118
130
|
</CalculatorLayout>
|
|
119
131
|
);
|
|
120
132
|
},
|
|
121
133
|
);
|
|
122
134
|
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
? renderRegistrationType({
|
|
137
|
-
title: 'Оформление',
|
|
138
|
-
...field('isRemoteRegistration'),
|
|
139
|
-
value: params.isRemoteRegistration,
|
|
140
|
-
})
|
|
141
|
-
: null}
|
|
142
|
-
</div>
|
|
143
|
-
);
|
|
135
|
+
const getTariffButton = (buttons: TariffsButtonContent[] = [], btnType = '') => {
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
137
|
+
const { type, ...button } = buttons.find((_) => _.type === btnType) ?? {};
|
|
138
|
+
|
|
139
|
+
return button;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const renderMaxRateButton = (handleDefaultParamsCals: () => void, isMaxRate = false) =>
|
|
143
|
+
isMaxRate ? null : (
|
|
144
|
+
<Button type="button" version="secondary" onClick={handleDefaultParamsCals}>
|
|
145
|
+
Показать максимальную ставку
|
|
146
|
+
</Button>
|
|
147
|
+
);
|
|
@@ -15,13 +15,23 @@ export interface CalculatorDepositParamsViewSettings {
|
|
|
15
15
|
* @default true
|
|
16
16
|
*/
|
|
17
17
|
isShowRemoteRegistration?: boolean;
|
|
18
|
+
/** @title Пополнение */
|
|
19
|
+
isShowReplenish?: boolean;
|
|
20
|
+
/** @title Снятие */
|
|
21
|
+
isShowWithdrawn?: boolean;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
export interface CommonDepositParams {
|
|
25
|
+
/** @title Возможность помолнять */
|
|
26
|
+
isReplenish?: boolean;
|
|
27
|
+
/** @title Возможно снимать */
|
|
28
|
+
isWithdrawn?: boolean;
|
|
21
29
|
/** @title Ежемесячная выплата процентов */
|
|
22
30
|
isMonthlyInterestPayment?: boolean;
|
|
23
31
|
/** @title Дистанционное оформление */
|
|
24
32
|
isRemoteRegistration?: boolean;
|
|
33
|
+
/** @title Тип депозита */
|
|
34
|
+
type?: string;
|
|
25
35
|
}
|
|
26
36
|
|
|
27
37
|
export interface DepositDefaultParams extends CommonDefaultParams, CommonDepositParams {}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type CalcValueProps,
|
|
4
4
|
} from '../../ui-kit/Calculator/CalculatorProps';
|
|
5
5
|
import { checkRangeByKeys, getRangeByKeys } from '../../ui-kit/Calculator/rangeHelpers';
|
|
6
|
+
import type { LinkButtonContent } from '../../ui-kit/LinkButton/LinkButtonContent';
|
|
6
7
|
import { arrayByRange } from '../../utils/arrayByRange';
|
|
7
8
|
import { mergeIntervals } from '../../utils/mergeIntervals';
|
|
8
9
|
import {
|
|
@@ -18,6 +19,9 @@ const DEFAULT_DEPOSIT_CALCULATOR_PARAMS: DepositCalculatorSourceBookParams = {
|
|
|
18
19
|
rate: 0,
|
|
19
20
|
isMonthlyInterestPayment: true,
|
|
20
21
|
isRemoteRegistration: true,
|
|
22
|
+
isReplenish: false,
|
|
23
|
+
isWithdrawn: false,
|
|
24
|
+
type: '',
|
|
21
25
|
};
|
|
22
26
|
|
|
23
27
|
export interface DepositCalculatorSourceBookParams
|
|
@@ -35,8 +39,13 @@ export interface DepositCalculatorParams
|
|
|
35
39
|
finalSum: number;
|
|
36
40
|
}
|
|
37
41
|
|
|
42
|
+
export type TariffsButtonContent = LinkButtonContent & {
|
|
43
|
+
type?: string;
|
|
44
|
+
};
|
|
45
|
+
|
|
38
46
|
export type DepositCalculatorData = {
|
|
39
47
|
rateRows?: DepositCalculatorSourceBookParams[];
|
|
48
|
+
buttons?: TariffsButtonContent[];
|
|
40
49
|
};
|
|
41
50
|
|
|
42
51
|
export const getDepositCalculatorParams = (
|
|
@@ -50,9 +59,23 @@ export const getDepositCalculatorParams = (
|
|
|
50
59
|
: 0;
|
|
51
60
|
const isExcludeMonthlyInterestPayment = !paramsViewSettings?.isShowMonthlyInterestPayment;
|
|
52
61
|
const isExcludeRemoteRegistration = !paramsViewSettings?.isShowRemoteRegistration;
|
|
62
|
+
const isExcludeReplenish = !paramsViewSettings?.isShowReplenish;
|
|
63
|
+
const isExcludeWithdrawn = !paramsViewSettings?.isShowWithdrawn;
|
|
53
64
|
const depositCalculatorSourceBookParams =
|
|
54
65
|
calcSource?.rateRows?.find(
|
|
55
66
|
(row) =>
|
|
67
|
+
checkRowByParam({
|
|
68
|
+
row,
|
|
69
|
+
userInputParams,
|
|
70
|
+
paramKey: 'isReplenish',
|
|
71
|
+
isExclude: isExcludeReplenish,
|
|
72
|
+
}) &&
|
|
73
|
+
checkRowByParam({
|
|
74
|
+
row,
|
|
75
|
+
userInputParams,
|
|
76
|
+
paramKey: 'isWithdrawn',
|
|
77
|
+
isExclude: isExcludeWithdrawn,
|
|
78
|
+
}) &&
|
|
56
79
|
checkRowByParam({
|
|
57
80
|
row,
|
|
58
81
|
userInputParams,
|