From e36a5e3b524d8bd4abd6787fc352441de682e1b5 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Tue, 6 Apr 2021 10:20:40 +0300 Subject: [PATCH] replace let with const --- src/client/hooks/Calculation/useValidation.ts | 4 ++-- .../Effects/actions/calculate/checkValidation.ts | 4 ++-- .../Effects/actions/calculate/prepareData.ts | 12 ++++++------ .../Effects/actions/calculate/results.ts | 2 +- .../Effects/actions/calculate/validate.ts | 2 +- .../Effects/reactions/loadKpReaction/index.ts | 2 +- .../Effects/reactions/priceReactions/index.ts | 4 ++-- .../Effects/reactions/recalcWoRevisionReactions.ts | 6 +++--- .../Effects/reactions/tablesReactions.ts | 2 +- src/core/services/CrmService/index.ts | 6 +++--- src/core/tools/string.ts | 2 +- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/client/hooks/Calculation/useValidation.ts b/src/client/hooks/Calculation/useValidation.ts index 7e8478d..b0fe468 100644 --- a/src/client/hooks/Calculation/useValidation.ts +++ b/src/client/hooks/Calculation/useValidation.ts @@ -49,7 +49,7 @@ export const useValidation = ({ calculationStore.setValidation(elementName, undefined); } else { if (validator) { - let validationResult = validator(value); + const validationResult = validator(value); calculationStore.setValidation(elementName, validationResult); } } @@ -109,7 +109,7 @@ export const useTableValidation = ({ ]); } else { if (validator) { - let validationResult = validator(value); + const validationResult = validator(value); calculationStore.setTableRows( tableName, rowIndex, diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/checkValidation.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/checkValidation.ts index d823d2e..140b5ea 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/checkValidation.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/checkValidation.ts @@ -7,7 +7,7 @@ import { toJS } from 'mobx'; import { omit } from 'lodash'; export default () => { - let invalidElements: string[] = []; + const invalidElements: string[] = []; const { validations: storeValidations } = CalculationStore; const validations = toJS(storeValidations); Object.keys(validations).forEach(elementName => { @@ -16,7 +16,7 @@ export default () => { } }); - let invalidTables: string[] = []; + const invalidTables: string[] = []; const { tables: storeTables } = CalculationStore; const tables = omit(toJS(storeTables), tablesExclusion); Object.keys(tables).forEach(tableName => { diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts index 8d39d3e..015fb78 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts @@ -16,7 +16,7 @@ export default ({ const { values, options, tables } = calculationStore; //@ts-ignore - let preparedPaymentsRows: PaymentRow[] = Array.from( + const preparedPaymentsRows: PaymentRow[] = Array.from( { length: values.leasingPeriod }, () => ({ numberPayment: 0, @@ -75,7 +75,7 @@ export default ({ } } - let preparedValues: PreparedValues = { + const preparedValues: PreparedValues = { brandId: NIL, configurationId: NIL, firstPaymentAbs: 0, @@ -133,19 +133,19 @@ export default ({ preparedValues.transportTaxGrYear = 0; preparedValues.transportTaxGr = 0; - let insuranceKaskoRow = tables.tableInsurance.rows.find( + const insuranceKaskoRow = tables.tableInsurance.rows.find( x => x.policyType?.value === 'КАСКО', ); - let insuranceNSRow = tables.tableInsurance.rows.find( + const insuranceNSRow = tables.tableInsurance.rows.find( x => x.policyType?.value === 'НС', ); - let insuranceDGORow = tables.tableInsurance.rows.find( + const insuranceDGORow = tables.tableInsurance.rows.find( x => x.policyType?.value === 'ДГО', ); - let insuranceOSAGORow = tables.tableInsurance.rows.find( + const insuranceOSAGORow = tables.tableInsurance.rows.find( x => x.policyType?.value === 'ОСАГО', ); diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts index 0addc48..8bd2bbb 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts @@ -11,7 +11,7 @@ export default { ) => { if (preparedData.preparedValues.nmper) { const { sumWithVatColumn, vatColumn, sumRepaymentColumn } = res.columns; - let results: TableProps[] = []; + const results: TableProps[] = []; for (let i = 0; i < preparedData.preparedValues.nmper; i++) { results.push({ diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/validate.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/validate.ts index d7d7323..ebcf53f 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate.ts @@ -212,7 +212,7 @@ const validatePaymentsTable = () => { const startPositions = seasonTypeOptions && seasonTypeOptions.startPositions; - let stepsValues = []; + const stepsValues = []; for (let i = 0; i < startPositions.length; i++) { const targetIndex = startPositions[i]; //@ts-ignore diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts index 12d0d8b..d9785f3 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts @@ -241,7 +241,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ x => x.evo_baseproductid === newValues.product, ); - let addProducts = Object.assign( + const addProducts = Object.assign( {}, ...Object.keys(map_add_product_types_to_values).map(elementName => { const target_add_product_type = quote?.evo_addproduct_types?.find( diff --git a/src/client/stores/CalculationStore/Effects/reactions/priceReactions/index.ts b/src/client/stores/CalculationStore/Effects/reactions/priceReactions/index.ts index 8c0e201..abe2685 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/priceReactions/index.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/priceReactions/index.ts @@ -250,7 +250,7 @@ export default [ ?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId); const evo_currencychangeValue = (evo_currencychange && evo_currencychange.evo_currencychange) || 0; - let price = convertPrice( + const price = convertPrice( supplierCurrency?.isocurrencycode, leaseObjectPrice, evo_currencychangeValue, @@ -287,7 +287,7 @@ export default [ ?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId); const evo_currencychangeValue = (evo_currencychange && evo_currencychange.evo_currencychange) || 0; - let price = convertPrice( + const price = convertPrice( supplierCurrency?.isocurrencycode, leaseObjectPrice, evo_currencychangeValue, diff --git a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts index 41f02c4..1b8ba93 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts @@ -42,13 +42,13 @@ const reactionEffects: IReactionEffect[] = [ ?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId); const evo_currencychangeValue = (evo_currencychange && evo_currencychange.evo_currencychange) || 0; - let price = convertPrice( + const price = convertPrice( supplierCurrency?.isocurrencycode, leaseObjectPrice, evo_currencychangeValue, ); - let maxPriceChange = + const maxPriceChange = price - supplierDiscountRub < 800000 ? price - supplierDiscountRub + 50000 : (price - supplierDiscountRub) * 1.05; @@ -118,7 +118,7 @@ const reactionEffects: IReactionEffect[] = [ ?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId); const evo_currencychangeValue = (evo_currencychange && evo_currencychange.evo_currencychange) || 0; - let price = convertPrice( + const price = convertPrice( supplierCurrency?.isocurrencycode, leaseObjectPrice, evo_currencychangeValue, diff --git a/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts index 8cec4ee..fa3298f 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts @@ -582,7 +582,7 @@ export default [ }, }), ); - for (let i in middleRows) { + for (const i in middleRows) { const currRow = middleRows[parseInt(i)]; const prevRow = middleRows[parseInt(i) - 1]; currRow.paymentRelation.value = parseFloat( diff --git a/src/core/services/CrmService/index.ts b/src/core/services/CrmService/index.ts index 263c9ab..0e046e4 100644 --- a/src/core/services/CrmService/index.ts +++ b/src/core/services/CrmService/index.ts @@ -30,7 +30,7 @@ export default class { if (!res.data || res.errors) { reject(res.error || res.errors); } - let resEntities: TEntities = cloneDeep( + const resEntities: TEntities = cloneDeep( res.data, ); @@ -42,8 +42,8 @@ export default class { //@ts-ignore if (toOptions.includes(targetName)) { if (Array.isArray(targetEnt)) { - let optionatedEntities: (TCRMEntity & IBaseOption)[] = []; - for (let entity of targetEnt) { + const optionatedEntities: (TCRMEntity & IBaseOption)[] = []; + for (const entity of targetEnt) { const entityOption = convertEntityToOption( entity, entity.__typename, diff --git a/src/core/tools/string.ts b/src/core/tools/string.ts index cc6ffa8..37719dc 100644 --- a/src/core/tools/string.ts +++ b/src/core/tools/string.ts @@ -2,7 +2,7 @@ export function stringifyObject(obj_from_json: any): string { if (typeof obj_from_json !== 'object' || Array.isArray(obj_from_json)) { return JSON.stringify(obj_from_json); } - let props = Object.keys(obj_from_json) + const props = Object.keys(obj_from_json) .map(key => `${key}:${stringifyObject(obj_from_json[key])}`) .join(','); return `${props}`;