diff --git a/apps/web/Components/Calculation/addons/irr-addon.tsx b/apps/web/Components/Calculation/addons/irr-addon.tsx
new file mode 100644
index 0000000..23ffc2d
--- /dev/null
+++ b/apps/web/Components/Calculation/addons/irr-addon.tsx
@@ -0,0 +1,31 @@
+import { useStore } from '@/stores/hooks';
+import { observer } from 'mobx-react-lite';
+import styled from 'styled-components';
+import { LoadingOutlined } from 'ui/elements/icons';
+
+const TextAddon = styled.span`
+ font-size: 14px;
+`;
+
+const formatter = Intl.NumberFormat('ru', {
+ minimumFractionDigits: 2,
+}).format;
+
+export const IRRAddon = observer(() => {
+ const { $calculation, $process } = useStore();
+
+ if ($process.has('Tarif')) {
+ return (
+
+
+ {' Подбирается тариф...'}
+
+ );
+ }
+
+ const tarif = $calculation.element('selectTarif').getValue();
+ if (!tarif) return Тариф не найден;
+
+ const { min, max } = $calculation.$values.getValue('irrInfo');
+ return {`${formatter(min)}% - ${formatter(max)}%`};
+});
diff --git a/apps/web/Components/Calculation/config/elements-render/override.tsx b/apps/web/Components/Calculation/config/elements-render/override.tsx
index df6723d..cf2576b 100644
--- a/apps/web/Components/Calculation/config/elements-render/override.tsx
+++ b/apps/web/Components/Calculation/config/elements-render/override.tsx
@@ -1,3 +1,4 @@
+import { IRRAddon } from '../../addons/irr-addon';
import { ProductAddon } from '../../addons/product-addon';
import { buildLink } from '../../builders';
import components from '../elements-components';
@@ -11,7 +12,6 @@ import { useErrors, useStore } from '@/stores/hooks';
import { useIsFetching } from '@tanstack/react-query';
import { observer } from 'mobx-react-lite';
import type { ComponentProps } from 'react';
-import styled from 'styled-components';
import { Link, Tooltip } from 'ui/elements';
import { LoadingOutlined } from 'ui/elements/icons';
@@ -22,14 +22,6 @@ const defaultLinkProps: ComponentProps = {
type: 'link',
};
-const formatter = Intl.NumberFormat('ru', {
- minimumFractionDigits: 2,
-}).format;
-
-const TextAddon = styled.span`
- font-size: 14px;
-`;
-
const overrideRender: Partial> = {
btnCalculate: {
render: () => {
@@ -55,7 +47,11 @@ const overrideRender: Partial> = {
);
@@ -89,7 +85,11 @@ const overrideRender: Partial> = {
);
@@ -334,11 +334,9 @@ const overrideRender: Partial> = {
const { $calculation } = useStore();
const { min, max } = $calculation.$values.getValue('irrInfo');
- const addon = {`${formatter(min)}% - ${formatter(max)}%`};
-
return (
-
+ } />
0 ? min : undefined} max={max > 0 ? max : undefined} />
);
diff --git a/apps/web/process/configurator/reactions/values.ts b/apps/web/process/configurator/reactions/values.ts
index 5abf5bd..8729837 100644
--- a/apps/web/process/configurator/reactions/values.ts
+++ b/apps/web/process/configurator/reactions/values.ts
@@ -36,6 +36,7 @@ export default function valuesReactions({ store, apolloClient, trpcClient }: Pro
if (abortController) abortController.abort();
abortController = new AbortController();
+ $process.add('Tarif');
const { evo_tarif } = await trpcClient.getTarif.query(values, {
signal: abortController.signal,
});
@@ -44,7 +45,10 @@ export default function valuesReactions({ store, apolloClient, trpcClient }: Pro
$calculation.element('selectTarif').setOptions(normalizeOptions([evo_tarif]));
$calculation.element('selectTarif').setValue(evo_tarif.evo_tarifid);
}
+
+ $process.delete('Tarif');
} catch {
+ $process.delete('Tarif');
$calculation.element('selectTarif').resetOptions();
}
},
diff --git a/apps/web/process/configurator/validation.ts b/apps/web/process/configurator/validation.ts
index 2cbd57f..5c6adf7 100644
--- a/apps/web/process/configurator/validation.ts
+++ b/apps/web/process/configurator/validation.ts
@@ -74,6 +74,14 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
const { tarif: tarifId, parmentsDecreasePercent } = values;
+ if (!tarifId) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: 'Не заполнено поле',
+ path: ['selectTarif'],
+ });
+ }
+
if (tarifId) {
const {
data: { evo_tarif },
diff --git a/apps/web/stores/process/index.ts b/apps/web/stores/process/index.ts
index 0e5d045..d414f53 100644
--- a/apps/web/stores/process/index.ts
+++ b/apps/web/stores/process/index.ts
@@ -1,7 +1,7 @@
import type { ObservableSet } from 'mobx';
import { observable } from 'mobx';
-export type Process = 'Calculate' | 'CreateKP' | 'ELT' | 'LoadKP' | 'Unlimited';
+export type Process = 'Calculate' | 'CreateKP' | 'ELT' | 'LoadKP' | 'Tarif' | 'Unlimited';
export type ProcessStore = ObservableSet;
export default function createProcessStore() {