diff --git a/apps/web/Components/Calculation/addons/loader-addon.tsx b/apps/web/Components/Calculation/addons/loader-addon.tsx new file mode 100644 index 0000000..f4a6ea7 --- /dev/null +++ b/apps/web/Components/Calculation/addons/loader-addon.tsx @@ -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 ( + + + {' идет загрузка тарифов...'} + + ); +} diff --git a/apps/web/Components/Calculation/config/elements-render/override.tsx b/apps/web/Components/Calculation/config/elements-render/override.tsx index df6723d..36e0967 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 { 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> = { ); @@ -331,14 +336,18 @@ const overrideRender: Partial> = { }); const RenderedComponent = observer(() => { - const { $calculation } = useStore(); + const { $calculation, $process } = useStore(); const { min, max } = $calculation.$values.getValue('irrInfo'); const addon = {`${formatter(min)}% - ${formatter(max)}%`}; return ( - + : addon} + /> 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..e9b10e7 100644 --- a/apps/web/process/configurator/validation.ts +++ b/apps/web/process/configurator/validation.ts @@ -94,6 +94,12 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { path: ['tbxParmentsDecreasePercent'], }); } + } else { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'Тариф не выбран', + path: ['selectTarif'], + }); } /** 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() {