diff --git a/apps/web/Components/Calculation/Form/ELT/lib/make-request.ts b/apps/web/Components/Calculation/Form/ELT/lib/make-request.ts index fcdcc0f..d82d045 100644 --- a/apps/web/Components/Calculation/Form/ELT/lib/make-request.ts +++ b/apps/web/Components/Calculation/Form/ELT/lib/make-request.ts @@ -4,7 +4,7 @@ import type { Row } from '../types'; import type { RequestEltKasko, RequestEltOsago } from '@/api/elt/types'; import * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; -import { getCurrentISODate } from '@/utils/date'; +import { getCurrentDateString } from '@/utils/date'; import dayjs from 'dayjs'; import { first, sort } from 'radash'; @@ -12,7 +12,7 @@ export async function makeOwnOsagoRequest( { store, apolloClient }: Pick, row: Row ): Promise[number]> { - const currentDate = getCurrentISODate(); + const currentDate = getCurrentDateString(); const { data: { evo_addproduct_types }, diff --git a/apps/web/process/add-product/reactions.ts b/apps/web/process/add-product/reactions.ts index 3e4b48b..9a4c1e5 100644 --- a/apps/web/process/add-product/reactions.ts +++ b/apps/web/process/add-product/reactions.ts @@ -4,7 +4,7 @@ import type { ProcessContext } from '../types'; import { createValidationSchema } from './validation'; import { selectRequirementTelematic } from '@/config/default-options'; import * as CRMTypes from '@/graphql/crm.types'; -import { getCurrentISODate } from '@/utils/date'; +import { getCurrentDateString } from '@/utils/date'; import { normalizeOptions } from '@/utils/entity'; import { debouncedReaction } from '@/utils/mobx'; import { reaction, toJS } from 'mobx'; @@ -20,7 +20,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) { return; } - const currentDate = getCurrentISODate(); + const currentDate = getCurrentDateString(); const { data: { evo_addproduct_types }, @@ -77,7 +77,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) { reaction( () => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType']), async ({ leasingPeriod, leaseObjectType }) => { - const currentDate = getCurrentISODate(); + const currentDate = getCurrentDateString(); const { data: { evo_addproduct_types }, @@ -161,7 +161,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) { leasingPeriod, plPriceRub, }) => { - const currentDate = getCurrentISODate(); + const currentDate = getCurrentDateString(); const { data: { evo_addproduct_types }, @@ -274,7 +274,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) { leaseObjectType: leaseObjectTypeId, engineType, }) => { - const currentDate = getCurrentISODate(); + const currentDate = getCurrentDateString(); const { data: { evo_addproduct_types: trackerTypes }, } = await apolloClient.query({ diff --git a/apps/web/process/bonuses/lib/helper.ts b/apps/web/process/bonuses/lib/helper.ts index dbd038d..1aeb09e 100644 --- a/apps/web/process/bonuses/lib/helper.ts +++ b/apps/web/process/bonuses/lib/helper.ts @@ -1,7 +1,7 @@ import type { ValidationContext } from '../../types'; import type { ElementsTypes } from '@/Components/Calculation/config/map/values'; import * as CRMTypes from '@/graphql/crm.types'; -import { getCurrentISODate } from '@/utils/date'; +import { getCurrentDateString } from '@/utils/date'; export type ProductId = ElementsTypes['selectProduct']; @@ -27,7 +27,7 @@ export default function helper({ apolloClient, user }: ValidationContext) { return null; } - const currentDate = getCurrentISODate(); + const currentDate = getCurrentDateString(); const { data: { evo_coefficients }, diff --git a/apps/web/process/configurator/lib/helper.ts b/apps/web/process/configurator/lib/helper.ts index 5e8e455..ab03dd2 100644 --- a/apps/web/process/configurator/lib/helper.ts +++ b/apps/web/process/configurator/lib/helper.ts @@ -3,7 +3,7 @@ import defaultValues from '@/config/default-values'; import * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; import type { CalculationValues } from '@/stores/calculation/values/types'; -import { getCurrentISODate } from '@/utils/date'; +import { getCurrentDateString } from '@/utils/date'; import dayjs from 'dayjs'; import { first, sort } from 'radash'; @@ -80,7 +80,7 @@ export default function helper({ apolloClient }: Pick $calculation.element('selectQuote').getValue(), async (quoteId) => { - const currentDate = getCurrentISODate(); + const currentDate = getCurrentDateString(); let { data: { evo_baseproducts }, diff --git a/apps/web/process/fingap/lib/helper.ts b/apps/web/process/fingap/lib/helper.ts index a6ddb66..25db76f 100644 --- a/apps/web/process/fingap/lib/helper.ts +++ b/apps/web/process/fingap/lib/helper.ts @@ -6,7 +6,7 @@ import { STALE_TIME } from '@/constants/request'; import * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; import type { CalculationValues } from '@/stores/calculation/values/types'; -import { getCurrentISODate } from '@/utils/date'; +import { getCurrentDateString } from '@/utils/date'; import type { QueryFunctionContext } from '@tanstack/react-query'; import { flatten } from 'tools/object'; @@ -38,7 +38,7 @@ export default function helper({ } = await apolloClient.query({ query: CRMTypes.GetAddproductTypesDocument, variables: { - currentDate: getCurrentISODate(), + currentDate: getCurrentDateString(), }, }); diff --git a/apps/web/process/gibdd/reactions.ts b/apps/web/process/gibdd/reactions.ts index 7bd56af..e59fd72 100644 --- a/apps/web/process/gibdd/reactions.ts +++ b/apps/web/process/gibdd/reactions.ts @@ -6,7 +6,7 @@ import { getTransTax } from '@/api/1c/query'; import { selectObjectCategoryTax } from '@/config/default-options'; import { STALE_TIME } from '@/constants/request'; import * as CRMTypes from '@/graphql/crm.types'; -import { getCurrentISODate } from '@/utils/date'; +import { getCurrentDateString } from '@/utils/date'; import { normalizeOptions } from '@/utils/entity'; import { disposableReaction } from '@/utils/mobx'; import dayjs from 'dayjs'; @@ -250,7 +250,7 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) { data: { evo_addproduct_types }, } = await apolloClient.query({ query: CRMTypes.GetRegistrationTypesDocument, - variables: { currentDate: getCurrentISODate() }, + variables: { currentDate: getCurrentDateString() }, }); const options = evo_addproduct_types?.filter((x) => { diff --git a/apps/web/process/hooks/init/get-main-data.js b/apps/web/process/hooks/init/get-main-data.js index 39a005c..fcc734c 100644 --- a/apps/web/process/hooks/init/get-main-data.js +++ b/apps/web/process/hooks/init/get-main-data.js @@ -4,7 +4,7 @@ import { STALE_TIME } from '@/constants/request'; import { crmTools } from '@/graphql/crm.tools'; import * as CRMTypes from '@/graphql/crm.types'; import { useStore } from '@/stores/hooks'; -import { getCurrentISODate } from '@/utils/date'; +import { getCurrentDateString } from '@/utils/date'; import { normalizeOptions } from '@/utils/entity'; import { useApolloClient } from '@apollo/client'; import { useQuery } from '@tanstack/react-query'; @@ -16,7 +16,7 @@ import { useEffect } from 'react'; * @param {*} onCompleted */ function getMainData({ query }, onCompleted, user) { - const currentDate = getCurrentISODate(); + const currentDate = getCurrentDateString(); query({ query: CRMTypes.GetLeadsDocument, diff --git a/apps/web/process/leasing-without-kasko/reactions.ts b/apps/web/process/leasing-without-kasko/reactions.ts index 35f33c0..ddcab7b 100644 --- a/apps/web/process/leasing-without-kasko/reactions.ts +++ b/apps/web/process/leasing-without-kasko/reactions.ts @@ -3,7 +3,7 @@ import { notification } from '@/Components/Common/Notification'; import * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; -import { getCurrentISODate } from '@/utils/date'; +import { getCurrentDateString } from '@/utils/date'; import { normalizeOptions } from '@/utils/entity'; import { reaction } from 'mobx'; import { uid } from 'radash'; @@ -64,7 +64,7 @@ export function common({ store, apolloClient }: ProcessContext) { firstPaymentPerc, model: modelId, }) => { - const currentDate = getCurrentISODate(); + const currentDate = getCurrentDateString(); const { data: { evo_addproduct_types }, diff --git a/apps/web/process/supplier-agent/lib/create-reactions.ts b/apps/web/process/supplier-agent/lib/create-reactions.ts index 2856bc6..dfc81eb 100644 --- a/apps/web/process/supplier-agent/lib/create-reactions.ts +++ b/apps/web/process/supplier-agent/lib/create-reactions.ts @@ -1,7 +1,7 @@ import type { AgentsFields, AgentsRewardConditionsFields, AgentsSumFields } from './types'; import * as CRMTypes from '@/graphql/crm.types'; import type RootStore from '@/stores/root'; -import { getCurrentISODate } from '@/utils/date'; +import { getCurrentDateString } from '@/utils/date'; import { normalizeOptions } from '@/utils/entity'; import { disposableReaction } from '@/utils/mobx'; import type { ApolloClient } from '@apollo/client'; @@ -41,7 +41,7 @@ export function fillAgentRewardReaction( query: CRMTypes.GetRewardConditionsDocument, variables: { agentid, - currentDate: getCurrentISODate(), + currentDate: getCurrentDateString(), }, }); diff --git a/apps/web/process/supplier-agent/validation.ts b/apps/web/process/supplier-agent/validation.ts index 0c94122..fbfad97 100644 --- a/apps/web/process/supplier-agent/validation.ts +++ b/apps/web/process/supplier-agent/validation.ts @@ -4,7 +4,7 @@ import type { ValidationContext } from '../types'; import type { Elements } from '@/Components/Calculation/config/map/values'; import ValuesSchema from '@/config/schema/values'; import * as CRMTypes from '@/graphql/crm.types'; -import { getCurrentISODate } from '@/utils/date'; +import { getCurrentDateString } from '@/utils/date'; import { normalizeOptions } from '@/utils/entity'; import type { RefinementCtx } from 'zod'; import { z } from 'zod'; @@ -29,7 +29,7 @@ function helper({ apolloClient, ctx }: ValidationContext & { ctx: RefinementCtx query: CRMTypes.GetRewardConditionsDocument, variables: { agentid, - currentDate: getCurrentISODate(), + currentDate: getCurrentDateString(), }, }); diff --git a/apps/web/server/routers/calculate/lib/request.ts b/apps/web/server/routers/calculate/lib/request.ts index 4e4a6c3..ee03527 100644 --- a/apps/web/server/routers/calculate/lib/request.ts +++ b/apps/web/server/routers/calculate/lib/request.ts @@ -5,7 +5,7 @@ import { ESN, NSIB_MAX, VAT } from '@/constants/values'; import * as CRMTypes from '@/graphql/crm.types'; import helper from '@/process/calculate/lib/helper'; import { createCurrencyUtility } from '@/utils/currency'; -import { getCurrentISODate } from '@/utils/date'; +import { getCurrentDateString } from '@/utils/date'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import { min, sum } from 'radash'; @@ -127,7 +127,7 @@ export async function createRequestData({ await apolloClient.query({ query: CRMTypes.GetCoefficientsDocument, variables: { - currentDate: getCurrentISODate(), + currentDate: getCurrentDateString(), }, }) ).data.evo_coefficients diff --git a/apps/web/utils/currency.ts b/apps/web/utils/currency.ts index c25c76a..0ad1587 100644 --- a/apps/web/utils/currency.ts +++ b/apps/web/utils/currency.ts @@ -1,4 +1,4 @@ -import { getCurrentISODate } from './date'; +import { getCurrentDateString } from './date'; import * as CRMTypes from '@/graphql/crm.types'; import type { ApolloClient } from '@apollo/client'; @@ -33,7 +33,7 @@ export function createCurrencyUtility({ apolloClient }: Context) { fetchPolicy: 'network-only', query: CRMTypes.GetCurrencyChangesDocument, variables: { - currentDate: getCurrentISODate(), + currentDate: getCurrentDateString(), }, }); diff --git a/apps/web/utils/date.ts b/apps/web/utils/date.ts index 9c35f6c..106d940 100644 --- a/apps/web/utils/date.ts +++ b/apps/web/utils/date.ts @@ -11,6 +11,10 @@ export function getCurrentISODate() { return _currentDate().toISOString(); } +export function getCurrentDateString() { + return _currentDate().format('YYYY-MM-DD'); +} + export function getCurrentDate() { return _currentDate().toDate(); }