@redneckz/wildless-cms-uni-blocks 0.6.34 → 0.6.35

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 (97) hide show
  1. package/bundle/bundle.umd.js +55 -20
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/components/Calculator/constants.d.ts +3 -0
  4. package/bundle/components/Calculator/useDepositCalculatorParams.d.ts +22 -0
  5. package/bundle/components/Header/HeaderSecondaryMenu.d.ts +1 -0
  6. package/bundle/services/sitemap/SitemapProps.d.ts +1 -2
  7. package/dist/components/Calculator/DepositCalculatorForm.js +13 -11
  8. package/dist/components/Calculator/DepositCalculatorForm.js.map +1 -1
  9. package/dist/components/Calculator/constants.d.ts +3 -0
  10. package/dist/components/Calculator/constants.js +10 -1
  11. package/dist/components/Calculator/constants.js.map +1 -1
  12. package/dist/components/Calculator/useDepositCalculatorParams.d.ts +22 -0
  13. package/dist/components/Calculator/useDepositCalculatorParams.js +28 -0
  14. package/dist/components/Calculator/useDepositCalculatorParams.js.map +1 -0
  15. package/dist/components/Header/Header.js +2 -2
  16. package/dist/components/Header/Header.js.map +1 -1
  17. package/dist/components/Header/HeaderSecondaryMenu.d.ts +1 -0
  18. package/dist/components/Header/HeaderSecondaryMenu.js +2 -2
  19. package/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
  20. package/dist/components/OtherProductsItem/OtherProductsItem.js +1 -1
  21. package/dist/components/OtherProductsItem/OtherProductsItem.js.map +1 -1
  22. package/dist/components/VerticalLayout/VerticalLayout.js +5 -3
  23. package/dist/components/VerticalLayout/VerticalLayout.js.map +1 -1
  24. package/dist/services/sitemap/SitemapProps.d.ts +1 -2
  25. package/lib/components/Calculator/DepositCalculatorForm.js +14 -12
  26. package/lib/components/Calculator/DepositCalculatorForm.js.map +1 -1
  27. package/lib/components/Calculator/constants.d.ts +3 -0
  28. package/lib/components/Calculator/constants.js +9 -0
  29. package/lib/components/Calculator/constants.js.map +1 -1
  30. package/lib/components/Calculator/useDepositCalculatorParams.d.ts +22 -0
  31. package/lib/components/Calculator/useDepositCalculatorParams.js +25 -0
  32. package/lib/components/Calculator/useDepositCalculatorParams.js.map +1 -0
  33. package/lib/components/Header/Header.js +2 -2
  34. package/lib/components/Header/Header.js.map +1 -1
  35. package/lib/components/Header/HeaderSecondaryMenu.d.ts +1 -0
  36. package/lib/components/Header/HeaderSecondaryMenu.js +2 -2
  37. package/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
  38. package/lib/components/OtherProductsItem/OtherProductsItem.js +1 -1
  39. package/lib/components/OtherProductsItem/OtherProductsItem.js.map +1 -1
  40. package/lib/components/VerticalLayout/VerticalLayout.js +5 -3
  41. package/lib/components/VerticalLayout/VerticalLayout.js.map +1 -1
  42. package/lib/services/sitemap/SitemapProps.d.ts +1 -2
  43. package/mobile/bundle/bundle.umd.js +1 -1
  44. package/mobile/bundle/bundle.umd.min.js +1 -1
  45. package/mobile/bundle/components/Calculator/constants.d.ts +3 -0
  46. package/mobile/bundle/components/Calculator/useDepositCalculatorParams.d.ts +22 -0
  47. package/mobile/bundle/components/Header/HeaderSecondaryMenu.d.ts +1 -0
  48. package/mobile/bundle/services/sitemap/SitemapProps.d.ts +1 -2
  49. package/mobile/dist/components/Calculator/DepositCalculatorForm.js +13 -11
  50. package/mobile/dist/components/Calculator/DepositCalculatorForm.js.map +1 -1
  51. package/mobile/dist/components/Calculator/constants.d.ts +3 -0
  52. package/mobile/dist/components/Calculator/constants.js +10 -1
  53. package/mobile/dist/components/Calculator/constants.js.map +1 -1
  54. package/mobile/dist/components/Calculator/useDepositCalculatorParams.d.ts +22 -0
  55. package/mobile/dist/components/Calculator/useDepositCalculatorParams.js +28 -0
  56. package/mobile/dist/components/Calculator/useDepositCalculatorParams.js.map +1 -0
  57. package/mobile/dist/components/Header/HeaderSecondaryMenu.d.ts +1 -0
  58. package/mobile/dist/components/Header/HeaderSecondaryMenu.js +2 -2
  59. package/mobile/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
  60. package/mobile/dist/components/OtherProductsItem/OtherProductsItem.js +1 -1
  61. package/mobile/dist/components/OtherProductsItem/OtherProductsItem.js.map +1 -1
  62. package/mobile/dist/components/VerticalLayout/VerticalLayout.js +5 -3
  63. package/mobile/dist/components/VerticalLayout/VerticalLayout.js.map +1 -1
  64. package/mobile/dist/services/sitemap/SitemapProps.d.ts +1 -2
  65. package/mobile/lib/components/Calculator/DepositCalculatorForm.js +14 -12
  66. package/mobile/lib/components/Calculator/DepositCalculatorForm.js.map +1 -1
  67. package/mobile/lib/components/Calculator/constants.d.ts +3 -0
  68. package/mobile/lib/components/Calculator/constants.js +9 -0
  69. package/mobile/lib/components/Calculator/constants.js.map +1 -1
  70. package/mobile/lib/components/Calculator/useDepositCalculatorParams.d.ts +22 -0
  71. package/mobile/lib/components/Calculator/useDepositCalculatorParams.js +25 -0
  72. package/mobile/lib/components/Calculator/useDepositCalculatorParams.js.map +1 -0
  73. package/mobile/lib/components/Header/HeaderSecondaryMenu.d.ts +1 -0
  74. package/mobile/lib/components/Header/HeaderSecondaryMenu.js +2 -2
  75. package/mobile/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
  76. package/mobile/lib/components/OtherProductsItem/OtherProductsItem.js +1 -1
  77. package/mobile/lib/components/OtherProductsItem/OtherProductsItem.js.map +1 -1
  78. package/mobile/lib/components/VerticalLayout/VerticalLayout.js +5 -3
  79. package/mobile/lib/components/VerticalLayout/VerticalLayout.js.map +1 -1
  80. package/mobile/lib/services/sitemap/SitemapProps.d.ts +1 -2
  81. package/mobile/src/components/Calculator/DepositCalculatorForm.tsx +17 -22
  82. package/mobile/src/components/Calculator/constants.ts +11 -0
  83. package/mobile/src/components/Calculator/useDepositCalculatorParams.ts +64 -0
  84. package/mobile/src/components/Header/HeaderSecondaryMenu.tsx +12 -9
  85. package/mobile/src/components/OtherProductsItem/OtherProductsItem.tsx +1 -1
  86. package/mobile/src/components/VerticalLayout/VerticalLayout.tsx +5 -3
  87. package/mobile/src/services/sitemap/SitemapProps.ts +1 -2
  88. package/package.json +1 -1
  89. package/src/components/Calculator/Calculator.fixture.tsx +0 -5
  90. package/src/components/Calculator/DepositCalculatorForm.tsx +17 -22
  91. package/src/components/Calculator/constants.ts +11 -0
  92. package/src/components/Calculator/useDepositCalculatorParams.ts +64 -0
  93. package/src/components/Header/Header.tsx +2 -1
  94. package/src/components/Header/HeaderSecondaryMenu.tsx +12 -9
  95. package/src/components/OtherProductsItem/OtherProductsItem.tsx +1 -1
  96. package/src/components/VerticalLayout/VerticalLayout.tsx +5 -3
  97. package/src/services/sitemap/SitemapProps.ts +1 -2
@@ -20,13 +20,12 @@ export interface DispositionItem extends LinkProps {
20
20
  }
21
21
 
22
22
  export interface SitemapDataProps {
23
- /** @title Основное меню */
24
23
  topItems?: TopMenuItem[];
25
- /** @title Дополнительное меню */
26
24
  dispositions?: DispositionItem[];
27
25
  logo?: {
28
26
  image?: Picture;
29
27
  title?: string;
30
28
  };
31
29
  defaultLocation?: string;
30
+ officesLink?: string;
32
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.6.34",
3
+ "version": "0.6.35",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -34,11 +34,6 @@ const CREDIT_CALCULATOR_BLOCK: CreditCalculatorParamsDef = {
34
34
 
35
35
  const DEPOSIT_CALCULATOR_BLOCK: DepositCalculatorParamsDef = {
36
36
  calcType: 'DepositCalculatorForm',
37
- minSum: 50000,
38
- maxSum: 5000000,
39
- minMonths: 2,
40
- maxMonths: 120,
41
- rate: 5.9,
42
37
  buttons: buttons,
43
38
  footnote,
44
39
  };
@@ -5,19 +5,13 @@ import { useState } from '@redneckz/uni-jsx/lib/hooks';
5
5
  import { RadioButtonGroup } from '../../ui-kit/RadioButtonGroup/RadioButtonGroup';
6
6
  import { CommonCalculatorProps, DepositCalculatorParams } from './CalculatorContent';
7
7
  import { CalculatorValueBlock } from './CalculatorValueBlock';
8
- import {
9
- DEFAULT_MAX_MONTHS,
10
- DEFAULT_MAX_SUM,
11
- DEFAULT_MIN_MONTHS,
12
- DEFAULT_MIN_SUM,
13
- DEFAULT_MONTHS,
14
- DEFAULT_SUM,
15
- } from './constants';
8
+ import { DEFAULT_MONTHS, DEFAULT_SUM } from './constants';
16
9
  import { Rate } from './Rate';
17
10
  import { renderButtonSection } from './renderButtonSection';
18
11
  import { renderFootnote } from './renderFootnote';
19
12
  import { renderMonthsInput } from './renderMonthsInput';
20
13
  import { renderWantedSumInput } from './renderWantedSumInput';
14
+ import { useDepositCalculatorParams } from './useDepositCalculatorParams';
21
15
 
22
16
  export interface DepositCalculatorProp extends DepositCalculatorParams, CommonCalculatorProps {
23
17
  className?: string;
@@ -38,13 +32,18 @@ const depositTypeItems = [
38
32
  ];
39
33
 
40
34
  export const DepositCalculatorForm = JSX<DepositCalculatorProp>(
41
- ({ className = '', rate, buttons, footnote }) => {
35
+ ({ className = '', sourceBookDir, buttons, footnote }) => {
42
36
  const [moneyValue, setMoneyValue] = useState(DEFAULT_SUM);
43
37
  const [monthsValue, setMonthsValue] = useState(DEFAULT_MONTHS);
44
- const [isEveryMonth, toggleIsEveryMonth] = useState(false);
38
+ const [isMonthlyInterestPayment, toggleIsMonthlyInterestPayment] = useState(false);
39
+ const userInputParams = {
40
+ moneyValue,
41
+ monthsValue,
42
+ isMonthlyInterestPayment,
43
+ };
45
44
 
46
- const income = 948841;
47
- const finallySum = 1218841;
45
+ const calculatorParams = useDepositCalculatorParams(userInputParams, sourceBookDir);
46
+ const { income, finalSum, rate } = calculatorParams;
48
47
 
49
48
  return (
50
49
  <section className={className}>
@@ -52,18 +51,14 @@ export const DepositCalculatorForm = JSX<DepositCalculatorProp>(
52
51
  {renderWantedSumInput(
53
52
  'Сумма вклада, ₽',
54
53
  {
55
- moneyValue,
56
- minSum: DEFAULT_MIN_SUM,
57
- maxSum: DEFAULT_MAX_SUM,
54
+ ...calculatorParams,
58
55
  },
59
56
  setMoneyValue,
60
57
  )}
61
58
  {renderMonthsInput(
62
59
  'Срок вклада, месяцев',
63
60
  {
64
- minMonths: DEFAULT_MIN_MONTHS,
65
- maxMonths: DEFAULT_MAX_MONTHS,
66
- monthsValue,
61
+ ...calculatorParams,
67
62
  },
68
63
  setMonthsValue,
69
64
  )}
@@ -73,13 +68,13 @@ export const DepositCalculatorForm = JSX<DepositCalculatorProp>(
73
68
  {income ? (
74
69
  <CalculatorValueBlock title="Доход по вкладу" value={income} postfix="₽" prefix="+" />
75
70
  ) : null}
76
- {finallySum ? (
77
- <CalculatorValueBlock title="Сумма в конце срока" value={finallySum} postfix="₽" />
71
+ {finalSum ? (
72
+ <CalculatorValueBlock title="Сумма в конце срока" value={finalSum} postfix="₽" />
78
73
  ) : null}
79
74
  <RadioButtonGroup
80
75
  items={depositTypeItems}
81
- checkedItem={isEveryMonth ? EVERY_MONTH : AT_END_TERM}
82
- onChange={(text: string) => toggleIsEveryMonth(text === EVERY_MONTH)}
76
+ checkedItem={isMonthlyInterestPayment ? EVERY_MONTH : AT_END_TERM}
77
+ onChange={(text: string) => toggleIsMonthlyInterestPayment(text === EVERY_MONTH)}
83
78
  />
84
79
  {renderButtonSection(buttons)}
85
80
  {renderFootnote(footnote)}
@@ -1,5 +1,6 @@
1
1
  import { BonusCalculatorSourceBookParams } from './useBonusCalculatorParams';
2
2
  import { CreditCalculatorSourceBookParams } from './useCreditCalculatorParams';
3
+ import { DepositCalculatorSourceBookParams } from './useDepositCalculatorParams';
3
4
 
4
5
  export const DEFAULT_MIN_SUM = 60000;
5
6
  export const DEFAULT_MAX_SUM = 2000000;
@@ -41,5 +42,15 @@ export const DEFAULT_BONUS_CALCULATOR_PARAMS: BonusCalculatorSourceBookParams =
41
42
  restBonusRate: 0.01,
42
43
  };
43
44
 
45
+ export const DEFAULT_DEPOSIT_CALCULATOR_PARAMS: DepositCalculatorSourceBookParams = {
46
+ minSum: 50000,
47
+ maxSum: 5000000,
48
+ minMonths: 2,
49
+ maxMonths: 120,
50
+ rate: 5.9,
51
+ isMonthlyInterestPayment: true,
52
+ };
53
+
44
54
  export const CREDIT_CALC_DEFAULT_DIR = 'credit-calculator-data';
45
55
  export const BONUS_CALC_DEFAULT_DIR = 'bonus-calculator-data';
56
+ export const DEPOSIT_CALC_DEFAULT_DIR = 'deposit-calculator-data';
@@ -0,0 +1,64 @@
1
+ import { DEFAULT_DEPOSIT_CALCULATOR_PARAMS, DEPOSIT_CALC_DEFAULT_DIR } from './constants';
2
+ import { useCalculatorParams } from './useCalculatorParams';
3
+
4
+ export interface CommonDepositParams {
5
+ isMonthlyInterestPayment: boolean;
6
+ }
7
+ export interface DepositCalculatorSourceBookParams extends CommonDepositParams {
8
+ minSum: number;
9
+ maxSum: number;
10
+ minMonths: number;
11
+ maxMonths: number;
12
+ rate: number;
13
+ }
14
+
15
+ export interface DepositCalculatorUserInputParams extends CommonDepositParams {
16
+ moneyValue: number;
17
+ monthsValue: number;
18
+ }
19
+
20
+ export interface DepositCalculatorParams
21
+ extends DepositCalculatorSourceBookParams,
22
+ DepositCalculatorUserInputParams {
23
+ income: number;
24
+ finalSum: number;
25
+ }
26
+
27
+ export type DepositCalculatorData = {
28
+ rows: DepositCalculatorSourceBookParams[];
29
+ };
30
+
31
+ export const useDepositCalculatorParams = (
32
+ userInputParams: DepositCalculatorUserInputParams,
33
+ sourceBookDir?: string,
34
+ ): DepositCalculatorParams => {
35
+ const { isMonthlyInterestPayment, moneyValue } = userInputParams;
36
+
37
+ const data = useCalculatorParams<DepositCalculatorData>(
38
+ sourceBookDir || DEPOSIT_CALC_DEFAULT_DIR,
39
+ );
40
+
41
+ const depositCalculatorSourceBookParams =
42
+ data?.rows.find((_) => isMonthlyInterestPayment === _.isMonthlyInterestPayment) ||
43
+ DEFAULT_DEPOSIT_CALCULATOR_PARAMS;
44
+
45
+ const { rate } = depositCalculatorSourceBookParams;
46
+
47
+ const income = getDepositIncome(rate, userInputParams);
48
+ const finalSum = moneyValue + income;
49
+
50
+ return { ...depositCalculatorSourceBookParams, ...userInputParams, income, finalSum };
51
+ };
52
+
53
+ const getDepositIncome = (rate: number, userInputParams: DepositCalculatorUserInputParams) => {
54
+ const { isMonthlyInterestPayment, moneyValue, monthsValue } = userInputParams;
55
+
56
+ if (isMonthlyInterestPayment) {
57
+ return Math.round(moneyValue * Math.pow((1200 + rate) / 1200, monthsValue) - moneyValue);
58
+ } else {
59
+ /*
60
+ Приблизительный расчёт, не учитывающий разницу в количестве дней в месяцах. Месяц принят за 30 дней, год за 365 дней.
61
+ */
62
+ return Math.round((moneyValue * rate * 30 * monthsValue) / 365 / 100);
63
+ }
64
+ };
@@ -25,7 +25,7 @@ export const Header = JSX<HeaderProps>(
25
25
  ({ bgColor = 'bg-white', className = '', showSubMenu = true, ...rest }) => {
26
26
  const router = useRouter();
27
27
 
28
- const { topItems, logo, defaultLocation } = useSWRResource<SitemapDataProps>(
28
+ const { topItems, logo, defaultLocation, officesLink } = useSWRResource<SitemapDataProps>(
29
29
  projectSettings.SITEMAP || 'sitemap',
30
30
  rest.options?.page?.fallback,
31
31
  );
@@ -57,6 +57,7 @@ export const Header = JSX<HeaderProps>(
57
57
  <HeaderSecondaryMenu
58
58
  className="ml-auto"
59
59
  defaultLocation={defaultLocation}
60
+ officesLink={officesLink}
60
61
  bgColor={bgColor}
61
62
  />
62
63
  </div>
@@ -8,6 +8,7 @@ import { HeaderSecondaryMenuButton } from './HeaderSecondaryMenuButton';
8
8
 
9
9
  interface HeaderSecondaryMenuContent {
10
10
  defaultLocation?: string;
11
+ officesLink?: string;
11
12
  bgColor?: BgColorVersion;
12
13
  }
13
14
 
@@ -29,7 +30,7 @@ const LINKS_ICON_VERSION_MAP: Record<BgColorVersion, IconVersion> = {
29
30
  };
30
31
 
31
32
  export const HeaderSecondaryMenu = JSX<HeaderSecondaryMenuProps>(
32
- ({ className, defaultLocation = 'Москва', bgColor = 'bg-white' }) => {
33
+ ({ className, officesLink, defaultLocation = 'Москва', bgColor = 'bg-white' }) => {
33
34
  const [city, getCity] = useGeolocation(defaultLocation);
34
35
 
35
36
  return (
@@ -43,14 +44,16 @@ export const HeaderSecondaryMenu = JSX<HeaderSecondaryMenuProps>(
43
44
  onClick={getCity}
44
45
  bgColor={bgColor}
45
46
  />
46
- <TopItem
47
- className="mr-7"
48
- flat={true}
49
- href="#"
50
- text="Офисы и банкоматы"
51
- ariaLabel="Список всех доступных офисов и банкоматов"
52
- bgColor={bgColor}
53
- />
47
+ {officesLink ? (
48
+ <TopItem
49
+ className="mr-7"
50
+ flat={true}
51
+ href={officesLink}
52
+ text="Офисы и банкоматы"
53
+ ariaLabel="Список всех доступных офисов и банкоматов"
54
+ bgColor={bgColor}
55
+ />
56
+ ) : null}
54
57
  <HeaderSecondaryMenuButton
55
58
  className={`mr-5 group ${COLORS_MAP[bgColor]}`}
56
59
  ariaLabel="Поиск по сайту"
@@ -35,7 +35,7 @@ export const OtherProductsItem: JSXBlock<OtherProductsItemProps> = JSX<OtherProd
35
35
  <DefaultFoldButton
36
36
  label={label}
37
37
  icon={icons[Number(isUnfolded)]}
38
- dataTheme={rest.options?.page?.colorPalette || colorPalette}
38
+ dataTheme={colorPalette || rest.options?.page?.colorPalette}
39
39
  onClick={onToggle}
40
40
  />
41
41
  )}
@@ -31,15 +31,17 @@ const backgroundStyleMap: Record<BlockVersionWithTransparent, string> = {
31
31
  };
32
32
 
33
33
  export const VerticalLayout: JSXBlock<VerticalLayoutProps> = JSX<VerticalLayoutProps>(
34
- ({ className = '', gap = '', align = 'left', version = 'transparent', ...rest }) => (
34
+ ({ className = '', gap = '', align, version = 'transparent', ...rest }) => (
35
35
  <BlockWrapper
36
36
  className={[
37
37
  'flex flex-col',
38
38
  gapStyleMap[gap],
39
- alignStyle[align],
39
+ align && alignStyle[align],
40
40
  backgroundStyleMap[version],
41
41
  className,
42
- ].join(' ')}
42
+ ]
43
+ .filter(Boolean)
44
+ .join(' ')}
43
45
  {...rest}
44
46
  >
45
47
  {renderChildren(rest)}
@@ -20,13 +20,12 @@ export interface DispositionItem extends LinkProps {
20
20
  }
21
21
 
22
22
  export interface SitemapDataProps {
23
- /** @title Основное меню */
24
23
  topItems?: TopMenuItem[];
25
- /** @title Дополнительное меню */
26
24
  dispositions?: DispositionItem[];
27
25
  logo?: {
28
26
  image?: Picture;
29
27
  title?: string;
30
28
  };
31
29
  defaultLocation?: string;
30
+ officesLink?: string;
32
31
  }