@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,27 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
2
|
import { useLeadFormData } from '../../retail/hooks/useLeadFormData.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const DEFAULT_CASHBACK = [
|
|
4
|
+
{
|
|
5
|
+
id: 0,
|
|
6
|
+
percent: {
|
|
7
|
+
text: 'Категория 1% "На всё"',
|
|
8
|
+
key: '1',
|
|
9
|
+
},
|
|
10
|
+
sum: 5000,
|
|
11
|
+
},
|
|
12
|
+
];
|
|
13
|
+
export const useCashbackCalculator = () => {
|
|
9
14
|
const { data } = useLeadFormData('CASHBACK_CATEGORY');
|
|
10
|
-
const [cashbacks, setCashbacks] = useState(
|
|
11
|
-
const [selectedCategories, setSelectedCategories] = useState([]);
|
|
15
|
+
const [cashbacks, setCashbacks] = useState(DEFAULT_CASHBACK);
|
|
12
16
|
const categories = data?.map((_) => ({
|
|
13
17
|
key: _.key || '',
|
|
14
18
|
text: _.value,
|
|
15
19
|
})) || [];
|
|
16
|
-
const filteredCategories = useMemo(() => {
|
|
17
|
-
const categoriesToRemove = selectedCategories.map((obj) => obj.category);
|
|
18
|
-
const keysToRemove = new Set(categoriesToRemove.map((item) => item.key));
|
|
19
|
-
return categories.filter((item) => !keysToRemove.has(item.key));
|
|
20
|
-
}, [selectedCategories, categories]);
|
|
21
20
|
const onAddNewCashback = () => setCashbacks((_) => [
|
|
22
21
|
..._,
|
|
23
22
|
{
|
|
24
|
-
id: _
|
|
23
|
+
id: _[_.length - 1].id + 1,
|
|
25
24
|
percent: {
|
|
26
25
|
text: 'Категория 1,5%',
|
|
27
26
|
key: '1.5',
|
|
@@ -36,15 +35,14 @@ export const useCashbackCalculator = (calculatorType) => {
|
|
|
36
35
|
return _;
|
|
37
36
|
}));
|
|
38
37
|
const onDeleteCashback = (id) => setCashbacks((prev) => prev.filter((_) => _.id !== id));
|
|
39
|
-
const onResetCashback = () => setCashbacks(
|
|
38
|
+
const onResetCashback = () => setCashbacks(DEFAULT_CASHBACK);
|
|
40
39
|
return {
|
|
41
40
|
cashbacks,
|
|
42
|
-
categories
|
|
41
|
+
categories,
|
|
43
42
|
onAddNewCashback,
|
|
44
43
|
onChangeCashback,
|
|
45
44
|
onDeleteCashback,
|
|
46
45
|
onResetCashback,
|
|
47
|
-
onChangeCategory: setSelectedCategories,
|
|
48
46
|
};
|
|
49
47
|
};
|
|
50
48
|
//# sourceMappingURL=useCashbackCalculator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCashbackCalculator.js","sourceRoot":"","sources":["../../../src/components/CashbackCalculator/useCashbackCalculator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useCashbackCalculator.js","sourceRoot":"","sources":["../../../src/components/CashbackCalculator/useCashbackCalculator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAKrE,MAAM,gBAAgB,GAAe;IACnC;QACE,EAAE,EAAE,CAAC;QACL,OAAO,EAAE;YACP,IAAI,EAAE,uBAAuB;YAC7B,GAAG,EAAE,GAAG;SACT;QACD,GAAG,EAAE,IAAI;KACV;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACxC,MAAM,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC;IACtD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAa,gBAAgB,CAAC,CAAC;IAEzE,MAAM,UAAU,GACd,IAAI,EAAE,GAAG,CAAC,CAAC,CAAiB,EAAE,EAAE,CAAC,CAAC;QAChC,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE;QAChB,IAAI,EAAE,CAAC,CAAC,KAAK;KACd,CAAC,CAAC,IAAI,EAAE,CAAC;IAEZ,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAC5B,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAClB,GAAG,CAAC;QACJ;YACE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;YAC1B,OAAO,EAAE;gBACP,IAAI,EAAE,gBAAgB;gBACtB,GAAG,EAAE,KAAK;aACX;YACD,GAAG,EAAE,IAAI;SACV;KACF,CAAC,CAAC;IAEL,MAAM,gBAAgB,GAAG,CAAC,IAAc,EAAE,EAAE,CAC1C,YAAY,CAAC,CAAC,IAAI,EAAE,EAAE,CACpB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACb,IAAI,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE;YACpB,OAAO,IAAI,CAAC;SACb;QAED,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CACH,CAAC;IAEJ,MAAM,gBAAgB,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAEjG,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAE7D,OAAO;QACL,SAAS;QACT,UAAU;QACV,gBAAgB;QAChB,gBAAgB;QAChB,gBAAgB;QAChB,eAAe;KAChB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -8,7 +8,6 @@ export declare const modifyBlock: (block: BlockDef, i: number) => {
|
|
|
8
8
|
__html?: string | undefined;
|
|
9
9
|
richVersion?: import("../../ui-kit/RichText/RichTextProps").RichVersion | undefined;
|
|
10
10
|
itemSize?: import("../../ui-kit/RichText/RichTextProps").RichTextItemSize | undefined;
|
|
11
|
-
className?: string | undefined;
|
|
12
11
|
} & import("../../ui-kit/Tags/TagsContent").TagsContent & import("../../ui-kit/LinkButton/ButtonsSectionContent").ButtonsSectionContent & import("../../ui-kit/Img/ImgProps").ImageContent & import("../../ui-kit/BaseProductTile/BaseProductTileContent").PriceListProps & {
|
|
13
12
|
imageOptions?: import("../../ui-kit/BaseProductTile/BaseProductTileContent").TileImageOptions | undefined;
|
|
14
13
|
isFullWidthTitle?: boolean | undefined;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@redneckz/uni-jsx/jsx-runtime";
|
|
2
2
|
import { JSX } from '@redneckz/uni-jsx';
|
|
3
3
|
import { style } from '../../utils/style.js';
|
|
4
|
-
export const RichText = JSX(({ __html = '', richVersion = '', itemSize = 'list-m',
|
|
4
|
+
export const RichText = JSX(({ __html = '', richVersion = '', itemSize = 'list-m', isDotted = true, children }) => {
|
|
5
5
|
const dotStyle = isDotted ? '' : 'without-dots';
|
|
6
6
|
return __html || children ? (
|
|
7
7
|
/* Attribute [data-component] need for correct render in wcms editor. Do not remove. */
|
|
8
|
-
_jsx("div", { "data-component": "rich-text-container", children: _jsx("div", { className: style(richVersion, itemSize, 'md-container group-data-secondary:text-white group-data-gray:text-secondary-text', dotStyle
|
|
8
|
+
_jsx("div", { "data-component": "rich-text-container", children: _jsx("div", { className: style(richVersion, itemSize, 'md-container group-data-secondary:text-white group-data-gray:text-secondary-text', dotStyle), dangerouslySetInnerHTML: __html ? { __html } : undefined, children: children }) })) : null;
|
|
9
9
|
});
|
|
10
10
|
//# sourceMappingURL=RichText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichText.js","sourceRoot":"","sources":["../../../src/ui-kit/RichText/RichText.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CACzB,CAAC,
|
|
1
|
+
{"version":3,"file":"RichText.js","sourceRoot":"","sources":["../../../src/ui-kit/RichText/RichText.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CACzB,CAAC,EAAE,MAAM,GAAG,EAAE,EAAE,WAAW,GAAG,EAAE,EAAE,QAAQ,GAAG,QAAQ,EAAE,QAAQ,GAAG,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;IACpF,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC;IAEhD,OAAO,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC;IAC1B,uFAAuF;IACvF,gCAAoB,qBAAqB,YACvC,cACE,SAAS,EAAE,KAAK,CACd,WAAW,EACX,QAAQ,EACR,kFAAkF,EAClF,QAAQ,CACT,EACD,uBAAuB,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,YAEvD,QAAQ,GACL,GACF,CACP,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CACF,CAAC"}
|
|
@@ -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', ''));
|
|
@@ -4,88 +4,107 @@ 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';
|
|
8
7
|
import { type Option } from '../../ui-kit/Select/Option';
|
|
9
8
|
import { Select } from '../../ui-kit/Select/Select';
|
|
10
9
|
import { Text } from '../../ui-kit/Text/Text';
|
|
11
10
|
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
import { type Cashback } from './CashbackCalculatorContent';
|
|
12
|
+
|
|
13
|
+
const AllPercentCategories: Option[] = [
|
|
14
|
+
{
|
|
15
|
+
text: 'Категория 1,5%',
|
|
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
|
+
];
|
|
17
46
|
|
|
18
47
|
export interface CashbackCategoryProps extends UniBlockProps {
|
|
19
48
|
categories?: Option[];
|
|
20
49
|
cashback: Cashback;
|
|
50
|
+
showIncreasedPercents: boolean;
|
|
21
51
|
maxInputRange: number;
|
|
22
52
|
deleteImage?: Picture;
|
|
23
53
|
onDelete: (id: number) => void;
|
|
24
54
|
onChange: (item: Cashback) => void;
|
|
25
|
-
isMainCashbackAdded?: boolean;
|
|
26
|
-
calculatorType?: string;
|
|
27
|
-
isShowDisclaimer?: boolean;
|
|
28
|
-
onChangeCategory: (item: (prev: SelectedCategory[]) => any) => void;
|
|
29
55
|
}
|
|
30
56
|
|
|
31
|
-
const defaultDeleteImage: Picture = {
|
|
32
|
-
src: 'IconDelete.svg',
|
|
33
|
-
format: 'webp',
|
|
34
|
-
alt: 'Иконка кнопки удаления блока кэшбека',
|
|
35
|
-
};
|
|
36
|
-
|
|
37
57
|
export const CashbackCategory = JSX<CashbackCategoryProps>(
|
|
38
58
|
({
|
|
39
59
|
categories,
|
|
40
60
|
cashback,
|
|
61
|
+
showIncreasedPercents,
|
|
41
62
|
maxInputRange,
|
|
42
|
-
deleteImage
|
|
43
|
-
isMainCashbackAdded = false,
|
|
44
|
-
calculatorType = 'standard',
|
|
63
|
+
deleteImage,
|
|
45
64
|
onDelete,
|
|
46
65
|
onChange,
|
|
47
|
-
isShowDisclaimer = false,
|
|
48
|
-
onChangeCategory = noop,
|
|
49
66
|
}) => {
|
|
50
67
|
const [currentCategory, setCurrentCategory] = useState(getRandomElement(categories));
|
|
51
|
-
const isMainCashback = cashback.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
const isMainCashback = cashback.id === 0;
|
|
69
|
+
const onChangePercent = (value: Option) => {
|
|
70
|
+
onChange({
|
|
71
|
+
...cashback,
|
|
72
|
+
percent: value,
|
|
73
|
+
});
|
|
74
|
+
};
|
|
55
75
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
const onChangeSum = (value: number) => {
|
|
77
|
+
onChange({
|
|
78
|
+
...cashback,
|
|
79
|
+
sum: value,
|
|
80
|
+
});
|
|
59
81
|
};
|
|
60
82
|
|
|
61
83
|
return (
|
|
62
84
|
<div className="w-full space-y-m">
|
|
63
85
|
<div className="space-y-xs">
|
|
64
|
-
<
|
|
86
|
+
<Text size="text-m" color="text-primary-text" font="font-light">
|
|
65
87
|
Выберите категорию
|
|
66
|
-
</
|
|
67
|
-
{isShowDisclaimer ? (
|
|
68
|
-
<Text size="text-s" color="text-primary-text" font="font-light" className="italic">
|
|
69
|
-
Категории покупок для расчёта баллов предварительные
|
|
70
|
-
</Text>
|
|
71
|
-
) : null}
|
|
88
|
+
</Text>
|
|
72
89
|
<div className="flex gap-m">
|
|
73
90
|
<Select
|
|
74
91
|
className="w-full"
|
|
75
92
|
isManualInput={isMainCashback}
|
|
76
93
|
placeholder="Выберите категорию"
|
|
77
|
-
options={getPercentCategories(
|
|
94
|
+
options={getPercentCategories(isMainCashback, showIncreasedPercents)}
|
|
78
95
|
value={cashback.percent}
|
|
79
96
|
onChange={onChangePercent}
|
|
80
97
|
/>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
{!isMainCashback ? (
|
|
99
|
+
<Button
|
|
100
|
+
version="secondary"
|
|
101
|
+
onClick={() => onDelete(cashback.id)}
|
|
102
|
+
shape="round"
|
|
103
|
+
className="px-4 rounded-md"
|
|
104
|
+
>
|
|
105
|
+
<Img image={deleteImage} />
|
|
106
|
+
</Button>
|
|
107
|
+
) : null}
|
|
89
108
|
</div>
|
|
90
109
|
</div>
|
|
91
110
|
{categories?.length && !isMainCashback ? (
|
|
@@ -94,7 +113,7 @@ export const CashbackCategory = JSX<CashbackCategoryProps>(
|
|
|
94
113
|
placeholder="Выберите категорию покупок"
|
|
95
114
|
options={categories}
|
|
96
115
|
value={currentCategory}
|
|
97
|
-
onChange={
|
|
116
|
+
onChange={setCurrentCategory}
|
|
98
117
|
/>
|
|
99
118
|
) : null}
|
|
100
119
|
<InputRange
|
|
@@ -113,29 +132,12 @@ export const CashbackCategory = JSX<CashbackCategoryProps>(
|
|
|
113
132
|
const getRandomElement = <T,>(arr?: T[]): T | undefined =>
|
|
114
133
|
arr?.[new Date().getTime().toString().slice(-1)];
|
|
115
134
|
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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];
|
|
135
|
+
const getPercentCategories = (isMainCashback: boolean, showIncreasedPercents: boolean) => {
|
|
136
|
+
if (isMainCashback) {
|
|
137
|
+
return [];
|
|
138
|
+
} else if (showIncreasedPercents) {
|
|
139
|
+
return AllPercentCategories;
|
|
140
|
+
} else {
|
|
141
|
+
return PercentCategoriesWithoutIncreased;
|
|
130
142
|
}
|
|
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];
|
|
141
143
|
};
|