@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.
Files changed (123) hide show
  1. package/bundle/blocks.schema.json +1 -1
  2. package/bundle/bundle.umd.js +93 -33
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/CalculatorDeposit/CalculatorDepositContent.d.ts +10 -0
  5. package/bundle/components/CalculatorDeposit/getDepositCalculatorParams.d.ts +5 -0
  6. package/bundle/components/CalculatorDeposit/renderDepositParamsForm.d.ts +5 -0
  7. package/bundle/ui-kit/Calculator/renderRate.d.ts +3 -1
  8. package/dist/components/CalculatorDeposit/CalculatorDeposit.js +31 -26
  9. package/dist/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
  10. package/dist/components/CalculatorDeposit/CalculatorDepositContent.d.ts +10 -0
  11. package/dist/components/CalculatorDeposit/getDepositCalculatorParams.d.ts +5 -0
  12. package/dist/components/CalculatorDeposit/getDepositCalculatorParams.js +19 -2
  13. package/dist/components/CalculatorDeposit/getDepositCalculatorParams.js.map +1 -1
  14. package/dist/components/CalculatorDeposit/renderDepositParamsForm.d.ts +5 -0
  15. package/dist/components/CalculatorDeposit/renderDepositParamsForm.js +45 -0
  16. package/dist/components/CalculatorDeposit/renderDepositParamsForm.js.map +1 -0
  17. package/dist/components/CalculatorDeposit/renderDepositResult.js +1 -1
  18. package/dist/components/CalculatorDeposit/renderDepositResult.js.map +1 -1
  19. package/dist/ui-kit/Calculator/CalculatorStyle.js +3 -3
  20. package/dist/ui-kit/Calculator/CalculatorStyle.js.map +1 -1
  21. package/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -2
  22. package/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
  23. package/dist/ui-kit/Calculator/renderRate.d.ts +3 -1
  24. package/dist/ui-kit/Calculator/renderRate.js +1 -1
  25. package/dist/ui-kit/Calculator/renderRate.js.map +1 -1
  26. package/lib/common.css +1 -1
  27. package/lib/components/CalculatorDeposit/CalculatorDeposit.fixture.d.ts +1 -0
  28. package/lib/components/CalculatorDeposit/CalculatorDeposit.js +30 -25
  29. package/lib/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
  30. package/lib/components/CalculatorDeposit/CalculatorDepositContent.d.ts +10 -0
  31. package/lib/components/CalculatorDeposit/getDepositCalculatorParams.d.ts +5 -0
  32. package/lib/components/CalculatorDeposit/getDepositCalculatorParams.js +19 -2
  33. package/lib/components/CalculatorDeposit/getDepositCalculatorParams.js.map +1 -1
  34. package/lib/components/CalculatorDeposit/renderDepositParamsForm.d.ts +4 -0
  35. package/lib/components/CalculatorDeposit/renderDepositParamsForm.js +42 -0
  36. package/lib/components/CalculatorDeposit/renderDepositParamsForm.js.map +1 -0
  37. package/lib/components/CalculatorDeposit/renderDepositResult.js +1 -1
  38. package/lib/components/CalculatorDeposit/renderDepositResult.js.map +1 -1
  39. package/lib/ui-kit/Calculator/CalculatorStyle.js +3 -3
  40. package/lib/ui-kit/Calculator/CalculatorStyle.js.map +1 -1
  41. package/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -2
  42. package/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
  43. package/lib/ui-kit/Calculator/renderRate.d.ts +3 -1
  44. package/lib/ui-kit/Calculator/renderRate.js +1 -1
  45. package/lib/ui-kit/Calculator/renderRate.js.map +1 -1
  46. package/mobile/bundle/bundle.umd.js +93 -33
  47. package/mobile/bundle/bundle.umd.min.js +1 -1
  48. package/mobile/bundle/components/CalculatorDeposit/CalculatorDepositContent.d.ts +10 -0
  49. package/mobile/bundle/components/CalculatorDeposit/getDepositCalculatorParams.d.ts +5 -0
  50. package/mobile/bundle/components/CalculatorDeposit/renderDepositParamsForm.d.ts +5 -0
  51. package/mobile/bundle/ui-kit/Calculator/renderRate.d.ts +3 -1
  52. package/mobile/dist/components/CalculatorDeposit/CalculatorDeposit.js +31 -26
  53. package/mobile/dist/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
  54. package/mobile/dist/components/CalculatorDeposit/CalculatorDepositContent.d.ts +10 -0
  55. package/mobile/dist/components/CalculatorDeposit/getDepositCalculatorParams.d.ts +5 -0
  56. package/mobile/dist/components/CalculatorDeposit/getDepositCalculatorParams.js +19 -2
  57. package/mobile/dist/components/CalculatorDeposit/getDepositCalculatorParams.js.map +1 -1
  58. package/mobile/dist/components/CalculatorDeposit/renderDepositParamsForm.d.ts +5 -0
  59. package/mobile/dist/components/CalculatorDeposit/renderDepositParamsForm.js +45 -0
  60. package/mobile/dist/components/CalculatorDeposit/renderDepositParamsForm.js.map +1 -0
  61. package/mobile/dist/components/CalculatorDeposit/renderDepositResult.js +1 -1
  62. package/mobile/dist/components/CalculatorDeposit/renderDepositResult.js.map +1 -1
  63. package/mobile/dist/ui-kit/Calculator/CalculatorStyle.js +3 -3
  64. package/mobile/dist/ui-kit/Calculator/CalculatorStyle.js.map +1 -1
  65. package/mobile/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -2
  66. package/mobile/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
  67. package/mobile/dist/ui-kit/Calculator/renderRate.d.ts +3 -1
  68. package/mobile/dist/ui-kit/Calculator/renderRate.js +1 -1
  69. package/mobile/dist/ui-kit/Calculator/renderRate.js.map +1 -1
  70. package/mobile/lib/common.css +1 -1
  71. package/mobile/lib/components/CalculatorDeposit/CalculatorDeposit.js +30 -25
  72. package/mobile/lib/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
  73. package/mobile/lib/components/CalculatorDeposit/CalculatorDepositContent.d.ts +10 -0
  74. package/mobile/lib/components/CalculatorDeposit/getDepositCalculatorParams.d.ts +5 -0
  75. package/mobile/lib/components/CalculatorDeposit/getDepositCalculatorParams.js +19 -2
  76. package/mobile/lib/components/CalculatorDeposit/getDepositCalculatorParams.js.map +1 -1
  77. package/mobile/lib/components/CalculatorDeposit/renderDepositParamsForm.d.ts +5 -0
  78. package/mobile/lib/components/CalculatorDeposit/renderDepositParamsForm.js +42 -0
  79. package/mobile/lib/components/CalculatorDeposit/renderDepositParamsForm.js.map +1 -0
  80. package/mobile/lib/components/CalculatorDeposit/renderDepositResult.js +1 -1
  81. package/mobile/lib/components/CalculatorDeposit/renderDepositResult.js.map +1 -1
  82. package/mobile/lib/ui-kit/Calculator/CalculatorStyle.js +3 -3
  83. package/mobile/lib/ui-kit/Calculator/CalculatorStyle.js.map +1 -1
  84. package/mobile/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -2
  85. package/mobile/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
  86. package/mobile/lib/ui-kit/Calculator/renderRate.d.ts +3 -1
  87. package/mobile/lib/ui-kit/Calculator/renderRate.js +1 -1
  88. package/mobile/lib/ui-kit/Calculator/renderRate.js.map +1 -1
  89. package/mobile/src/components/CalculatorDeposit/CalculatorDeposit.tsx +45 -41
  90. package/mobile/src/components/CalculatorDeposit/CalculatorDepositContent.ts +10 -0
  91. package/mobile/src/components/CalculatorDeposit/getDepositCalculatorParams.ts +23 -0
  92. package/mobile/src/components/CalculatorDeposit/renderDepositParamsForm.tsx +59 -0
  93. package/mobile/src/components/CalculatorDeposit/renderDepositResult.tsx +1 -1
  94. package/mobile/src/ui-kit/Calculator/CalculatorStyle.tsx +3 -3
  95. package/mobile/src/ui-kit/Calculator/renderBinaryRadioButtonGroup.tsx +2 -3
  96. package/mobile/src/ui-kit/Calculator/renderRate.tsx +5 -1
  97. package/package.json +1 -1
  98. package/src/components/CalculatorDeposit/CalculatorDeposit.fixture.tsx +20 -0
  99. package/src/components/CalculatorDeposit/CalculatorDeposit.tsx +45 -41
  100. package/src/components/CalculatorDeposit/CalculatorDepositContent.ts +10 -0
  101. package/src/components/CalculatorDeposit/getDepositCalculatorParams.ts +23 -0
  102. package/src/components/CalculatorDeposit/renderDepositParamsForm.tsx +59 -0
  103. package/src/components/CalculatorDeposit/renderDepositResult.tsx +1 -1
  104. package/src/ui-kit/Calculator/CalculatorStyle.tsx +3 -3
  105. package/src/ui-kit/Calculator/renderBinaryRadioButtonGroup.tsx +2 -3
  106. package/src/ui-kit/Calculator/renderRate.tsx +5 -1
  107. package/tailwind.config.cjs +1 -1
  108. package/bundle/ui-kit/Breadcrumb.d.ts +0 -6
  109. package/dist/ui-kit/Breadcrumb.d.ts +0 -6
  110. package/dist/ui-kit/Breadcrumb.js +0 -11
  111. package/dist/ui-kit/Breadcrumb.js.map +0 -1
  112. package/lib/ui-kit/Breadcrumb.d.ts +0 -6
  113. package/lib/ui-kit/Breadcrumb.js +0 -9
  114. package/lib/ui-kit/Breadcrumb.js.map +0 -1
  115. package/mobile/bundle/ui-kit/Breadcrumb.d.ts +0 -6
  116. package/mobile/dist/ui-kit/Breadcrumb.d.ts +0 -6
  117. package/mobile/dist/ui-kit/Breadcrumb.js +0 -11
  118. package/mobile/dist/ui-kit/Breadcrumb.js.map +0 -1
  119. package/mobile/lib/ui-kit/Breadcrumb.d.ts +0 -6
  120. package/mobile/lib/ui-kit/Breadcrumb.js +0 -9
  121. package/mobile/lib/ui-kit/Breadcrumb.js.map +0 -1
  122. package/mobile/src/ui-kit/Breadcrumb.tsx +0 -21
  123. 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, type FormFieldRegisterer } from '../../hooks/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
- setDefaultParamsCalc({
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 renderDepositParamsForm = (
124
- params: DepositCalculatorParams & CalculatorDepositParamsViewSettings,
125
- field: FormFieldRegisterer<any>,
126
- ) => (
127
- <div className="flex flex-col gap-y-2xl">
128
- {params.isShowMonthlyInterestPayment
129
- ? renderPayout({
130
- title: 'Выплата процентов',
131
- ...field('isMonthlyInterestPayment'),
132
- value: params.isMonthlyInterestPayment,
133
- })
134
- : null}
135
- {params.isShowRemoteRegistration
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
+ );
@@ -14,7 +14,7 @@ type DepositResultProps = {
14
14
  export const renderDepositResult = ({
15
15
  income,
16
16
  finalSum,
17
- buttons,
17
+ buttons = [],
18
18
  footnotes = [],
19
19
  }: DepositResultProps) => (
20
20
  <div className={CalculatorStyle.result}>
@@ -1,6 +1,6 @@
1
1
  export const CalculatorStyle = {
2
- wrapper: 'flex flex-col justify-between @4xl:flex-row gap-x-m gap-y-7 @xl:gap-y-4xl',
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 @xl:max-w-md gap-2xl border-b border-b-main-divider @xl:border-none pb-3xl @xl:pb-0',
5
- result: 'flex flex-col gap-y-xl @xl:w-96',
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="space-y-s">
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={style('flex-col sm:flex-row', radioGroupClassName)}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.430",
3
+ "version": "0.14.431",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -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, type FormFieldRegisterer } from '../../hooks/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
- setDefaultParamsCalc({
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 renderDepositParamsForm = (
124
- params: DepositCalculatorParams & CalculatorDepositParamsViewSettings,
125
- field: FormFieldRegisterer<any>,
126
- ) => (
127
- <div className="flex flex-col gap-y-2xl">
128
- {params.isShowMonthlyInterestPayment
129
- ? renderPayout({
130
- title: 'Выплата процентов',
131
- ...field('isMonthlyInterestPayment'),
132
- value: params.isMonthlyInterestPayment,
133
- })
134
- : null}
135
- {params.isShowRemoteRegistration
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,