diff --git a/apps/web/Components/Calculation/Settings/config.ts b/apps/web/Components/Calculation/Settings/config.ts index 982cef7..d3de030 100644 --- a/apps/web/Components/Calculation/Settings/config.ts +++ b/apps/web/Components/Calculation/Settings/config.ts @@ -16,9 +16,23 @@ export const mainRows: FormTabRows = [ ], ]; +export const unlimitedMainRows: FormTabRows = [ + { title: 'Выбор Интереса/ЛС' }, + [['selectUser'], defaultRowStyle], + [['selectLead'], defaultRowStyle], + [['selectOpportunity'], defaultRowStyle], + [['cbxRecalcWithRevision'], defaultRowStyle], + [['selectQuote'], defaultRowStyle], + [ + ['btnCalculate', 'btnCreateKPMini'], + { + gridTemplateColumns: ['1fr 0.15fr'], + }, + ], +]; + export const paramsRows: FormTabRows = [ { title: 'Параметры расчета' }, - [['labelIrrInfo'], defaultRowStyle], [['radioCalcType'], defaultRowStyle], [['tbxIRR_Perc'], defaultRowStyle], [['tbxTotalPayments'], defaultRowStyle], @@ -26,7 +40,6 @@ export const paramsRows: FormTabRows = [ export const unlimitedParamsRows: FormTabRows = [ { title: 'Параметры расчета' }, - [['labelIrrInfo'], defaultRowStyle], [['radioCalcType'], defaultRowStyle], [['tbxIRR_Perc', 'tbxPi'], { gridTemplateColumns: '1fr 1fr' }], [['tbxTotalPayments'], defaultRowStyle], diff --git a/apps/web/Components/Calculation/Settings/index.jsx b/apps/web/Components/Calculation/Settings/index.jsx index f7c0a6e..7c140bd 100644 --- a/apps/web/Components/Calculation/Settings/index.jsx +++ b/apps/web/Components/Calculation/Settings/index.jsx @@ -20,7 +20,9 @@ const Wrapper = styled(Background)` export default function Settings() { const { $process } = useStore(); - const mainRows = renderFormRows(config.mainRows); + const mainRows = $process.has('Unlimited') + ? renderFormRows(config.unlimitedMainRows) + : renderFormRows(config.mainRows); const paramsRows = $process.has('Unlimited') ? renderFormRows(config.unlimitedParamsRows) : renderFormRows(config.paramsRows); diff --git a/apps/web/Components/Calculation/config/elements-render/override.tsx b/apps/web/Components/Calculation/config/elements-render/override.tsx index 1b7d4c3..7f0ce2a 100644 --- a/apps/web/Components/Calculation/config/elements-render/override.tsx +++ b/apps/web/Components/Calculation/config/elements-render/override.tsx @@ -20,6 +20,10 @@ const defaultLinkProps: ComponentProps = { type: 'link', }; +const formatter = Intl.NumberFormat('ru', { + minimumFractionDigits: 2, +}).format; + const overrideRender: Partial> = { selectHighSeasonStart: { render: () => { @@ -181,6 +185,40 @@ const overrideRender: Partial> = { }, }, + tbxIRR_Perc: { + render: () => { + const elementName = 'tbxIRR_Perc'; + const title = titles.tbxIRR_Perc; + const valueName = map.tbxIRR_Perc; + const Component = components.tbxIRR_Perc; + const props = elementsProps.tbxIRR_Perc; + const { builder } = types.tbxIRR_Perc(); + + const Element = builder(Component, { + elementName, + valueName, + }); + + const RenderedComponent = observer(() => { + const { $calculation } = useStore(); + const { min, max } = $calculation.$values.getValue('irrInfo'); + + return ( + + + + + ); + }); + + return ; + }, + }, + tbxVehicleTaxInYear: { render: () => { const elementName = 'tbxVehicleTaxInYear'; diff --git a/apps/web/config/default-values.ts b/apps/web/config/default-values.ts index f2dd0e1..446d400 100644 --- a/apps/web/config/default-values.ts +++ b/apps/web/config/default-values.ts @@ -65,7 +65,7 @@ const defaultValues: CalculationValues = { insUnlimitDrivers: true, insurance: true, IRR_Perc: 20, - irrInfo: '-', + irrInfo: { min: 0, max: 0 }, kpUrl: null, lastPaymentPerc: 1, lastPaymentRedemption: true, diff --git a/apps/web/config/schema/values.ts b/apps/web/config/schema/values.ts index 06b0478..7919d83 100644 --- a/apps/web/config/schema/values.ts +++ b/apps/web/config/schema/values.ts @@ -142,7 +142,10 @@ const ValuesSchema = z.object({ depreciationGroup: z.string().nullable(), discountRub: z.number(), insKaskoPriceLeasePeriod: z.number(), - irrInfo: z.string().nullable(), + irrInfo: z.object({ + min: z.number(), + max: z.number(), + }), leaseObjectRiskName: z.string().nullable(), plPriceRub: z.number(), registrationDescription: z.string().nullable(), diff --git a/apps/web/process/calculate/reactions/common.ts b/apps/web/process/calculate/reactions/common.ts index db14853..5d1e5d6 100644 --- a/apps/web/process/calculate/reactions/common.ts +++ b/apps/web/process/calculate/reactions/common.ts @@ -2,10 +2,6 @@ import helper from '../lib/helper'; import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; -export const formatter = Intl.NumberFormat('ru', { - minimumFractionDigits: 2, -}).format; - export default function reactions({ store, apolloClient }: ProcessContext) { const { $calculation } = store; @@ -38,7 +34,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) { async (values) => { const { min, max } = await getIrr(values); - $calculation.element('labelIrrInfo').setValue(`${formatter(min)}% - ${formatter(max)}%`); + $calculation.element('labelIrrInfo').setValue({ max, min }); } ); }