@cloud-ru/uikit-product-calculator 0.33.3
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/CHANGELOG.md +1508 -0
- package/LICENSE +201 -0
- package/README.md +85 -0
- package/package.json +75 -0
- package/src/components/Calculator/Calculator.tsx +79 -0
- package/src/components/Calculator/index.ts +1 -0
- package/src/components/CalculatorContent/CalculatorContent.tsx +38 -0
- package/src/components/CalculatorContent/index.ts +1 -0
- package/src/components/CalculatorContent/styles.module.scss +79 -0
- package/src/components/Catalog/Catalog.tsx +225 -0
- package/src/components/Catalog/components/PrivateCardHeader.tsx +63 -0
- package/src/components/Catalog/components/index.ts +1 -0
- package/src/components/Catalog/components/styles.module.scss +35 -0
- package/src/components/Catalog/index.ts +1 -0
- package/src/components/Catalog/styles.module.scss +104 -0
- package/src/components/Controls/AlertControl/AlertControl.tsx +44 -0
- package/src/components/Controls/AlertControl/index.ts +1 -0
- package/src/components/Controls/ArrayControl/ArrayControl.tsx +105 -0
- package/src/components/Controls/ArrayControl/index.ts +1 -0
- package/src/components/Controls/ArrayControl/styles.module.scss +33 -0
- package/src/components/Controls/CarouselControl/CarouselControl.tsx +173 -0
- package/src/components/Controls/CarouselControl/index.ts +1 -0
- package/src/components/Controls/CarouselControl/styles.module.scss +32 -0
- package/src/components/Controls/Control/Control.tsx +205 -0
- package/src/components/Controls/Control/index.ts +1 -0
- package/src/components/Controls/ObjectControl/ObjectControl.tsx +150 -0
- package/src/components/Controls/ObjectControl/index.ts +1 -0
- package/src/components/Controls/ObjectControl/styles.module.scss +18 -0
- package/src/components/Controls/ObjectDecorator/ObjectDecorator.tsx +23 -0
- package/src/components/Controls/ObjectDecorator/index.ts +1 -0
- package/src/components/Controls/ObjectDecorator/styles.module.scss +15 -0
- package/src/components/Controls/SegmentedControl/SegmentedControl.tsx +79 -0
- package/src/components/Controls/SegmentedControl/SegmentedControlCard.tsx +38 -0
- package/src/components/Controls/SegmentedControl/index.ts +1 -0
- package/src/components/Controls/SegmentedControl/styles.module.scss +8 -0
- package/src/components/Controls/SelectControl/SelectControl.tsx +172 -0
- package/src/components/Controls/SelectControl/index.ts +1 -0
- package/src/components/Controls/SelectControl/styles.module.scss +5 -0
- package/src/components/Controls/SliderControl/SliderControl.tsx +92 -0
- package/src/components/Controls/SliderControl/index.ts +1 -0
- package/src/components/Controls/StepperControl/StepperControl.tsx +160 -0
- package/src/components/Controls/StepperControl/index.ts +1 -0
- package/src/components/Controls/StepperControl/styles.module.scss +16 -0
- package/src/components/Controls/TableControl/TableControl.tsx +162 -0
- package/src/components/Controls/TableControl/helperComponents/StepperWithAllowedValues.tsx +50 -0
- package/src/components/Controls/TableControl/helperComponents/index.ts +1 -0
- package/src/components/Controls/TableControl/helperComponents/styles.module.scss +53 -0
- package/src/components/Controls/TableControl/index.ts +1 -0
- package/src/components/Controls/TableControl/styles.module.scss +104 -0
- package/src/components/Controls/ToggleCard/ToggleCard.tsx +46 -0
- package/src/components/Controls/ToggleCard/index.ts +1 -0
- package/src/components/Controls/ToggleCard/styles.module.scss +11 -0
- package/src/components/Controls/ToggleCardsControl/ToggleCardsControl.tsx +93 -0
- package/src/components/Controls/ToggleCardsControl/index.ts +1 -0
- package/src/components/Controls/ToggleCardsControl/styles.module.scss +40 -0
- package/src/components/Controls/ToggleControl/ToggleControl.tsx +59 -0
- package/src/components/Controls/ToggleControl/components/SwitchRow.tsx +98 -0
- package/src/components/Controls/ToggleControl/components/index.ts +1 -0
- package/src/components/Controls/ToggleControl/components/styles.module.scss +110 -0
- package/src/components/Controls/ToggleControl/index.ts +1 -0
- package/src/components/Controls/ToggleObjectControl/ToggleObjectControl.tsx +111 -0
- package/src/components/Controls/ToggleObjectControl/index.ts +1 -0
- package/src/components/Controls/ToggleObjectControl/styles.module.scss +13 -0
- package/src/components/Controls/constants.ts +16 -0
- package/src/components/Controls/index.tsx +26 -0
- package/src/components/Controls/types.ts +181 -0
- package/src/components/Controls/utils.ts +49 -0
- package/src/components/Disclaimer/Disclaimer.tsx +33 -0
- package/src/components/Disclaimer/index.ts +1 -0
- package/src/components/Disclaimer/styles.module.scss +14 -0
- package/src/components/HeaderContainer/index.tsx +32 -0
- package/src/components/HeaderContainer/styles.module.scss +24 -0
- package/src/components/PriceSummary/PriceSummary.tsx +158 -0
- package/src/components/PriceSummary/components/PricePeriodSelect/PricePeriodSelect.tsx +81 -0
- package/src/components/PriceSummary/components/PricePeriodSelect/index.ts +1 -0
- package/src/components/PriceSummary/components/ProductCard/ProductCard.tsx +85 -0
- package/src/components/PriceSummary/components/ProductCard/index.ts +1 -0
- package/src/components/PriceSummary/components/ProductCard/styles.module.scss +7 -0
- package/src/components/PriceSummary/components/ProductListActions/ProductListActions.tsx +118 -0
- package/src/components/PriceSummary/components/ProductListActions/index.ts +1 -0
- package/src/components/PriceSummary/components/ProductListActions/styles.module.scss +38 -0
- package/src/components/PriceSummary/components/index.ts +3 -0
- package/src/components/PriceSummary/hooks.ts +36 -0
- package/src/components/PriceSummary/index.ts +1 -0
- package/src/components/PriceSummary/styles.module.scss +110 -0
- package/src/components/PriceSummary/utils/getTotalPrice.ts +19 -0
- package/src/components/PriceSummary/utils/index.ts +2 -0
- package/src/components/PriceSummary/utils/transformToProductCardData.ts +36 -0
- package/src/components/ProductHeadline/ProductPageHeadline.tsx +134 -0
- package/src/components/ProductHeadline/components/PriceCount.tsx +93 -0
- package/src/components/ProductHeadline/components/index.ts +1 -0
- package/src/components/ProductHeadline/components/styles.module.scss +52 -0
- package/src/components/ProductHeadline/index.ts +1 -0
- package/src/components/ProductHeadline/styles.module.scss +32 -0
- package/src/components/ProductPage/ProductPage.tsx +105 -0
- package/src/components/ProductPage/index.ts +1 -0
- package/src/components/ProductPage/styles.module.scss +13 -0
- package/src/components/Welcome/Welcome.tsx +138 -0
- package/src/components/Welcome/index.ts +1 -0
- package/src/components/Welcome/styles.module.scss +155 -0
- package/src/components/index.ts +3 -0
- package/src/config/config.tsx +27 -0
- package/src/config/index.ts +2 -0
- package/src/config/platforms/advanced/catalog.ts +82 -0
- package/src/config/platforms/advanced/constants.ts +23 -0
- package/src/config/platforms/advanced/index.ts +5 -0
- package/src/config/platforms/advanced/platform.tsx +13 -0
- package/src/config/platforms/advanced/product-config/AdvancedCloudBackup.ts +76 -0
- package/src/config/platforms/advanced/product-config/AdvancedCloudContainerEngine.tsx +260 -0
- package/src/config/platforms/advanced/product-config/AdvancedCloudServer.tsx +526 -0
- package/src/config/platforms/advanced/product-config/AdvancedDataAsYouUse.ts +159 -0
- package/src/config/platforms/advanced/product-config/AdvancedDataLakeInsight.ts +134 -0
- package/src/config/platforms/advanced/product-config/AdvancedDataWarehouseService.ts +94 -0
- package/src/config/platforms/advanced/product-config/AdvancedDcsMemcached.ts +69 -0
- package/src/config/platforms/advanced/product-config/AdvancedDcsRedis.ts +220 -0
- package/src/config/platforms/advanced/product-config/AdvancedDmsKafka.tsx +186 -0
- package/src/config/platforms/advanced/product-config/AdvancedDmsRabbitMq.ts +202 -0
- package/src/config/platforms/advanced/product-config/AdvancedDocumentDatabase.tsx +323 -0
- package/src/config/platforms/advanced/product-config/AdvancedElasticLoadBalance.tsx +252 -0
- package/src/config/platforms/advanced/product-config/AdvancedElasticSearch.ts +365 -0
- package/src/config/platforms/advanced/product-config/AdvancedFunctionGraph.tsx +65 -0
- package/src/config/platforms/advanced/product-config/AdvancedMapReduce.tsx +394 -0
- package/src/config/platforms/advanced/product-config/AdvancedMySqlDataBase.ts +417 -0
- package/src/config/platforms/advanced/product-config/AdvancedNetwork.ts +146 -0
- package/src/config/platforms/advanced/product-config/AdvancedObjectStorage.ts +232 -0
- package/src/config/platforms/advanced/product-config/AdvancedPostgreSqlDatabase.ts +402 -0
- package/src/config/platforms/advanced/product-config/AdvancedScalableFile.tsx +161 -0
- package/src/config/platforms/advanced/product-config/AdvancedSqlDatabase.ts +380 -0
- package/src/config/platforms/advanced/product-config/index.ts +21 -0
- package/src/config/platforms/advanced/products.ts +267 -0
- package/src/config/platforms/evolution/catalog.tsx +107 -0
- package/src/config/platforms/evolution/constants.ts +80 -0
- package/src/config/platforms/evolution/index.ts +5 -0
- package/src/config/platforms/evolution/platform.tsx +13 -0
- package/src/config/platforms/evolution/product-config/EvolutionArenadataDb.ts +151 -0
- package/src/config/platforms/evolution/product-config/EvolutionArtifactRegistry.ts +57 -0
- package/src/config/platforms/evolution/product-config/EvolutionBareMetal.tsx +172 -0
- package/src/config/platforms/evolution/product-config/EvolutionCloudServer.tsx +407 -0
- package/src/config/platforms/evolution/product-config/EvolutionCloudServerFreeTier.tsx +185 -0
- package/src/config/platforms/evolution/product-config/EvolutionCloudServerGpu.tsx +301 -0
- package/src/config/platforms/evolution/product-config/EvolutionContainerApps.ts +84 -0
- package/src/config/platforms/evolution/product-config/EvolutionContainerAppsFreeTier.ts +29 -0
- package/src/config/platforms/evolution/product-config/EvolutionKubernetes.ts +388 -0
- package/src/config/platforms/evolution/product-config/EvolutionManagedMetastore.ts +38 -0
- package/src/config/platforms/evolution/product-config/EvolutionManagedRedis.ts +161 -0
- package/src/config/platforms/evolution/product-config/EvolutionManagedSpark.ts +360 -0
- package/src/config/platforms/evolution/product-config/EvolutionManagedTrino.ts +53 -0
- package/src/config/platforms/evolution/product-config/EvolutionMlInference.tsx +703 -0
- package/src/config/platforms/evolution/product-config/EvolutionPostgreSql.ts +217 -0
- package/src/config/platforms/evolution/product-config/EvolutionPublicIp.ts +39 -0
- package/src/config/platforms/evolution/product-config/EvolutionSnatGateway.ts +22 -0
- package/src/config/platforms/evolution/product-config/EvolutionStorageS3.ts +223 -0
- package/src/config/platforms/evolution/product-config/EvolutionStorageS3FreeTier.ts +97 -0
- package/src/config/platforms/evolution/product-config/index.ts +17 -0
- package/src/config/platforms/evolution/products.ts +260 -0
- package/src/config/platforms/index.ts +3 -0
- package/src/config/platforms/vmware/catalog.ts +19 -0
- package/src/config/platforms/vmware/constants.ts +6 -0
- package/src/config/platforms/vmware/index.ts +5 -0
- package/src/config/platforms/vmware/platform.tsx +13 -0
- package/src/config/platforms/vmware/product-config/VmWareCloudBackup.ts +56 -0
- package/src/config/platforms/vmware/product-config/VmWareVirtualDataCenter.ts +309 -0
- package/src/config/platforms/vmware/product-config/VmWareVirtualMachinesBackup.ts +58 -0
- package/src/config/platforms/vmware/product-config/VmWareVirtualWorkspaces.tsx +210 -0
- package/src/config/platforms/vmware/product-config/index.ts +4 -0
- package/src/config/platforms/vmware/products.ts +63 -0
- package/src/config/styles.module.scss +9 -0
- package/src/config/utils/disk.ts +94 -0
- package/src/config/utils/diskPostgreSqlMySQL.ts +94 -0
- package/src/config/utils/eip.ts +104 -0
- package/src/config/utils/index.ts +52 -0
- package/src/config/utils/obs.ts +100 -0
- package/src/constants.ts +56 -0
- package/src/contexts/CalculatorContext.tsx +193 -0
- package/src/contexts/ProductContext.ts +25 -0
- package/src/contexts/index.ts +2 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useAdaptive.ts +20 -0
- package/src/hooks/useCatalogCardClick.ts +37 -0
- package/src/hooks/useProductClick.ts +14 -0
- package/src/hooks/useProductDelete.ts +46 -0
- package/src/index.ts +6 -0
- package/src/services/constants.ts +5 -0
- package/src/services/getFetcherFn.ts +57 -0
- package/src/services/getInitPrice.ts +64 -0
- package/src/services/getOnDownloadFileClick.ts +37 -0
- package/src/services/getOnShareClick.ts +56 -0
- package/src/services/index.ts +4 -0
- package/src/types/CalculatorType.ts +16 -0
- package/src/types/CatalogConfig.ts +13 -0
- package/src/types/Category.ts +14 -0
- package/src/types/FetcherFn.ts +26 -0
- package/src/types/FormValues.ts +4 -0
- package/src/types/Platform.ts +24 -0
- package/src/types/Price.ts +18 -0
- package/src/types/Product.ts +39 -0
- package/src/types/ProductState.ts +11 -0
- package/src/types/State.ts +7 -0
- package/src/types/index.ts +10 -0
- package/src/utils/filterNonEmptyArrays.ts +13 -0
- package/src/utils/formatNumber.ts +5 -0
- package/src/utils/getPrice.ts +38 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/parseKeyToDataTest.ts +14 -0
- package/src/utils/value.ts +11 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { copyToClipboard } from '@cloud-ru/ft-copy-to-clipboard';
|
|
2
|
+
|
|
3
|
+
import { State } from '../types';
|
|
4
|
+
import { DEFAULT_BACKEND_HOST, DEFAULT_BASE_URL, DEFAULT_HEADERS } from './constants';
|
|
5
|
+
|
|
6
|
+
const CALCULATOR_SHARE_SAVE_URL = '/calculator-share/v2/save';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* Функция для получения ссылки на расчет
|
|
11
|
+
* @function helper
|
|
12
|
+
*/
|
|
13
|
+
function getShareSaveService(backendHost: string) {
|
|
14
|
+
return async function shareSaveService(state: State) {
|
|
15
|
+
const totalUrl = backendHost + CALCULATOR_SHARE_SAVE_URL;
|
|
16
|
+
|
|
17
|
+
const body = {
|
|
18
|
+
calculatorType: state.calculatorType,
|
|
19
|
+
products: state.products,
|
|
20
|
+
};
|
|
21
|
+
const params = {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
headers: DEFAULT_HEADERS,
|
|
24
|
+
body: JSON.stringify(body),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const res = await fetch(totalUrl, params);
|
|
28
|
+
|
|
29
|
+
if (!res.ok) throw new Error(`fetcher`);
|
|
30
|
+
const response = await res.json();
|
|
31
|
+
if (!response.data) throw new Error(`fetcher`);
|
|
32
|
+
|
|
33
|
+
return response.data;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type GetOnShareClickProps = {
|
|
38
|
+
/** @default 'https://api.cloud.ru' */
|
|
39
|
+
backendHost?: string;
|
|
40
|
+
/** @default 'https://cloud.ru' */
|
|
41
|
+
baseUrl?: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export function getOnShareClick(props: GetOnShareClickProps = {}) {
|
|
45
|
+
const { backendHost = DEFAULT_BACKEND_HOST, baseUrl = DEFAULT_BASE_URL } = props;
|
|
46
|
+
|
|
47
|
+
const shareSaveService = getShareSaveService(backendHost);
|
|
48
|
+
|
|
49
|
+
return async function onShareClick(state: State) {
|
|
50
|
+
return shareSaveService(state).then(({ Hash: hash }) => {
|
|
51
|
+
const shareLink = `${baseUrl}/calculator?hash=${hash}`;
|
|
52
|
+
|
|
53
|
+
shareLink && copyToClipboard(shareLink);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ValueOf } from '@snack-uikit/utils';
|
|
2
|
+
|
|
3
|
+
export const CALCULATOR_TYPE = {
|
|
4
|
+
/** калькулятор на странице /calculator */
|
|
5
|
+
Main: 'main',
|
|
6
|
+
/** калькулятор на странице партнеров /calculator/partners */
|
|
7
|
+
Partners: 'partners',
|
|
8
|
+
/** калькулятор на страницах продуктах и на промо страницах посвященных продукту */
|
|
9
|
+
Product: 'product',
|
|
10
|
+
/** остальные калькуляторы на сайте */
|
|
11
|
+
Additional: 'additional',
|
|
12
|
+
/** тестовый калькулятор /calculator/test */
|
|
13
|
+
Test: 'test',
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
16
|
+
export type CalculatorType = ValueOf<typeof CALCULATOR_TYPE>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Category } from './Category';
|
|
2
|
+
import { Platform, PlatformType } from './Platform';
|
|
3
|
+
import { Product } from './Product';
|
|
4
|
+
|
|
5
|
+
/** Конфигурация каталога */
|
|
6
|
+
export type CatalogConfig = {
|
|
7
|
+
/** Платформы */
|
|
8
|
+
platforms: Platform[];
|
|
9
|
+
/** Продукты */
|
|
10
|
+
products: Record<string, Product>;
|
|
11
|
+
/** Каталог */
|
|
12
|
+
catalog: Record<PlatformType, Category[]>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export type Category = {
|
|
4
|
+
/** Уникальный идентификатор категории */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Название */
|
|
7
|
+
label: string;
|
|
8
|
+
/** data-test-id */
|
|
9
|
+
dataTestId: string;
|
|
10
|
+
/** Массив Id продуктов отображаемых в категории */
|
|
11
|
+
visibleProducts: string[];
|
|
12
|
+
/** Слот для "промо" баннера */
|
|
13
|
+
banner?: ReactNode;
|
|
14
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CalculatorType } from './CalculatorType';
|
|
2
|
+
import { AnyType, FormValues } from './FormValues';
|
|
3
|
+
import { Price } from './Price';
|
|
4
|
+
|
|
5
|
+
export type FetcherFnProps = {
|
|
6
|
+
/** Продукт */
|
|
7
|
+
productId: string;
|
|
8
|
+
/** Конфигурация продукта */
|
|
9
|
+
formData: AnyType;
|
|
10
|
+
/** Тип калькулятора */
|
|
11
|
+
calculatorType: CalculatorType;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type FetcherFnResponse =
|
|
15
|
+
| {
|
|
16
|
+
/** Цена */
|
|
17
|
+
price: Price;
|
|
18
|
+
/** Цены по отдельным опциям */
|
|
19
|
+
priceList?: FormValues;
|
|
20
|
+
/** Дополнительные поля по продукту */
|
|
21
|
+
values?: FormValues;
|
|
22
|
+
}
|
|
23
|
+
| undefined;
|
|
24
|
+
|
|
25
|
+
/** Функция для запроса цен по продукту */
|
|
26
|
+
export type FetcherFn = (props: FetcherFnProps) => Promise<FetcherFnResponse>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { PLATFORM } from '../constants';
|
|
4
|
+
|
|
5
|
+
type ValueOf<T> = T[keyof T];
|
|
6
|
+
|
|
7
|
+
export type PlatformType = ValueOf<typeof PLATFORM>;
|
|
8
|
+
|
|
9
|
+
export type Platform = {
|
|
10
|
+
/** Уникальный id */
|
|
11
|
+
id: PlatformType;
|
|
12
|
+
/** Иконка */
|
|
13
|
+
icon: ReactNode;
|
|
14
|
+
/** Название */
|
|
15
|
+
label: string;
|
|
16
|
+
/** Дополнительное описание */
|
|
17
|
+
description: string;
|
|
18
|
+
/** Доступ к платформе */
|
|
19
|
+
access: 'public' | 'request' | 'legal';
|
|
20
|
+
/** data-test-id */
|
|
21
|
+
dataTestId: string;
|
|
22
|
+
/** Колбек клика на карточку платформы */
|
|
23
|
+
onClick?(id: PlatformType): void;
|
|
24
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ValueOf } from '@snack-uikit/utils';
|
|
2
|
+
|
|
3
|
+
export type Price = {
|
|
4
|
+
priceHourNds: number;
|
|
5
|
+
priceDayNds: number;
|
|
6
|
+
priceMonthNds: number;
|
|
7
|
+
pricePartnersHourNds: number;
|
|
8
|
+
pricePartnersDayNds: number;
|
|
9
|
+
pricePartnersMonthNds: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export enum PRICE_PERIOD {
|
|
13
|
+
Month = 'month',
|
|
14
|
+
Day = 'day',
|
|
15
|
+
Hour = 'hour',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type PricePeriod = ValueOf<typeof PRICE_PERIOD>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { JSXElementConstructor } from 'react';
|
|
2
|
+
|
|
3
|
+
import { FormConfig } from '../components';
|
|
4
|
+
import { PlatformType } from './Platform';
|
|
5
|
+
|
|
6
|
+
export type Product = {
|
|
7
|
+
/** Уникальный id */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Название продукта */
|
|
10
|
+
label: string;
|
|
11
|
+
/** Дополнительное описание */
|
|
12
|
+
caption: string;
|
|
13
|
+
/** Иконка */
|
|
14
|
+
icon: JSXElementConstructor<{
|
|
15
|
+
size?: number;
|
|
16
|
+
className?: string;
|
|
17
|
+
}>;
|
|
18
|
+
/** Платформа */
|
|
19
|
+
platform: PlatformType;
|
|
20
|
+
/** data-test-id */
|
|
21
|
+
dataTestId?: string;
|
|
22
|
+
/** Флаг является ли продукт фритирным */
|
|
23
|
+
freeTier?: boolean;
|
|
24
|
+
/** Можно ли менять кол-во продуктов текущей конфигурации в чеке */
|
|
25
|
+
enableChangeProductQuantity?: boolean;
|
|
26
|
+
/** Задизейблить изменение количества продуктов */
|
|
27
|
+
disabledProductQuantity?: boolean;
|
|
28
|
+
/** Ограничить минимальное и максимальное количество продукта */
|
|
29
|
+
productQuantityValues?: {
|
|
30
|
+
min?: number;
|
|
31
|
+
max?: number;
|
|
32
|
+
};
|
|
33
|
+
/** Можно ли подключить продукта в консоли */
|
|
34
|
+
enableConnectToConsole?: boolean;
|
|
35
|
+
/** Конфиг страницы расчета по продукту */
|
|
36
|
+
formConfig?: FormConfig;
|
|
37
|
+
/** Имеет ли продукт сервисы hasPayaGo (только с помесячной тарификацией) */
|
|
38
|
+
hasPayaGo?: boolean;
|
|
39
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FormValues } from './FormValues';
|
|
2
|
+
import { Price } from './Price';
|
|
3
|
+
|
|
4
|
+
export type ProductState = {
|
|
5
|
+
/** Конфигурация продукта */
|
|
6
|
+
data: FormValues;
|
|
7
|
+
/** Цена продукта */
|
|
8
|
+
price: Price;
|
|
9
|
+
/** Цены по отдельным опциям */
|
|
10
|
+
priceList?: FormValues;
|
|
11
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './Category';
|
|
2
|
+
export * from './Platform';
|
|
3
|
+
export * from './Product';
|
|
4
|
+
export * from './Price';
|
|
5
|
+
export * from './FormValues';
|
|
6
|
+
export * from './CatalogConfig';
|
|
7
|
+
export * from './CalculatorType';
|
|
8
|
+
export * from './FetcherFn';
|
|
9
|
+
export * from './State';
|
|
10
|
+
export * from './ProductState';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FormValues } from '../types';
|
|
2
|
+
|
|
3
|
+
export function filterNonEmptyArrays(input: FormValues): FormValues {
|
|
4
|
+
const result: FormValues = {};
|
|
5
|
+
|
|
6
|
+
for (const key in input) {
|
|
7
|
+
if (input[key]?.length > 0) {
|
|
8
|
+
result[key] = input?.[key];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DEFAULT_PRICE } from '../constants';
|
|
2
|
+
|
|
3
|
+
export function getPrice({
|
|
4
|
+
price = DEFAULT_PRICE,
|
|
5
|
+
pricePeriod,
|
|
6
|
+
partners,
|
|
7
|
+
}: {
|
|
8
|
+
price?: typeof DEFAULT_PRICE;
|
|
9
|
+
pricePeriod: string;
|
|
10
|
+
partners?: boolean;
|
|
11
|
+
}) {
|
|
12
|
+
if (partners) {
|
|
13
|
+
switch (pricePeriod) {
|
|
14
|
+
case 'day': {
|
|
15
|
+
return price?.pricePartnersDayNds;
|
|
16
|
+
}
|
|
17
|
+
case 'hour': {
|
|
18
|
+
return price?.pricePartnersHourNds;
|
|
19
|
+
}
|
|
20
|
+
case 'month':
|
|
21
|
+
default: {
|
|
22
|
+
return price?.pricePartnersMonthNds;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
switch (pricePeriod) {
|
|
27
|
+
case 'day': {
|
|
28
|
+
return price?.priceDayNds;
|
|
29
|
+
}
|
|
30
|
+
case 'hour': {
|
|
31
|
+
return price?.priceHourNds;
|
|
32
|
+
}
|
|
33
|
+
case 'month':
|
|
34
|
+
default: {
|
|
35
|
+
return price?.priceMonthNds;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CALCULATOR_DATA_TEST_ID } from '../constants';
|
|
2
|
+
|
|
3
|
+
export function parseKeyToDataTest(component: string, value?: string) {
|
|
4
|
+
if (!value) {
|
|
5
|
+
return `${CALCULATOR_DATA_TEST_ID}-${component}`;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const parsed = value
|
|
9
|
+
.replace(/\./g, '-')
|
|
10
|
+
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
11
|
+
.toLowerCase();
|
|
12
|
+
|
|
13
|
+
return `${CALCULATOR_DATA_TEST_ID}-${component}-${parsed}`;
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { get, set } from 'lodash';
|
|
2
|
+
|
|
3
|
+
import { AnyType } from '../types';
|
|
4
|
+
|
|
5
|
+
export function getValue(obj: AnyType, key: string): AnyType {
|
|
6
|
+
return get(obj, key);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function setValue(obj: AnyType, key: string, value: AnyType): AnyType {
|
|
10
|
+
return set(obj, key, value);
|
|
11
|
+
}
|