apps/web: use dates w/ zero time
This commit is contained in:
parent
fba7c240b1
commit
49715531d9
@ -4,14 +4,11 @@ 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 { normalizeOptions } from '@/utils/entity';
|
||||
import { debouncedReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction, toJS } from 'mobx';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
const { $calculation, $tables } = store;
|
||||
|
||||
@ -23,7 +20,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
|
||||
return;
|
||||
}
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_addproduct_types },
|
||||
@ -80,7 +77,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
reaction(
|
||||
() => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType']),
|
||||
async ({ leasingPeriod, leaseObjectType }) => {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_addproduct_types },
|
||||
@ -164,7 +161,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
leasingPeriod,
|
||||
plPriceRub,
|
||||
}) => {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_addproduct_types },
|
||||
@ -277,7 +274,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
leaseObjectType: leaseObjectTypeId,
|
||||
engineType,
|
||||
}) => {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
const {
|
||||
data: { evo_addproduct_types: trackerTypes },
|
||||
} = await apolloClient.query({
|
||||
|
||||
@ -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 dayjs from 'dayjs';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
|
||||
export type ProductId = ElementsTypes['selectProduct'];
|
||||
|
||||
@ -25,7 +25,7 @@ export default function helper({ apolloClient, user }: ValidationContext) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_coefficients },
|
||||
|
||||
@ -2,13 +2,9 @@ import type { ProcessContext } from '../../types';
|
||||
import helper from '../lib/helper';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
import { round } from 'tools';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export default function reactions(context: ProcessContext) {
|
||||
const { store, apolloClient } = context;
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
@ -3,6 +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 dayjs from 'dayjs';
|
||||
import { first, sort } from 'radash';
|
||||
|
||||
@ -79,7 +80,7 @@ export default function helper({ apolloClient }: Pick<ProcessContext, 'apolloCli
|
||||
},
|
||||
|
||||
async getRates({ tarif: tarifId }: GetRatesInputValues) {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_rates },
|
||||
@ -134,7 +135,7 @@ export default function helper({ apolloClient }: Pick<ProcessContext, 'apolloCli
|
||||
floatingRate,
|
||||
partialVAT,
|
||||
}: GetTarifInputValues) {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_tarifs = [] },
|
||||
|
||||
@ -4,15 +4,12 @@ import { crmTools } from '@/graphql/crm.tools';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { SEASON_TYPES } from '@/process/payments/lib/seasons-constants';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
import { diff, sift } from 'radash';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export default function reactions({ store, apolloClient, user }: ProcessContext) {
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
@ -358,7 +355,7 @@ export default function reactions({ store, apolloClient, user }: ProcessContext)
|
||||
reaction(
|
||||
() => $calculation.element('selectQuote').getValue(),
|
||||
async (quoteId) => {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
let {
|
||||
data: { evo_baseproducts },
|
||||
|
||||
@ -4,12 +4,8 @@ import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import { disposableDebouncedReaction, disposableReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { comparer, reaction } from 'mobx';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export default function valuesReactions({ store, apolloClient, trpcClient }: ProcessContext) {
|
||||
let abortController = new AbortController();
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
@ -6,8 +6,8 @@ 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 type { QueryFunctionContext } from '@tanstack/react-query';
|
||||
import dayjs from 'dayjs';
|
||||
import { flatten } from 'tools/object';
|
||||
|
||||
type GetFingapRisksInputValues = Pick<
|
||||
@ -38,7 +38,7 @@ export default function helper({
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetAddproductTypesDocument,
|
||||
variables: {
|
||||
currentDate: dayjs().utc(false).toISOString(),
|
||||
currentDate: getCurrentISODate(),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
import helper from '../lib/helper';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { comparer, reaction } from 'mobx';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export default function reactions({ store, apolloClient, queryClient }: ProcessContext) {
|
||||
const { getFingapRisks } = helper({ apolloClient, queryClient });
|
||||
|
||||
|
||||
@ -6,14 +6,12 @@ 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 { normalizeOptions } from '@/utils/entity';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
@ -239,8 +237,6 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
||||
leaseObjectType,
|
||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||
}) => {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
|
||||
let evo_region: CRMTypes.GetRegionQuery['evo_region'];
|
||||
if (objectRegionRegistrationId) {
|
||||
const { data } = await apolloClient.query({
|
||||
@ -254,7 +250,7 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
||||
data: { evo_addproduct_types },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetRegistrationTypesDocument,
|
||||
variables: { currentDate },
|
||||
variables: { currentDate: getCurrentISODate() },
|
||||
});
|
||||
|
||||
const options = evo_addproduct_types?.filter((x) => {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import type { User } from '@/api/user/types';
|
||||
import { crmTools } from '@/graphql/crm.tools';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
import type { ApolloClient } from '@apollo/client';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export async function getInitialData({ query }: ApolloClient<object>, user: User) {
|
||||
const leadsQuery = query({
|
||||
@ -17,7 +17,7 @@ export async function getInitialData({ query }: ApolloClient<object>, user: User
|
||||
const productsQuery = query({
|
||||
fetchPolicy: 'network-only',
|
||||
query: CRMTypes.GetProductsDocument,
|
||||
variables: { currentDate: dayjs().utc(false).toISOString() },
|
||||
variables: { currentDate: getCurrentISODate() },
|
||||
});
|
||||
const systemUserQuery = query({
|
||||
fetchPolicy: 'network-only',
|
||||
|
||||
@ -3,13 +3,9 @@ import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { useStore } from '@/stores/hooks';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@ -3,14 +3,11 @@
|
||||
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 { normalizeOptions } from '@/utils/entity';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
import { uid } from 'radash';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
const NOTIFICATION_KEY = uid(7);
|
||||
|
||||
export function common({ store, apolloClient }: ProcessContext) {
|
||||
@ -67,7 +64,7 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
firstPaymentPerc,
|
||||
model: modelId,
|
||||
}) => {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_addproduct_types },
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
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 { normalizeOptions } from '@/utils/entity';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import type { ApolloClient } from '@apollo/client';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { comparer, reaction } from 'mobx';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export function fillAgentRewardReaction(
|
||||
store: RootStore,
|
||||
apolloClient: ApolloClient<object>,
|
||||
@ -44,7 +41,7 @@ export function fillAgentRewardReaction(
|
||||
query: CRMTypes.GetRewardConditionsDocument,
|
||||
variables: {
|
||||
agentid,
|
||||
currentDate: dayjs().utc(false).toISOString(),
|
||||
currentDate: getCurrentISODate(),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -4,15 +4,11 @@ import * as fillAgentsFromLead from '../lib/fill-agents-from-lead';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
|
||||
const { fillIndAgent, fillCalcBroker, fillCalcDoubleAgent, fillFinDepartment } = fillAgentsFromLead;
|
||||
const { fillAgentRewardReaction, fillAgentRewardSummReaction } = createReactions;
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
class Helper {
|
||||
public enabled: boolean;
|
||||
/**
|
||||
|
||||
@ -2,13 +2,9 @@ import * as createReactions from '../lib/create-reactions';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
import { sift } from 'radash';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export function common({ store, apolloClient }: ProcessContext) {
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
|
||||
@ -4,14 +4,11 @@ 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 { normalizeOptions } from '@/utils/entity';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import type { RefinementCtx } from 'zod';
|
||||
import { z } from 'zod';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
function helper({ apolloClient, ctx }: ValidationContext & { ctx: RefinementCtx }) {
|
||||
return {
|
||||
async validateRewardSum({
|
||||
@ -32,7 +29,7 @@ function helper({ apolloClient, ctx }: ValidationContext & { ctx: RefinementCtx
|
||||
query: CRMTypes.GetRewardConditionsDocument,
|
||||
variables: {
|
||||
agentid,
|
||||
currentDate: dayjs().utc(false).toISOString(),
|
||||
currentDate: getCurrentISODate(),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -5,6 +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 dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { min, sum } from 'radash';
|
||||
@ -126,7 +127,7 @@ export async function createRequestData({
|
||||
await apolloClient.query({
|
||||
query: CRMTypes.GetCoefficientsDocument,
|
||||
variables: {
|
||||
currentDate: currentDate.toISOString(),
|
||||
currentDate: getCurrentISODate(),
|
||||
},
|
||||
})
|
||||
).data.evo_coefficients
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ApolloClient } from '@apollo/client';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
|
||||
dayjs.extend(utc);
|
||||
import { getCurrentISODate } from './date';
|
||||
|
||||
type Context = {
|
||||
apolloClient: ApolloClient<object>;
|
||||
@ -36,7 +33,7 @@ export function createCurrencyUtility({ apolloClient }: Context) {
|
||||
fetchPolicy: 'network-only',
|
||||
query: CRMTypes.GetCurrencyChangesDocument,
|
||||
variables: {
|
||||
currentDate: dayjs().utc(false).toISOString(),
|
||||
currentDate: getCurrentISODate(),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
16
apps/web/utils/date.ts
Normal file
16
apps/web/utils/date.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
function _currentDate() {
|
||||
return dayjs().utc(false).hour(0).minute(0).second(0).millisecond(0);
|
||||
}
|
||||
|
||||
export function getCurrentISODate() {
|
||||
return _currentDate().toISOString();
|
||||
}
|
||||
|
||||
export function getCurrentDate() {
|
||||
return _currentDate().toDate();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user