@redneckz/wildless-cms-uni-blocks 0.14.1073 → 0.14.1074
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 +274 -407
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/CashbackCalculator/CashbackCalculator.d.ts +2 -7
- package/bundle/components/CashbackCalculator/CashbackCalculatorContent.d.ts +25 -0
- package/bundle/components/CashbackCalculator/CashbackCalculatorResult.d.ts +1 -2
- package/bundle/components/CashbackCalculator/CashbackCategory.d.ts +2 -6
- package/bundle/components/CashbackCalculator/useCashbackCalculator.d.ts +2 -4
- package/bundle/components/GalleryLayout/utils.d.ts +0 -1
- package/bundle/ui-kit/RichText/RichTextProps.d.ts +0 -2
- package/dist/components/Blocks.js +2 -4
- package/dist/components/Blocks.js.map +1 -1
- package/dist/components/CashbackCalculator/CashbackCalculator.d.ts +2 -7
- package/dist/components/CashbackCalculator/CashbackCalculator.js +14 -25
- package/dist/components/CashbackCalculator/CashbackCalculator.js.map +1 -1
- package/dist/components/CashbackCalculator/CashbackCalculatorContent.d.ts +25 -0
- package/dist/components/CashbackCalculator/CashbackCalculatorContent.js +1 -0
- package/dist/components/CashbackCalculator/CashbackCalculatorResult.d.ts +1 -2
- package/dist/components/CashbackCalculator/CashbackCalculatorResult.js +11 -9
- package/dist/components/CashbackCalculator/CashbackCalculatorResult.js.map +1 -1
- package/dist/components/CashbackCalculator/CashbackCategory.d.ts +2 -6
- package/dist/components/CashbackCalculator/CashbackCategory.js +54 -33
- package/dist/components/CashbackCalculator/CashbackCategory.js.map +1 -1
- package/dist/components/CashbackCalculator/useCashbackCalculator.d.ts +2 -4
- package/dist/components/CashbackCalculator/useCashbackCalculator.js +15 -17
- package/dist/components/CashbackCalculator/useCashbackCalculator.js.map +1 -1
- package/dist/components/GalleryLayout/utils.d.ts +0 -1
- package/dist/ui-kit/RichText/RichText.js +2 -2
- package/dist/ui-kit/RichText/RichText.js.map +1 -1
- package/dist/ui-kit/RichText/RichTextProps.d.ts +0 -2
- package/lib/common.css +1 -1
- package/lib/components/Blocks.js +2 -4
- package/lib/components/Blocks.js.map +1 -1
- package/lib/components/CashbackCalculator/CashbackCalculator.d.ts +2 -7
- package/lib/components/CashbackCalculator/CashbackCalculator.js +14 -25
- package/lib/components/CashbackCalculator/CashbackCalculator.js.map +1 -1
- package/lib/components/CashbackCalculator/CashbackCalculatorContent.d.ts +25 -0
- package/lib/components/CashbackCalculator/CashbackCalculatorContent.js +1 -0
- package/lib/components/CashbackCalculator/CashbackCalculatorResult.d.ts +1 -2
- package/lib/components/CashbackCalculator/CashbackCalculatorResult.js +11 -9
- package/lib/components/CashbackCalculator/CashbackCalculatorResult.js.map +1 -1
- package/lib/components/CashbackCalculator/CashbackCategory.d.ts +2 -6
- package/lib/components/CashbackCalculator/CashbackCategory.js +54 -33
- package/lib/components/CashbackCalculator/CashbackCategory.js.map +1 -1
- package/lib/components/CashbackCalculator/useCashbackCalculator.d.ts +2 -4
- package/lib/components/CashbackCalculator/useCashbackCalculator.js +16 -18
- package/lib/components/CashbackCalculator/useCashbackCalculator.js.map +1 -1
- package/lib/components/GalleryLayout/utils.d.ts +0 -1
- package/lib/ui-kit/RichText/RichText.js +2 -2
- package/lib/ui-kit/RichText/RichText.js.map +1 -1
- package/lib/ui-kit/RichText/RichTextProps.d.ts +0 -2
- package/mobile/bundle/bundle.umd.js +67 -153
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/CashbackCalculator/CashbackCalculator.d.ts +2 -7
- package/mobile/bundle/components/CashbackCalculator/CashbackCalculatorContent.d.ts +25 -0
- package/mobile/bundle/components/CashbackCalculator/CashbackCalculatorResult.d.ts +1 -2
- package/mobile/bundle/components/CashbackCalculator/CashbackCategory.d.ts +2 -6
- package/mobile/bundle/components/CashbackCalculator/useCashbackCalculator.d.ts +2 -4
- package/mobile/bundle/components/GalleryLayout/utils.d.ts +0 -1
- package/mobile/bundle/ui-kit/RichText/RichTextProps.d.ts +0 -2
- package/mobile/dist/components/CashbackCalculator/CashbackCalculator.d.ts +2 -7
- package/mobile/dist/components/CashbackCalculator/CashbackCalculator.js +14 -25
- package/mobile/dist/components/CashbackCalculator/CashbackCalculator.js.map +1 -1
- package/mobile/dist/components/CashbackCalculator/CashbackCalculatorContent.d.ts +25 -0
- package/mobile/dist/components/CashbackCalculator/CashbackCalculatorContent.js +1 -0
- package/mobile/dist/components/CashbackCalculator/CashbackCalculatorResult.d.ts +1 -2
- package/mobile/dist/components/CashbackCalculator/CashbackCalculatorResult.js +11 -9
- package/mobile/dist/components/CashbackCalculator/CashbackCalculatorResult.js.map +1 -1
- package/mobile/dist/components/CashbackCalculator/CashbackCategory.d.ts +2 -6
- package/mobile/dist/components/CashbackCalculator/CashbackCategory.js +54 -33
- package/mobile/dist/components/CashbackCalculator/CashbackCategory.js.map +1 -1
- package/mobile/dist/components/CashbackCalculator/useCashbackCalculator.d.ts +2 -4
- package/mobile/dist/components/CashbackCalculator/useCashbackCalculator.js +15 -17
- package/mobile/dist/components/CashbackCalculator/useCashbackCalculator.js.map +1 -1
- package/mobile/dist/components/GalleryLayout/utils.d.ts +0 -1
- package/mobile/dist/ui-kit/RichText/RichText.js +2 -2
- package/mobile/dist/ui-kit/RichText/RichText.js.map +1 -1
- package/mobile/dist/ui-kit/RichText/RichTextProps.d.ts +0 -2
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/CashbackCalculator/CashbackCalculator.d.ts +2 -7
- package/mobile/lib/components/CashbackCalculator/CashbackCalculator.js +14 -25
- package/mobile/lib/components/CashbackCalculator/CashbackCalculator.js.map +1 -1
- package/mobile/lib/components/CashbackCalculator/CashbackCalculatorContent.d.ts +25 -0
- package/mobile/lib/components/CashbackCalculator/CashbackCalculatorContent.js +1 -0
- package/mobile/lib/components/CashbackCalculator/CashbackCalculatorResult.d.ts +1 -2
- package/mobile/lib/components/CashbackCalculator/CashbackCalculatorResult.js +11 -9
- package/mobile/lib/components/CashbackCalculator/CashbackCalculatorResult.js.map +1 -1
- package/mobile/lib/components/CashbackCalculator/CashbackCategory.d.ts +2 -6
- package/mobile/lib/components/CashbackCalculator/CashbackCategory.js +54 -33
- package/mobile/lib/components/CashbackCalculator/CashbackCategory.js.map +1 -1
- package/mobile/lib/components/CashbackCalculator/useCashbackCalculator.d.ts +2 -4
- package/mobile/lib/components/CashbackCalculator/useCashbackCalculator.js +16 -18
- package/mobile/lib/components/CashbackCalculator/useCashbackCalculator.js.map +1 -1
- package/mobile/lib/components/GalleryLayout/utils.d.ts +0 -1
- package/mobile/lib/ui-kit/RichText/RichText.js +2 -2
- package/mobile/lib/ui-kit/RichText/RichText.js.map +1 -1
- package/mobile/lib/ui-kit/RichText/RichTextProps.d.ts +0 -2
- package/mobile/src/components/CashbackCalculator/CashbackCalculator.example.json +1 -0
- package/mobile/src/components/CashbackCalculator/CashbackCalculator.tsx +69 -73
- package/mobile/src/components/{CashbackCalculatorLayout/CashbackCalculatorLayout.ui.json → CashbackCalculator/CashbackCalculator.ui.json} +0 -6
- package/mobile/src/components/CashbackCalculator/CashbackCalculatorContent.ts +28 -0
- package/mobile/src/components/CashbackCalculator/CashbackCalculatorResult.tsx +23 -23
- package/mobile/src/components/CashbackCalculator/CashbackCategory.tsx +71 -69
- package/mobile/src/components/CashbackCalculator/useCashbackCalculator.ts +17 -26
- package/mobile/src/ui-kit/RichText/RichText.tsx +1 -9
- package/mobile/src/ui-kit/RichText/RichTextProps.ts +0 -2
- package/package.json +2 -2
- package/src/components/Blocks.ts +2 -4
- package/src/components/CashbackCalculator/CashbackCalculator.example.json +1 -0
- package/src/components/CashbackCalculator/CashbackCalculator.tsx +69 -73
- package/src/components/{CashbackCalculatorLayout/CashbackCalculatorLayout.ui.json → CashbackCalculator/CashbackCalculator.ui.json} +0 -6
- package/src/components/CashbackCalculator/CashbackCalculatorContent.ts +28 -0
- package/src/components/CashbackCalculator/CashbackCalculatorResult.tsx +23 -23
- package/src/components/CashbackCalculator/CashbackCategory.tsx +71 -69
- package/src/components/CashbackCalculator/useCashbackCalculator.ts +17 -26
- package/src/ui-kit/RichText/RichText.tsx +1 -9
- package/src/ui-kit/RichText/RichTextProps.ts +0 -2
- package/bundle/components/CashbackCalculator/constants.d.ts +0 -16
- package/bundle/components/CashbackCalculator/getPercentCategories.d.ts +0 -1
- package/bundle/components/CashbackCalculator/renderButtons.d.ts +0 -9
- package/bundle/components/CashbackCalculatorLayout/CashbackCalculatorLayout.d.ts +0 -6
- package/bundle/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.d.ts +0 -38
- package/dist/components/CashbackCalculator/constants.d.ts +0 -16
- package/dist/components/CashbackCalculator/constants.js +0 -89
- package/dist/components/CashbackCalculator/constants.js.map +0 -1
- package/dist/components/CashbackCalculator/getPercentCategories.d.ts +0 -1
- package/dist/components/CashbackCalculator/getPercentCategories.js +0 -16
- package/dist/components/CashbackCalculator/getPercentCategories.js.map +0 -1
- package/dist/components/CashbackCalculator/renderButtons.d.ts +0 -9
- package/dist/components/CashbackCalculator/renderButtons.js +0 -10
- package/dist/components/CashbackCalculator/renderButtons.js.map +0 -1
- package/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayout.d.ts +0 -6
- package/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js +0 -56
- package/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js.map +0 -1
- package/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.d.ts +0 -38
- package/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js +0 -2
- package/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js.map +0 -1
- package/lib/components/CashbackCalculator/constants.d.ts +0 -16
- package/lib/components/CashbackCalculator/constants.js +0 -87
- package/lib/components/CashbackCalculator/constants.js.map +0 -1
- package/lib/components/CashbackCalculator/getPercentCategories.d.ts +0 -1
- package/lib/components/CashbackCalculator/getPercentCategories.js +0 -13
- package/lib/components/CashbackCalculator/getPercentCategories.js.map +0 -1
- package/lib/components/CashbackCalculator/renderButtons.d.ts +0 -9
- package/lib/components/CashbackCalculator/renderButtons.js +0 -7
- package/lib/components/CashbackCalculator/renderButtons.js.map +0 -1
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.d.ts +0 -6
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.fixture.d.ts +0 -5
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js +0 -54
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js.map +0 -1
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.d.ts +0 -38
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js +0 -2
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js.map +0 -1
- package/mobile/bundle/components/CashbackCalculator/constants.d.ts +0 -16
- package/mobile/bundle/components/CashbackCalculator/getPercentCategories.d.ts +0 -1
- package/mobile/bundle/components/CashbackCalculator/renderButtons.d.ts +0 -9
- package/mobile/bundle/components/CashbackCalculatorLayout/CashbackCalculatorLayout.d.ts +0 -6
- package/mobile/bundle/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.d.ts +0 -38
- package/mobile/dist/components/CashbackCalculator/constants.d.ts +0 -16
- package/mobile/dist/components/CashbackCalculator/constants.js +0 -89
- package/mobile/dist/components/CashbackCalculator/constants.js.map +0 -1
- package/mobile/dist/components/CashbackCalculator/getPercentCategories.d.ts +0 -1
- package/mobile/dist/components/CashbackCalculator/getPercentCategories.js +0 -16
- package/mobile/dist/components/CashbackCalculator/getPercentCategories.js.map +0 -1
- package/mobile/dist/components/CashbackCalculator/renderButtons.d.ts +0 -9
- package/mobile/dist/components/CashbackCalculator/renderButtons.js +0 -10
- package/mobile/dist/components/CashbackCalculator/renderButtons.js.map +0 -1
- package/mobile/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayout.d.ts +0 -6
- package/mobile/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js +0 -56
- package/mobile/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js.map +0 -1
- package/mobile/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.d.ts +0 -38
- package/mobile/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js +0 -2
- package/mobile/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js.map +0 -1
- package/mobile/lib/components/CashbackCalculator/constants.d.ts +0 -16
- package/mobile/lib/components/CashbackCalculator/constants.js +0 -87
- package/mobile/lib/components/CashbackCalculator/constants.js.map +0 -1
- package/mobile/lib/components/CashbackCalculator/getPercentCategories.d.ts +0 -1
- package/mobile/lib/components/CashbackCalculator/getPercentCategories.js +0 -13
- package/mobile/lib/components/CashbackCalculator/getPercentCategories.js.map +0 -1
- package/mobile/lib/components/CashbackCalculator/renderButtons.d.ts +0 -9
- package/mobile/lib/components/CashbackCalculator/renderButtons.js +0 -7
- package/mobile/lib/components/CashbackCalculator/renderButtons.js.map +0 -1
- package/mobile/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.d.ts +0 -6
- package/mobile/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js +0 -54
- package/mobile/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js.map +0 -1
- package/mobile/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.d.ts +0 -38
- package/mobile/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js +0 -2
- package/mobile/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js.map +0 -1
- package/mobile/src/components/CashbackCalculator/constants.ts +0 -97
- package/mobile/src/components/CashbackCalculator/getPercentCategories.ts +0 -24
- package/mobile/src/components/CashbackCalculator/renderButtons.tsx +0 -38
- package/mobile/src/components/CashbackCalculatorLayout/CashbackCalculatorLayout.example.json +0 -47
- package/mobile/src/components/CashbackCalculatorLayout/CashbackCalculatorLayout.tsx +0 -116
- package/mobile/src/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.ts +0 -49
- package/src/components/CashbackCalculator/constants.ts +0 -97
- package/src/components/CashbackCalculator/getPercentCategories.ts +0 -24
- package/src/components/CashbackCalculator/renderButtons.tsx +0 -38
- package/src/components/CashbackCalculatorLayout/CashbackCalculatorLayout.example.json +0 -47
- package/src/components/CashbackCalculatorLayout/CashbackCalculatorLayout.fixture.tsx +0 -61
- package/src/components/CashbackCalculatorLayout/CashbackCalculatorLayout.tsx +0 -116
- package/src/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.ts +0 -49
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
2
|
import { useLeadFormData } from '../../retail/hooks/useLeadFormData';
|
|
3
3
|
import { type DictionaryItem } from '../../retail/model/LeadFormData';
|
|
4
4
|
import { type Option } from '../../ui-kit/Select/Option';
|
|
5
|
-
import {
|
|
6
|
-
type Cashback,
|
|
7
|
-
type CashbackCalculatorType,
|
|
8
|
-
} from '../CashbackCalculatorLayout/CashbackCalculatorLayoutContent';
|
|
9
|
-
import { type SelectedCategory } from './CashbackCalculator';
|
|
10
|
-
import { DEFAULT_PREMIUM_CASHBACK, DEFAULT_STANDARD_CASHBACK } from './constants';
|
|
5
|
+
import { type Cashback } from './CashbackCalculatorContent';
|
|
11
6
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
const DEFAULT_CASHBACK: Cashback[] = [
|
|
8
|
+
{
|
|
9
|
+
id: 0,
|
|
10
|
+
percent: {
|
|
11
|
+
text: 'Категория 1% "На всё"',
|
|
12
|
+
key: '1',
|
|
13
|
+
},
|
|
14
|
+
sum: 5000,
|
|
15
|
+
},
|
|
16
|
+
];
|
|
16
17
|
|
|
17
|
-
export const useCashbackCalculator = (
|
|
18
|
+
export const useCashbackCalculator = () => {
|
|
18
19
|
const { data } = useLeadFormData('CASHBACK_CATEGORY');
|
|
19
|
-
const [cashbacks, setCashbacks] = useState<Cashback[]>(
|
|
20
|
-
|
|
21
|
-
const [selectedCategories, setSelectedCategories] = useState<SelectedCategory[]>([]);
|
|
20
|
+
const [cashbacks, setCashbacks] = useState<Cashback[]>(DEFAULT_CASHBACK);
|
|
22
21
|
|
|
23
22
|
const categories: Option[] =
|
|
24
23
|
data?.map((_: DictionaryItem) => ({
|
|
@@ -26,18 +25,11 @@ export const useCashbackCalculator = (calculatorType: CashbackCalculatorType) =>
|
|
|
26
25
|
text: _.value,
|
|
27
26
|
})) || [];
|
|
28
27
|
|
|
29
|
-
const filteredCategories = useMemo(() => {
|
|
30
|
-
const categoriesToRemove: Option[] = selectedCategories.map((obj) => obj.category);
|
|
31
|
-
const keysToRemove = new Set(categoriesToRemove.map((item) => item.key));
|
|
32
|
-
|
|
33
|
-
return categories.filter((item) => !keysToRemove.has(item.key));
|
|
34
|
-
}, [selectedCategories, categories]);
|
|
35
|
-
|
|
36
28
|
const onAddNewCashback = () =>
|
|
37
29
|
setCashbacks((_) => [
|
|
38
30
|
..._,
|
|
39
31
|
{
|
|
40
|
-
id: _
|
|
32
|
+
id: _[_.length - 1].id + 1,
|
|
41
33
|
percent: {
|
|
42
34
|
text: 'Категория 1,5%',
|
|
43
35
|
key: '1.5',
|
|
@@ -59,15 +51,14 @@ export const useCashbackCalculator = (calculatorType: CashbackCalculatorType) =>
|
|
|
59
51
|
|
|
60
52
|
const onDeleteCashback = (id: number) => setCashbacks((prev) => prev.filter((_) => _.id !== id));
|
|
61
53
|
|
|
62
|
-
const onResetCashback = () => setCashbacks(
|
|
54
|
+
const onResetCashback = () => setCashbacks(DEFAULT_CASHBACK);
|
|
63
55
|
|
|
64
56
|
return {
|
|
65
57
|
cashbacks,
|
|
66
|
-
categories
|
|
58
|
+
categories,
|
|
67
59
|
onAddNewCashback,
|
|
68
60
|
onChangeCashback,
|
|
69
61
|
onDeleteCashback,
|
|
70
62
|
onResetCashback,
|
|
71
|
-
onChangeCategory: setSelectedCategories,
|
|
72
63
|
};
|
|
73
64
|
};
|
|
@@ -3,14 +3,7 @@ import { style } from '../../utils/style';
|
|
|
3
3
|
import { type RichTextProps } from './RichTextProps';
|
|
4
4
|
|
|
5
5
|
export const RichText = JSX<RichTextProps>(
|
|
6
|
-
({
|
|
7
|
-
__html = '',
|
|
8
|
-
richVersion = '',
|
|
9
|
-
itemSize = 'list-m',
|
|
10
|
-
className,
|
|
11
|
-
isDotted = true,
|
|
12
|
-
children,
|
|
13
|
-
}) => {
|
|
6
|
+
({ __html = '', richVersion = '', itemSize = 'list-m', isDotted = true, children }) => {
|
|
14
7
|
const dotStyle = isDotted ? '' : 'without-dots';
|
|
15
8
|
|
|
16
9
|
return __html || children ? (
|
|
@@ -22,7 +15,6 @@ export const RichText = JSX<RichTextProps>(
|
|
|
22
15
|
itemSize,
|
|
23
16
|
'md-container group-data-secondary:text-white group-data-gray:text-secondary-text',
|
|
24
17
|
dotStyle,
|
|
25
|
-
className,
|
|
26
18
|
)}
|
|
27
19
|
dangerouslySetInnerHTML={__html ? { __html } : undefined}
|
|
28
20
|
>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redneckz/wildless-cms-uni-blocks",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.1074",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ЦК",
|
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
"path": "lib/common.css"
|
|
206
206
|
},
|
|
207
207
|
{
|
|
208
|
-
"limit": "
|
|
208
|
+
"limit": "120 kB",
|
|
209
209
|
"path": "bundle/bundle.umd.min.js"
|
|
210
210
|
}
|
|
211
211
|
],
|
package/src/components/Blocks.ts
CHANGED
|
@@ -19,7 +19,6 @@ import { CarouselCatalogCard } from './CarouselCatalogCard/CarouselCatalogCard';
|
|
|
19
19
|
import { CarouselRecommendationCard } from './CarouselRecommendationCard/CarouselRecommendationCard';
|
|
20
20
|
import { CarouselTariffsCard } from './CarouselTariffsCard/CarouselTariffsCard';
|
|
21
21
|
import { CashbackCalculator } from './CashbackCalculator/CashbackCalculator';
|
|
22
|
-
import { CashbackCalculatorLayout } from './CashbackCalculatorLayout/CashbackCalculatorLayout';
|
|
23
22
|
import { ContactsBlock } from './ContactsBlock/ContactsBlock';
|
|
24
23
|
import { CreditCardForm } from './CreditCardForm/CreditCardForm';
|
|
25
24
|
import { CreditForm } from './CreditForm/CreditForm';
|
|
@@ -87,19 +86,18 @@ export const Blocks: BlocksRegistry = {
|
|
|
87
86
|
RollupItem,
|
|
88
87
|
StepsBlock,
|
|
89
88
|
StickyBottomMenu,
|
|
90
|
-
TextBlock,
|
|
91
89
|
TabsLayout,
|
|
92
90
|
TariffsTable,
|
|
91
|
+
TextBlock,
|
|
93
92
|
VerticalLayout,
|
|
94
93
|
Video,
|
|
95
94
|
ApplicationLeadForm,
|
|
96
95
|
CreditCardForm,
|
|
97
96
|
CreditForm,
|
|
98
97
|
DebitForm,
|
|
98
|
+
CashbackCalculator,
|
|
99
99
|
CalculatorRko,
|
|
100
100
|
RkoTariffCardsTable,
|
|
101
101
|
RatesTable,
|
|
102
102
|
ReferalForm,
|
|
103
|
-
CashbackCalculator,
|
|
104
|
-
CashbackCalculatorLayout,
|
|
105
103
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
|
-
import { type Picture } from '../../model/Picture';
|
|
4
2
|
import { BlockWrapper } from '../../ui-kit/BlockWrapper';
|
|
3
|
+
import { Button } from '../../ui-kit/Button/Button';
|
|
5
4
|
import { Img } from '../../ui-kit/Img/Img';
|
|
6
5
|
import { InfoCard } from '../../ui-kit/InfoCard/InfoCard';
|
|
7
6
|
import { LinkButton } from '../../ui-kit/LinkButton/LinkButton';
|
|
8
|
-
import type
|
|
9
|
-
import { RichText } from '../../ui-kit/RichText/RichText';
|
|
10
|
-
import { type Option } from '../../ui-kit/Select/Option';
|
|
11
|
-
import { Text } from '../../ui-kit/Text/Text';
|
|
7
|
+
import { type LinkButtonContent } from '../../ui-kit/LinkButton/LinkButtonContent';
|
|
12
8
|
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
13
9
|
import { style } from '../../utils/style';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
type CashbackCalculatorLayoutContent,
|
|
17
|
-
} from '../CashbackCalculatorLayout/CashbackCalculatorLayoutContent';
|
|
10
|
+
import { Headline } from '../Headline/Headline';
|
|
11
|
+
import { type Cashback, type CashbackCalculatorContent } from './CashbackCalculatorContent';
|
|
18
12
|
import { CashbackCalculatorResult } from './CashbackCalculatorResult';
|
|
19
13
|
import { CashbackCategory } from './CashbackCategory';
|
|
20
|
-
import { INFO_BLOCK_HTML, MAIN_CASHBACK_KEY, MAX_MONTH_CASHBACK } from './constants';
|
|
21
|
-
import { renderButtons } from './renderButtons';
|
|
22
14
|
import { useCashbackCalculator } from './useCashbackCalculator';
|
|
23
15
|
|
|
24
16
|
const defaultButton: LinkButtonContent = {
|
|
@@ -27,25 +19,22 @@ const defaultButton: LinkButtonContent = {
|
|
|
27
19
|
target: '_self',
|
|
28
20
|
};
|
|
29
21
|
|
|
30
|
-
|
|
31
|
-
extends CalculatorParams,
|
|
32
|
-
CashbackCalculatorLayoutContent,
|
|
33
|
-
UniBlockProps {}
|
|
22
|
+
const INCREASED_PERCENTS = ['5', '10', '15'];
|
|
34
23
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
const MAX_CATEGORIES = 5;
|
|
25
|
+
|
|
26
|
+
const INFO_BLOCK_HTML = `<p>Полученные баллы можно конвертировать в рубли и компенсировать покупки у партнеров. Подробнее в <a href='#docs'>документах</a></p>`;
|
|
27
|
+
|
|
28
|
+
interface CashbackCalculatorProps extends CashbackCalculatorContent, UniBlockProps {}
|
|
39
29
|
|
|
40
30
|
export const CashbackCalculator = JSX<CashbackCalculatorProps>(
|
|
41
|
-
// eslint-disable-next-line max-lines-per-function
|
|
42
31
|
({
|
|
43
32
|
maxInputRange = 300000,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
button = defaultButton,
|
|
33
|
+
image,
|
|
34
|
+
deleteImage,
|
|
35
|
+
infoImage,
|
|
48
36
|
className = '',
|
|
37
|
+
button = defaultButton,
|
|
49
38
|
...rest
|
|
50
39
|
}) => {
|
|
51
40
|
const {
|
|
@@ -55,53 +44,41 @@ export const CashbackCalculator = JSX<CashbackCalculatorProps>(
|
|
|
55
44
|
onChangeCashback,
|
|
56
45
|
onDeleteCashback,
|
|
57
46
|
onResetCashback,
|
|
58
|
-
|
|
59
|
-
} = useCashbackCalculator(calculatorType);
|
|
60
|
-
|
|
61
|
-
const { deleteImage, infoImage, image } = rest;
|
|
62
|
-
const [isMainCashbackAdded, setIsMainCashbackAdded] = useState(false);
|
|
47
|
+
} = useCashbackCalculator();
|
|
63
48
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
);
|
|
68
|
-
}, [cashbacks]);
|
|
49
|
+
const img = image?.src ? (
|
|
50
|
+
<Img image={image} className="hidden w-full @xl:block" imageClassName="justify-self-center" />
|
|
51
|
+
) : null;
|
|
69
52
|
|
|
70
53
|
return (
|
|
71
54
|
<BlockWrapper
|
|
72
55
|
className={style('flex flex-col justify-center items-center gap-lg', className)}
|
|
73
|
-
defaultPadding={style('p-
|
|
56
|
+
defaultPadding={style('p-6xl')}
|
|
74
57
|
{...rest}
|
|
75
58
|
>
|
|
76
|
-
<
|
|
59
|
+
<Headline
|
|
60
|
+
title="Калькулятор расчета баллов"
|
|
61
|
+
description="Можно выбрать не более 5 категорий, одна из них из повышенной категории"
|
|
62
|
+
headlineVersion="XL"
|
|
63
|
+
isEmbedded={true}
|
|
64
|
+
/>
|
|
65
|
+
<div className="flex flex-row items-start gap-lg">
|
|
77
66
|
<div className="w-full flex flex-col justify-center items-center gap-lg">
|
|
78
|
-
{cashbacks.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/>
|
|
93
|
-
))
|
|
94
|
-
: renderNoCategoryText()}
|
|
95
|
-
{renderButtons({
|
|
96
|
-
cashbacksLength: cashbacks.length,
|
|
97
|
-
onAddNewCashback: onAddNewCashback,
|
|
98
|
-
onResetCashback: onResetCashback,
|
|
99
|
-
calculatorType: calculatorType,
|
|
100
|
-
maxCategories,
|
|
101
|
-
})}
|
|
102
|
-
<CashbackCalculatorResult cashbacks={cashbacks} maxMonthCashback={maxMonthCashback} />
|
|
67
|
+
{cashbacks.map((_) => (
|
|
68
|
+
<CashbackCategory
|
|
69
|
+
key={String(_.id)}
|
|
70
|
+
categories={categories}
|
|
71
|
+
cashback={_}
|
|
72
|
+
showIncreasedPercents={showIncreasedPercents(_, cashbacks)}
|
|
73
|
+
maxInputRange={maxInputRange}
|
|
74
|
+
deleteImage={deleteImage}
|
|
75
|
+
onDelete={onDeleteCashback}
|
|
76
|
+
onChange={onChangeCashback}
|
|
77
|
+
/>
|
|
78
|
+
))}
|
|
79
|
+
{renderButtons(cashbacks.length, onAddNewCashback, onResetCashback)}
|
|
80
|
+
<CashbackCalculatorResult cashbacks={cashbacks} />
|
|
103
81
|
<InfoCard __html={INFO_BLOCK_HTML} image={infoImage} />
|
|
104
|
-
<RichText __html='* Подробнее по условиям и начислениям можно узнать во вкладке <a href="#docs">документы</a>' />
|
|
105
82
|
<LinkButton
|
|
106
83
|
className="w-full @lg:w-auto self-start"
|
|
107
84
|
href={button.href}
|
|
@@ -110,20 +87,39 @@ export const CashbackCalculator = JSX<CashbackCalculatorProps>(
|
|
|
110
87
|
version="primary"
|
|
111
88
|
/>
|
|
112
89
|
</div>
|
|
113
|
-
{
|
|
90
|
+
{img}
|
|
114
91
|
</div>
|
|
115
92
|
</BlockWrapper>
|
|
116
93
|
);
|
|
117
94
|
},
|
|
118
95
|
);
|
|
119
96
|
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
)
|
|
97
|
+
const renderButtons = (
|
|
98
|
+
cashbacksLength: number,
|
|
99
|
+
onAddNewCashback: () => void,
|
|
100
|
+
onResetCashback: () => void,
|
|
101
|
+
) => {
|
|
102
|
+
return (
|
|
103
|
+
<div className="w-full flex flex-col gap-lg">
|
|
104
|
+
{cashbacksLength < MAX_CATEGORIES ? (
|
|
105
|
+
<Button
|
|
106
|
+
className="self-start text-primary-main"
|
|
107
|
+
embedded
|
|
108
|
+
version="secondary"
|
|
109
|
+
onClick={onAddNewCashback}
|
|
110
|
+
>
|
|
111
|
+
Добавить еще
|
|
112
|
+
</Button>
|
|
113
|
+
) : null}
|
|
114
|
+
{cashbacksLength > 2 ? (
|
|
115
|
+
<Button className="self-start" version="secondary" onClick={onResetCashback}>
|
|
116
|
+
Сбросить все категории
|
|
117
|
+
</Button>
|
|
118
|
+
) : null}
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
125
122
|
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
) : null;
|
|
123
|
+
const showIncreasedPercents = (currentCashback: Cashback, cashback: Cashback[]) =>
|
|
124
|
+
INCREASED_PERCENTS.includes(currentCashback.percent.key) ||
|
|
125
|
+
!cashback.some((_) => INCREASED_PERCENTS.includes(_.percent.key));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type TitleProps } from '../../model/HeadlineType';
|
|
2
|
+
import { type Picture } from '../../model/Picture';
|
|
3
|
+
import { type LinkButtonContent } from '../../ui-kit/LinkButton/LinkButtonContent';
|
|
4
|
+
import { type Option } from '../../ui-kit/Select/Option';
|
|
5
|
+
import { type UniBlockContent } from '../../UniBlock/UniBlockProps';
|
|
6
|
+
|
|
7
|
+
export type Cashback = {
|
|
8
|
+
id: number;
|
|
9
|
+
percent: Option;
|
|
10
|
+
sum: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @title Блок калькулятора кэшбека
|
|
15
|
+
*/
|
|
16
|
+
export type CashbackCalculatorContent = UniBlockContent &
|
|
17
|
+
TitleProps & {
|
|
18
|
+
/** @title Кнопка */
|
|
19
|
+
button?: LinkButtonContent;
|
|
20
|
+
/** @title Максимальное значение поля 'Сумма покупок в категории' */
|
|
21
|
+
maxInputRange?: number;
|
|
22
|
+
/** @title Изображение */
|
|
23
|
+
image?: Picture;
|
|
24
|
+
/** @title Иконка кнопки удаления категории */
|
|
25
|
+
deleteImage?: Picture;
|
|
26
|
+
/** @title Иконка информационного блока */
|
|
27
|
+
infoImage?: Picture;
|
|
28
|
+
};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
2
|
import { Heading } from '../../ui-kit/Heading/Heading';
|
|
3
|
+
import { RichText } from '../../ui-kit/RichText/RichText';
|
|
3
4
|
import { Text } from '../../ui-kit/Text/Text';
|
|
4
5
|
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
5
6
|
import { toLocalNumberFormat } from '../../utils/toLocalNumberFormat';
|
|
6
|
-
import { type Cashback } from '
|
|
7
|
+
import { type Cashback } from './CashbackCalculatorContent';
|
|
8
|
+
|
|
9
|
+
const MAX_MONTH_CASHBACK = 5000;
|
|
10
|
+
const MAX_YEAR_CASHBACK = 60000;
|
|
7
11
|
|
|
8
12
|
export type CashbackCalculatorResultProps = UniBlockProps & {
|
|
9
13
|
cashbacks: Cashback[];
|
|
10
|
-
maxMonthCashback: number;
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
type ResultTextProps = {
|
|
@@ -26,37 +29,34 @@ const ResultText = JSX<ResultTextProps>(({ text, value }) => (
|
|
|
26
29
|
</div>
|
|
27
30
|
));
|
|
28
31
|
|
|
29
|
-
export const CashbackCalculatorResult = JSX<CashbackCalculatorResultProps>(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
</div>
|
|
32
|
+
export const CashbackCalculatorResult = JSX<CashbackCalculatorResultProps>(({ cashbacks }) => {
|
|
33
|
+
const { mounth, year } = getResult(cashbacks);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="w-full flex flex-col gap-lg">
|
|
37
|
+
<Heading className="text-left" headingType="h5" as="h2" title="Результат расчета" />
|
|
38
|
+
<RichText __html='Категории покупок для расчета баллов предварительные.<br />Подробнее по условиям и начислениям можно узнать во вкладке <a href="#docs">документы</a>' />
|
|
39
|
+
<div className="flex flex-col @xs:flex-row gap-lg">
|
|
40
|
+
<ResultText text="Баллов в месяц" value={mounth} />
|
|
41
|
+
<ResultText text="Баллов в год" value={year} />
|
|
40
42
|
</div>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
);
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
});
|
|
44
46
|
|
|
45
|
-
const getResult = (cashbacks: Cashback[]
|
|
47
|
+
const getResult = (cashbacks: Cashback[]) => {
|
|
46
48
|
return cashbacks.reduce(
|
|
47
49
|
(acc, val) => {
|
|
48
|
-
const mounthSum = (
|
|
50
|
+
const mounthSum = (Number(val.percent.key) / 100) * val.sum;
|
|
49
51
|
|
|
50
52
|
return {
|
|
51
|
-
|
|
52
|
-
year: Math.min(acc.year + mounthSum * 12,
|
|
53
|
+
mounth: Math.min(acc.mounth + mounthSum, MAX_MONTH_CASHBACK),
|
|
54
|
+
year: Math.min(acc.year + mounthSum * 12, MAX_YEAR_CASHBACK),
|
|
53
55
|
};
|
|
54
56
|
},
|
|
55
57
|
{
|
|
56
|
-
|
|
58
|
+
mounth: 0,
|
|
57
59
|
year: 0,
|
|
58
60
|
},
|
|
59
61
|
);
|
|
60
62
|
};
|
|
61
|
-
|
|
62
|
-
const formatKey = (key: string) => Number(key.replace('-main', ''));
|