From 1940f6e07dce7edcf12e40386a05f4646dace7f3 Mon Sep 17 00:00:00 2001 From: obarykina Date: Mon, 12 Feb 2024 11:34:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B8=20=D0=BF=D0=BE=D0=B4=D0=B1?= =?UTF-8?q?=D0=BE=D1=80=D0=B5=20=D1=82=D0=B0=D1=80=D0=B8=D1=84=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F=D1=82=D1=8C=20=D1=80?= =?UTF-8?q?=D1=8F=D0=B4=D0=BE=D0=BC=20=D1=81=20=D0=B4=D0=B8=D0=B0=D0=BF?= =?UTF-8?q?=D0=B0=D0=B7=D0=BE=D0=BD=D0=BE=D0=BC=20=D0=98=D0=A0=D0=A0=20?= =?UTF-8?q?=D1=84=D1=80=D0=B0=D0=B7=D1=83=20"=D0=B8=D0=B4=D0=B5=D1=82=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=B1=D0=BE=D1=80"=20=D0=98=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D1=87=D1=82=D0=BE=20?= =?UTF-8?q?=D0=B5=D1=81=D0=BB=D0=B8=20=D0=BC=D0=B8=D0=BD.=D0=98=D0=A0?= =?UTF-8?q?=D0=A0=20=D0=B8=20=D0=BC=D0=B0=D0=BA=D1=81.=D0=98=D0=A0=D0=A0?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B2=D0=BD=D1=8B=200,=20=D1=82=D0=BE=20=D0=B1?= =?UTF-8?q?=D0=BB=D0=BE=D0=BA=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20?= =?UTF-8?q?=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D1=83=20"=D0=A0=D0=B0=D1=81?= =?UTF-8?q?=D1=81=D1=87=D0=B8=D1=82=D0=B0=D1=82=D1=8C=20=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D1=84=D0=B8=D0=BA"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + еще в configurator/validation: добавить проверку на наличие выбранного тарифа в поле selectTarif --- .../Calculation/addons/loader-addon.tsx | 15 +++++++++++++++ .../config/elements-render/override.tsx | 15 ++++++++++++--- apps/web/process/configurator/reactions/values.ts | 4 ++++ apps/web/process/configurator/validation.ts | 6 ++++++ apps/web/stores/process/index.ts | 2 +- 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 apps/web/Components/Calculation/addons/loader-addon.tsx 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() {