При подборе тарифа добавлять рядом с диапазоном ИРР фразу "идет подбор" И добавить что если мин.ИРР и макс.ИРР равны 0, то блокировать кнопку "Рассчитать график"

+ еще в configurator/validation: добавить проверку на наличие выбранного тарифа в поле selectTarif
This commit is contained in:
obarykina 2024-02-12 11:34:06 +03:00
parent 35ce71c149
commit 1940f6e07d
5 changed files with 38 additions and 4 deletions

View File

@ -0,0 +1,15 @@
import styled from 'styled-components';
import { LoadingOutlined } from 'ui/elements/icons';
const TextAddon = styled.span`
font-size: 14px;
`;
export function LoaderAddon() {
return (
<TextAddon>
<LoadingOutlined rev="" />
{' идет загрузка тарифов...'}
</TextAddon>
);
}

View File

@ -1,3 +1,4 @@
import { LoaderAddon } from '../../addons/loader-addon';
import { ProductAddon } from '../../addons/product-addon';
import { buildLink } from '../../builders';
import components from '../elements-components';
@ -55,7 +56,11 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
<Element
{...props}
loading={$process.has('Calculate') || $process.has('CreateKP')}
disabled={$process.has('LoadKP') || (!$process.has('Unlimited') && hasErrors)}
disabled={
$process.has('LoadKP') ||
!$process.has('Unlimited') ||
($process.has('Tarif') && hasErrors)
}
/>
</Container>
);
@ -331,14 +336,18 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
});
const RenderedComponent = observer(() => {
const { $calculation } = useStore();
const { $calculation, $process } = useStore();
const { min, max } = $calculation.$values.getValue('irrInfo');
const addon = <TextAddon>{`${formatter(min)}% - ${formatter(max)}%`}</TextAddon>;
return (
<Container>
<Head htmlFor={elementName} title={title} addon={addon} />
<Head
htmlFor={elementName}
title={title}
addon={$process.has('Tarif') ? <LoaderAddon /> : addon}
/>
<Element {...props} min={min > 0 ? min : undefined} max={max > 0 ? max : undefined} />
</Container>
);

View File

@ -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();
}
},

View File

@ -94,6 +94,12 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
path: ['tbxParmentsDecreasePercent'],
});
}
} else {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Тариф не выбран',
path: ['selectTarif'],
});
}
/**

View File

@ -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<Process>;
export default function createProcessStore() {