@redneckz/wildless-cms-uni-blocks 0.14.1069 → 0.14.1071
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 +442 -297
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/CashbackCalculator/CashbackCalculator.d.ts +7 -2
- package/bundle/components/CashbackCalculator/CashbackCalculatorResult.d.ts +2 -1
- package/bundle/components/CashbackCalculator/CashbackCategory.d.ts +6 -2
- package/bundle/components/CashbackCalculator/constants.d.ts +16 -0
- package/bundle/components/CashbackCalculator/getPercentCategories.d.ts +1 -0
- package/bundle/components/CashbackCalculator/renderButtons.d.ts +9 -0
- package/bundle/components/CashbackCalculator/useCashbackCalculator.d.ts +4 -2
- package/bundle/components/CashbackCalculatorLayout/CashbackCalculatorLayout.d.ts +6 -0
- package/bundle/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.d.ts +38 -0
- package/bundle/components/GalleryLayout/utils.d.ts +1 -0
- package/bundle/retail/model/ApplicationLeadFormTypes.d.ts +1 -1
- package/bundle/ui-kit/RichText/RichTextProps.d.ts +2 -0
- package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +34 -22
- package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
- package/dist/components/Blocks.js +4 -2
- package/dist/components/Blocks.js.map +1 -1
- package/dist/components/CashbackCalculator/CashbackCalculator.d.ts +7 -2
- package/dist/components/CashbackCalculator/CashbackCalculator.js +25 -14
- package/dist/components/CashbackCalculator/CashbackCalculator.js.map +1 -1
- package/dist/components/CashbackCalculator/CashbackCalculatorContent.d.ts +0 -25
- package/dist/components/CashbackCalculator/CashbackCalculatorContent.js +0 -1
- package/dist/components/CashbackCalculator/CashbackCalculatorResult.d.ts +2 -1
- package/dist/components/CashbackCalculator/CashbackCalculatorResult.js +9 -11
- package/dist/components/CashbackCalculator/CashbackCalculatorResult.js.map +1 -1
- package/dist/components/CashbackCalculator/CashbackCategory.d.ts +6 -2
- package/dist/components/CashbackCalculator/CashbackCategory.js +33 -54
- package/dist/components/CashbackCalculator/CashbackCategory.js.map +1 -1
- package/dist/components/CashbackCalculator/constants.d.ts +16 -0
- package/dist/components/CashbackCalculator/constants.js +89 -0
- package/dist/components/CashbackCalculator/constants.js.map +1 -0
- package/dist/components/CashbackCalculator/getPercentCategories.d.ts +1 -0
- package/dist/components/CashbackCalculator/getPercentCategories.js +16 -0
- package/dist/components/CashbackCalculator/getPercentCategories.js.map +1 -0
- package/dist/components/CashbackCalculator/renderButtons.d.ts +9 -0
- package/dist/components/CashbackCalculator/renderButtons.js +10 -0
- package/dist/components/CashbackCalculator/renderButtons.js.map +1 -0
- package/dist/components/CashbackCalculator/useCashbackCalculator.d.ts +4 -2
- package/dist/components/CashbackCalculator/useCashbackCalculator.js +17 -15
- package/dist/components/CashbackCalculator/useCashbackCalculator.js.map +1 -1
- package/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayout.d.ts +6 -0
- package/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js +56 -0
- package/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js.map +1 -0
- package/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.d.ts +38 -0
- package/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js +2 -0
- package/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js.map +1 -0
- package/dist/components/GalleryLayout/utils.d.ts +1 -0
- package/dist/retail/api/createParticipant.js +1 -1
- package/dist/retail/api/createParticipant.js.map +1 -1
- package/dist/retail/model/ApplicationLeadFormTypes.d.ts +1 -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 +2 -0
- package/lib/common.css +1 -1
- package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +34 -22
- package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
- package/lib/components/Blocks.js +4 -2
- package/lib/components/Blocks.js.map +1 -1
- package/lib/components/CashbackCalculator/CashbackCalculator.d.ts +7 -2
- package/lib/components/CashbackCalculator/CashbackCalculator.js +25 -14
- package/lib/components/CashbackCalculator/CashbackCalculator.js.map +1 -1
- package/lib/components/CashbackCalculator/CashbackCalculatorContent.d.ts +0 -25
- package/lib/components/CashbackCalculator/CashbackCalculatorContent.js +0 -1
- package/lib/components/CashbackCalculator/CashbackCalculatorResult.d.ts +2 -1
- package/lib/components/CashbackCalculator/CashbackCalculatorResult.js +9 -11
- package/lib/components/CashbackCalculator/CashbackCalculatorResult.js.map +1 -1
- package/lib/components/CashbackCalculator/CashbackCategory.d.ts +6 -2
- package/lib/components/CashbackCalculator/CashbackCategory.js +33 -54
- package/lib/components/CashbackCalculator/CashbackCategory.js.map +1 -1
- package/lib/components/CashbackCalculator/constants.d.ts +16 -0
- package/lib/components/CashbackCalculator/constants.js +87 -0
- package/lib/components/CashbackCalculator/constants.js.map +1 -0
- package/lib/components/CashbackCalculator/getPercentCategories.d.ts +1 -0
- package/lib/components/CashbackCalculator/getPercentCategories.js +13 -0
- package/lib/components/CashbackCalculator/getPercentCategories.js.map +1 -0
- package/lib/components/CashbackCalculator/renderButtons.d.ts +9 -0
- package/lib/components/CashbackCalculator/renderButtons.js +7 -0
- package/lib/components/CashbackCalculator/renderButtons.js.map +1 -0
- package/lib/components/CashbackCalculator/useCashbackCalculator.d.ts +4 -2
- package/lib/components/CashbackCalculator/useCashbackCalculator.js +18 -16
- package/lib/components/CashbackCalculator/useCashbackCalculator.js.map +1 -1
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.d.ts +6 -0
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.fixture.d.ts +5 -0
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js +54 -0
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js.map +1 -0
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.d.ts +38 -0
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js +2 -0
- package/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js.map +1 -0
- package/lib/components/GalleryLayout/utils.d.ts +1 -0
- package/lib/retail/api/createParticipant.js +1 -1
- package/lib/retail/api/createParticipant.js.map +1 -1
- package/lib/retail/model/ApplicationLeadFormTypes.d.ts +1 -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 +2 -0
- package/mobile/bundle/bundle.umd.js +188 -90
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/CashbackCalculator/CashbackCalculator.d.ts +7 -2
- package/mobile/bundle/components/CashbackCalculator/CashbackCalculatorResult.d.ts +2 -1
- package/mobile/bundle/components/CashbackCalculator/CashbackCategory.d.ts +6 -2
- package/mobile/bundle/components/CashbackCalculator/constants.d.ts +16 -0
- package/mobile/bundle/components/CashbackCalculator/getPercentCategories.d.ts +1 -0
- package/mobile/bundle/components/CashbackCalculator/renderButtons.d.ts +9 -0
- package/mobile/bundle/components/CashbackCalculator/useCashbackCalculator.d.ts +4 -2
- package/mobile/bundle/components/CashbackCalculatorLayout/CashbackCalculatorLayout.d.ts +6 -0
- package/mobile/bundle/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.d.ts +38 -0
- package/mobile/bundle/components/GalleryLayout/utils.d.ts +1 -0
- package/mobile/bundle/retail/model/ApplicationLeadFormTypes.d.ts +1 -1
- package/mobile/bundle/ui-kit/RichText/RichTextProps.d.ts +2 -0
- package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +34 -22
- package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
- package/mobile/dist/components/CashbackCalculator/CashbackCalculator.d.ts +7 -2
- package/mobile/dist/components/CashbackCalculator/CashbackCalculator.js +25 -14
- package/mobile/dist/components/CashbackCalculator/CashbackCalculator.js.map +1 -1
- package/mobile/dist/components/CashbackCalculator/CashbackCalculatorContent.d.ts +0 -25
- package/mobile/dist/components/CashbackCalculator/CashbackCalculatorContent.js +0 -1
- package/mobile/dist/components/CashbackCalculator/CashbackCalculatorResult.d.ts +2 -1
- package/mobile/dist/components/CashbackCalculator/CashbackCalculatorResult.js +9 -11
- package/mobile/dist/components/CashbackCalculator/CashbackCalculatorResult.js.map +1 -1
- package/mobile/dist/components/CashbackCalculator/CashbackCategory.d.ts +6 -2
- package/mobile/dist/components/CashbackCalculator/CashbackCategory.js +33 -54
- package/mobile/dist/components/CashbackCalculator/CashbackCategory.js.map +1 -1
- package/mobile/dist/components/CashbackCalculator/constants.d.ts +16 -0
- package/mobile/dist/components/CashbackCalculator/constants.js +89 -0
- package/mobile/dist/components/CashbackCalculator/constants.js.map +1 -0
- package/mobile/dist/components/CashbackCalculator/getPercentCategories.d.ts +1 -0
- package/mobile/dist/components/CashbackCalculator/getPercentCategories.js +16 -0
- package/mobile/dist/components/CashbackCalculator/getPercentCategories.js.map +1 -0
- package/mobile/dist/components/CashbackCalculator/renderButtons.d.ts +9 -0
- package/mobile/dist/components/CashbackCalculator/renderButtons.js +10 -0
- package/mobile/dist/components/CashbackCalculator/renderButtons.js.map +1 -0
- package/mobile/dist/components/CashbackCalculator/useCashbackCalculator.d.ts +4 -2
- package/mobile/dist/components/CashbackCalculator/useCashbackCalculator.js +17 -15
- package/mobile/dist/components/CashbackCalculator/useCashbackCalculator.js.map +1 -1
- package/mobile/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayout.d.ts +6 -0
- package/mobile/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js +56 -0
- package/mobile/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js.map +1 -0
- package/mobile/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.d.ts +38 -0
- package/mobile/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js +2 -0
- package/mobile/dist/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js.map +1 -0
- package/mobile/dist/components/GalleryLayout/utils.d.ts +1 -0
- package/mobile/dist/retail/api/createParticipant.js +1 -1
- package/mobile/dist/retail/api/createParticipant.js.map +1 -1
- package/mobile/dist/retail/model/ApplicationLeadFormTypes.d.ts +1 -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 +2 -0
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +34 -22
- package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
- package/mobile/lib/components/CashbackCalculator/CashbackCalculator.d.ts +7 -2
- package/mobile/lib/components/CashbackCalculator/CashbackCalculator.js +25 -14
- package/mobile/lib/components/CashbackCalculator/CashbackCalculator.js.map +1 -1
- package/mobile/lib/components/CashbackCalculator/CashbackCalculatorContent.d.ts +0 -25
- package/mobile/lib/components/CashbackCalculator/CashbackCalculatorContent.js +0 -1
- package/mobile/lib/components/CashbackCalculator/CashbackCalculatorResult.d.ts +2 -1
- package/mobile/lib/components/CashbackCalculator/CashbackCalculatorResult.js +9 -11
- package/mobile/lib/components/CashbackCalculator/CashbackCalculatorResult.js.map +1 -1
- package/mobile/lib/components/CashbackCalculator/CashbackCategory.d.ts +6 -2
- package/mobile/lib/components/CashbackCalculator/CashbackCategory.js +33 -54
- package/mobile/lib/components/CashbackCalculator/CashbackCategory.js.map +1 -1
- package/mobile/lib/components/CashbackCalculator/constants.d.ts +16 -0
- package/mobile/lib/components/CashbackCalculator/constants.js +87 -0
- package/mobile/lib/components/CashbackCalculator/constants.js.map +1 -0
- package/mobile/lib/components/CashbackCalculator/getPercentCategories.d.ts +1 -0
- package/mobile/lib/components/CashbackCalculator/getPercentCategories.js +13 -0
- package/mobile/lib/components/CashbackCalculator/getPercentCategories.js.map +1 -0
- package/mobile/lib/components/CashbackCalculator/renderButtons.d.ts +9 -0
- package/mobile/lib/components/CashbackCalculator/renderButtons.js +7 -0
- package/mobile/lib/components/CashbackCalculator/renderButtons.js.map +1 -0
- package/mobile/lib/components/CashbackCalculator/useCashbackCalculator.d.ts +4 -2
- package/mobile/lib/components/CashbackCalculator/useCashbackCalculator.js +18 -16
- package/mobile/lib/components/CashbackCalculator/useCashbackCalculator.js.map +1 -1
- package/mobile/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.d.ts +6 -0
- package/mobile/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js +54 -0
- package/mobile/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayout.js.map +1 -0
- package/mobile/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.d.ts +38 -0
- package/mobile/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js +2 -0
- package/mobile/lib/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.js.map +1 -0
- package/mobile/lib/components/GalleryLayout/utils.d.ts +1 -0
- package/mobile/lib/retail/api/createParticipant.js +1 -1
- package/mobile/lib/retail/api/createParticipant.js.map +1 -1
- package/mobile/lib/retail/model/ApplicationLeadFormTypes.d.ts +1 -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 +2 -0
- package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +47 -28
- package/mobile/src/components/CashbackCalculator/CashbackCalculator.tsx +73 -69
- package/mobile/src/components/CashbackCalculator/CashbackCalculatorContent.ts +0 -28
- package/mobile/src/components/CashbackCalculator/CashbackCalculatorResult.tsx +23 -23
- package/mobile/src/components/CashbackCalculator/CashbackCategory.tsx +69 -71
- package/mobile/src/components/CashbackCalculator/constants.ts +97 -0
- package/mobile/src/components/CashbackCalculator/getPercentCategories.ts +24 -0
- package/mobile/src/components/CashbackCalculator/renderButtons.tsx +38 -0
- package/mobile/src/components/CashbackCalculator/useCashbackCalculator.ts +26 -17
- package/mobile/src/components/CashbackCalculatorLayout/CashbackCalculatorLayout.example.json +47 -0
- package/mobile/src/components/CashbackCalculatorLayout/CashbackCalculatorLayout.tsx +116 -0
- package/{src/components/CashbackCalculator/CashbackCalculator.ui.json → mobile/src/components/CashbackCalculatorLayout/CashbackCalculatorLayout.ui.json} +6 -0
- package/mobile/src/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.ts +49 -0
- package/mobile/src/retail/api/createParticipant.ts +1 -1
- package/mobile/src/retail/model/ApplicationLeadFormTypes.ts +1 -1
- package/mobile/src/ui-kit/RichText/RichText.tsx +9 -1
- package/mobile/src/ui-kit/RichText/RichTextProps.ts +2 -0
- package/package.json +2 -2
- package/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +47 -28
- package/src/components/Blocks.ts +4 -2
- package/src/components/CashbackCalculator/CashbackCalculator.tsx +73 -69
- package/src/components/CashbackCalculator/CashbackCalculatorContent.ts +0 -28
- package/src/components/CashbackCalculator/CashbackCalculatorResult.tsx +23 -23
- package/src/components/CashbackCalculator/CashbackCategory.tsx +69 -71
- package/src/components/CashbackCalculator/constants.ts +97 -0
- package/src/components/CashbackCalculator/getPercentCategories.ts +24 -0
- package/src/components/CashbackCalculator/renderButtons.tsx +38 -0
- package/src/components/CashbackCalculator/useCashbackCalculator.ts +26 -17
- package/src/components/CashbackCalculatorLayout/CashbackCalculatorLayout.example.json +47 -0
- package/src/components/CashbackCalculatorLayout/CashbackCalculatorLayout.fixture.tsx +61 -0
- package/src/components/CashbackCalculatorLayout/CashbackCalculatorLayout.tsx +116 -0
- package/{mobile/src/components/CashbackCalculator/CashbackCalculator.ui.json → src/components/CashbackCalculatorLayout/CashbackCalculatorLayout.ui.json} +6 -0
- package/src/components/CashbackCalculatorLayout/CashbackCalculatorLayoutContent.ts +49 -0
- package/src/retail/api/createParticipant.ts +1 -1
- package/src/retail/model/ApplicationLeadFormTypes.ts +1 -1
- package/src/ui-kit/RichText/RichText.tsx +9 -1
- package/src/ui-kit/RichText/RichTextProps.ts +2 -0
- package/bundle/components/CashbackCalculator/CashbackCalculatorContent.d.ts +0 -25
- package/mobile/bundle/components/CashbackCalculator/CashbackCalculatorContent.d.ts +0 -25
- package/mobile/src/components/CashbackCalculator/CashbackCalculator.example.json +0 -1
- package/src/components/CashbackCalculator/CashbackCalculator.example.json +0 -1
package/src/components/Blocks.ts
CHANGED
|
@@ -19,6 +19,7 @@ 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';
|
|
22
23
|
import { ContactsBlock } from './ContactsBlock/ContactsBlock';
|
|
23
24
|
import { CreditCardForm } from './CreditCardForm/CreditCardForm';
|
|
24
25
|
import { CreditForm } from './CreditForm/CreditForm';
|
|
@@ -86,18 +87,19 @@ export const Blocks: BlocksRegistry = {
|
|
|
86
87
|
RollupItem,
|
|
87
88
|
StepsBlock,
|
|
88
89
|
StickyBottomMenu,
|
|
90
|
+
TextBlock,
|
|
89
91
|
TabsLayout,
|
|
90
92
|
TariffsTable,
|
|
91
|
-
TextBlock,
|
|
92
93
|
VerticalLayout,
|
|
93
94
|
Video,
|
|
94
95
|
ApplicationLeadForm,
|
|
95
96
|
CreditCardForm,
|
|
96
97
|
CreditForm,
|
|
97
98
|
DebitForm,
|
|
98
|
-
CashbackCalculator,
|
|
99
99
|
CalculatorRko,
|
|
100
100
|
RkoTariffCardsTable,
|
|
101
101
|
RatesTable,
|
|
102
102
|
ReferalForm,
|
|
103
|
+
CashbackCalculator,
|
|
104
|
+
CashbackCalculatorLayout,
|
|
103
105
|
};
|
|
@@ -1,16 +1,24 @@
|
|
|
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';
|
|
2
4
|
import { BlockWrapper } from '../../ui-kit/BlockWrapper';
|
|
3
|
-
import { Button } from '../../ui-kit/Button/Button';
|
|
4
5
|
import { Img } from '../../ui-kit/Img/Img';
|
|
5
6
|
import { InfoCard } from '../../ui-kit/InfoCard/InfoCard';
|
|
6
7
|
import { LinkButton } from '../../ui-kit/LinkButton/LinkButton';
|
|
7
|
-
import {
|
|
8
|
+
import type { LinkButtonContent } from '../../ui-kit/LinkButton/LinkButtonContent';
|
|
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';
|
|
8
12
|
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
9
13
|
import { style } from '../../utils/style';
|
|
10
|
-
import {
|
|
11
|
-
|
|
14
|
+
import {
|
|
15
|
+
type CalculatorParams,
|
|
16
|
+
type CashbackCalculatorLayoutContent,
|
|
17
|
+
} from '../CashbackCalculatorLayout/CashbackCalculatorLayoutContent';
|
|
12
18
|
import { CashbackCalculatorResult } from './CashbackCalculatorResult';
|
|
13
19
|
import { CashbackCategory } from './CashbackCategory';
|
|
20
|
+
import { INFO_BLOCK_HTML, MAIN_CASHBACK_KEY, MAX_MONTH_CASHBACK } from './constants';
|
|
21
|
+
import { renderButtons } from './renderButtons';
|
|
14
22
|
import { useCashbackCalculator } from './useCashbackCalculator';
|
|
15
23
|
|
|
16
24
|
const defaultButton: LinkButtonContent = {
|
|
@@ -19,22 +27,25 @@ const defaultButton: LinkButtonContent = {
|
|
|
19
27
|
target: '_self',
|
|
20
28
|
};
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
interface CashbackCalculatorProps
|
|
31
|
+
extends CalculatorParams,
|
|
32
|
+
CashbackCalculatorLayoutContent,
|
|
33
|
+
UniBlockProps {}
|
|
23
34
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
interface CashbackCalculatorProps extends CashbackCalculatorContent, UniBlockProps {}
|
|
35
|
+
export type SelectedCategory = {
|
|
36
|
+
id: number;
|
|
37
|
+
category: Option;
|
|
38
|
+
};
|
|
29
39
|
|
|
30
40
|
export const CashbackCalculator = JSX<CashbackCalculatorProps>(
|
|
41
|
+
// eslint-disable-next-line max-lines-per-function
|
|
31
42
|
({
|
|
32
43
|
maxInputRange = 300000,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
className = '',
|
|
44
|
+
maxCategories,
|
|
45
|
+
calculatorType = 'standard',
|
|
46
|
+
maxMonthCashback = MAX_MONTH_CASHBACK[calculatorType],
|
|
37
47
|
button = defaultButton,
|
|
48
|
+
className = '',
|
|
38
49
|
...rest
|
|
39
50
|
}) => {
|
|
40
51
|
const {
|
|
@@ -44,41 +55,53 @@ export const CashbackCalculator = JSX<CashbackCalculatorProps>(
|
|
|
44
55
|
onChangeCashback,
|
|
45
56
|
onDeleteCashback,
|
|
46
57
|
onResetCashback,
|
|
47
|
-
|
|
58
|
+
onChangeCategory,
|
|
59
|
+
} = useCashbackCalculator(calculatorType);
|
|
60
|
+
|
|
61
|
+
const { deleteImage, infoImage, image } = rest;
|
|
62
|
+
const [isMainCashbackAdded, setIsMainCashbackAdded] = useState(false);
|
|
48
63
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
setIsMainCashbackAdded(
|
|
66
|
+
Boolean(cashbacks.find((item) => item.percent.key === MAIN_CASHBACK_KEY[calculatorType])),
|
|
67
|
+
);
|
|
68
|
+
}, [cashbacks]);
|
|
52
69
|
|
|
53
70
|
return (
|
|
54
71
|
<BlockWrapper
|
|
55
72
|
className={style('flex flex-col justify-center items-center gap-lg', className)}
|
|
56
|
-
defaultPadding={style('p-
|
|
73
|
+
defaultPadding={style('p-0')}
|
|
57
74
|
{...rest}
|
|
58
75
|
>
|
|
59
|
-
<
|
|
60
|
-
title="Калькулятор расчета баллов"
|
|
61
|
-
description="Можно выбрать не более 5 категорий, одна из них из повышенной категории"
|
|
62
|
-
headlineVersion="XL"
|
|
63
|
-
isEmbedded={true}
|
|
64
|
-
/>
|
|
65
|
-
<div className="flex flex-row items-start gap-lg">
|
|
76
|
+
<div className="flex flex-row items-start gap-lg mt-5">
|
|
66
77
|
<div className="w-full flex flex-col justify-center items-center gap-lg">
|
|
67
|
-
{cashbacks.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
{cashbacks.length
|
|
79
|
+
? cashbacks.map((_, index) => (
|
|
80
|
+
<CashbackCategory
|
|
81
|
+
key={String(_.id)}
|
|
82
|
+
categories={categories}
|
|
83
|
+
cashback={_}
|
|
84
|
+
maxInputRange={maxInputRange}
|
|
85
|
+
deleteImage={deleteImage}
|
|
86
|
+
onDelete={onDeleteCashback}
|
|
87
|
+
onChange={onChangeCashback}
|
|
88
|
+
isMainCashbackAdded={isMainCashbackAdded}
|
|
89
|
+
calculatorType={calculatorType}
|
|
90
|
+
isShowDisclaimer={index === 0}
|
|
91
|
+
onChangeCategory={onChangeCategory}
|
|
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} />
|
|
81
103
|
<InfoCard __html={INFO_BLOCK_HTML} image={infoImage} />
|
|
104
|
+
<RichText __html='* Подробнее по условиям и начислениям можно узнать во вкладке <a href="#docs">документы</a>' />
|
|
82
105
|
<LinkButton
|
|
83
106
|
className="w-full @lg:w-auto self-start"
|
|
84
107
|
href={button.href}
|
|
@@ -87,39 +110,20 @@ export const CashbackCalculator = JSX<CashbackCalculatorProps>(
|
|
|
87
110
|
version="primary"
|
|
88
111
|
/>
|
|
89
112
|
</div>
|
|
90
|
-
{
|
|
113
|
+
{renderImage(image)}
|
|
91
114
|
</div>
|
|
92
115
|
</BlockWrapper>
|
|
93
116
|
);
|
|
94
117
|
},
|
|
95
118
|
);
|
|
96
119
|
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
};
|
|
120
|
+
const renderNoCategoryText = () => (
|
|
121
|
+
<Text align="text-left" className="w-full">
|
|
122
|
+
Категория не выбрана
|
|
123
|
+
</Text>
|
|
124
|
+
);
|
|
122
125
|
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
const renderImage = (image: Picture = {}) =>
|
|
127
|
+
image?.src ? (
|
|
128
|
+
<Img image={image} className="hidden w-full @xl:block" imageClassName="justify-self-center" />
|
|
129
|
+
) : null;
|
|
@@ -1,28 +0,0 @@
|
|
|
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,16 +1,13 @@
|
|
|
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';
|
|
4
3
|
import { Text } from '../../ui-kit/Text/Text';
|
|
5
4
|
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
6
5
|
import { toLocalNumberFormat } from '../../utils/toLocalNumberFormat';
|
|
7
|
-
import { type Cashback } from '
|
|
8
|
-
|
|
9
|
-
const MAX_MONTH_CASHBACK = 5000;
|
|
10
|
-
const MAX_YEAR_CASHBACK = 60000;
|
|
6
|
+
import { type Cashback } from '../CashbackCalculatorLayout/CashbackCalculatorLayoutContent';
|
|
11
7
|
|
|
12
8
|
export type CashbackCalculatorResultProps = UniBlockProps & {
|
|
13
9
|
cashbacks: Cashback[];
|
|
10
|
+
maxMonthCashback: number;
|
|
14
11
|
};
|
|
15
12
|
|
|
16
13
|
type ResultTextProps = {
|
|
@@ -29,34 +26,37 @@ const ResultText = JSX<ResultTextProps>(({ text, value }) => (
|
|
|
29
26
|
</div>
|
|
30
27
|
));
|
|
31
28
|
|
|
32
|
-
export const CashbackCalculatorResult = JSX<CashbackCalculatorResultProps>(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
export const CashbackCalculatorResult = JSX<CashbackCalculatorResultProps>(
|
|
30
|
+
({ cashbacks, maxMonthCashback }) => {
|
|
31
|
+
const { month, year } = getResult(cashbacks, maxMonthCashback);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className="w-full flex flex-col gap-lg">
|
|
35
|
+
<Heading className="text-left" headingType="h5" as="h2" title="Результат расчета" />
|
|
36
|
+
<div className="flex flex-col @xs:flex-row gap-lg">
|
|
37
|
+
<ResultText text="Баллов в месяц" value={month} />
|
|
38
|
+
<ResultText text="Баллов в год" value={year} />
|
|
39
|
+
</div>
|
|
42
40
|
</div>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
);
|
|
46
44
|
|
|
47
|
-
const getResult = (cashbacks: Cashback[]) => {
|
|
45
|
+
const getResult = (cashbacks: Cashback[], maxMonthCashback: number) => {
|
|
48
46
|
return cashbacks.reduce(
|
|
49
47
|
(acc, val) => {
|
|
50
|
-
const mounthSum = (
|
|
48
|
+
const mounthSum = (formatKey(val.percent.key) / 100) * val.sum;
|
|
51
49
|
|
|
52
50
|
return {
|
|
53
|
-
|
|
54
|
-
year: Math.min(acc.year + mounthSum * 12,
|
|
51
|
+
month: Math.min(acc.month + mounthSum, maxMonthCashback),
|
|
52
|
+
year: Math.min(acc.year + mounthSum * 12, maxMonthCashback * 12),
|
|
55
53
|
};
|
|
56
54
|
},
|
|
57
55
|
{
|
|
58
|
-
|
|
56
|
+
month: 0,
|
|
59
57
|
year: 0,
|
|
60
58
|
},
|
|
61
59
|
);
|
|
62
60
|
};
|
|
61
|
+
|
|
62
|
+
const formatKey = (key: string) => Number(key.replace('-main', ''));
|
|
@@ -4,107 +4,88 @@ import { type Picture } from '../../model/Picture';
|
|
|
4
4
|
import { Button } from '../../ui-kit/Button/Button';
|
|
5
5
|
import { Img } from '../../ui-kit/Img/Img';
|
|
6
6
|
import { InputRange } from '../../ui-kit/InputRange/InputRange';
|
|
7
|
+
import { Paragraph } from '../../ui-kit/Paragraph/Paragraph';
|
|
7
8
|
import { type Option } from '../../ui-kit/Select/Option';
|
|
8
9
|
import { Select } from '../../ui-kit/Select/Select';
|
|
9
10
|
import { Text } from '../../ui-kit/Text/Text';
|
|
10
11
|
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
key: '1.5',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
text: 'Категория 3%',
|
|
20
|
-
key: '3',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
text: 'Категория 5%',
|
|
24
|
-
key: '5',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
text: 'Категория 10%',
|
|
28
|
-
key: '10',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
text: 'Категория 15%',
|
|
32
|
-
key: '15',
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
const PercentCategoriesWithoutIncreased: Option[] = [
|
|
37
|
-
{
|
|
38
|
-
text: 'Категория 1,5%',
|
|
39
|
-
key: '1.5',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
text: 'Категория 3%',
|
|
43
|
-
key: '3',
|
|
44
|
-
},
|
|
45
|
-
];
|
|
12
|
+
import { noop } from '../../utils/noop';
|
|
13
|
+
import { type Cashback } from '../CashbackCalculatorLayout/CashbackCalculatorLayoutContent';
|
|
14
|
+
import { type SelectedCategory } from './CashbackCalculator';
|
|
15
|
+
import { MAIN_CASHBACK_KEY } from './constants';
|
|
16
|
+
import { getPercentCategories } from './getPercentCategories';
|
|
46
17
|
|
|
47
18
|
export interface CashbackCategoryProps extends UniBlockProps {
|
|
48
19
|
categories?: Option[];
|
|
49
20
|
cashback: Cashback;
|
|
50
|
-
showIncreasedPercents: boolean;
|
|
51
21
|
maxInputRange: number;
|
|
52
22
|
deleteImage?: Picture;
|
|
53
23
|
onDelete: (id: number) => void;
|
|
54
24
|
onChange: (item: Cashback) => void;
|
|
25
|
+
isMainCashbackAdded?: boolean;
|
|
26
|
+
calculatorType?: string;
|
|
27
|
+
isShowDisclaimer?: boolean;
|
|
28
|
+
onChangeCategory: (item: (prev: SelectedCategory[]) => any) => void;
|
|
55
29
|
}
|
|
56
30
|
|
|
31
|
+
const defaultDeleteImage: Picture = {
|
|
32
|
+
src: 'IconDelete.svg',
|
|
33
|
+
format: 'webp',
|
|
34
|
+
alt: 'Иконка кнопки удаления блока кэшбека',
|
|
35
|
+
};
|
|
36
|
+
|
|
57
37
|
export const CashbackCategory = JSX<CashbackCategoryProps>(
|
|
58
38
|
({
|
|
59
39
|
categories,
|
|
60
40
|
cashback,
|
|
61
|
-
showIncreasedPercents,
|
|
62
41
|
maxInputRange,
|
|
63
|
-
deleteImage,
|
|
42
|
+
deleteImage = defaultDeleteImage,
|
|
43
|
+
isMainCashbackAdded = false,
|
|
44
|
+
calculatorType = 'standard',
|
|
64
45
|
onDelete,
|
|
65
46
|
onChange,
|
|
47
|
+
isShowDisclaimer = false,
|
|
48
|
+
onChangeCategory = noop,
|
|
66
49
|
}) => {
|
|
67
50
|
const [currentCategory, setCurrentCategory] = useState(getRandomElement(categories));
|
|
68
|
-
const isMainCashback = cashback.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
percent: value,
|
|
73
|
-
});
|
|
74
|
-
};
|
|
51
|
+
const isMainCashback = cashback.percent.key === MAIN_CASHBACK_KEY[calculatorType];
|
|
52
|
+
|
|
53
|
+
const onChangePercent = createChangeHandler(cashback, 'percent', onChange);
|
|
54
|
+
const onChangeSum = createChangeHandler(cashback, 'sum', onChange);
|
|
75
55
|
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
sum: value,
|
|
80
|
-
});
|
|
56
|
+
const onChangeCashbackCategory = (value: Option) => {
|
|
57
|
+
setCurrentCategory(value);
|
|
58
|
+
onChangeCategory((prev) => updateSelectedCategories(prev, cashback, value));
|
|
81
59
|
};
|
|
82
60
|
|
|
83
61
|
return (
|
|
84
62
|
<div className="w-full space-y-m">
|
|
85
63
|
<div className="space-y-xs">
|
|
86
|
-
<
|
|
64
|
+
<Paragraph size="text-m" color="text-primary-text" font="font-light">
|
|
87
65
|
Выберите категорию
|
|
88
|
-
</
|
|
66
|
+
</Paragraph>
|
|
67
|
+
{isShowDisclaimer ? (
|
|
68
|
+
<Text size="text-s" color="text-primary-text" font="font-light" className="italic">
|
|
69
|
+
Категории покупок для расчёта баллов предварительные
|
|
70
|
+
</Text>
|
|
71
|
+
) : null}
|
|
89
72
|
<div className="flex gap-m">
|
|
90
73
|
<Select
|
|
91
74
|
className="w-full"
|
|
92
75
|
isManualInput={isMainCashback}
|
|
93
76
|
placeholder="Выберите категорию"
|
|
94
|
-
options={getPercentCategories(
|
|
77
|
+
options={getPercentCategories(isMainCashbackAdded, calculatorType)}
|
|
95
78
|
value={cashback.percent}
|
|
96
79
|
onChange={onChangePercent}
|
|
97
80
|
/>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
</Button>
|
|
107
|
-
) : null}
|
|
81
|
+
<Button
|
|
82
|
+
version="secondary"
|
|
83
|
+
onClick={() => onDelete(cashback.id)}
|
|
84
|
+
shape="round"
|
|
85
|
+
className="px-4 rounded-md"
|
|
86
|
+
>
|
|
87
|
+
<Img image={deleteImage} />
|
|
88
|
+
</Button>
|
|
108
89
|
</div>
|
|
109
90
|
</div>
|
|
110
91
|
{categories?.length && !isMainCashback ? (
|
|
@@ -113,7 +94,7 @@ export const CashbackCategory = JSX<CashbackCategoryProps>(
|
|
|
113
94
|
placeholder="Выберите категорию покупок"
|
|
114
95
|
options={categories}
|
|
115
96
|
value={currentCategory}
|
|
116
|
-
onChange={
|
|
97
|
+
onChange={onChangeCashbackCategory}
|
|
117
98
|
/>
|
|
118
99
|
) : null}
|
|
119
100
|
<InputRange
|
|
@@ -132,12 +113,29 @@ export const CashbackCategory = JSX<CashbackCategoryProps>(
|
|
|
132
113
|
const getRandomElement = <T,>(arr?: T[]): T | undefined =>
|
|
133
114
|
arr?.[new Date().getTime().toString().slice(-1)];
|
|
134
115
|
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
116
|
+
const createChangeHandler =
|
|
117
|
+
<T, K extends keyof T>(obj: T, field: K, onChange: (value: T) => void) =>
|
|
118
|
+
(value: T[K]) => {
|
|
119
|
+
onChange({
|
|
120
|
+
...obj,
|
|
121
|
+
[field]: value,
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const updateSelectedCategories = (prev: SelectedCategory[], cashback: Cashback, value: Option) => {
|
|
126
|
+
const newItem = { id: cashback.id, category: value };
|
|
127
|
+
|
|
128
|
+
if (prev.length === 0) {
|
|
129
|
+
return [newItem];
|
|
142
130
|
}
|
|
131
|
+
const index = prev.findIndex((item) => item.id === cashback.id);
|
|
132
|
+
|
|
133
|
+
if (index !== -1) {
|
|
134
|
+
const updated = [...prev];
|
|
135
|
+
updated[index] = newItem;
|
|
136
|
+
|
|
137
|
+
return updated;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return [...prev, newItem];
|
|
143
141
|
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { Option } from '../../ui-kit/Select/Option';
|
|
2
|
+
import { type Cashback } from '../CashbackCalculatorLayout/CashbackCalculatorLayoutContent';
|
|
3
|
+
|
|
4
|
+
export const ALL_PERCENT_STANDARD_CATEGORIES: Option[] = [
|
|
5
|
+
{
|
|
6
|
+
text: 'Категория 1% «На всё»',
|
|
7
|
+
key: '1-main',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
text: 'Категория 1,5%',
|
|
11
|
+
key: '1.5',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
text: 'Категория 3%',
|
|
15
|
+
key: '3',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
text: 'Категория 5%',
|
|
19
|
+
key: '5',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
text: 'Категория 10%',
|
|
23
|
+
key: '10',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
text: 'Категория 15%',
|
|
27
|
+
key: '15',
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
export const ALL_PERCENT_PREMIUM_CATEGORIES: Option[] = [
|
|
32
|
+
{
|
|
33
|
+
text: 'Категория 1,5% «На всё»',
|
|
34
|
+
key: '1.5-main',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
text: 'Категория 1,5%',
|
|
38
|
+
key: '1.5',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
text: 'Категория 3%',
|
|
42
|
+
key: '3',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
text: 'Категория 5%',
|
|
46
|
+
key: '5',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
text: 'Категория 10%',
|
|
50
|
+
key: '10',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
text: 'Категория 15%',
|
|
54
|
+
key: '15',
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
export const MAIN_CASHBACK_KEY = {
|
|
59
|
+
standard: '1-main',
|
|
60
|
+
premium: '1.5-main',
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const DEFAULT_STANDARD_CASHBACK: Cashback[] = [
|
|
64
|
+
{
|
|
65
|
+
id: 0,
|
|
66
|
+
percent: {
|
|
67
|
+
text: 'Категория 1% «На всё»',
|
|
68
|
+
key: '1-main',
|
|
69
|
+
},
|
|
70
|
+
sum: 5000,
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
export const DEFAULT_PREMIUM_CASHBACK: Cashback[] = [
|
|
75
|
+
{
|
|
76
|
+
id: 0,
|
|
77
|
+
percent: {
|
|
78
|
+
text: 'Категория 1,5% «На всё»',
|
|
79
|
+
key: '1.5-main',
|
|
80
|
+
},
|
|
81
|
+
sum: 5000,
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
// export const INCREASED_PERCENTS = ['5', '10', '15'];
|
|
86
|
+
|
|
87
|
+
export const MAX_CATEGORIES = {
|
|
88
|
+
standard: 5,
|
|
89
|
+
premium: 7,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const INFO_BLOCK_HTML = `<p>Полученные баллы можно конвертировать в рубли и компенсировать покупки у партнеров.</p>`;
|
|
93
|
+
|
|
94
|
+
export const MAX_MONTH_CASHBACK: Record<string, number> = {
|
|
95
|
+
standard: 5000,
|
|
96
|
+
premium: 15000,
|
|
97
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ALL_PERCENT_PREMIUM_CATEGORIES,
|
|
3
|
+
ALL_PERCENT_STANDARD_CATEGORIES,
|
|
4
|
+
MAIN_CASHBACK_KEY,
|
|
5
|
+
} from './constants';
|
|
6
|
+
|
|
7
|
+
export const getPercentCategories = (isMainCashbackAdded: boolean, calculatorType: string) => {
|
|
8
|
+
const allPercentCategories =
|
|
9
|
+
calculatorType === 'premium' ? ALL_PERCENT_PREMIUM_CATEGORIES : ALL_PERCENT_STANDARD_CATEGORIES;
|
|
10
|
+
|
|
11
|
+
let updatedCategories = allPercentCategories;
|
|
12
|
+
|
|
13
|
+
if (!isMainCashbackAdded) {
|
|
14
|
+
return allPercentCategories;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (isMainCashbackAdded) {
|
|
18
|
+
updatedCategories = updatedCategories.filter(
|
|
19
|
+
(_) => _.key !== MAIN_CASHBACK_KEY[calculatorType],
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return updatedCategories;
|
|
24
|
+
};
|