@redneckz/wildless-cms-uni-blocks 0.2.79 → 0.2.83
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/bundle.umd.js +158 -9
- package/bundle/bundle.umd.min.js +1 -1
- package/dist/ProjectSettings.d.ts +1 -0
- package/dist/ProjectSettings.js.map +1 -1
- package/dist/components/Blocks.d.ts +1 -0
- package/dist/components/Blocks.js +2 -0
- package/dist/components/Blocks.js.map +1 -1
- package/dist/components/CreditCalculator/CreditCalculator.d.ts +2 -1
- package/dist/components/CreditCalculator/CreditCalculator.js +43 -15
- package/dist/components/CreditCalculator/CreditCalculator.js.map +1 -1
- package/dist/components/CreditCalculator/CreditCalculatorContent.d.ts +15 -0
- package/dist/components/CreditCalculator/CreditCalculatorContent.js +2 -0
- package/dist/components/CreditCalculator/CreditCalculatorContent.js.map +1 -0
- package/dist/components/CreditCalculator/constants.d.ts +7 -0
- package/dist/components/CreditCalculator/constants.js +10 -0
- package/dist/components/CreditCalculator/constants.js.map +1 -0
- package/dist/components/CreditCalculator/getCalculatorParams.d.ts +7 -0
- package/dist/components/CreditCalculator/getCalculatorParams.js +11 -0
- package/dist/components/CreditCalculator/getCalculatorParams.js.map +1 -0
- package/dist/components/CreditCalculator/getCreditRate.d.ts +7 -0
- package/dist/components/CreditCalculator/getCreditRate.js +13 -0
- package/dist/components/CreditCalculator/getCreditRate.js.map +1 -0
- package/dist/components/CreditCalculator/getCreditTermYears.d.ts +1 -0
- package/dist/components/CreditCalculator/getCreditTermYears.js +15 -0
- package/dist/components/CreditCalculator/getCreditTermYears.js.map +1 -0
- package/dist/components/CreditCalculator/getMonthlyPayment.d.ts +11 -0
- package/dist/components/CreditCalculator/getMonthlyPayment.js +19 -0
- package/dist/components/CreditCalculator/getMonthlyPayment.js.map +1 -0
- package/dist/components/Footer/SocialMedia.js +11 -5
- package/dist/components/Footer/SocialMedia.js.map +1 -1
- package/dist/components/Header/HeaderSecondaryMenu.js +1 -1
- package/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
- package/dist/hooks/useCreditCalculatorData.d.ts +3 -0
- package/dist/hooks/useCreditCalculatorData.js +15 -0
- package/dist/hooks/useCreditCalculatorData.js.map +1 -0
- package/dist/ui-kit/Icon/Icon.js +1 -1
- package/dist/ui-kit/Icon/Icon.js.map +1 -1
- package/dist/ui-kit/InputRange/InputRange.js +3 -2
- package/dist/ui-kit/InputRange/InputRange.js.map +1 -1
- package/dist/utils/addSpacesBetweenNumbers.d.ts +1 -0
- package/dist/utils/addSpacesBetweenNumbers.js +5 -0
- package/dist/utils/addSpacesBetweenNumbers.js.map +1 -0
- package/lib/ProjectSettings.d.ts +1 -0
- package/lib/ProjectSettings.js.map +1 -1
- package/lib/common.css +1 -1
- package/lib/components/Accordion/Accordion.fixture.d.ts +4 -0
- package/lib/components/BenefitsBlock/BenefitsBlock.fixture.d.ts +2 -0
- package/lib/components/Blocks.d.ts +1 -0
- package/lib/components/Blocks.js +2 -0
- package/lib/components/Blocks.js.map +1 -1
- package/lib/components/ComparisonTable/ComparisonTable.fixture.d.ts +8 -0
- package/lib/components/ContentPage/ContentPage.fixture.d.ts +6 -0
- package/lib/components/CreditCalculator/CreditCalculator.d.ts +2 -1
- package/lib/components/CreditCalculator/CreditCalculator.fixture.d.ts +2 -0
- package/lib/components/CreditCalculator/CreditCalculator.js +43 -15
- package/lib/components/CreditCalculator/CreditCalculator.js.map +1 -1
- package/lib/components/CreditCalculator/CreditCalculatorContent.d.ts +15 -0
- package/lib/components/CreditCalculator/CreditCalculatorContent.js +2 -0
- package/lib/components/CreditCalculator/CreditCalculatorContent.js.map +1 -0
- package/lib/components/CreditCalculator/constants.d.ts +7 -0
- package/lib/components/CreditCalculator/constants.js +8 -0
- package/lib/components/CreditCalculator/constants.js.map +1 -0
- package/lib/components/CreditCalculator/getCalculatorParams.d.ts +7 -0
- package/lib/components/CreditCalculator/getCalculatorParams.js +8 -0
- package/lib/components/CreditCalculator/getCalculatorParams.js.map +1 -0
- package/lib/components/CreditCalculator/getCreditRate.d.ts +7 -0
- package/lib/components/CreditCalculator/getCreditRate.js +10 -0
- package/lib/components/CreditCalculator/getCreditRate.js.map +1 -0
- package/lib/components/CreditCalculator/getCreditTermYears.d.ts +1 -0
- package/lib/components/CreditCalculator/getCreditTermYears.js +12 -0
- package/lib/components/CreditCalculator/getCreditTermYears.js.map +1 -0
- package/lib/components/CreditCalculator/getMonthlyPayment.d.ts +11 -0
- package/lib/components/CreditCalculator/getMonthlyPayment.js +16 -0
- package/lib/components/CreditCalculator/getMonthlyPayment.js.map +1 -0
- package/lib/components/ExchangeRateTile/ExchangeRateTile.fixture.d.ts +4 -0
- package/lib/components/Footer/Footer.fixture.d.ts +2 -0
- package/lib/components/Footer/SocialMedia.js +11 -5
- package/lib/components/Footer/SocialMedia.js.map +1 -1
- package/lib/components/Gallery/Gallery.fixture.d.ts +9 -0
- package/lib/components/Header/Header.fixture.d.ts +2 -0
- package/lib/components/Header/HeaderSecondaryMenu.js +1 -1
- package/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
- package/lib/components/LikeControl/LikeControl.fixture.d.ts +2 -0
- package/lib/components/MiniGallery/MiniGallery.fixture.d.ts +5 -0
- package/lib/components/MobileAppTile/MobileAppTile.fixture.d.ts +4 -0
- package/lib/components/Placeholder/Placeholder.fixture.d.ts +2 -0
- package/lib/components/ProductBlock/ProductBlock.fixture.d.ts +5 -0
- package/lib/components/ProductGallery/ProductGallery.fixture.d.ts +2 -0
- package/lib/components/ProductTile/ProductTile.fixture.d.ts +7 -0
- package/lib/components/PromoTile/PromoTile.fixture.d.ts +4 -0
- package/lib/components/StepsBlock/StepsBlock.fixture.d.ts +2 -0
- package/lib/components/TextBlock/TextBlock.fixture.d.ts +2 -0
- package/lib/components/Tile/Tile.fixture.d.ts +8 -0
- package/lib/cosmos.decorator.d.ts +4 -0
- package/lib/hooks/useCreditCalculatorData.d.ts +3 -0
- package/lib/hooks/useCreditCalculatorData.js +12 -0
- package/lib/hooks/useCreditCalculatorData.js.map +1 -0
- package/lib/setup-fixture.d.ts +3 -0
- package/lib/ui-kit/BlockItem/BlockItem.fixture.d.ts +3 -0
- package/lib/ui-kit/Button/Button.fixture.d.ts +13 -0
- package/lib/ui-kit/Button/LikeButton.fixture.d.ts +5 -0
- package/lib/ui-kit/HeaderItem/HeaderItem.fixture.d.ts +6 -0
- package/lib/ui-kit/Icon/Icon.fixture.d.ts +5 -0
- package/lib/ui-kit/Icon/Icon.js +2 -2
- package/lib/ui-kit/Icon/Icon.js.map +1 -1
- package/lib/ui-kit/InputRange/InputRange.js +3 -2
- package/lib/ui-kit/InputRange/InputRange.js.map +1 -1
- package/lib/ui-kit/Logo/Logo.fixture.d.ts +3 -0
- package/lib/ui-kit/TopItem/TopItem.fixture.d.ts +6 -0
- package/lib/utils/addSpacesBetweenNumbers.d.ts +1 -0
- package/lib/utils/addSpacesBetweenNumbers.js +2 -0
- package/lib/utils/addSpacesBetweenNumbers.js.map +1 -0
- package/package.json +3 -2
- package/src/ProjectSettings.ts +1 -0
- package/src/components/Blocks.ts +2 -0
- package/src/components/ContentPage/ContentPage.page.json +7 -0
- package/src/components/CreditCalculator/CreditCalculator.fixture.tsx +1 -1
- package/src/components/CreditCalculator/CreditCalculator.tsx +132 -85
- package/src/components/CreditCalculator/CreditCalculatorContent.ts +17 -0
- package/src/components/CreditCalculator/constants.ts +8 -0
- package/src/components/CreditCalculator/getCalculatorParams.ts +16 -0
- package/src/components/CreditCalculator/getCreditRate.ts +18 -0
- package/src/components/CreditCalculator/getCreditTermYears.spec.ts +10 -0
- package/src/components/CreditCalculator/getCreditTermYears.ts +15 -0
- package/src/components/CreditCalculator/getMonthlyPayment.ts +32 -0
- package/src/components/Footer/Footer.fixture.tsx +1 -1
- package/src/components/Footer/SocialMedia.tsx +26 -7
- package/src/components/Header/HeaderSecondaryMenu.tsx +6 -2
- package/src/hooks/useCreditCalculatorData.ts +23 -0
- package/src/icons/ActualBalanceIcon.svg +1 -0
- package/src/icons/AppleIcon.svg +1 -1
- package/src/icons/CalendarIcon.svg +1 -1
- package/src/icons/ClockIcon.svg +1 -0
- package/src/icons/ComfortableCompIcon.svg +1 -0
- package/src/icons/DollarIcon.svg +1 -1
- package/src/icons/EmptyWalletIcon.svg +1 -1
- package/src/icons/EuroIcon.svg +1 -1
- package/src/icons/GlassIcon.svg +1 -1
- package/src/icons/GridIcon.svg +2 -2
- package/src/icons/LoupeIcon.svg +1 -1
- package/src/icons/NewDocIcon.svg +1 -0
- package/src/icons/OkIcon.svg +1 -2
- package/src/icons/PassSendIcon.svg +1 -0
- package/src/icons/PercentageSquareIcon.svg +1 -1
- package/src/icons/PlayMarketIcon.svg +1 -1
- package/src/icons/ProfileIcon.svg +1 -1
- package/src/icons/SignDocsIcon.svg +1 -0
- package/src/icons/TelegramIcon.svg +1 -2
- package/src/icons/VKIcon.svg +1 -2
- package/src/ui-kit/Icon/Icon.tsx +8 -7
- package/src/ui-kit/InputRange/InputRange.tsx +3 -2
- package/src/utils/addSpacesBetweenNumbers.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputRange.js","sourceRoot":"","sources":["../../../src/ui-kit/InputRange/InputRange.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"InputRange.js","sourceRoot":"","sources":["../../../src/ui-kit/InputRange/InputRange.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAG9E,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAC3B,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE;IACxF,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE;QACrC,IAAI,CAAC,QAAQ;YAAE,OAAO;QAEtB,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;QACxD,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC3B,CAAC,CAAC;IAEF,MAAM,UAAU,GAAG;QACjB,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;KAC5E,CAAC;IAEF,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,IAAI,CAAC,QAAQ;YAAE,OAAO;QAEtB,IAAI,KAAK,GAAG,GAAG;YAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,GAAG,GAAG;YAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC,CAAC;IAEF,OAAO,CACL,eAAK,SAAS,EAAE,SAAS,aACvB,eAAK,SAAS,EAAC,UAAU,aACtB,KAAK,CAAC,CAAC,CAAC,CACP,eAAM,SAAS,EAAC,+DAA+D,YAC5E,KAAK,GACD,CACR,CAAC,CAAC,CAAC,IAAI,EACR,gBACE,SAAS,EAAE,iJACT,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EACnB,EAAE,EACF,KAAK,EAAE,uBAAuB,CAAC,KAAK,CAAC,EACrC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC7C,MAAM,EAAE,UAAU,GAClB,EACF,cAAK,SAAS,EAAC,sCAAsC,YACnD,gBACE,SAAS,EAAC,6CAA6C,EACvD,IAAI,EAAC,OAAO,EACZ,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC7C,KAAK,EAAE,UAAU,GACjB,GACE,IACF,EACN,cAAK,SAAS,EAAC,gCAAgC,YAC5C,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CACtB,eAAsB,SAAS,EAAC,kCAAkC,YAC/D,IAAI,IADI,MAAM,CAAC,CAAC,CAAC,CAEb,CACR,CAAC,GACE,IACF,CACP,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const addSpacesBetweenNumbers: (number: number) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addSpacesBetweenNumbers.js","sourceRoot":"","sources":["../../src/utils/addSpacesBetweenNumbers.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAAc,EAAE,EAAE,CACxD,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,wBAAwB,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redneckz/wildless-cms-uni-blocks",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.83",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"scripts": {
|
|
80
80
|
"start": "npm run cosmos",
|
|
81
81
|
"build": "npm run build:lib && npm run build:commonjs && npm run bundle && npm run build:style && npm run build:icons",
|
|
82
|
-
"postbuild": "npm run size",
|
|
82
|
+
"postbuild": "npm run size && npm run cosmos:export && copyfiles --up 1 \"./docs/**/*\" ./build",
|
|
83
83
|
"build:lib": "rimraf ./lib && tsc --build --verbose",
|
|
84
84
|
"postbuild:lib": "replace-in-file --configFile=replace-config.lib.cjs --verbose",
|
|
85
85
|
"build:commonjs": "rimraf ./dist && tsc --module commonjs --noImplicitUseStrict --outDir dist",
|
|
@@ -121,6 +121,7 @@
|
|
|
121
121
|
"@size-limit/file": "^7.0.8",
|
|
122
122
|
"@types/jest": "^28.1.1",
|
|
123
123
|
"autoprefixer": "^10.4.7",
|
|
124
|
+
"copyfiles": "^2.4.1",
|
|
124
125
|
"css-loader": "^6.7.1",
|
|
125
126
|
"cssnano": "^5.1.11",
|
|
126
127
|
"html-webpack-plugin": "^5.5.0",
|
package/src/ProjectSettings.ts
CHANGED
package/src/components/Blocks.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { TextBlock } from './TextBlock/TextBlock';
|
|
|
15
15
|
import { Tile } from './Tile/Tile';
|
|
16
16
|
import { ComparisonTable } from './ComparisonTable/ComparisonTable';
|
|
17
17
|
import { Accordion } from './Accordion/Accordion';
|
|
18
|
+
import { CreditCalculator } from './CreditCalculator/CreditCalculator';
|
|
18
19
|
|
|
19
20
|
export const Blocks = {
|
|
20
21
|
Header,
|
|
@@ -34,4 +35,5 @@ export const Blocks = {
|
|
|
34
35
|
MiniGallery,
|
|
35
36
|
ComparisonTable,
|
|
36
37
|
Accordion,
|
|
38
|
+
CreditCalculator,
|
|
37
39
|
};
|
|
@@ -1360,6 +1360,13 @@
|
|
|
1360
1360
|
]
|
|
1361
1361
|
}
|
|
1362
1362
|
},
|
|
1363
|
+
{
|
|
1364
|
+
"type": "CreditCalculator",
|
|
1365
|
+
"style": ["col-span-12"],
|
|
1366
|
+
"content": {
|
|
1367
|
+
"directoryName": "credit-calculator-data"
|
|
1368
|
+
}
|
|
1369
|
+
},
|
|
1363
1370
|
{
|
|
1364
1371
|
"type": "Footer",
|
|
1365
1372
|
"style": ["col-span-12"],
|
|
@@ -1,106 +1,153 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { useCreditCalculatorData } from '../../hooks/useCreditCalculatorData';
|
|
2
3
|
import { UniBlockProps } from '../../types';
|
|
3
4
|
import { Button } from '../../ui-kit/Button/Button';
|
|
4
5
|
import { Checkbox } from '../../ui-kit/Checkbox/Checkbox';
|
|
5
6
|
import { InputRange } from '../../ui-kit/InputRange/InputRange';
|
|
7
|
+
import { addSpacesBetweenNumbers } from '../../utils/addSpacesBetweenNumbers';
|
|
6
8
|
import { clamp } from '../../utils/clamp';
|
|
9
|
+
import {
|
|
10
|
+
DEFAULT_MAX_MONTHS,
|
|
11
|
+
DEFAULT_MAX_SUM,
|
|
12
|
+
DEFAULT_MIN_MONTHS,
|
|
13
|
+
DEFAULT_MIN_SUM,
|
|
14
|
+
DEFAULT_MONTHS,
|
|
15
|
+
DEFAULT_SUM,
|
|
16
|
+
MONTHS_IN_YEAR,
|
|
17
|
+
} from './constants';
|
|
18
|
+
import { CreditCalculatorContent } from './CreditCalculatorContent';
|
|
19
|
+
import { getCalculatorParams } from './getCalculatorParams';
|
|
20
|
+
import { getCreditRate } from './getCreditRate';
|
|
21
|
+
import { getCreditTermYears } from './getCreditTermYears';
|
|
22
|
+
import { getMonthlyPayment } from './getMonthlyPayment';
|
|
7
23
|
|
|
8
|
-
export interface CreditCalculatorProps extends UniBlockProps {}
|
|
24
|
+
export interface CreditCalculatorProps extends CreditCalculatorContent, UniBlockProps {}
|
|
25
|
+
|
|
26
|
+
const STEP_MONEY = 1000;
|
|
27
|
+
const STEP_MONTHS = 1;
|
|
28
|
+
const DEFAULT_PAYMENT_TYPE = 'annuity';
|
|
9
29
|
|
|
10
30
|
const borderStyle = 'border-solid border-3 border-primary-main rounded-md';
|
|
11
31
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const
|
|
32
|
+
export const CreditCalculator = JSX<CreditCalculatorProps>(
|
|
33
|
+
({ context, className, directoryName }) => {
|
|
34
|
+
const [moneyValue, setMoneyValue] = context.useState<number | undefined>(undefined);
|
|
35
|
+
const [monthsValue, setMonthsValue] = context.useState<number | undefined>(undefined);
|
|
36
|
+
const [isAnnuityChecked, setIsAnnuityChecked] = context.useState(true);
|
|
37
|
+
const [isInsuranceChecked, setIsInsuranceChecked] = context.useState(true);
|
|
15
38
|
|
|
16
|
-
const
|
|
39
|
+
const tableRows = useCreditCalculatorData(context.useAsyncData, directoryName).rows;
|
|
17
40
|
|
|
18
|
-
const
|
|
19
|
-
const MAX_MONTHS = 84;
|
|
20
|
-
const STEP_MONTHS = 1;
|
|
41
|
+
const calculatorParams = getCalculatorParams({ tableRows, isAnnuity: isAnnuityChecked });
|
|
21
42
|
|
|
22
|
-
const
|
|
43
|
+
const defaultSum =
|
|
44
|
+
calculatorParams.maxSum && calculatorParams.minSum
|
|
45
|
+
? (calculatorParams.maxSum - calculatorParams.minSum) / 2
|
|
46
|
+
: DEFAULT_SUM;
|
|
23
47
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const [isInsuranceChecked, setIsInsuranceChecked] = context.useState(true);
|
|
48
|
+
const defaultMonths =
|
|
49
|
+
calculatorParams.maxMonths && calculatorParams.minMonths
|
|
50
|
+
? Math.round((calculatorParams.maxMonths - calculatorParams.minMonths) / 2)
|
|
51
|
+
: DEFAULT_MONTHS;
|
|
29
52
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
53
|
+
const minSum = calculatorParams?.minSum || DEFAULT_MIN_SUM;
|
|
54
|
+
const maxSum = calculatorParams?.maxSum || DEFAULT_MAX_SUM;
|
|
55
|
+
const minMonths = calculatorParams?.minMonths || DEFAULT_MIN_MONTHS;
|
|
56
|
+
const maxMonths = calculatorParams?.maxMonths || DEFAULT_MAX_MONTHS;
|
|
33
57
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
const rate = getCreditRate({ calculatorParams, isInsurance: isInsuranceChecked });
|
|
59
|
+
|
|
60
|
+
const montlyPayment = getMonthlyPayment({
|
|
61
|
+
calculatorParams,
|
|
62
|
+
paymentType: DEFAULT_PAYMENT_TYPE,
|
|
63
|
+
rate,
|
|
64
|
+
sum: moneyValue || defaultSum,
|
|
65
|
+
months: monthsValue || defaultMonths,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const creditTermYears = getCreditTermYears(minMonths, maxMonths);
|
|
69
|
+
|
|
70
|
+
function handleButtonClick(value: number) {
|
|
71
|
+
setMonthsValue(clamp(value * MONTHS_IN_YEAR, minMonths, maxMonths));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<section className={`font-sans text-primary-text bg-white p-4 ${className}`}>
|
|
76
|
+
<div className={`box-border p-12 flex flex-col justify-between ${borderStyle}`}>
|
|
77
|
+
<div className="flex justify-between">
|
|
78
|
+
<div className="grow mr-11">
|
|
79
|
+
<InputRange
|
|
80
|
+
title="Желаемая сумма кредита, ₽"
|
|
81
|
+
items={[
|
|
82
|
+
`От ${addSpacesBetweenNumbers(minSum)} рублей`,
|
|
83
|
+
`До ${addSpacesBetweenNumbers(maxSum)} рублей`,
|
|
84
|
+
]}
|
|
85
|
+
min={minSum}
|
|
86
|
+
max={maxSum}
|
|
87
|
+
step={STEP_MONEY}
|
|
88
|
+
value={moneyValue || defaultSum}
|
|
89
|
+
onChange={setMoneyValue}
|
|
90
|
+
/>
|
|
91
|
+
<InputRange
|
|
92
|
+
title="Срок кредита, месяцев"
|
|
93
|
+
items={['Или выберите из предложенных вариантов ниже']}
|
|
94
|
+
min={minMonths}
|
|
95
|
+
max={maxMonths}
|
|
96
|
+
step={STEP_MONTHS}
|
|
97
|
+
value={monthsValue || defaultMonths}
|
|
98
|
+
onChange={setMonthsValue}
|
|
99
|
+
/>
|
|
100
|
+
<div className="flex mb-7">
|
|
101
|
+
{creditTermYears.map((number, i) => renderButton(number, i, handleButtonClick))}
|
|
102
|
+
</div>
|
|
103
|
+
<Checkbox
|
|
104
|
+
text="Получаю пенсию на карту Россельхозбанка"
|
|
105
|
+
checked={isAnnuityChecked}
|
|
106
|
+
onChange={setIsAnnuityChecked}
|
|
107
|
+
/>
|
|
108
|
+
<Checkbox
|
|
109
|
+
className="mb-4"
|
|
110
|
+
text="Комплексная страховая защита"
|
|
111
|
+
checked={isInsuranceChecked}
|
|
112
|
+
onChange={setIsInsuranceChecked}
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
115
|
+
<div className="p-9 bg-primary-main rounded-md text-white">
|
|
116
|
+
<div className="text-base mb-5">Наше предложение</div>
|
|
117
|
+
<div className="text-sm opacity-60">Ежемесячный платёж</div>
|
|
118
|
+
<div className="text-lg mb-3">
|
|
119
|
+
{addSpacesBetweenNumbers(Math.round(montlyPayment))} ₽
|
|
120
|
+
</div>
|
|
121
|
+
<div className="text-sm opacity-60">Ставка</div>
|
|
122
|
+
<div className="text-lg">{rate} %</div>
|
|
59
123
|
</div>
|
|
60
|
-
<Checkbox
|
|
61
|
-
text="Получаю пенсию на карту Россельхозбанка"
|
|
62
|
-
checked={isAnnuityChecked}
|
|
63
|
-
onChange={setIsAnnuityChecked}
|
|
64
|
-
/>
|
|
65
|
-
<Checkbox
|
|
66
|
-
className="mb-4"
|
|
67
|
-
text="Комплексная страховая защита"
|
|
68
|
-
checked={isInsuranceChecked}
|
|
69
|
-
onChange={setIsInsuranceChecked}
|
|
70
|
-
/>
|
|
71
|
-
</div>
|
|
72
|
-
<div className="p-9 bg-primary-main rounded-md text-white">
|
|
73
|
-
<div className="text-base mb-5">Наше предложение</div>
|
|
74
|
-
<div className="text-sm opacity-60">Ежемесячный платёж</div>
|
|
75
|
-
<div className="text-lg mb-3">26 827 ₽</div>
|
|
76
|
-
<div className="text-sm opacity-60">Ставка</div>
|
|
77
|
-
<div className="text-lg">16,9 %</div>
|
|
78
124
|
</div>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
125
|
+
<div className="flex items-center">
|
|
126
|
+
<Button className="mr-3" text="Отправить заявку" version="primary" href="#" />
|
|
127
|
+
<div
|
|
128
|
+
className="w-80 text-xxs leading-4 text-secondary-text"
|
|
129
|
+
aria-label="Соглашение на обработку персональных данных"
|
|
130
|
+
>
|
|
131
|
+
Отправляя заявку, вы соглашаетесь на обработку персональных данных соответственно
|
|
132
|
+
требованиям ФЗ «О персональных данных»
|
|
133
|
+
</div>
|
|
88
134
|
</div>
|
|
89
135
|
</div>
|
|
90
|
-
</
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const renderButton = (number: number, i: number, handleClick: (number: number) => void) => (
|
|
96
|
-
<div
|
|
97
|
-
key={String(i)}
|
|
98
|
-
className="bg-secondary-light rounded-3xl h-10 w-[75px] box-border mr-2 flex items-center justify-center cursor-pointer"
|
|
99
|
-
role="button"
|
|
100
|
-
onClick={() => handleClick(number)}
|
|
101
|
-
>
|
|
102
|
-
<span className="font-medium text-sm">
|
|
103
|
-
{number} {number > 4 ? 'лет' : 'года'}
|
|
104
|
-
</span>
|
|
105
|
-
</div>
|
|
136
|
+
</section>
|
|
137
|
+
);
|
|
138
|
+
},
|
|
106
139
|
);
|
|
140
|
+
|
|
141
|
+
function renderButton(number: number, i: number, handleClick: (number: number) => void) {
|
|
142
|
+
return (
|
|
143
|
+
<button
|
|
144
|
+
key={String(i)}
|
|
145
|
+
className="bg-secondary-light rounded-3xl h-10 w-[75px] box-border mr-2 flex items-center justify-center cursor-pointer border-none"
|
|
146
|
+
onClick={() => handleClick(number)}
|
|
147
|
+
>
|
|
148
|
+
<span className="font-semibold text-sm">
|
|
149
|
+
{number} {number === 1 ? 'год' : number > 4 ? 'лет' : 'года'}
|
|
150
|
+
</span>
|
|
151
|
+
</button>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface CalculatorParams {
|
|
2
|
+
isAnnuity?: boolean;
|
|
3
|
+
minSum?: number;
|
|
4
|
+
maxSum?: number;
|
|
5
|
+
minMonths?: number;
|
|
6
|
+
maxMonths?: number;
|
|
7
|
+
rateWithInsurance?: number;
|
|
8
|
+
rateWithoutInsurance?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface CreditCalculatorData {
|
|
12
|
+
rows?: CalculatorParams[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface CreditCalculatorContent {
|
|
16
|
+
directoryName?: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const DEFAULT_MIN_SUM = 30000;
|
|
2
|
+
export const DEFAULT_MAX_SUM = 3000000;
|
|
3
|
+
export const DEFAULT_SUM = (DEFAULT_MAX_SUM - DEFAULT_MIN_SUM) / 2;
|
|
4
|
+
export const DEFAULT_MIN_MONTHS = 1;
|
|
5
|
+
export const DEFAULT_MAX_MONTHS = 84;
|
|
6
|
+
export const DEFAULT_MONTHS = Math.round((DEFAULT_MAX_MONTHS - DEFAULT_MIN_MONTHS) / 2);
|
|
7
|
+
|
|
8
|
+
export const MONTHS_IN_YEAR = 12;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CalculatorParams } from './CreditCalculatorContent';
|
|
2
|
+
|
|
3
|
+
interface GetCalculatorParamsParams {
|
|
4
|
+
tableRows?: CalculatorParams[];
|
|
5
|
+
isAnnuity?: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const getCalculatorParams = (params: GetCalculatorParamsParams) => {
|
|
9
|
+
const { tableRows, isAnnuity = false } = params;
|
|
10
|
+
|
|
11
|
+
if (!tableRows) return {};
|
|
12
|
+
|
|
13
|
+
const calculatorParams = tableRows.find((row) => row.isAnnuity === isAnnuity);
|
|
14
|
+
|
|
15
|
+
return calculatorParams || {};
|
|
16
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CalculatorParams } from './CreditCalculatorContent';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_RATE = 5;
|
|
4
|
+
|
|
5
|
+
interface GetCreditRateParams {
|
|
6
|
+
calculatorParams?: CalculatorParams;
|
|
7
|
+
isInsurance: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const getCreditRate = (params: GetCreditRateParams) => {
|
|
11
|
+
const { calculatorParams, isInsurance } = params;
|
|
12
|
+
|
|
13
|
+
if (!calculatorParams) return DEFAULT_RATE;
|
|
14
|
+
|
|
15
|
+
return isInsurance
|
|
16
|
+
? calculatorParams?.rateWithInsurance || DEFAULT_RATE
|
|
17
|
+
: calculatorParams?.rateWithoutInsurance || DEFAULT_RATE;
|
|
18
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getCreditTermYears } from './getCreditTermYears';
|
|
2
|
+
|
|
3
|
+
describe('getCreditTermYears', () => {
|
|
4
|
+
it('should return array starts from min year plus one and ends with max year', () => {
|
|
5
|
+
const minMonths = 12;
|
|
6
|
+
const maxMonths = 96;
|
|
7
|
+
const items = [2, 3, 4, 5, 6, 8];
|
|
8
|
+
expect(getCreditTermYears(minMonths, maxMonths)).toEqual(items);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MONTHS_IN_YEAR } from './constants';
|
|
2
|
+
|
|
3
|
+
const MAX_YEARS_LENGTH = 5;
|
|
4
|
+
|
|
5
|
+
export const getCreditTermYears = (minMonths: number, maxMonths: number) => {
|
|
6
|
+
const totalYears = Math.ceil((maxMonths - minMonths) / 12);
|
|
7
|
+
const firstYear = Math.floor(minMonths / MONTHS_IN_YEAR) + 1;
|
|
8
|
+
|
|
9
|
+
const result = new Array(Math.min(totalYears - 1, MAX_YEARS_LENGTH))
|
|
10
|
+
.fill(0)
|
|
11
|
+
.map((_, i) => firstYear + i);
|
|
12
|
+
|
|
13
|
+
const maxYear = totalYears + firstYear - 1;
|
|
14
|
+
return result.concat(maxYear);
|
|
15
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { clamp } from '../../utils/clamp';
|
|
2
|
+
import { DEFAULT_MAX_SUM, DEFAULT_MIN_SUM, MONTHS_IN_YEAR } from './constants';
|
|
3
|
+
import { CalculatorParams } from './CreditCalculatorContent';
|
|
4
|
+
|
|
5
|
+
type PaymentType = 'annuity' | 'differentiated';
|
|
6
|
+
|
|
7
|
+
interface GetMonthlyPaymentParams {
|
|
8
|
+
calculatorParams?: CalculatorParams;
|
|
9
|
+
paymentType: PaymentType;
|
|
10
|
+
rate: number;
|
|
11
|
+
sum: number;
|
|
12
|
+
months: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const getMonthlyPayment = (params: GetMonthlyPaymentParams) => {
|
|
16
|
+
const { calculatorParams, paymentType, rate, sum, months } = params;
|
|
17
|
+
|
|
18
|
+
if (!calculatorParams) return 0;
|
|
19
|
+
|
|
20
|
+
const finalSum = clamp(
|
|
21
|
+
sum,
|
|
22
|
+
calculatorParams.minSum || DEFAULT_MIN_SUM,
|
|
23
|
+
calculatorParams.maxSum || DEFAULT_MAX_SUM,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if (paymentType === 'annuity') {
|
|
27
|
+
const annuityCoef = Number(rate) / (MONTHS_IN_YEAR * 100);
|
|
28
|
+
return finalSum * (annuityCoef + annuityCoef / (Math.pow(1 + annuityCoef, months) - 1));
|
|
29
|
+
} else {
|
|
30
|
+
return finalSum / months + finalSum * (Number(rate) / 12);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -188,7 +188,7 @@ export default (
|
|
|
188
188
|
],
|
|
189
189
|
},
|
|
190
190
|
]}
|
|
191
|
-
socialMedia={[{ href: 'https://
|
|
191
|
+
socialMedia={[{ href: 'https://t.me' }, { href: 'https://vk.com' }, { href: 'https://ok.ru' }]}
|
|
192
192
|
contacts={[
|
|
193
193
|
{
|
|
194
194
|
text: '+7 (495) 787-7-787',
|
|
@@ -6,10 +6,22 @@ import type { IconName } from '../../ui-kit/Icon/IconProps';
|
|
|
6
6
|
import { useLink } from '../../hooks/useLink';
|
|
7
7
|
import { Button } from '../../ui-kit/Button/Button';
|
|
8
8
|
|
|
9
|
-
const ICONS_MAP: Array<{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const ICONS_MAP: Array<{
|
|
10
|
+
origins: string[];
|
|
11
|
+
icon: IconName;
|
|
12
|
+
label: string;
|
|
13
|
+
width: string;
|
|
14
|
+
height: string;
|
|
15
|
+
}> = [
|
|
16
|
+
{
|
|
17
|
+
origins: ['t.me', 'telegram.org'],
|
|
18
|
+
icon: 'TelegramIcon',
|
|
19
|
+
label: 'Телеграм',
|
|
20
|
+
width: '20px',
|
|
21
|
+
height: '16px',
|
|
22
|
+
},
|
|
23
|
+
{ origins: ['vk.com'], icon: 'VKIcon', label: 'ВКонтакте', width: '24px', height: '12px' },
|
|
24
|
+
{ origins: ['ok.ru'], icon: 'OkIcon', label: 'Одноклассники', width: '12px', height: '20px' },
|
|
13
25
|
];
|
|
14
26
|
|
|
15
27
|
export interface SocialMediaProps extends UniBlockProps {
|
|
@@ -33,7 +45,7 @@ interface MediaButtonProps {
|
|
|
33
45
|
}
|
|
34
46
|
|
|
35
47
|
const MediaButton = JSX<MediaButtonProps>(({ href }) => {
|
|
36
|
-
const { icon, label } =
|
|
48
|
+
const { icon, label, width, height } =
|
|
37
49
|
ICONS_MAP.find(({ origins }) => origins.some((_) => href?.includes(_))) || {};
|
|
38
50
|
|
|
39
51
|
if (!icon) return null;
|
|
@@ -45,8 +57,15 @@ const MediaButton = JSX<MediaButtonProps>(({ href }) => {
|
|
|
45
57
|
target="_blank"
|
|
46
58
|
rel="noopener noreferrer"
|
|
47
59
|
aria-label={label}
|
|
48
|
-
className="border-solid border border-main-divider w-9 h-9 flex items-center justify-center hover:
|
|
49
|
-
appendLeft={
|
|
60
|
+
className="border-solid border border-main-divider w-9 h-9 flex items-center justify-center hover:fill-primary-main"
|
|
61
|
+
appendLeft={
|
|
62
|
+
<Icon
|
|
63
|
+
name={icon}
|
|
64
|
+
width={width}
|
|
65
|
+
height={height}
|
|
66
|
+
className="[&>*]:fill-primary-text [&>*]:hover:fill-primary-main"
|
|
67
|
+
/>
|
|
68
|
+
}
|
|
50
69
|
/>
|
|
51
70
|
);
|
|
52
71
|
});
|
|
@@ -45,10 +45,14 @@ export const HeaderSecondaryMenu = JSX<HeaderSecondaryMenuProps>(
|
|
|
45
45
|
<Icon name="ProfileIcon" aria-hidden="true" />
|
|
46
46
|
</HeaderSecondaryMenuButton>
|
|
47
47
|
<HeaderSecondaryMenuButton
|
|
48
|
-
className="mr-5 text-secondary-light hover:text-
|
|
48
|
+
className="mr-5 text-secondary-light hover:text-primary-main min-w-[32px] min-h-[32px]"
|
|
49
49
|
ariaLabel="Дополнительные ссылки"
|
|
50
50
|
>
|
|
51
|
-
<Icon
|
|
51
|
+
<Icon
|
|
52
|
+
name="GridIcon"
|
|
53
|
+
aria-hidden="true"
|
|
54
|
+
className="[&>*]:fill-secondary-light [&>*]:hover:fill-primary-main"
|
|
55
|
+
/>
|
|
52
56
|
</HeaderSecondaryMenuButton>
|
|
53
57
|
</div>
|
|
54
58
|
);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AsyncDataHook } from '../components/ContentPage/ContentPageContext';
|
|
2
|
+
import { CreditCalculatorData } from '../components/CreditCalculator/CreditCalculatorContent';
|
|
3
|
+
|
|
4
|
+
export function useCreditCalculatorData(
|
|
5
|
+
useAsyncData: AsyncDataHook,
|
|
6
|
+
directoryName: string | undefined,
|
|
7
|
+
): CreditCalculatorData {
|
|
8
|
+
const { data } = useAsyncData(creditCalculatorUrl(directoryName), () =>
|
|
9
|
+
fetchCreditCalculatorData(directoryName),
|
|
10
|
+
);
|
|
11
|
+
return data || {};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function fetchCreditCalculatorData(
|
|
15
|
+
directoryName: string | undefined,
|
|
16
|
+
): Promise<CreditCalculatorData> {
|
|
17
|
+
const response = await fetch(creditCalculatorUrl(directoryName));
|
|
18
|
+
return await response.json();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function creditCalculatorUrl(directoryName: string | undefined) {
|
|
22
|
+
return `/wcms-resources/${directoryName || 'credit-calculator-data'}.json`;
|
|
23
|
+
}
|
package/src/icons/AppleIcon.svg
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 24"><path d="M18.406 12.761c-.023-3.028 2.793-4.511 2.93-4.572-1.603-2.073-4.075-2.357-4.968-2.377-2.083-.204-4.098 1.117-5.174 1.117-1.076 0-2.725-1.097-4.488-1.056-2.266.04-4.395 1.198-5.563 3.007-2.404 3.698-.618 9.124 1.694 12.09 1.145 1.464 2.496 3.09 4.259 3.028 1.717-.06 2.358-.975 4.441-.975 2.06 0 2.656.975 4.465.935 1.854-.02 3.022-1.463 4.12-2.947 1.329-1.666 1.855-3.332 1.878-3.413 0 0-3.549-1.2-3.594-4.837Zm-3.389-8.92c.916-1.037 1.557-2.419 1.374-3.841-1.35.061-3.022.833-3.984 1.829-.847.894-1.625 2.337-1.42 3.698 1.512.102 3.069-.67 4.03-1.686Z" fill="#42AB44"/></svg>
|
|
1
|
+
<svg id="icon" fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 24"><path d="M18.406 12.761c-.023-3.028 2.793-4.511 2.93-4.572-1.603-2.073-4.075-2.357-4.968-2.377-2.083-.204-4.098 1.117-5.174 1.117-1.076 0-2.725-1.097-4.488-1.056-2.266.04-4.395 1.198-5.563 3.007-2.404 3.698-.618 9.124 1.694 12.09 1.145 1.464 2.496 3.09 4.259 3.028 1.717-.06 2.358-.975 4.441-.975 2.06 0 2.656.975 4.465.935 1.854-.02 3.022-1.463 4.12-2.947 1.329-1.666 1.855-3.332 1.878-3.413 0 0-3.549-1.2-3.594-4.837Zm-3.389-8.92c.916-1.037 1.557-2.419 1.374-3.841-1.35.061-3.022.833-3.984 1.829-.847.894-1.625 2.337-1.42 3.698 1.512.102 3.069-.67 4.03-1.686Z" fill="#42AB44"/></svg>
|
package/src/icons/ClockIcon.svg
CHANGED
package/src/icons/DollarIcon.svg
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1
|
+
<svg id="icon" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
2
|
<path
|
|
3
3
|
d="M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24Z"
|
|
4
4
|
fill="#46B448"
|
package/src/icons/EuroIcon.svg
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1
|
+
<svg id="icon" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
2
|
<path
|
|
3
3
|
d="M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24Z"
|
|
4
4
|
fill="#3060BF"
|