diff --git a/apps/web/process/supplier-agent/lib/query.ts b/apps/web/process/supplier-agent/lib/query.ts index 79482d8..e487114 100644 --- a/apps/web/process/supplier-agent/lib/query.ts +++ b/apps/web/process/supplier-agent/lib/query.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/prefer-default-export */ import { gql } from '@apollo/client'; export const QUERY_GET_AGENT = gql` @@ -9,3 +8,11 @@ export const QUERY_GET_AGENT = gql` } } `; + +export const QUERY_GET_DEALER_RETURN_LEASING = gql` + query GetDealerReturnLeasing($dealerId: Uuid!) { + dealer: account(accountid: $dealerId) { + evo_return_leasing_dealer + } + } +`; diff --git a/apps/web/process/supplier-agent/reactions/leaseback.ts b/apps/web/process/supplier-agent/reactions/leaseback.ts index fb644f9..de54da9 100644 --- a/apps/web/process/supplier-agent/reactions/leaseback.ts +++ b/apps/web/process/supplier-agent/reactions/leaseback.ts @@ -1,7 +1,7 @@ -import { gql } from '@apollo/client'; import type * as CRMTypes from 'graphql/crm.types'; import { reaction } from 'mobx'; import type { ReactionsContext } from 'process/types'; +import * as query from '../lib/query'; export default function leasebackReactions({ store, apolloClient }: ReactionsContext) { const { $calculation, $tables } = store; @@ -20,14 +20,6 @@ export default function leasebackReactions({ store, apolloClient }: ReactionsCon 3) ПЛ БУ cbxLeaseObjectUsed = true */ - const QUERY_GET_DEALER_RETURN_LEASING = gql` - query GetDealerReturnLeasing($dealerId: Uuid!) { - dealer: account(accountid: $dealerId) { - evo_return_leasing_dealer - } - } - `; - reaction( () => $calculation.element('selectDealer').getValue(), async (dealerId) => { @@ -39,16 +31,18 @@ export default function leasebackReactions({ store, apolloClient }: ReactionsCon CRMTypes.GetDealerReturnLeasingQuery, CRMTypes.GetDealerReturnLeasingQueryVariables >({ - query: QUERY_GET_DEALER_RETURN_LEASING, + query: query.QUERY_GET_DEALER_RETURN_LEASING, variables: { dealerId, }, }); if (dealer?.evo_return_leasing_dealer === true) { + $calculation.element('selectDealerPerson').block().resetValue(); $tables.insurance.row('kasko').setValue('insured', 100_000_000).block('insured'); $calculation.element('cbxLeaseObjectUsed').setValue(true); } else { + $calculation.element('selectDealerPerson').unblock(); $tables.insurance.row('kasko').resetStatus('insured'); } } @@ -71,7 +65,7 @@ export default function leasebackReactions({ store, apolloClient }: ReactionsCon CRMTypes.GetDealerReturnLeasingQuery, CRMTypes.GetDealerReturnLeasingQueryVariables >({ - query: QUERY_GET_DEALER_RETURN_LEASING, + query: query.QUERY_GET_DEALER_RETURN_LEASING, variables: { dealerId, }, diff --git a/apps/web/process/supplier-agent/reactions/supplier.ts b/apps/web/process/supplier-agent/reactions/supplier.ts index 435cadb..9d702f4 100644 --- a/apps/web/process/supplier-agent/reactions/supplier.ts +++ b/apps/web/process/supplier-agent/reactions/supplier.ts @@ -43,6 +43,22 @@ export function commonReactions({ store, apolloClient }: ReactionsContext) { return; } + const { + data: { dealer }, + } = await apolloClient.query< + CRMTypes.GetDealerReturnLeasingQuery, + CRMTypes.GetDealerReturnLeasingQueryVariables + >({ + query: query.QUERY_GET_DEALER_RETURN_LEASING, + variables: { + dealerId, + }, + }); + + if (dealer?.evo_return_leasing_dealer) { + return; + } + const { data: { salon_providers }, } = await apolloClient.query<