From 4e1d63b6eeb1a661fbf22778bf2e9f33f8cc4f63 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Mon, 1 Apr 2024 10:16:00 +0300 Subject: [PATCH] fix --- apps/web/process/leasing-object/reactions/common.ts | 7 +++---- apps/web/process/leasing-object/validation.ts | 12 ++++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/apps/web/process/leasing-object/reactions/common.ts b/apps/web/process/leasing-object/reactions/common.ts index 55f00b5..8fee96d 100644 --- a/apps/web/process/leasing-object/reactions/common.ts +++ b/apps/web/process/leasing-object/reactions/common.ts @@ -366,9 +366,10 @@ export default function reactions({ store, apolloClient }: ProcessContext) { 'engineVolume', 'engineType', 'leaseObjectMotorPower', + 'model', ]), - async ({ leaseObjectType: leaseObjectTypeId }) => { - if (!leaseObjectTypeId) { + async ({ leaseObjectType: leaseObjectTypeId, model: modelId }) => { + if (!leaseObjectTypeId || !modelId) { $calculation.element('selectEngineType').unblock(); $calculation.element('tbxEngineVolume').unblock(); $calculation.element('tbxLeaseObjectMotorPower').unblock(); @@ -385,8 +386,6 @@ export default function reactions({ store, apolloClient }: ProcessContext) { }, }); - const modelId = $calculation.element('selectModel').getValue(); - if (!modelId) return; const { data: { evo_model }, } = await apolloClient.query({ diff --git a/apps/web/process/leasing-object/validation.ts b/apps/web/process/leasing-object/validation.ts index c892c06..60f3cf4 100644 --- a/apps/web/process/leasing-object/validation.ts +++ b/apps/web/process/leasing-object/validation.ts @@ -29,7 +29,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { maxMass, leaseObjectCategory, brand, - model, + model: modelId, leaseObjectUseFor, configuration, }, @@ -51,7 +51,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { }); } - if (!model) { + if (!modelId) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Не заполнено поле', @@ -59,12 +59,12 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { }); } - if (model && !configuration) { + if (modelId && !configuration) { const { data: { evo_equipments }, } = await apolloClient.query({ query: CRMTypes.GetConfigurationsDocument, - variables: { modelId: model }, + variables: { modelId }, }); if (evo_equipments?.length) { @@ -94,13 +94,13 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { }, }); - if (model) { + if (modelId) { const { data: { evo_model }, } = await apolloClient.query({ query: CRMTypes.GetModelDocument, variables: { - modelId: model, + modelId, }, });