diff --git a/apps/web/graphql/crm.types.ts b/apps/web/graphql/crm.types.ts index d0c447d..9ea74d1 100644 --- a/apps/web/graphql/crm.types.ts +++ b/apps/web/graphql/crm.types.ts @@ -186,7 +186,7 @@ export type GetTarifs_ProcessConfiguratorQueryVariables = Exact<{ }>; -export type GetTarifs_ProcessConfiguratorQuery = { __typename?: 'Query', evo_tarifs: Array<{ __typename?: 'evo_tarif', evo_tarifid: string | null, evo_baseproductid: string | null, evo_min_period: number | null, evo_max_period: number | null, evo_delivery_time: Array | null, evo_min_first_payment: number | null, evo_max_first_payment: number | null, evo_min_last_payment: number | null, evo_max_last_payment: number | null, evo_used: boolean | null } | null> | null }; +export type GetTarifs_ProcessConfiguratorQuery = { __typename?: 'Query', evo_tarifs: Array<{ __typename?: 'evo_tarif', evo_tarifid: string | null, evo_baseproductid: string | null, evo_min_period: number | null, evo_max_period: number | null, evo_delivery_time: Array | null, evo_min_first_payment: number | null, evo_max_first_payment: number | null, evo_min_last_payment: number | null, evo_max_last_payment: number | null, evo_used: boolean | null, label: string | null, value: string | null } | null> | null }; export type GetRisksDataFromQuoteQueryVariables = Exact<{ quoteId: Scalars['Uuid']; @@ -243,7 +243,9 @@ export type GetDealersQueryVariables = Exact<{ [key: string]: never; }>; export type GetDealersQuery = { __typename?: 'Query', selectDealer: Array<{ __typename?: 'account', label: string | null, value: string | null } | null> | null }; -export type GetAddproductTypesQueryVariables = Exact<{ [key: string]: never; }>; +export type GetAddproductTypesQueryVariables = Exact<{ + currentDate: InputMaybe; +}>; export type GetAddproductTypesQuery = { __typename?: 'Query', evo_addproduct_types: Array<{ __typename?: 'evo_addproduct_type', evo_graph_price: number | null, evo_product_type: number | null, label: string | null, value: string | null } | null> | null }; diff --git a/apps/web/process/configurator/reactions/values.ts b/apps/web/process/configurator/reactions/values.ts index ab35e09..8e16bb5 100644 --- a/apps/web/process/configurator/reactions/values.ts +++ b/apps/web/process/configurator/reactions/values.ts @@ -6,7 +6,7 @@ import { autorun, reaction } from 'mobx'; import type * as CRMTypes from 'graphql/crm.types'; import type { ReactionsContext } from 'process/types'; -import { makeDisposable } from 'tools'; +import { makeDisposable, normalizeOptions } from 'tools'; import { QUERY_GET_TARIF } from '../lib/query'; dayjs.extend(utc); @@ -18,6 +18,8 @@ const QUERY_GET_TARIFS = gql` evo_datefrom_param: { lte: $currentDate } evo_dateto_param: { gte: $currentDate } ) { + label: evo_name + value: evo_tarifid evo_tarifid evo_baseproductid evo_min_period @@ -65,18 +67,18 @@ export default function valuesReactions({ store, apolloClient }: ReactionsContex (tarif) => tarif && tarif.evo_baseproductid === product && - tarif.evo_min_period && + tarif.evo_min_period !== null && tarif.evo_min_period <= leasingPeriod && - tarif.evo_max_period && + tarif.evo_max_period !== null && tarif.evo_max_period >= leasingPeriod && tarif.evo_delivery_time?.includes(deliveryTime) && - tarif.evo_min_first_payment && + tarif.evo_min_first_payment !== null && tarif.evo_min_first_payment <= firstPaymentPerc && - tarif.evo_max_first_payment && + tarif.evo_max_first_payment !== null && tarif.evo_max_first_payment >= firstPaymentPerc && - tarif.evo_min_last_payment && + tarif.evo_min_last_payment !== null && tarif.evo_min_last_payment <= lastPaymentPerc && - tarif.evo_max_last_payment && + tarif.evo_max_last_payment !== null && tarif.evo_max_last_payment >= lastPaymentPerc ); } else { @@ -93,7 +95,10 @@ export default function valuesReactions({ store, apolloClient }: ReactionsContex }); } - $calculation.element('selectTarif').setValue(evo_tarifs?.at(0)?.evo_tarifid || null); + $calculation + .element('selectTarif') + .setOptions(normalizeOptions(evo_tarifs)) + .setValue(evo_tarifs?.at(0)?.evo_tarifid || null); }, { delay: 10,