diff --git a/Components/Calculation/config/elements-props.ts b/Components/Calculation/config/elements-props.ts index f292187..82f02f3 100644 --- a/Components/Calculation/config/elements-props.ts +++ b/Components/Calculation/config/elements-props.ts @@ -8,36 +8,36 @@ import type { ElementsProps } from '../types/elements-props'; const props: Partial = { tbxLeaseObjectPrice: { - min: 0.0, - max: 1000000000.0, - step: 10000.0, + min: 0, + max: 1_000_000_000, + step: 10_000, precision: 2, formatter: formatNumber, }, tbxLeaseObjectPriceWthtVAT: { - min: 0.0, - max: 1000000000.0, - step: 10000.0, + min: 0, + max: 1_000_000_000, + step: 10_000, precision: 2, formatter: formatNumber, }, tbxVATInLeaseObjectPrice: { - min: 0.0, - max: 1000000000.0, - step: 10000.0, + min: 0, + max: 1_000_000_000, + step: 10_000, precision: 2, formatter: formatNumber, }, tbxEngineHours: { - min: 0.0, - step: 10.0, + min: 0, + step: 10, precision: 2, formatter: formatNumber, }, tbxSupplierDiscountRub: { min: 0, - max: 1000000000, - step: 10000.0, + max: 1_000_000_000, + step: 10_000, precision: 2, formatter: formatNumber, }, @@ -52,7 +52,7 @@ const props: Partial = { buttonStyle: 'solid', }, tbxSaleBonus: { - min: 0.0, + min: 0, // max: 1.30, step: 0.1, precision: 2, @@ -66,29 +66,29 @@ const props: Partial = { }, tbxFirstPaymentRub: { min: 0, - max: 1000000000, - step: 10000.0, + max: 1_000_000_000, + step: 10_000, precision: 2, formatter: formatNumber, }, tbxLastPaymentPerc: { min: 0, max: 70, - step: 1.0, + step: 1, precision: 6, formatter: formatNumber, }, tbxLastPaymentRub: { min: 0, - max: 1000000000, - step: 10000.0, + max: 1_000_000_000, + step: 10_000, precision: 2, formatter: formatNumber, }, tbxRedemptionPaymentSum: { min: 1000, max: 2000, - step: 1000.0, + step: 1000, precision: 2, formatter: formatNumber, }, @@ -106,8 +106,8 @@ const props: Partial = { }, tbxComissionRub: { min: 0, - max: 1000000000, - step: 10000.0, + max: 1_000_000_000, + step: 10_000, }, selectLeaseObjectType: { showSearch: true, @@ -143,14 +143,14 @@ const props: Partial = { showSearch: true, }, tbxLeaseObjectMotorPower: { - min: 0.0, - max: 20000.0, - step: 10.0, + min: 0, + max: 20_000, + step: 10, precision: 2, formatter: formatNumber, }, tbxEngineVolume: { - min: 0.0, + min: 0, max: 99.9999, step: 0.5, precision: 4, @@ -158,7 +158,7 @@ const props: Partial = { }, tbxMaxMass: { min: 0, - max: 999999, + max: 999_999, step: 100, formatter: formatNumber, }, @@ -174,43 +174,43 @@ const props: Partial = { showSearch: true, }, tbxDealerRewardSumm: { - min: 0.0, - max: 20.0, + min: 0, + max: 20, step: 0.1, precision: 2, formatter: formatNumber, }, tbxDealerBrokerRewardSumm: { - min: 0.0, - max: 20.0, + min: 0, + max: 20, step: 0.1, precision: 2, formatter: formatNumber, }, tbxIndAgentRewardSumm: { - min: 0.0, - max: 20.0, + min: 0, + max: 20, step: 0.1, precision: 2, formatter: formatNumber, }, tbxCalcDoubleAgentRewardSumm: { - min: 0.0, - max: 20.0, + min: 0, + max: 20, step: 0.1, precision: 2, formatter: formatNumber, }, tbxCalcBrokerRewardSum: { - min: 0.0, - max: 20.0, + min: 0, + max: 20, step: 0.1, precision: 2, formatter: formatNumber, }, tbxFinDepartmentRewardSumm: { - min: 0.0, - max: 20.0, + min: 0, + max: 20, step: 0.1, precision: 2, formatter: formatNumber, @@ -222,7 +222,7 @@ const props: Partial = { tbxInsFranchise: { min: 0, max: MAX_FRANCHISE, - step: 10000.0, + step: 10_000, precision: 2, formatter: formatNumber, }, @@ -249,30 +249,30 @@ const props: Partial = { text: 'Создать КП', }, tbxCreditRate: { - min: 0.0, + min: 0, max: 99.99, step: 0.1, }, tbxMaxPriceChange: { min: 0, - max: 34999990, - step: 10000.0, + max: 34_999_990, + step: 10_000, }, tbxMinPriceChange: { min: 0, - max: 34999990, - step: 10000.0, + max: 34_999_990, + step: 10_000, }, tbxImporterRewardPerc: { - min: 0.0, + min: 0, max: 99.99, step: 0.1, precision: 2, }, tbxImporterRewardRub: { - min: 0.0, - max: 1000000000.0, - step: 10000.0, + min: 0, + max: 1_000_000_000, + step: 10_000, precision: 2, }, selectLead: { @@ -289,8 +289,8 @@ const props: Partial = { type: 'primary', }, tbxIRR_Perc: { - min: 0.0, - max: 500.0, + min: 0, + max: 500, step: 0.0001, precision: 6, formatter: formatNumber, @@ -302,7 +302,7 @@ const props: Partial = { }, tbxMileage: { min: 0, - step: 100.0, + step: 100, precision: 2, formatter: formatNumber, }, @@ -325,13 +325,13 @@ const props: Partial = { tbxVehicleTaxInYear: { min: 0, step: 100, - max: 9999999, + max: 9_999_999, precision: 2, }, tbxVehicleTaxInLeasingPeriod: { min: 0, step: 100, - max: 9999999, + max: 9_999_999, precision: 2, }, selectObjectRegionRegistration: { @@ -356,51 +356,47 @@ const props: Partial = { }, }; -const moneyResultElementsProps = ( - [ - 'labelResultTotalGraphwithNDS', - 'labelResultPlPrice', - 'labelResultInsKasko', - 'labelResultInsOsago', - 'labelResultDopProdSum', - 'labelResultFirstPayment', - 'labelResultLastPayment', - 'labelResultAB_FL', - 'labelResultAB_UL', - 'labelResultBonusMPL', - 'labelResultDopMPLLeasing', - 'labelResultBonusDopProd', - 'labelSubsidySum', - 'labelResultBonusSafeFinance', - ] as (keyof ElementsProps)[] -).reduce( - (ac, a) => ({ - ...ac, - [a]: { +const moneyResultElementsProps = Object.fromEntries( + ( + [ + 'labelResultTotalGraphwithNDS', + 'labelResultPlPrice', + 'labelResultInsKasko', + 'labelResultInsOsago', + 'labelResultDopProdSum', + 'labelResultFirstPayment', + 'labelResultLastPayment', + 'labelResultAB_FL', + 'labelResultAB_UL', + 'labelResultBonusMPL', + 'labelResultDopMPLLeasing', + 'labelResultBonusDopProd', + 'labelSubsidySum', + 'labelResultBonusSafeFinance', + ] as (keyof ElementsProps)[] + ).map((a) => [ + a, + { middleware: (value: number) => pipe(round, formatMoney)(value), }, - }), - // eslint-disable-next-line object-curly-newline - {} + ]) ); -const numberResultElementsProps = ( - [ - 'labelResultPriceUpPr', - 'labelResultIRRGraphPerc', - 'labelResultIRRNominalPerc', - 'labelResultTerm', - 'labelResultFirstPaymentRiskPolicy', - ] as (keyof ElementsProps)[] -).reduce( - (ac, a) => ({ - ...ac, - [a]: { +const numberResultElementsProps = Object.fromEntries( + ( + [ + 'labelResultPriceUpPr', + 'labelResultIRRGraphPerc', + 'labelResultIRRNominalPerc', + 'labelResultTerm', + 'labelResultFirstPaymentRiskPolicy', + ] as (keyof ElementsProps)[] + ).map((a) => [ + a, + { middleware: (value: number) => pipe(round)(value), }, - }), - // eslint-disable-next-line object-curly-newline - {} + ]) ); export default Object.assign(props, moneyResultElementsProps, numberResultElementsProps); diff --git a/Elements/Input.tsx b/Elements/Input.tsx index 470f84a..b73e5be 100644 --- a/Elements/Input.tsx +++ b/Elements/Input.tsx @@ -1,4 +1,3 @@ -import type { InputProps } from 'antd'; import { Form, Input as AntInput } from 'antd'; import type { ChangeEvent } from 'react'; import type { BaseElementProps } from './types'; @@ -24,4 +23,4 @@ export default function Input({ ); } -export type { InputProps }; +export { type InputProps } from 'antd'; diff --git a/Elements/Radio.tsx b/Elements/Radio.tsx index 8a2ef29..feee975 100644 --- a/Elements/Radio.tsx +++ b/Elements/Radio.tsx @@ -1,4 +1,4 @@ -import type { RadioChangeEvent, RadioGroupProps } from 'antd'; +import type { RadioChangeEvent } from 'antd'; import { Form, Radio as AntRadio } from 'antd'; import type { BaseElementProps, BaseOption } from './types'; @@ -34,4 +34,4 @@ export default function Radio({ ); } -export type { RadioGroupProps as RadioProps }; +export { type RadioGroupProps as RadioProps } from 'antd'; diff --git a/Elements/Select.tsx b/Elements/Select.tsx index 077ac4c..51dba15 100644 --- a/Elements/Select.tsx +++ b/Elements/Select.tsx @@ -1,4 +1,3 @@ -import type { SelectProps } from 'antd'; import { Form, Select as AntSelect } from 'antd'; import { useMemo } from 'react'; import type { BaseElementProps, BaseOption } from './types'; @@ -44,4 +43,4 @@ export default function Select({ ); } -export type { SelectProps }; +export { type SelectProps } from 'antd'; diff --git a/Elements/Switch.tsx b/Elements/Switch.tsx index e3575d1..7f0bb23 100644 --- a/Elements/Switch.tsx +++ b/Elements/Switch.tsx @@ -1,4 +1,3 @@ -import type { SwitchProps } from 'antd'; import { Form, Switch as AntSwitch } from 'antd'; import type { BaseElementProps } from './types'; @@ -19,4 +18,4 @@ export default function Switch({ ); } -export type { SwitchProps }; +export { type SwitchProps } from 'antd'; diff --git a/UIKit/grid.js b/UIKit/grid.js index 4c1a5c5..674afd5 100644 --- a/UIKit/grid.js +++ b/UIKit/grid.js @@ -1,3 +1 @@ -import { Box, Flex } from 'rebass/styled-components'; - -export { Box, Flex }; +export { Box, Flex } from 'rebass/styled-components'; diff --git a/config/default-options.ts b/config/default-options.ts index 73b6c22..3a0eb8a 100644 --- a/config/default-options.ts +++ b/config/default-options.ts @@ -5,84 +5,84 @@ const defaultOptions: Partial = { radioLastPaymentRule: [ { label: 'равен платежу', - value: 100000002, + value: 100_000_002, }, { label: 'в рублях', - value: 100000000, + value: 100_000_000, }, { label: 'в %', - value: 100000001, + value: 100_000_001, }, ], radioBalanceHolder: [ { label: 'Лизингополучатель', - value: 100000000, + value: 100_000_000, }, { label: 'Лизингодатель', - value: 100000001, + value: 100_000_001, }, ], radioGraphType: [ { label: 'аннуитет', - value: 100000000, + value: 100_000_000, }, { label: 'дегрессия (ступенчатая)', - value: 100000001, + value: 100_000_001, }, { label: 'равноубывающий', - value: 100000002, + value: 100_000_002, }, { label: 'сезонный', - value: 100000003, + value: 100_000_003, }, { label: 'легкий старт', - value: 100000004, + value: 100_000_004, }, ], selectSeasonType: [ { label: '6/6', - value: 100000000, + value: 100_000_000, }, { label: '8/4', - value: 100000001, + value: 100_000_001, }, { label: '4/4/4', - value: 100000002, + value: 100_000_002, }, { label: 'Гибкая дегрессия', - value: 100000007, + value: 100_000_007, }, { label: '100.50.25', - value: 100000003, + value: 100_000_003, }, { label: '100.30.10', - value: 100000004, + value: 100_000_004, }, { label: '100.70.40', - value: 100000005, + value: 100_000_005, }, { label: '100.7.3', - value: 100000006, + value: 100_000_006, }, ], @@ -92,64 +92,64 @@ const defaultOptions: Partial = { }, (_, i) => ({ label: `${i + 2}`, - value: 100000000 + i, + value: 100_000_000 + i, }) ), radioDeliveryTime: [ { label: 'В наличии', - value: 100000000, + value: 100_000_000, }, { label: 'В поставке', - value: 100000001, + value: 100_000_001, }, ], selectEngineType: [ { label: 'Бензин', - value: 100000000, + value: 100_000_000, }, { label: 'Дизель', - value: 100000001, + value: 100_000_001, }, { label: 'Газ', - value: 100000002, + value: 100_000_002, }, { label: 'Электрический', - value: 100000003, + value: 100_000_003, }, { label: 'Гибрид', - value: 100000004, + value: 100_000_004, }, ], selectLeaseObjectCategory: [ { label: 'A', - value: 100000000, + value: 100_000_000, }, { label: 'B', - value: 100000001, + value: 100_000_001, }, { label: 'C', - value: 100000002, + value: 100_000_002, }, { label: 'D', - value: 100000003, + value: 100_000_003, }, { label: 'Прицеп', - value: 100000004, + value: 100_000_004, }, ], @@ -157,83 +157,83 @@ const defaultOptions: Partial = { [ { label: 'Для представительских целей', - value: 100000000, + value: 100_000_000, }, { label: 'Для использования в качестве «такси»', - value: 100000001, + value: 100_000_001, }, { label: 'Для передачи третьим лицам (прокат; аренда)', - value: 100000002, + value: 100_000_002, }, { label: 'Каршеринг', - value: 100000003, + value: 100_000_003, }, { label: 'Тест-драйв', - value: 100000004, + value: 100_000_004, }, { label: 'Для доставки продуктов конечному потребителю', - value: 100000005, + value: 100_000_005, }, { label: 'Для обучения вождению', - value: 100000006, + value: 100_000_006, }, { label: 'Маршрутные такси / Рейсовые автобусы', - value: 100000007, + value: 100_000_007, }, { label: 'Междугородние перевозки', - value: 100000008, + value: 100_000_008, }, { label: 'Для перевозки крупногабаритных грузов', - value: 100000009, + value: 100_000_009, }, { label: 'Для перевозки малогабаритных грузов', - value: 100000010, + value: 100_000_010, }, { label: 'Для перевозки сотрудников других организаций (водитель ЛП)', - value: 100000011, + value: 100_000_011, }, { label: 'Для перевозки сотрудников ЛП', - value: 100000012, + value: 100_000_012, }, { label: 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.', - value: 100000013, + value: 100_000_013, }, { label: 'Дорожно-строительная техника', - value: 100000014, + value: 100_000_014, }, { label: 'Жилищно-коммунальное хозяйство', - value: 100000015, + value: 100_000_015, }, { label: 'Лесное хозяйство', - value: 100000016, + value: 100_000_016, }, { label: 'Подъёмно-транспортная отрасль', - value: 100000017, + value: 100_000_017, }, { label: 'Сельское хозяйство', - value: 100000018, + value: 100_000_018, }, { label: 'Строительство', - value: 100000019, + value: 100_000_019, }, ], (objectUseFor) => objectUseFor.label.toLowerCase(), @@ -243,98 +243,98 @@ const defaultOptions: Partial = { radioInfuranceOPF: [ { label: 'ЮЛ', - value: 100000000, + value: 100_000_000, }, { label: 'ИП', - value: 100000001, + value: 100_000_001, }, ], radioInsKaskoType: [ { label: 'Полное', - value: 100000000, + value: 100_000_000, }, { label: 'Усеченное', - value: 100000001, + value: 100_000_001, }, ], radioQuoteContactGender: [ { label: 'Мужской', - value: 100000000, + value: 100_000_000, }, { label: 'Женский', - value: 100000001, + value: 100_000_001, }, ], radioRequirementTelematic: [ { label: 'Не требуется', - value: 100000004, + value: 100_000_004, }, { label: 'START', - value: 100000000, + value: 100_000_000, }, { label: 'START+', - value: 100000001, + value: 100_000_001, }, { label: 'COMFORT', - value: 100000002, + value: 100_000_002, }, { label: 'COMFORT+', - value: 100000003, + value: 100_000_003, }, { label: 'Omnicomm_1', - value: 100000005, + value: 100_000_005, }, { label: 'Omnicomm_2', - value: 100000006, + value: 100_000_006, }, { label: 'Omnicomm_3', - value: 100000007, + value: 100_000_007, }, ], radioCalcType: [ { label: 'IRR', - value: 100000000, + value: 100_000_000, }, { label: 'Суммы', - value: 100000001, + value: 100_000_001, }, ], radioObjectRegistration: [ { label: 'Лизингополучатель', - value: 100000000, + value: 100_000_000, }, { label: 'Лизингодатель', - value: 100000001, + value: 100_000_001, }, ], radioTypePTS: [ { label: 'Бумажный', - value: 100000000, + value: 100_000_000, }, { label: 'Электронный', - value: 100000001, + value: 100_000_001, }, ], selectObjectCategoryTax: [ @@ -361,7 +361,7 @@ const defaultOptions: Partial = { 'L5', ].map((label, i) => ({ label, - value: 100000000 + i, + value: 100_000_000 + i, })), selectObjectTypeTax: [ { @@ -386,7 +386,7 @@ const defaultOptions: Partial = { }, ].map((v, i) => ({ ...v, - value: 100000000 + i, + value: 100_000_000 + i, })), }; diff --git a/config/default-values.ts b/config/default-values.ts index 2579f4e..5c00e09 100644 --- a/config/default-values.ts +++ b/config/default-values.ts @@ -7,7 +7,7 @@ const defaultValues: CalculationValues = { opportunity: null, quote: null, recalcWithRevision: false, - leaseObjectPrice: 1000000, + leaseObjectPrice: 1_000_000, VATInLeaseObjectPrice: 0, leaseObjectPriceWthtVAT: 0, engineHours: 0, @@ -18,13 +18,13 @@ const defaultValues: CalculationValues = { firstPaymentPerc: 25, firstPaymentRub: 0, lastPaymentPerc: 1, - lastPaymentRule: 100000001, + lastPaymentRule: 100_000_001, redemptionPaymentSum: 1000, - balanceHolder: 100000001, - graphType: 100000000, + balanceHolder: 100_000_001, + graphType: 100_000_000, parmentsDecreasePercent: 94, - seasonType: 100000000, - highSeasonStart: 100000000, + seasonType: 100_000_000, + highSeasonStart: 100_000_000, comissionPerc: 0, comissionRub: 0, saleBonus: 1.3, @@ -32,7 +32,7 @@ const defaultValues: CalculationValues = { brand: null, model: null, configuration: null, - deliveryTime: 100000000, + deliveryTime: 100_000_000, leaseObjectCount: 1, withTrailer: false, leaseObjectUsed: false, @@ -40,7 +40,7 @@ const defaultValues: CalculationValues = { countSeats: 0, maxSpeed: 0, leaseObjectYear: date().year(), - engineType: 100000000, + engineType: 100_000_000, leaseObjectCategory: null, leaseObjectMotorPower: 0, engineVolume: 0, @@ -57,7 +57,7 @@ const defaultValues: CalculationValues = { calcDoubleAgentRewardSumm: 0, calcBrokerRewardSum: 0, finDepartmentRewardSumm: 0, - insKaskoType: 100000000, + insKaskoType: 100_000_000, insDecentral: false, insUnlimitDrivers: true, insAgeDrivers: 0, @@ -70,23 +70,23 @@ const defaultValues: CalculationValues = { registrationQuote: true, technicalCardQuote: true, NSIB: true, - quoteContactGender: 100000000, + quoteContactGender: 100_000_000, quoteRedemptionGraph: true, showFinGAP: true, creditRate: RATE, - requirementTelematic: 100000000, + requirementTelematic: 100_000_000, maxPriceChange: 0, importerRewardPerc: 0, importerRewardRub: 0, disableChecks: false, insFranchise: 0, rate: 'BASE', - calcType: 100000000, + calcType: 100_000_000, totalPayments: 0, vehicleTaxInYear: 0, vehicleTaxInLeasingPeriod: 0, - objectRegistration: 100000000, - typePTS: 100000001, + objectRegistration: 100_000_000, + typePTS: 100_000_001, insNSIB: null, regionRegistration: null, legalClientRegion: null, diff --git a/constants/values.js b/constants/values.js index 7c51249..32d90a3 100644 --- a/constants/values.js +++ b/constants/values.js @@ -1,5 +1,5 @@ -export const MAX_FRANCHISE = 75000; -export const MAX_INSURANCE = 2500000; +export const MAX_FRANCHISE = 75_000; +export const MAX_INSURANCE = 2_500_000; export const MIN_INSURANCE = 3000; export const RATE = 7.75; diff --git a/pages/index.tsx b/pages/index.tsx index 8e60abd..4969199 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -3,7 +3,7 @@ import type { GetServerSideProps } from 'next'; import { fetchUser } from 'services/user'; import type { BasePageProps } from 'types/page'; -interface PageProps extends BasePageProps {} +type PageProps = BasePageProps; function Home() { return
Home
; diff --git a/stores/calculation/index.ts b/stores/calculation/index.ts index 96525b0..65fad3a 100644 --- a/stores/calculation/index.ts +++ b/stores/calculation/index.ts @@ -1,5 +1,5 @@ /* eslint-disable import/no-cycle */ -import RootStore from 'stores/root'; +import type RootStore from 'stores/root'; import OptionsStore from './options'; import StatusStore from './statuses'; import ValidationStore from './validation'; diff --git a/stores/calculation/options/index.ts b/stores/calculation/options/index.ts index f9838b8..e810278 100644 --- a/stores/calculation/options/index.ts +++ b/stores/calculation/options/index.ts @@ -1,3 +1,4 @@ +/* eslint-disable unicorn/prefer-set-has */ /* eslint-disable function-paren-newline */ /* eslint-disable implicit-arrow-linebreak */ /* eslint-disable no-confusing-arrow */ diff --git a/tools/date.js b/tools/date.js index b8bb00f..41ba8e8 100644 --- a/tools/date.js +++ b/tools/date.js @@ -1,3 +1,4 @@ +/* eslint-disable unicorn/prefer-export-from */ import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; diff --git a/tools/number.ts b/tools/number.ts index 28b110f..6408519 100644 --- a/tools/number.ts +++ b/tools/number.ts @@ -1,4 +1,3 @@ /* eslint-disable import/prefer-default-export */ -import { round } from 'lodash'; -export { round }; +export { round } from 'lodash';