apps/web: add getCurrentDateString
This commit is contained in:
parent
9c3f2bbd78
commit
83031218ea
@ -4,7 +4,7 @@ import type { Row } from '../types';
|
|||||||
import type { RequestEltKasko, RequestEltOsago } from '@/api/elt/types';
|
import type { RequestEltKasko, RequestEltOsago } from '@/api/elt/types';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import type { ProcessContext } from '@/process/types';
|
import type { ProcessContext } from '@/process/types';
|
||||||
import { getCurrentISODate } from '@/utils/date';
|
import { getCurrentDateString } from '@/utils/date';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { first, sort } from 'radash';
|
import { first, sort } from 'radash';
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ export async function makeOwnOsagoRequest(
|
|||||||
{ store, apolloClient }: Pick<ProcessContext, 'apolloClient' | 'store'>,
|
{ store, apolloClient }: Pick<ProcessContext, 'apolloClient' | 'store'>,
|
||||||
row: Row
|
row: Row
|
||||||
): Promise<NonNullable<CRMTypes.GetOsagoAddproductTypesQuery['evo_addproduct_types']>[number]> {
|
): Promise<NonNullable<CRMTypes.GetOsagoAddproductTypesQuery['evo_addproduct_types']>[number]> {
|
||||||
const currentDate = getCurrentISODate();
|
const currentDate = getCurrentDateString();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_addproduct_types },
|
data: { evo_addproduct_types },
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import type { ProcessContext } from '../types';
|
|||||||
import { createValidationSchema } from './validation';
|
import { createValidationSchema } from './validation';
|
||||||
import { selectRequirementTelematic } from '@/config/default-options';
|
import { selectRequirementTelematic } from '@/config/default-options';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { getCurrentISODate } from '@/utils/date';
|
import { getCurrentDateString } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { debouncedReaction } from '@/utils/mobx';
|
import { debouncedReaction } from '@/utils/mobx';
|
||||||
import { reaction, toJS } from 'mobx';
|
import { reaction, toJS } from 'mobx';
|
||||||
@ -20,7 +20,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const currentDate = getCurrentISODate();
|
const currentDate = getCurrentDateString();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_addproduct_types },
|
data: { evo_addproduct_types },
|
||||||
@ -77,7 +77,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
reaction(
|
reaction(
|
||||||
() => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType']),
|
() => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType']),
|
||||||
async ({ leasingPeriod, leaseObjectType }) => {
|
async ({ leasingPeriod, leaseObjectType }) => {
|
||||||
const currentDate = getCurrentISODate();
|
const currentDate = getCurrentDateString();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_addproduct_types },
|
data: { evo_addproduct_types },
|
||||||
@ -161,7 +161,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
leasingPeriod,
|
leasingPeriod,
|
||||||
plPriceRub,
|
plPriceRub,
|
||||||
}) => {
|
}) => {
|
||||||
const currentDate = getCurrentISODate();
|
const currentDate = getCurrentDateString();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_addproduct_types },
|
data: { evo_addproduct_types },
|
||||||
@ -274,7 +274,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
leaseObjectType: leaseObjectTypeId,
|
leaseObjectType: leaseObjectTypeId,
|
||||||
engineType,
|
engineType,
|
||||||
}) => {
|
}) => {
|
||||||
const currentDate = getCurrentISODate();
|
const currentDate = getCurrentDateString();
|
||||||
const {
|
const {
|
||||||
data: { evo_addproduct_types: trackerTypes },
|
data: { evo_addproduct_types: trackerTypes },
|
||||||
} = await apolloClient.query({
|
} = await apolloClient.query({
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import type { ValidationContext } from '../../types';
|
import type { ValidationContext } from '../../types';
|
||||||
import type { ElementsTypes } from '@/Components/Calculation/config/map/values';
|
import type { ElementsTypes } from '@/Components/Calculation/config/map/values';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { getCurrentISODate } from '@/utils/date';
|
import { getCurrentDateString } from '@/utils/date';
|
||||||
|
|
||||||
export type ProductId = ElementsTypes['selectProduct'];
|
export type ProductId = ElementsTypes['selectProduct'];
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ export default function helper({ apolloClient, user }: ValidationContext) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentDate = getCurrentISODate();
|
const currentDate = getCurrentDateString();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_coefficients },
|
data: { evo_coefficients },
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import defaultValues from '@/config/default-values';
|
|||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import type { ProcessContext } from '@/process/types';
|
import type { ProcessContext } from '@/process/types';
|
||||||
import type { CalculationValues } from '@/stores/calculation/values/types';
|
import type { CalculationValues } from '@/stores/calculation/values/types';
|
||||||
import { getCurrentISODate } from '@/utils/date';
|
import { getCurrentDateString } from '@/utils/date';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { first, sort } from 'radash';
|
import { first, sort } from 'radash';
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ export default function helper({ apolloClient }: Pick<ProcessContext, 'apolloCli
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getRates({ tarif: tarifId }: GetRatesInputValues) {
|
async getRates({ tarif: tarifId }: GetRatesInputValues) {
|
||||||
const currentDate = getCurrentISODate();
|
const currentDate = getCurrentDateString();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_rates },
|
data: { evo_rates },
|
||||||
@ -138,7 +138,7 @@ export default function helper({ apolloClient }: Pick<ProcessContext, 'apolloCli
|
|||||||
floatingRate,
|
floatingRate,
|
||||||
partialVAT,
|
partialVAT,
|
||||||
}: GetTarifInputValues) {
|
}: GetTarifInputValues) {
|
||||||
const currentDate = getCurrentISODate();
|
const currentDate = getCurrentDateString();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_tarifs = [] },
|
data: { evo_tarifs = [] },
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { crmTools } from '@/graphql/crm.tools';
|
|||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { SEASON_TYPES } from '@/process/payments/lib/seasons-constants';
|
import { SEASON_TYPES } from '@/process/payments/lib/seasons-constants';
|
||||||
import type { ProcessContext } from '@/process/types';
|
import type { ProcessContext } from '@/process/types';
|
||||||
import { getCurrentISODate } from '@/utils/date';
|
import { getCurrentDateString } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { disposableReaction } from '@/utils/mobx';
|
import { disposableReaction } from '@/utils/mobx';
|
||||||
import { reaction } from 'mobx';
|
import { reaction } from 'mobx';
|
||||||
@ -355,7 +355,7 @@ export default function reactions({ store, apolloClient, user }: ProcessContext)
|
|||||||
reaction(
|
reaction(
|
||||||
() => $calculation.element('selectQuote').getValue(),
|
() => $calculation.element('selectQuote').getValue(),
|
||||||
async (quoteId) => {
|
async (quoteId) => {
|
||||||
const currentDate = getCurrentISODate();
|
const currentDate = getCurrentDateString();
|
||||||
|
|
||||||
let {
|
let {
|
||||||
data: { evo_baseproducts },
|
data: { evo_baseproducts },
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { STALE_TIME } from '@/constants/request';
|
|||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import type { ProcessContext } from '@/process/types';
|
import type { ProcessContext } from '@/process/types';
|
||||||
import type { CalculationValues } from '@/stores/calculation/values/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 type { QueryFunctionContext } from '@tanstack/react-query';
|
||||||
import { flatten } from 'tools/object';
|
import { flatten } from 'tools/object';
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ export default function helper({
|
|||||||
} = await apolloClient.query({
|
} = await apolloClient.query({
|
||||||
query: CRMTypes.GetAddproductTypesDocument,
|
query: CRMTypes.GetAddproductTypesDocument,
|
||||||
variables: {
|
variables: {
|
||||||
currentDate: getCurrentISODate(),
|
currentDate: getCurrentDateString(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { getTransTax } from '@/api/1c/query';
|
|||||||
import { selectObjectCategoryTax } from '@/config/default-options';
|
import { selectObjectCategoryTax } from '@/config/default-options';
|
||||||
import { STALE_TIME } from '@/constants/request';
|
import { STALE_TIME } from '@/constants/request';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { getCurrentISODate } from '@/utils/date';
|
import { getCurrentDateString } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { disposableReaction } from '@/utils/mobx';
|
import { disposableReaction } from '@/utils/mobx';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
@ -250,7 +250,7 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
|||||||
data: { evo_addproduct_types },
|
data: { evo_addproduct_types },
|
||||||
} = await apolloClient.query({
|
} = await apolloClient.query({
|
||||||
query: CRMTypes.GetRegistrationTypesDocument,
|
query: CRMTypes.GetRegistrationTypesDocument,
|
||||||
variables: { currentDate: getCurrentISODate() },
|
variables: { currentDate: getCurrentDateString() },
|
||||||
});
|
});
|
||||||
|
|
||||||
const options = evo_addproduct_types?.filter((x) => {
|
const options = evo_addproduct_types?.filter((x) => {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { STALE_TIME } from '@/constants/request';
|
|||||||
import { crmTools } from '@/graphql/crm.tools';
|
import { crmTools } from '@/graphql/crm.tools';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { useStore } from '@/stores/hooks';
|
import { useStore } from '@/stores/hooks';
|
||||||
import { getCurrentISODate } from '@/utils/date';
|
import { getCurrentDateString } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { useApolloClient } from '@apollo/client';
|
import { useApolloClient } from '@apollo/client';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
@ -16,7 +16,7 @@ import { useEffect } from 'react';
|
|||||||
* @param {*} onCompleted
|
* @param {*} onCompleted
|
||||||
*/
|
*/
|
||||||
function getMainData({ query }, onCompleted, user) {
|
function getMainData({ query }, onCompleted, user) {
|
||||||
const currentDate = getCurrentISODate();
|
const currentDate = getCurrentDateString();
|
||||||
|
|
||||||
query({
|
query({
|
||||||
query: CRMTypes.GetLeadsDocument,
|
query: CRMTypes.GetLeadsDocument,
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
import { notification } from '@/Components/Common/Notification';
|
import { notification } from '@/Components/Common/Notification';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import type { ProcessContext } from '@/process/types';
|
import type { ProcessContext } from '@/process/types';
|
||||||
import { getCurrentISODate } from '@/utils/date';
|
import { getCurrentDateString } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { reaction } from 'mobx';
|
import { reaction } from 'mobx';
|
||||||
import { uid } from 'radash';
|
import { uid } from 'radash';
|
||||||
@ -64,7 +64,7 @@ export function common({ store, apolloClient }: ProcessContext) {
|
|||||||
firstPaymentPerc,
|
firstPaymentPerc,
|
||||||
model: modelId,
|
model: modelId,
|
||||||
}) => {
|
}) => {
|
||||||
const currentDate = getCurrentISODate();
|
const currentDate = getCurrentDateString();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { evo_addproduct_types },
|
data: { evo_addproduct_types },
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import type { AgentsFields, AgentsRewardConditionsFields, AgentsSumFields } from './types';
|
import type { AgentsFields, AgentsRewardConditionsFields, AgentsSumFields } from './types';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import type RootStore from '@/stores/root';
|
import type RootStore from '@/stores/root';
|
||||||
import { getCurrentISODate } from '@/utils/date';
|
import { getCurrentDateString } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { disposableReaction } from '@/utils/mobx';
|
import { disposableReaction } from '@/utils/mobx';
|
||||||
import type { ApolloClient } from '@apollo/client';
|
import type { ApolloClient } from '@apollo/client';
|
||||||
@ -41,7 +41,7 @@ export function fillAgentRewardReaction(
|
|||||||
query: CRMTypes.GetRewardConditionsDocument,
|
query: CRMTypes.GetRewardConditionsDocument,
|
||||||
variables: {
|
variables: {
|
||||||
agentid,
|
agentid,
|
||||||
currentDate: getCurrentISODate(),
|
currentDate: getCurrentDateString(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import type { ValidationContext } from '../types';
|
|||||||
import type { Elements } from '@/Components/Calculation/config/map/values';
|
import type { Elements } from '@/Components/Calculation/config/map/values';
|
||||||
import ValuesSchema from '@/config/schema/values';
|
import ValuesSchema from '@/config/schema/values';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { getCurrentISODate } from '@/utils/date';
|
import { getCurrentDateString } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import type { RefinementCtx } from 'zod';
|
import type { RefinementCtx } from 'zod';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
@ -29,7 +29,7 @@ function helper({ apolloClient, ctx }: ValidationContext & { ctx: RefinementCtx
|
|||||||
query: CRMTypes.GetRewardConditionsDocument,
|
query: CRMTypes.GetRewardConditionsDocument,
|
||||||
variables: {
|
variables: {
|
||||||
agentid,
|
agentid,
|
||||||
currentDate: getCurrentISODate(),
|
currentDate: getCurrentDateString(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { ESN, NSIB_MAX, VAT } from '@/constants/values';
|
|||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import helper from '@/process/calculate/lib/helper';
|
import helper from '@/process/calculate/lib/helper';
|
||||||
import { createCurrencyUtility } from '@/utils/currency';
|
import { createCurrencyUtility } from '@/utils/currency';
|
||||||
import { getCurrentISODate } from '@/utils/date';
|
import { getCurrentDateString } from '@/utils/date';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import utc from 'dayjs/plugin/utc';
|
import utc from 'dayjs/plugin/utc';
|
||||||
import { min, sum } from 'radash';
|
import { min, sum } from 'radash';
|
||||||
@ -127,7 +127,7 @@ export async function createRequestData({
|
|||||||
await apolloClient.query({
|
await apolloClient.query({
|
||||||
query: CRMTypes.GetCoefficientsDocument,
|
query: CRMTypes.GetCoefficientsDocument,
|
||||||
variables: {
|
variables: {
|
||||||
currentDate: getCurrentISODate(),
|
currentDate: getCurrentDateString(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
).data.evo_coefficients
|
).data.evo_coefficients
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { getCurrentISODate } from './date';
|
import { getCurrentDateString } from './date';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import type { ApolloClient } from '@apollo/client';
|
import type { ApolloClient } from '@apollo/client';
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ export function createCurrencyUtility({ apolloClient }: Context) {
|
|||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
query: CRMTypes.GetCurrencyChangesDocument,
|
query: CRMTypes.GetCurrencyChangesDocument,
|
||||||
variables: {
|
variables: {
|
||||||
currentDate: getCurrentISODate(),
|
currentDate: getCurrentDateString(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,10 @@ export function getCurrentISODate() {
|
|||||||
return _currentDate().toISOString();
|
return _currentDate().toISOString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCurrentDateString() {
|
||||||
|
return _currentDate().format('YYYY-MM-DD');
|
||||||
|
}
|
||||||
|
|
||||||
export function getCurrentDate() {
|
export function getCurrentDate() {
|
||||||
return _currentDate().toDate();
|
return _currentDate().toDate();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user